1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.pde.internal.runtime.logview;
|
12
|
|
13
|
import java.util.Comparator;
|
14
|
|
15
|
import org.eclipse.core.runtime.Assert;
|
16
|
import org.eclipse.core.runtime.IAdaptable;
|
17
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
18
|
import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
|
19
|
import org.eclipse.swt.widgets.Shell;
|
20
|
import org.eclipse.ui.actions.SelectionProviderAction;
|
21
|
|
22
|
|
23
|
public class EventDetailsDialogAction extends SelectionProviderAction{
|
24
|
|
25
|
/**
|
26
|
* The shell in which to open the property dialog
|
27
|
*/
|
28
|
private Shell shell;
|
29
|
private ISelectionProvider provider;
|
30
|
private EventDetailsDialog propertyDialog;
|
31
|
private Comparator comparator;
|
32
|
/**
|
33
|
* Creates a new action for opening a property dialog
|
34
|
* on the elements from the given selection provider
|
35
|
* @param shell - the shell in which the dialog will open
|
36
|
* @param provider - the selection provider whose elements
|
37
|
* the property dialog will describe
|
38
|
*/
|
39
|
public EventDetailsDialogAction(Shell shell, ISelectionProvider provider){
|
40
|
super(provider, PDERuntimeMessages.get().EventDetailsDialog_title);
|
41
|
Assert.isNotNull(shell);
|
42
|
this.shell = shell;
|
43
|
this.provider = provider;
|
44
|
// setToolTipText
|
45
|
//WorkbenchHelp.setHelp
|
46
|
}
|
47
|
|
48
|
public boolean resetSelection(byte sortType, int sortOrder){
|
49
|
IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
|
50
|
if (element == null)
|
51
|
return false;
|
52
|
if (propertyDialog != null && propertyDialog.isOpen()){
|
53
|
propertyDialog.resetSelection(element, sortType, sortOrder);
|
54
|
return true;
|
55
|
}
|
56
|
return false;
|
57
|
}
|
58
|
public void resetSelection(){
|
59
|
IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
|
60
|
if (element == null)
|
61
|
return;
|
62
|
if (propertyDialog != null && propertyDialog.isOpen())
|
63
|
propertyDialog.resetSelection(element);
|
64
|
}
|
65
|
|
66
|
public void resetDialogButtons(){
|
67
|
if (propertyDialog != null && propertyDialog.isOpen())
|
68
|
propertyDialog.resetButtons();
|
69
|
}
|
70
|
|
71
|
public void setComparator(Comparator comparator){
|
72
|
this.comparator = comparator;
|
73
|
if (propertyDialog != null && propertyDialog.isOpen())
|
74
|
propertyDialog.setComparator(comparator);
|
75
|
}
|
76
|
|
77
|
public void run(){
|
78
|
if (propertyDialog != null && propertyDialog.isOpen()){
|
79
|
resetSelection();
|
80
|
return;
|
81
|
}
|
82
|
|
83
|
//get initial selection
|
84
|
IAdaptable element = (IAdaptable) getStructuredSelection().getFirstElement();
|
85
|
if (element == null)
|
86
|
return;
|
87
|
|
88
|
propertyDialog = new EventDetailsDialog(shell, element, provider, comparator);
|
89
|
propertyDialog.create();
|
90
|
propertyDialog.getShell().setText(PDERuntimeMessages.get().EventDetailsDialog_title);
|
91
|
propertyDialog.open();
|
92
|
}
|
93
|
}
|