19
19
import org.eclipse.core.runtime.CoreException;
20
20
import org.eclipse.core.runtime.IProgressMonitor;
21
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
22
23
import org.eclipse.core.runtime.jobs.Job;
23
import org.eclipse.core.runtime.Status;
24
24
import org.eclipse.jface.preference.IPreferenceStore;
25
25
import org.eclipse.jface.util.IPropertyChangeListener;
26
26
import org.eclipse.jface.util.PropertyChangeEvent;
27
import org.eclipse.jface.viewers.DoubleClickEvent;
28
import org.eclipse.jface.viewers.IDoubleClickListener;
29
27
import org.eclipse.linuxtools.internal.systemtap.ui.ide.IDEPlugin;
30
28
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
31
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.hidden.KernelSourceAction;
29
import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.KernelSourceAction;
32
30
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.IDEPreferenceConstants;
33
31
import org.eclipse.linuxtools.internal.systemtap.ui.ide.preferences.PathPreferencePage;
34
32
import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
35
33
import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
36
import org.eclipse.linuxtools.systemtap.ui.logging.LogManager;
37
import org.eclipse.linuxtools.systemtap.ui.structures.KernelSourceTree;
38
import org.eclipse.linuxtools.systemtap.ui.structures.TreeNode;
34
import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.ExceptionErrorDialog;
35
import org.eclipse.linuxtools.systemtap.structures.KernelSourceTree;
36
import org.eclipse.linuxtools.systemtap.structures.TreeNode;
39
37
import org.eclipse.swt.widgets.Composite;
40
38
import org.eclipse.ui.progress.UIJob;
66
64
IPreferenceStore p = IDEPlugin.getDefault().getPreferenceStore();
67
65
KernelSourceTree kst = new KernelSourceTree();
68
66
String excluded[] = p.getString(IDEPreferenceConstants.P_EXCLUDED_KERNEL_SOURCE).split(File.pathSeparator);
70
kst.buildKernelTree(kernelLocationURI, excluded, proxy, monitor);
69
kst.buildKernelTree(kernelLocationURI, excluded, proxy, monitor);
70
} catch (CoreException e) {
71
ExceptionErrorDialog.openError(Localization.getString("KernelBrowserView.CouldNotInitializeTree"), e); //$NON-NLS-1$
72
74
kst.buildKernelTree(kernelSource, excluded);
73
if (monitor.isCanceled())
76
if (monitor.isCanceled()) {
74
77
return Status.CANCEL_STATUS;
75
79
UpdateKernelBrowserJob job = new UpdateKernelBrowserJob(kst);
101
106
public static final String ID = "org.eclipse.linuxtools.internal.systemtap.ui.ide.views.KernelBrowserView"; //$NON-NLS-1$
102
107
private KernelSourceAction doubleClickAction;
103
private IDoubleClickListener dblClickListener;
105
public KernelBrowserView() {
107
LogManager.logInfo("Initializing", this); //$NON-NLS-1$
111
110
* Creates the UI on the given <code>Composite</code>
114
113
public void createPartControl(Composite parent) {
115
LogManager.logDebug("Start createPartControl: parent-" + parent, this); //$NON-NLS-1$
116
114
super.createPartControl(parent);
120
LogManager.logDebug("End createPartControl", this); //$NON-NLS-1$
124
120
* Wires up all of the actions for this browser, such as double and right click handlers.
126
122
public void makeActions() {
127
LogManager.logDebug("Start makeActions:", this); //$NON-NLS-1$
128
123
doubleClickAction = new KernelSourceAction(getSite().getWorkbenchWindow(), this);
129
dblClickListener = new IDoubleClickListener() {
130
public void doubleClick(DoubleClickEvent event) {
131
LogManager.logDebug("Start doubleClick: event-" + event, this); //$NON-NLS-1$
132
doubleClickAction.run();
133
LogManager.logDebug("End doubleClick:", this); //$NON-NLS-1$
136
viewer.addDoubleClickListener(dblClickListener);
124
viewer.addDoubleClickListener(doubleClickAction);
137
125
IDEPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
138
LogManager.logDebug("End makeActions:", this); //$NON-NLS-1$
147
134
public void refresh() {
148
LogManager.logDebug("Start refresh:", this); //$NON-NLS-1$
150
135
IPreferenceStore p = IDEPlugin.getDefault().getPreferenceStore();
151
136
String kernelSource = p.getString(IDEPreferenceConstants.P_KERNEL_SOURCE);
152
137
if(null == kernelSource || kernelSource.length() < 1) {
162
147
boolean error = false;
164
149
kernelLocationURI = IDEPlugin.getDefault().createRemoteUri(kernelSource);
165
if (kernelLocationURI == null)
150
if (kernelLocationURI == null) {
168
153
proxy = RemoteProxyManager.getInstance().getFileProxy(kernelLocationURI);
169
if (!validateProxy(proxy, kernelSource))
154
if (!validateProxy(proxy, kernelSource)) {
172
158
} catch (CoreException e2) {
182
168
refreshJob.setUser(true);
183
169
refreshJob.setPriority(Job.SHORT);
184
170
refreshJob.schedule();
185
LogManager.logDebug("End refresh:", this); //$NON-NLS-1$
188
173
private boolean validateProxy(IRemoteFileProxy proxy, String kernelSource) {
191
177
IFileStore fs = proxy.getResource(kernelSource);
194
181
IFileInfo info = fs.fetchInfo();
185
if (!info.exists()) {
202
191
private void showBrowserErrorMessage(String message) {
203
192
TreeNode t = new TreeNode("", "", false); //$NON-NLS-1$ //$NON-NLS-2$
204
193
t.add(new TreeNode("", message, false)); //$NON-NLS-1$
210
199
* and runs the <code>updateKernelSourceTree</code> method.
212
201
private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
213
203
public void propertyChange(PropertyChangeEvent event) {
214
LogManager.logDebug("Start propertyChange: event-" + event, this); //$NON-NLS-1$
215
204
if(event.getProperty().equals(IDEPreferenceConstants.P_KERNEL_SOURCE) ||
216
205
event.getProperty().equals(IDEPreferenceConstants.P_REMOTE_LOCAL_KERNEL_SOURCE) ||
217
206
event.getProperty().equals(IDEPreferenceConstants.P_EXCLUDED_KERNEL_SOURCE)) {
220
LogManager.logDebug("End propertyChange:", this); //$NON-NLS-1$
225
213
public void dispose() {
226
LogManager.logInfo("Disposing", this); //$NON-NLS-1$
228
215
IDEPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
230
viewer.removeDoubleClickListener(dblClickListener);
231
dblClickListener = null;
232
if(null != doubleClickAction)
217
viewer.removeDoubleClickListener(doubleClickAction);
219
if(null != doubleClickAction) {
233
220
doubleClickAction.dispose();
234
222
doubleClickAction = null;