~ubuntu-branches/ubuntu/utopic/eclipse-linuxtools/utopic

« back to all changes in this revision

Viewing changes to systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/views/KernelBrowserView.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2014-05-12 18:11:40 UTC
  • mfrom: (3.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140512181140-w237r3vsah1tmybz
Tags: 2.2.1-1
* New upstream release.
* Refreshed d/patches.
* Removed eclipse-cdt-valgrind-remote package, all its functionality
  is now provided by eclipse-cdt-profiling-framework-remote.
* Added remove-license-feature.patch.
* Bump Standards-Version to 3.9.5.
* Enable eclipse-changelog package.
* Enable eclipse-rpm-editor package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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;
41
39
 
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);
69
 
                        if (remote)
70
 
                                kst.buildKernelTree(kernelLocationURI, excluded, proxy, monitor);
71
 
                        else
 
67
                        if (remote) {
 
68
                                try {
 
69
                                        kst.buildKernelTree(kernelLocationURI, excluded, proxy, monitor);
 
70
                                } catch (CoreException e) {
 
71
                                        ExceptionErrorDialog.openError(Localization.getString("KernelBrowserView.CouldNotInitializeTree"), e); //$NON-NLS-1$
 
72
                                }
 
73
                        } else {
72
74
                                kst.buildKernelTree(kernelSource, excluded);
73
 
                        if (monitor.isCanceled())
 
75
                        }
 
76
                        if (monitor.isCanceled()) {
74
77
                                return Status.CANCEL_STATUS;
 
78
                        }
75
79
                        UpdateKernelBrowserJob job = new UpdateKernelBrowserJob(kst);
76
80
                        job.schedule();
77
81
                        monitor.done();
89
93
                @Override
90
94
                public IStatus runInUIThread(IProgressMonitor monitor) {
91
95
                        monitor.beginTask(Localization.getString("KernelBrowserView.UpdateKernelBrowser"), 100); //$NON-NLS-1$
92
 
                        if (kst == null)
 
96
                        if (kst == null) {
93
97
                                return Status.OK_STATUS;
 
98
                        }
94
99
                        viewer.setInput(kst.getTree());
95
100
                        kst.dispose();
96
101
                        monitor.done();
100
105
 
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;
104
 
 
105
 
        public KernelBrowserView() {
106
 
                super();
107
 
                LogManager.logInfo("Initializing", this); //$NON-NLS-1$
108
 
        }
109
108
 
110
109
        /**
111
110
         * Creates the UI on the given <code>Composite</code>
112
111
         */
113
112
        @Override
114
113
        public void createPartControl(Composite parent) {
115
 
                LogManager.logDebug("Start createPartControl: parent-" + parent, this); //$NON-NLS-1$
116
114
                super.createPartControl(parent);
117
 
 
118
115
                refresh();
119
116
                makeActions();
120
 
                LogManager.logDebug("End createPartControl", this); //$NON-NLS-1$
121
117
        }
122
118
 
123
119
        /**
124
120
         * Wires up all of the actions for this browser, such as double and right click handlers.
125
121
         */
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$
134
 
                        }
135
 
                };
136
 
                viewer.addDoubleClickListener(dblClickListener);
 
124
                viewer.addDoubleClickListener(doubleClickAction);
137
125
                IDEPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener);
138
 
                LogManager.logDebug("End makeActions:", this); //$NON-NLS-1$
139
126
        }
140
127
 
141
128
        /**
145
132
         */
146
133
        @Override
147
134
        public void refresh() {
148
 
                LogManager.logDebug("Start refresh:", this); //$NON-NLS-1$
149
 
                
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;
163
148
                        try {
164
149
                                kernelLocationURI = IDEPlugin.getDefault().createRemoteUri(kernelSource);
165
 
                                if (kernelLocationURI == null)
 
150
                                if (kernelLocationURI == null) {
166
151
                                        error = true;
167
 
                                else {
 
152
                                } else {
168
153
                                        proxy = RemoteProxyManager.getInstance().getFileProxy(kernelLocationURI);
169
 
                                        if (!validateProxy(proxy, kernelSource))
 
154
                                        if (!validateProxy(proxy, kernelSource)) {
170
155
                                                error = true;
 
156
                                        }
171
157
                                }
172
158
                        } catch (CoreException e2) {
173
159
                                error = true;
182
168
                refreshJob.setUser(true);
183
169
                refreshJob.setPriority(Job.SHORT);
184
170
                refreshJob.schedule();
185
 
                LogManager.logDebug("End refresh:", this); //$NON-NLS-1$
186
171
        }
187
172
 
188
173
        private boolean validateProxy(IRemoteFileProxy proxy, String kernelSource) {
189
 
                if (proxy == null)
 
174
                if (proxy == null) {
190
175
                        return false;
 
176
                }
191
177
                IFileStore fs = proxy.getResource(kernelSource);
192
 
                if (fs == null)
 
178
                if (fs == null) {
193
179
                        return false;
 
180
                }
194
181
                IFileInfo info = fs.fetchInfo();
195
 
                if (info == null)
196
 
                        return false;
197
 
                if (!info.exists())
198
 
                        return false;
 
182
                if (info == null) {
 
183
                        return false;
 
184
                }
 
185
                if (!info.exists()) {
 
186
                        return false;
 
187
                }
199
188
                return true;
200
189
        }
201
 
        
 
190
 
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.
211
200
         */
212
201
        private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() {
 
202
                @Override
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)) {
218
207
                                refresh();
219
208
                        }
220
 
                        LogManager.logDebug("End propertyChange:", this); //$NON-NLS-1$
221
209
                }
222
210
        };
223
 
        
 
211
 
224
212
        @Override
225
213
        public void dispose() {
226
 
                LogManager.logInfo("Disposing", this); //$NON-NLS-1$
227
214
                super.dispose();
228
215
                IDEPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(propertyChangeListener);
229
 
                if(null != viewer)
230
 
                        viewer.removeDoubleClickListener(dblClickListener);
231
 
                dblClickListener = null;
232
 
                if(null != doubleClickAction)
 
216
                if(null != viewer) {
 
217
                        viewer.removeDoubleClickListener(doubleClickAction);
 
218
                }
 
219
                if(null != doubleClickAction) {
233
220
                        doubleClickAction.dispose();
 
221
                }
234
222
                doubleClickAction = null;
235
223
        }
236
224
}