Lines 25-47
Link Here
|
25 |
import org.eclipse.jface.viewers.ViewerFilter; |
25 |
import org.eclipse.jface.viewers.ViewerFilter; |
26 |
import org.eclipse.swt.SWT; |
26 |
import org.eclipse.swt.SWT; |
27 |
import org.eclipse.swt.widgets.Composite; |
27 |
import org.eclipse.swt.widgets.Composite; |
|
|
28 |
import org.eclipse.ui.IActionBars; |
28 |
import org.eclipse.ui.IEditorInput; |
29 |
import org.eclipse.ui.IEditorInput; |
29 |
import org.eclipse.ui.IMemento; |
30 |
import org.eclipse.ui.IMemento; |
30 |
import org.eclipse.ui.ISaveablePart; |
31 |
import org.eclipse.ui.ISaveablePart; |
31 |
import org.eclipse.ui.ISaveablesLifecycleListener; |
32 |
import org.eclipse.ui.ISaveablesLifecycleListener; |
32 |
import org.eclipse.ui.ISaveablesSource; |
33 |
import org.eclipse.ui.ISaveablesSource; |
33 |
import org.eclipse.ui.IViewSite; |
34 |
import org.eclipse.ui.IViewSite; |
|
|
35 |
import org.eclipse.ui.IWorkbenchSite; |
34 |
import org.eclipse.ui.PartInitException; |
36 |
import org.eclipse.ui.PartInitException; |
35 |
import org.eclipse.ui.PlatformUI; |
37 |
import org.eclipse.ui.PlatformUI; |
36 |
import org.eclipse.ui.Saveable; |
38 |
import org.eclipse.ui.Saveable; |
37 |
import org.eclipse.ui.SaveablesLifecycleEvent; |
39 |
import org.eclipse.ui.SaveablesLifecycleEvent; |
38 |
import org.eclipse.ui.actions.ActionGroup; |
40 |
import org.eclipse.ui.actions.ActionGroup; |
39 |
import org.eclipse.ui.internal.navigator.CommonNavigatorActionGroup; |
|
|
40 |
import org.eclipse.ui.internal.navigator.CommonNavigatorManager; |
41 |
import org.eclipse.ui.internal.navigator.CommonNavigatorManager; |
|
|
42 |
import org.eclipse.ui.internal.navigator.CommonNavigatorViewActionGroup; |
41 |
import org.eclipse.ui.internal.navigator.NavigatorContentService; |
43 |
import org.eclipse.ui.internal.navigator.NavigatorContentService; |
42 |
import org.eclipse.ui.internal.navigator.NavigatorPlugin; |
44 |
import org.eclipse.ui.internal.navigator.NavigatorPlugin; |
43 |
import org.eclipse.ui.internal.navigator.extensions.LinkHelperService; |
45 |
import org.eclipse.ui.internal.navigator.extensions.LinkHelperService; |
44 |
import org.eclipse.ui.part.ISetSelectionTarget; |
|
|
45 |
import org.eclipse.ui.part.IShowInTarget; |
46 |
import org.eclipse.ui.part.IShowInTarget; |
46 |
import org.eclipse.ui.part.ShowInContext; |
47 |
import org.eclipse.ui.part.ShowInContext; |
47 |
import org.eclipse.ui.part.ViewPart; |
48 |
import org.eclipse.ui.part.ViewPart; |
Lines 50-120
Link Here
|
50 |
* <p> |
51 |
* <p> |
51 |
* This class provides the IViewPart for the Common Navigator framework in the |
52 |
* This class provides the IViewPart for the Common Navigator framework in the |
52 |
* Eclipse workbench. This class also serves as the backbone for navigational |
53 |
* Eclipse workbench. This class also serves as the backbone for navigational |
53 |
* viewers. The following types are used by this class to render the Common |
54 |
* viewers. |
54 |
* Navigator: |
|
|
55 |
* <ul> |
56 |
* <li> |
57 |
* <p> |
58 |
* {@link org.eclipse.ui.navigator.CommonViewer}: The viewer that renders the |
59 |
* extensible tree. Creates and manages the lifecylce of the Navigator Content |
60 |
* Service (described below). |
61 |
* </p> |
62 |
* </li> |
63 |
* <li> |
64 |
* <p> |
65 |
* {@link org.eclipse.ui.navigator.NavigatorActionService}: Manages instances |
66 |
* of {@link org.eclipse.ui.navigator.CommonActionProvider}s provided by |
67 |
* individual extensions and content extensions. |
68 |
* </p> |
69 |
* </li> |
70 |
* <li> |
71 |
* <p> |
72 |
* {@link org.eclipse.ui.navigator.INavigatorContentService}: Manages instances |
73 |
* of Navigator Content Extensions. Instances are created as needed, and |
74 |
* disposed of upon the disposal of the Navigator Content Service. |
75 |
* </p> |
76 |
* </li> |
77 |
* </ul> |
78 |
* <p> |
79 |
* Clients are not expected to subclass CommonNavigator. Clients that wish to |
80 |
* define their own custom extensible navigator view need to specify an instance |
81 |
* of the <b>org.eclipse.ui.views</b> extension point: |
82 |
* |
55 |
* |
83 |
* <pre> |
56 |
* </p> |
84 |
* |
|
|
85 |
* <extension |
86 |
* point="org.eclipse.ui.views"> |
87 |
* <view |
88 |
* name="My Custom View" |
89 |
* icon="relative/path/to/icon.gif" |
90 |
* category="org.acme.mycategory" |
91 |
* class="org.eclipse.ui.navigator.CommonNavigator" |
92 |
* id="org.acme.MyCustomNavigatorID"> |
93 |
* </view> |
94 |
* </extension> |
95 |
* |
96 |
* </pre> |
97 |
* |
98 |
* </p> |
99 |
* Clients that wish to extend the view menu provided via the |
57 |
* Clients that wish to extend the view menu provided via the |
100 |
* <b>org.eclipse.ui.popupMenu</b>s extension may specify the the <i>popupMenuId</i> |
58 |
* <b>org.eclipse.ui.popupMenu</b>s extension may specify the the |
101 |
* specified by <b>org.eclipse.ui.navigator.viewer</b> (or a nested <b>popupMenu</b> element) of their target viewer |
59 |
* <i>popupMenuId</i> specified by <b>org.eclipse.ui.navigator.viewer</b> (or a |
102 |
* as their target menu id. |
60 |
* nested <b>popupMenu</b> element) of their target viewer as their target menu |
|
|
61 |
* id. |
103 |
* |
62 |
* |
104 |
* <p> |
63 |
* <p> |
105 |
* This class may be instantiated; it is not intended to be subclassed. |
64 |
* This class may be instantiated; it is not intended to be subclassed. |
106 |
* </p> |
65 |
* </p> |
|
|
66 |
* |
107 |
* @noextend This class is not intended to be subclassed by clients. |
67 |
* @noextend This class is not intended to be subclassed by clients. |
108 |
* |
68 |
* |
109 |
* @since 3.2 |
69 |
* @since 3.2 |
110 |
*/ |
70 |
*/ |
111 |
public class CommonNavigator extends ViewPart implements ISetSelectionTarget, ISaveablePart, ISaveablesSource, IShowInTarget { |
71 |
public class CommonNavigator extends ViewPart implements ICommonNavigator, |
112 |
|
72 |
ISaveablePart, ISaveablesSource, IShowInTarget { |
|
|
73 |
|
113 |
private static final Class INAVIGATOR_CONTENT_SERVICE = INavigatorContentService.class; |
74 |
private static final Class INAVIGATOR_CONTENT_SERVICE = INavigatorContentService.class; |
114 |
private static final Class COMMON_VIEWER_CLASS = CommonViewer.class; |
75 |
private static final Class COMMON_VIEWER_CLASS = CommonViewer.class; |
115 |
private static final Class ISHOW_IN_TARGET_CLASS = IShowInTarget.class; |
76 |
private static final Class ISHOW_IN_TARGET_CLASS = IShowInTarget.class; |
116 |
|
77 |
|
117 |
private static final String HELP_CONTEXT = NavigatorPlugin.PLUGIN_ID + ".common_navigator"; //$NON-NLS-1$ |
78 |
private static final String HELP_CONTEXT = NavigatorPlugin.PLUGIN_ID |
|
|
79 |
+ ".common_navigator"; //$NON-NLS-1$ |
118 |
|
80 |
|
119 |
/** |
81 |
/** |
120 |
* <p> |
82 |
* <p> |
Lines 136-142
Link Here
|
136 |
private String LINKING_ENABLED = "CommonNavigator.LINKING_ENABLED"; //$NON-NLS-1$ |
98 |
private String LINKING_ENABLED = "CommonNavigator.LINKING_ENABLED"; //$NON-NLS-1$ |
137 |
|
99 |
|
138 |
private LinkHelperService linkService; |
100 |
private LinkHelperService linkService; |
139 |
|
101 |
|
140 |
/** |
102 |
/** |
141 |
* |
103 |
* |
142 |
*/ |
104 |
*/ |
Lines 155-184
Link Here
|
155 |
*/ |
117 |
*/ |
156 |
public void createPartControl(Composite aParent) { |
118 |
public void createPartControl(Composite aParent) { |
157 |
|
119 |
|
158 |
commonViewer = createCommonViewer(aParent); |
120 |
commonViewer = createCommonViewer(aParent); |
159 |
|
121 |
|
160 |
try { |
122 |
try { |
161 |
commonViewer.getControl().setRedraw(false); |
123 |
commonViewer.getControl().setRedraw(false); |
162 |
|
124 |
|
163 |
INavigatorFilterService filterService = commonViewer |
125 |
INavigatorFilterService filterService = commonViewer |
164 |
.getNavigatorContentService().getFilterService(); |
126 |
.getNavigatorContentService().getFilterService(); |
165 |
ViewerFilter[] visibleFilters = filterService.getVisibleFilters(true); |
127 |
ViewerFilter[] visibleFilters = filterService |
|
|
128 |
.getVisibleFilters(true); |
166 |
for (int i = 0; i < visibleFilters.length; i++) { |
129 |
for (int i = 0; i < visibleFilters.length; i++) { |
167 |
commonViewer.addFilter(visibleFilters[i]); |
130 |
commonViewer.addFilter(visibleFilters[i]); |
168 |
} |
131 |
} |
169 |
|
132 |
|
170 |
commonViewer.setSorter(new CommonViewerSorter()); |
133 |
commonViewer.setSorter(new CommonViewerSorter()); |
171 |
|
134 |
|
172 |
/* |
135 |
/* |
173 |
* make sure input is set after sorters and filters to avoid unnecessary |
136 |
* make sure input is set after sorters and filters to avoid |
174 |
* refreshes |
137 |
* unnecessary refreshes |
175 |
*/ |
138 |
*/ |
176 |
commonViewer.setInput(getInitialInput()); |
139 |
commonViewer.setInput(getInitialInput()); |
177 |
|
140 |
|
178 |
getSite().setSelectionProvider(commonViewer); |
141 |
getSite().setSelectionProvider(commonViewer); |
179 |
|
142 |
|
180 |
updateTitle(); |
143 |
updateTitle(); |
181 |
} finally { |
144 |
} finally { |
182 |
commonViewer.getControl().setRedraw(true); |
145 |
commonViewer.getControl().setRedraw(true); |
183 |
} |
146 |
} |
184 |
|
147 |
|
Lines 188-200
Link Here
|
188 |
* the CommonNavigatorManager |
151 |
* the CommonNavigatorManager |
189 |
*/ |
152 |
*/ |
190 |
commonManager = createCommonManager(); |
153 |
commonManager = createCommonManager(); |
191 |
if (memento != null) { |
154 |
if (memento != null) { |
192 |
commonViewer.getNavigatorContentService().restoreState(memento); |
155 |
commonViewer.getNavigatorContentService().restoreState(memento); |
193 |
} |
156 |
} |
194 |
|
157 |
|
195 |
commonActionGroup = createCommonActionGroup(); |
158 |
commonActionGroup = createCommonActionGroup(); |
196 |
commonActionGroup.fillActionBars(getViewSite().getActionBars()); |
159 |
commonActionGroup.fillActionBars(getViewSite().getActionBars()); |
197 |
|
160 |
|
198 |
ISaveablesLifecycleListener saveablesLifecycleListener = new ISaveablesLifecycleListener() { |
161 |
ISaveablesLifecycleListener saveablesLifecycleListener = new ISaveablesLifecycleListener() { |
199 |
ISaveablesLifecycleListener siteSaveablesLifecycleListener = (ISaveablesLifecycleListener) getSite() |
162 |
ISaveablesLifecycleListener siteSaveablesLifecycleListener = (ISaveablesLifecycleListener) getSite() |
200 |
.getService(ISaveablesLifecycleListener.class); |
163 |
.getService(ISaveablesLifecycleListener.class); |
Lines 206-222
Link Here
|
206 |
siteSaveablesLifecycleListener.handleLifecycleEvent(event); |
169 |
siteSaveablesLifecycleListener.handleLifecycleEvent(event); |
207 |
} |
170 |
} |
208 |
}; |
171 |
}; |
209 |
commonViewer.getNavigatorContentService() |
172 |
commonViewer.getNavigatorContentService().getSaveablesService().init( |
210 |
.getSaveablesService().init(this, getCommonViewer(), |
173 |
this, getCommonViewer(), saveablesLifecycleListener); |
211 |
saveablesLifecycleListener); |
174 |
|
212 |
|
175 |
commonViewer |
213 |
commonViewer.addSelectionChangedListener(new ISelectionChangedListener() { |
176 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
214 |
|
177 |
|
215 |
public void selectionChanged(SelectionChangedEvent event) { |
178 |
public void selectionChanged(SelectionChangedEvent event) { |
216 |
firePropertyChange(PROP_DIRTY); |
179 |
firePropertyChange(PROP_DIRTY); |
217 |
}}); |
180 |
} |
218 |
|
181 |
}); |
219 |
PlatformUI.getWorkbench().getHelpSystem().setHelp(commonViewer.getControl(), HELP_CONTEXT); |
182 |
|
|
|
183 |
PlatformUI.getWorkbench().getHelpSystem().setHelp( |
184 |
commonViewer.getControl(), HELP_CONTEXT); |
220 |
} |
185 |
} |
221 |
|
186 |
|
222 |
/** |
187 |
/** |
Lines 235-241
Link Here
|
235 |
if (commonManager != null) { |
200 |
if (commonManager != null) { |
236 |
commonManager.dispose(); |
201 |
commonManager.dispose(); |
237 |
} |
202 |
} |
238 |
if(commonActionGroup != null) { |
203 |
if (commonActionGroup != null) { |
239 |
commonActionGroup.dispose(); |
204 |
commonActionGroup.dispose(); |
240 |
} |
205 |
} |
241 |
super.dispose(); |
206 |
super.dispose(); |
Lines 303-315
Link Here
|
303 |
*/ |
268 |
*/ |
304 |
public void selectReveal(ISelection selection) { |
269 |
public void selectReveal(ISelection selection) { |
305 |
if (commonViewer != null) { |
270 |
if (commonViewer != null) { |
306 |
if(selection instanceof IStructuredSelection) { |
271 |
if (selection instanceof IStructuredSelection) { |
307 |
Object[] newSelection = ((IStructuredSelection)selection).toArray(); |
272 |
Object[] newSelection = ((IStructuredSelection) selection) |
|
|
273 |
.toArray(); |
308 |
Object[] expandedElements = commonViewer.getExpandedElements(); |
274 |
Object[] expandedElements = commonViewer.getExpandedElements(); |
309 |
Object[] newExpandedElements = new Object[newSelection.length + expandedElements.length]; |
275 |
Object[] newExpandedElements = new Object[newSelection.length |
310 |
System.arraycopy(expandedElements, 0, newExpandedElements, 0, expandedElements.length); |
276 |
+ expandedElements.length]; |
311 |
System.arraycopy(newSelection, 0, newExpandedElements, expandedElements.length, newSelection.length); |
277 |
System.arraycopy(expandedElements, 0, newExpandedElements, 0, |
312 |
commonViewer.setExpandedElements(newExpandedElements); |
278 |
expandedElements.length); |
|
|
279 |
System.arraycopy(newSelection, 0, newExpandedElements, |
280 |
expandedElements.length, newSelection.length); |
281 |
commonViewer.setExpandedElements(newExpandedElements); |
313 |
} |
282 |
} |
314 |
commonViewer.setSelection(selection, true); |
283 |
commonViewer.setSelection(selection, true); |
315 |
} |
284 |
} |
Lines 317-325
Link Here
|
317 |
|
286 |
|
318 |
/** |
287 |
/** |
319 |
* <p> |
288 |
* <p> |
320 |
* Linking is handled by an action which listens for |
289 |
* Linking is handled by an action which listens for changes to the |
321 |
* changes to the {@link CommonNavigator#IS_LINKING_ENABLED_PROPERTY}. |
290 |
* {@link CommonNavigator#IS_LINKING_ENABLED_PROPERTY}. Custom |
322 |
* Custom implementations that wish to override this functionality, need to |
291 |
* implementations that wish to override this functionality, need to |
323 |
* override the action used by the default ActionGroup and listen for |
292 |
* override the action used by the default ActionGroup and listen for |
324 |
* changes to the above property. |
293 |
* changes to the above property. |
325 |
* |
294 |
* |
Lines 341-382
Link Here
|
341 |
|
310 |
|
342 |
/** |
311 |
/** |
343 |
* <p> |
312 |
* <p> |
344 |
* Provides access to the commonViewer used by the current CommonNavigator. |
|
|
345 |
* The field will not be valid until after |
313 |
* The field will not be valid until after |
346 |
* {@link #init(IViewSite, IMemento)} has been called by the |
314 |
* {@link #init(IViewSite, IMemento)} has been called by the Workbench. |
347 |
* Workbench. |
|
|
348 |
* </p> |
315 |
* </p> |
349 |
* |
316 |
* |
350 |
* @return The (already created) instance of Common Viewer. |
317 |
* @return The (already created) instance of Common Viewer. |
|
|
318 |
* @see org.eclipse.ui.navigator.ICommonNavigator#getCommonViewer() |
351 |
*/ |
319 |
*/ |
352 |
public CommonViewer getCommonViewer() { |
320 |
public CommonViewer getCommonViewer() { |
353 |
return commonViewer; |
321 |
return commonViewer; |
354 |
} |
322 |
} |
355 |
|
323 |
|
356 |
/** |
324 |
/** |
357 |
* @return The Navigator Content Service which populates this instance of |
325 |
* @see org.eclipse.ui.navigator.ICommonNavigator#getNavigatorContentService() |
358 |
* Common Navigator |
|
|
359 |
*/ |
326 |
*/ |
360 |
public INavigatorContentService getNavigatorContentService() { |
327 |
public INavigatorContentService getNavigatorContentService() { |
361 |
return getCommonViewer().getNavigatorContentService(); |
328 |
return getCommonViewer().getNavigatorContentService(); |
362 |
} |
329 |
} |
363 |
|
330 |
|
364 |
/** |
331 |
/** |
365 |
* Returns an object which is an instance of the given class |
332 |
* Returns an object which is an instance of the given class associated with |
366 |
* associated with this object. Returns <code>null</code> if |
333 |
* this object. Returns <code>null</code> if no such object can be found. |
367 |
* no such object can be found. |
334 |
* |
368 |
* |
335 |
* @param adapter |
369 |
* @param adapter the adapter class to look up |
336 |
* the adapter class to look up |
370 |
* @return a object castable to the given class, |
337 |
* @return a object castable to the given class, or <code>null</code> if |
371 |
* or <code>null</code> if this object does not |
338 |
* this object does not have an adapter for the given class |
372 |
* have an adapter for the given class |
|
|
373 |
*/ |
339 |
*/ |
374 |
public Object getAdapter(Class adapter) { |
340 |
public Object getAdapter(Class adapter) { |
375 |
if (adapter == COMMON_VIEWER_CLASS) { |
341 |
if (adapter == COMMON_VIEWER_CLASS) { |
376 |
return getCommonViewer(); |
342 |
return getCommonViewer(); |
377 |
} else if (adapter == INAVIGATOR_CONTENT_SERVICE) { |
343 |
} else if (adapter == INAVIGATOR_CONTENT_SERVICE) { |
378 |
return getCommonViewer().getNavigatorContentService(); |
344 |
return getCommonViewer().getNavigatorContentService(); |
379 |
} else if ( adapter == ISHOW_IN_TARGET_CLASS) { |
345 |
} else if (adapter == ISHOW_IN_TARGET_CLASS) { |
380 |
return this; |
346 |
return this; |
381 |
} |
347 |
} |
382 |
return super.getAdapter(adapter); |
348 |
return super.getAdapter(adapter); |
Lines 392-401
Link Here
|
392 |
|
358 |
|
393 |
/** |
359 |
/** |
394 |
* <p> |
360 |
* <p> |
395 |
* Constructs and returns an instance of {@link CommonViewer}. The ID of |
361 |
* Constructs and returns an instance of {@link CommonViewer}. The ID of the |
396 |
* the Eclipse view part will be used to create the viewer. The ID is |
362 |
* Eclipse view part will be used to create the viewer. The ID is important |
397 |
* important as some extensions indicate they should only be used with a |
363 |
* as some extensions indicate they should only be used with a particular |
398 |
* particular viewer ID. |
364 |
* viewer ID. |
399 |
* <p> |
365 |
* <p> |
400 |
* |
366 |
* |
401 |
* @param aParent |
367 |
* @param aParent |
Lines 444-459
Link Here
|
444 |
*/ |
410 |
*/ |
445 |
protected void handleDoubleClick(DoubleClickEvent anEvent) { |
411 |
protected void handleDoubleClick(DoubleClickEvent anEvent) { |
446 |
|
412 |
|
447 |
IAction openHandler = getViewSite().getActionBars().getGlobalActionHandler(ICommonActionConstants.OPEN); |
413 |
IAction openHandler = getViewSite().getActionBars() |
448 |
|
414 |
.getGlobalActionHandler(ICommonActionConstants.OPEN); |
449 |
if(openHandler == null) { |
415 |
|
|
|
416 |
if (openHandler == null) { |
450 |
IStructuredSelection selection = (IStructuredSelection) anEvent |
417 |
IStructuredSelection selection = (IStructuredSelection) anEvent |
451 |
.getSelection(); |
418 |
.getSelection(); |
452 |
Object element = selection.getFirstElement(); |
419 |
Object element = selection.getFirstElement(); |
453 |
|
420 |
|
454 |
TreeViewer viewer = getCommonViewer(); |
421 |
TreeViewer viewer = getCommonViewer(); |
455 |
if (viewer.isExpandable(element)) { |
422 |
if (viewer.isExpandable(element)) { |
456 |
viewer.setExpandedState(element, !viewer.getExpandedState(element)); |
423 |
viewer.setExpandedState(element, !viewer |
|
|
424 |
.getExpandedState(element)); |
457 |
} |
425 |
} |
458 |
} |
426 |
} |
459 |
} |
427 |
} |
Lines 461-469
Link Here
|
461 |
/** |
429 |
/** |
462 |
* <p> |
430 |
* <p> |
463 |
* The Common Navigator Manager handles the setup of the Common Navigator |
431 |
* The Common Navigator Manager handles the setup of the Common Navigator |
464 |
* Menu, manages updates to the ActionBars from |
432 |
* Menu, manages updates to the ActionBars from {@link CommonActionProvider} |
465 |
* {@link CommonActionProvider} extensions as the user's selection |
433 |
* extensions as the user's selection changes, and also updates the |
466 |
* changes, and also updates the status bar based on the current selection. |
434 |
* status bar based on the current selection. |
467 |
* |
435 |
* |
468 |
* @return The Common Navigator Manager class which handles menu population |
436 |
* @return The Common Navigator Manager class which handles menu population |
469 |
* and ActionBars |
437 |
* and ActionBars |
Lines 476-482
Link Here
|
476 |
* <p> |
444 |
* <p> |
477 |
* The ActionGroup is used to populate the ActionBars of Common Navigator |
445 |
* The ActionGroup is used to populate the ActionBars of Common Navigator |
478 |
* View Part, and the returned implementation will have an opportunity to |
446 |
* View Part, and the returned implementation will have an opportunity to |
479 |
* fill the ActionBars of the view as soon as it is created. ({@link ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)}. |
447 |
* fill the ActionBars of the view as soon as it is created. ( |
|
|
448 |
* {@link ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)}. |
480 |
* </p> |
449 |
* </p> |
481 |
* <p> |
450 |
* <p> |
482 |
* The default implementation returns an action group which will add the |
451 |
* The default implementation returns an action group which will add the |
Lines 503-509
Link Here
|
503 |
* Part. |
472 |
* Part. |
504 |
*/ |
473 |
*/ |
505 |
protected ActionGroup createCommonActionGroup() { |
474 |
protected ActionGroup createCommonActionGroup() { |
506 |
return new CommonNavigatorActionGroup(this, commonViewer, getLinkHelperService()); |
475 |
return new CommonNavigatorViewActionGroup(this, commonViewer, |
|
|
476 |
getLinkHelperService()); |
507 |
} |
477 |
} |
508 |
|
478 |
|
509 |
/** |
479 |
/** |
Lines 555-576
Link Here
|
555 |
return ""; //$NON-NLS-1$ |
525 |
return ""; //$NON-NLS-1$ |
556 |
} |
526 |
} |
557 |
|
527 |
|
558 |
/* (non-Javadoc) |
528 |
/* |
|
|
529 |
* (non-Javadoc) |
530 |
* |
559 |
* @see org.eclipse.ui.ISaveablesSource#getSaveables() |
531 |
* @see org.eclipse.ui.ISaveablesSource#getSaveables() |
560 |
*/ |
532 |
*/ |
561 |
public Saveable[] getSaveables() { |
533 |
public Saveable[] getSaveables() { |
562 |
return getNavigatorContentService().getSaveablesService().getSaveables(); |
534 |
return getNavigatorContentService().getSaveablesService() |
|
|
535 |
.getSaveables(); |
563 |
} |
536 |
} |
564 |
|
537 |
|
565 |
/* (non-Javadoc) |
538 |
/* |
|
|
539 |
* (non-Javadoc) |
540 |
* |
566 |
* @see org.eclipse.ui.ISaveablesSource#getActiveSaveables() |
541 |
* @see org.eclipse.ui.ISaveablesSource#getActiveSaveables() |
567 |
*/ |
542 |
*/ |
568 |
public Saveable[] getActiveSaveables() { |
543 |
public Saveable[] getActiveSaveables() { |
569 |
return getNavigatorContentService().getSaveablesService().getActiveSaveables(); |
544 |
return getNavigatorContentService().getSaveablesService() |
|
|
545 |
.getActiveSaveables(); |
570 |
} |
546 |
} |
571 |
|
547 |
|
572 |
/* (non-Javadoc) |
548 |
/* |
573 |
* @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
549 |
* (non-Javadoc) |
|
|
550 |
* |
551 |
* @see |
552 |
* org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor |
553 |
* ) |
574 |
*/ |
554 |
*/ |
575 |
public void doSave(IProgressMonitor monitor) { |
555 |
public void doSave(IProgressMonitor monitor) { |
576 |
// Ignore. This method is not called because CommonNavigator implements |
556 |
// Ignore. This method is not called because CommonNavigator implements |
Lines 578-626
Link Here
|
578 |
// Saveable protocol. |
558 |
// Saveable protocol. |
579 |
} |
559 |
} |
580 |
|
560 |
|
581 |
/* (non-Javadoc) |
561 |
/* |
|
|
562 |
* (non-Javadoc) |
563 |
* |
582 |
* @see org.eclipse.ui.ISaveablePart#doSaveAs() |
564 |
* @see org.eclipse.ui.ISaveablePart#doSaveAs() |
583 |
*/ |
565 |
*/ |
584 |
public void doSaveAs() { |
566 |
public void doSaveAs() { |
585 |
// ignore |
567 |
// ignore |
586 |
} |
568 |
} |
587 |
|
569 |
|
588 |
/* (non-Javadoc) |
570 |
/* |
|
|
571 |
* (non-Javadoc) |
572 |
* |
589 |
* @see org.eclipse.ui.ISaveablePart#isDirty() |
573 |
* @see org.eclipse.ui.ISaveablePart#isDirty() |
590 |
*/ |
574 |
*/ |
591 |
public boolean isDirty() { |
575 |
public boolean isDirty() { |
592 |
Saveable[] saveables = getSaveables(); |
576 |
Saveable[] saveables = getSaveables(); |
593 |
for (int i = 0; i < saveables.length; i++) { |
577 |
for (int i = 0; i < saveables.length; i++) { |
594 |
if(saveables[i].isDirty()) { |
578 |
if (saveables[i].isDirty()) { |
595 |
return true; |
579 |
return true; |
596 |
} |
580 |
} |
597 |
} |
581 |
} |
598 |
return false; |
582 |
return false; |
599 |
} |
583 |
} |
600 |
|
584 |
|
601 |
/* (non-Javadoc) |
585 |
/* |
|
|
586 |
* (non-Javadoc) |
587 |
* |
602 |
* @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() |
588 |
* @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed() |
603 |
*/ |
589 |
*/ |
604 |
public boolean isSaveAsAllowed() { |
590 |
public boolean isSaveAsAllowed() { |
605 |
return false; |
591 |
return false; |
606 |
} |
592 |
} |
607 |
|
593 |
|
608 |
/* (non-Javadoc) |
594 |
/* |
|
|
595 |
* (non-Javadoc) |
596 |
* |
609 |
* @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() |
597 |
* @see org.eclipse.ui.ISaveablePart#isSaveOnCloseNeeded() |
610 |
*/ |
598 |
*/ |
611 |
public boolean isSaveOnCloseNeeded() { |
599 |
public boolean isSaveOnCloseNeeded() { |
612 |
return isDirty(); |
600 |
return isDirty(); |
613 |
} |
601 |
} |
614 |
|
602 |
|
615 |
/* (non-Javadoc) |
603 |
/* |
616 |
* @see org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext) |
604 |
* (non-Javadoc) |
|
|
605 |
* |
606 |
* @see |
607 |
* org.eclipse.ui.part.IShowInTarget#show(org.eclipse.ui.part.ShowInContext) |
617 |
*/ |
608 |
*/ |
618 |
public boolean show(ShowInContext context) { |
609 |
public boolean show(ShowInContext context) { |
619 |
IStructuredSelection selection = getSelection(context); |
610 |
IStructuredSelection selection = getSelection(context); |
620 |
if (selection != null && !selection.isEmpty()) { |
611 |
if (selection != null && !selection.isEmpty()) { |
621 |
selectReveal(selection); |
612 |
selectReveal(selection); |
622 |
return true; |
613 |
return true; |
623 |
} |
614 |
} |
624 |
return false; |
615 |
return false; |
625 |
} |
616 |
} |
626 |
|
617 |
|
Lines 628-635
Link Here
|
628 |
if (context == null) |
619 |
if (context == null) |
629 |
return StructuredSelection.EMPTY; |
620 |
return StructuredSelection.EMPTY; |
630 |
ISelection selection = context.getSelection(); |
621 |
ISelection selection = context.getSelection(); |
631 |
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) |
622 |
if (selection != null && !selection.isEmpty() |
632 |
return (IStructuredSelection)selection; |
623 |
&& selection instanceof IStructuredSelection) |
|
|
624 |
return (IStructuredSelection) selection; |
633 |
Object input = context.getInput(); |
625 |
Object input = context.getInput(); |
634 |
if (input instanceof IEditorInput) { |
626 |
if (input instanceof IEditorInput) { |
635 |
LinkHelperService lhs = getLinkHelperService(); |
627 |
LinkHelperService lhs = getLinkHelperService(); |
Lines 643-650
Link Here
|
643 |
|
635 |
|
644 |
private synchronized LinkHelperService getLinkHelperService() { |
636 |
private synchronized LinkHelperService getLinkHelperService() { |
645 |
if (linkService == null) |
637 |
if (linkService == null) |
646 |
linkService = new LinkHelperService((NavigatorContentService)getCommonViewer().getNavigatorContentService()); |
638 |
linkService = new LinkHelperService( |
|
|
639 |
(NavigatorContentService) getCommonViewer() |
640 |
.getNavigatorContentService()); |
647 |
return linkService; |
641 |
return linkService; |
648 |
} |
642 |
} |
649 |
|
643 |
|
|
|
644 |
/** |
645 |
* @see org.eclipse.ui.navigator.ICommonNavigator#getActionBars() |
646 |
*/ |
647 |
public IActionBars getActionBars() { |
648 |
return getViewSite().getActionBars(); |
649 |
} |
650 |
|
651 |
/** |
652 |
* @see org.eclipse.ui.navigator.ICommonNavigator#getWorkbenchSite() |
653 |
*/ |
654 |
public IWorkbenchSite getWorkbenchSite() { |
655 |
return getViewSite(); |
656 |
} |
657 |
|
658 |
/** |
659 |
* @see org.eclipse.ui.navigator.ICommonNavigator#getCommonViewerSite() |
660 |
*/ |
661 |
public ICommonViewerSite getCommonViewerSite() { |
662 |
return CommonViewerSiteFactory.createCommonViewerSite(getViewSite()); |
663 |
} |
650 |
} |
664 |
} |