View | Details | Raw Unified | Return to bug 235768 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/navigator/CommonNavigatorManager.java (-18 / +13 lines)
Lines 35-45 Link Here
35
import org.eclipse.ui.IWorkbenchActionConstants;
35
import org.eclipse.ui.IWorkbenchActionConstants;
36
import org.eclipse.ui.actions.ActionContext;
36
import org.eclipse.ui.actions.ActionContext;
37
import org.eclipse.ui.actions.RetargetAction;
37
import org.eclipse.ui.actions.RetargetAction;
38
import org.eclipse.ui.navigator.CommonNavigator;
39
import org.eclipse.ui.navigator.CommonViewer;
38
import org.eclipse.ui.navigator.CommonViewer;
40
import org.eclipse.ui.navigator.CommonViewerSiteFactory;
41
import org.eclipse.ui.navigator.ICommonActionConstants;
39
import org.eclipse.ui.navigator.ICommonActionConstants;
42
import org.eclipse.ui.navigator.ICommonViewerSite;
40
import org.eclipse.ui.navigator.ICommonNavigator;
43
import org.eclipse.ui.navigator.IDescriptionProvider;
41
import org.eclipse.ui.navigator.IDescriptionProvider;
44
import org.eclipse.ui.navigator.INavigatorContentService;
42
import org.eclipse.ui.navigator.INavigatorContentService;
45
import org.eclipse.ui.navigator.NavigatorActionService;
43
import org.eclipse.ui.navigator.NavigatorActionService;
Lines 62-68 Link Here
62
	// delay for updating the action bars (in ms)
60
	// delay for updating the action bars (in ms)
63
	private static final long DELAY = 200;
61
	private static final long DELAY = 200;
64
62
65
	private final CommonNavigator commonNavigator;
63
	private final ICommonNavigator commonNavigator;
66
64
67
	private final INavigatorContentService contentService;
65
	private final INavigatorContentService contentService;
68
66
Lines 101-107 Link Here
101
					if(commonNavigator.getCommonViewer().getInput() != null) {
99
					if(commonNavigator.getCommonViewer().getInput() != null) {
102
						IStructuredSelection selection = new StructuredSelection(commonNavigator.getCommonViewer().getInput());
100
						IStructuredSelection selection = new StructuredSelection(commonNavigator.getCommonViewer().getInput());
103
						actionService.setContext(new ActionContext(selection));
101
						actionService.setContext(new ActionContext(selection));
104
						actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());
102
						actionService.fillActionBars(commonNavigator.getActionBars());
105
					}
103
					}
106
				}
104
				}
107
				/*
105
				/*
Lines 127-133 Link Here
127
	 *            The CommonNavigator managed by this class. Requires a non-null
125
	 *            The CommonNavigator managed by this class. Requires a non-null
128
	 *            value.
126
	 *            value.
129
	 */
127
	 */
130
	public CommonNavigatorManager(CommonNavigator aNavigator) {
128
	public CommonNavigatorManager(ICommonNavigator aNavigator) {
131
		this(aNavigator, null);
129
		this(aNavigator, null);
132
	}
130
	}
133
	
131
	
Lines 142-152 Link Here
142
	 *            value.
140
	 *            value.
143
	 * @param aMemento a memento for restoring state, or <code>null</code>
141
	 * @param aMemento a memento for restoring state, or <code>null</code>
144
	 */
142
	 */
145
	public CommonNavigatorManager(CommonNavigator aNavigator, IMemento aMemento) {
143
	public CommonNavigatorManager(ICommonNavigator aNavigator, IMemento aMemento) {
146
		super();
144
		super();
147
		commonNavigator = aNavigator;
145
		commonNavigator = aNavigator;
148
		contentService = commonNavigator.getNavigatorContentService();
146
		contentService = commonNavigator.getNavigatorContentService();
149
		statusLineManager = commonNavigator.getViewSite().getActionBars()
147
		statusLineManager = commonNavigator.getActionBars()
150
				.getStatusLineManager();
148
				.getStatusLineManager();
151
		commonDescriptionProvider = contentService
149
		commonDescriptionProvider = contentService
152
				.createCommonDescriptionProvider();
150
				.createCommonDescriptionProvider();
Lines 166-186 Link Here
166
		commonViewer.addPostSelectionChangedListener(statusBarListener);
164
		commonViewer.addPostSelectionChangedListener(statusBarListener);
167
		updateStatusBar(commonViewer.getSelection());
165
		updateStatusBar(commonViewer.getSelection());
168
166
169
		ICommonViewerSite commonViewerSite = CommonViewerSiteFactory
167
		actionService = new NavigatorActionService(commonNavigator
170
				.createCommonViewerSite(commonNavigator.getViewSite());
168
				.getCommonViewerSite(), commonViewer, commonViewer.getNavigatorContentService()); 
171
		actionService = new NavigatorActionService(commonViewerSite,
172
				commonViewer, commonViewer.getNavigatorContentService()); 
173
169
174
		final RetargetAction openAction = new RetargetAction(
170
		final RetargetAction openAction = new RetargetAction(
175
				ICommonActionConstants.OPEN,
171
				ICommonActionConstants.OPEN,
176
				CommonNavigatorMessages.Open_action_label);
172
				CommonNavigatorMessages.Open_action_label);
177
		commonNavigator.getViewSite().getPage().addPartListener(openAction);
173
		commonNavigator.getWorkbenchSite().getPage().addPartListener(openAction);
178
		openAction.setActionDefinitionId(ICommonActionConstants.OPEN);
174
		openAction.setActionDefinitionId(ICommonActionConstants.OPEN);
179
175
180
		commonNavigator.getCommonViewer().addOpenListener(new IOpenListener() {
176
		commonNavigator.getCommonViewer().addOpenListener(new IOpenListener() {
181
			public void open(OpenEvent event) {
177
			public void open(OpenEvent event) {
182
				actionService.setContext(new ActionContext(commonNavigator.getCommonViewer().getSelection()));		
178
				actionService.setContext(new ActionContext(commonNavigator.getCommonViewer().getSelection()));		
183
				actionService.fillActionBars(commonNavigator.getViewSite().getActionBars());							
179
				actionService.fillActionBars(commonNavigator.getActionBars());							
184
				openAction.run();
180
				openAction.run();
185
			}
181
			}
186
		});  
182
		});  
Lines 195-201 Link Here
195
191
196
	/**
192
	/**
197
	 * <p>
193
	 * <p>
198
	 * Called by {@link CommonNavigator} when the View Part is disposed.
194
	 * Called by {@link ICommonNavigator} when the View Part is disposed.
199
	 * 
195
	 * 
200
	 */
196
	 */
201
	public void dispose() {
197
	public void dispose() {
Lines 217-224 Link Here
217
			IStructuredSelection structuredSelection = (IStructuredSelection) anEvent
213
			IStructuredSelection structuredSelection = (IStructuredSelection) anEvent
218
					.getSelection();
214
					.getSelection();
219
			actionService.setContext(new ActionContext(structuredSelection));
215
			actionService.setContext(new ActionContext(structuredSelection));
220
			actionService.fillActionBars(commonNavigator.getViewSite()
216
			actionService.fillActionBars(commonNavigator.getActionBars());
221
					.getActionBars());
222
		}
217
		}
223
	}
218
	}
224
219
Lines 284-290 Link Here
284
	}
279
	}
285
280
286
	protected void initViewMenu() {
281
	protected void initViewMenu() {
287
		IMenuManager viewMenu = commonNavigator.getViewSite().getActionBars()
282
		IMenuManager viewMenu = commonNavigator.getActionBars()
288
				.getMenuManager();
283
				.getMenuManager();
289
		viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
284
		viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
290
		viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS
285
		viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS
(-)src/org/eclipse/ui/internal/navigator/CommonNavigatorActionGroup.java (-40 / +20 lines)
Lines 10-29 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.navigator;
11
package org.eclipse.ui.internal.navigator;
12
12
13
import org.eclipse.jface.action.IMenuManager;
14
import org.eclipse.jface.commands.ActionHandler;
15
import org.eclipse.jface.resource.ImageDescriptor;
13
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.ui.IActionBars;
14
import org.eclipse.ui.IActionBars;
17
import org.eclipse.ui.IWorkbenchActionConstants;
18
import org.eclipse.ui.actions.ActionGroup;
15
import org.eclipse.ui.actions.ActionGroup;
19
import org.eclipse.ui.handlers.CollapseAllHandler;
16
import org.eclipse.ui.handlers.CollapseAllHandler;
20
import org.eclipse.ui.handlers.IHandlerService;
17
import org.eclipse.ui.handlers.IHandlerService;
21
import org.eclipse.ui.internal.navigator.actions.CollapseAllAction;
18
import org.eclipse.ui.internal.navigator.actions.CollapseAllAction;
22
import org.eclipse.ui.internal.navigator.actions.LinkEditorAction;
23
import org.eclipse.ui.internal.navigator.extensions.LinkHelperService;
24
import org.eclipse.ui.internal.navigator.filters.FilterActionGroup;
19
import org.eclipse.ui.internal.navigator.filters.FilterActionGroup;
25
import org.eclipse.ui.navigator.CommonNavigator;
26
import org.eclipse.ui.navigator.CommonViewer;
20
import org.eclipse.ui.navigator.CommonViewer;
21
import org.eclipse.ui.navigator.ICommonNavigator;
27
import org.eclipse.ui.navigator.INavigatorViewerDescriptor;
22
import org.eclipse.ui.navigator.INavigatorViewerDescriptor;
28
23
29
/**
24
/**
Lines 33-49 Link Here
33
 */
28
 */
34
public class CommonNavigatorActionGroup extends ActionGroup {
29
public class CommonNavigatorActionGroup extends ActionGroup {
35
30
36
	private LinkEditorAction toggleLinkingAction;
37
38
	private CollapseAllAction collapseAllAction;
31
	private CollapseAllAction collapseAllAction;
39
32
40
	private FilterActionGroup filterGroup;
33
	private FilterActionGroup filterGroup;
41
34
42
	private final CommonViewer commonViewer;
35
	private final CommonViewer commonViewer;
43
36
44
	private CommonNavigator commonNavigator;
37
	private ICommonNavigator commonNavigator;
45
46
	private final LinkHelperService linkHelperService;
47
38
48
	private CollapseAllHandler collapseAllHandler;
39
	private CollapseAllHandler collapseAllHandler;
49
40
Lines 52-68 Link Here
52
	 * Filters.
43
	 * Filters.
53
	 * 
44
	 * 
54
	 * @param aNavigator
45
	 * @param aNavigator
55
	 *            The IViewPart for this action group
46
	 *            The ICommonNavigator for this action group
56
	 * @param aViewer
47
	 * @param aViewer
57
	 *            The Viewer for this action group
48
	 *            The Viewer for this action group
58
	 * @param linkHelperService the link service helper
59
	 */
49
	 */
60
	public CommonNavigatorActionGroup(CommonNavigator aNavigator,
50
	public CommonNavigatorActionGroup(ICommonNavigator aNavigator,
61
			CommonViewer aViewer, LinkHelperService linkHelperService) {
51
			CommonViewer aViewer) {
62
		super();
52
		super();
63
		commonNavigator = aNavigator;
53
		commonNavigator = aNavigator;
64
		commonViewer = aViewer;
54
		commonViewer = aViewer;
65
		this.linkHelperService = linkHelperService;
66
		makeActions();
55
		makeActions();
67
	}
56
	}
68
57
Lines 75-99 Link Here
75
	}
64
	}
76
65
77
	/**
66
	/**
67
	 * @return The ICommonNavigator for this action group
68
	 */
69
	protected ICommonNavigator getCommonNavigator() {
70
		return commonNavigator;
71
	}
72
73
	/**
74
	 * @return The viewer for this action group
75
	 */
76
	protected CommonViewer getCommonViewer() {
77
		return commonViewer;
78
	}
79
80
	/**
78
	 * 
81
	 * 
79
	 */
82
	 */
80
	private void makeActions() {
83
	private void makeActions() {
81
		IHandlerService service = (IHandlerService) commonNavigator.getSite()
84
		IHandlerService service = (IHandlerService) commonNavigator.getWorkbenchSite()
82
				.getService(IHandlerService.class);
85
				.getService(IHandlerService.class);
83
86
84
		INavigatorViewerDescriptor viewerDescriptor = commonViewer
87
		INavigatorViewerDescriptor viewerDescriptor = commonViewer
85
				.getNavigatorContentService().getViewerDescriptor();
88
				.getNavigatorContentService().getViewerDescriptor();
86
		boolean hideLinkWithEditorAction = viewerDescriptor
87
				.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_LINK_WITH_EDITOR_ACTION);
88
		if (!hideLinkWithEditorAction) {
89
			toggleLinkingAction = new LinkEditorAction(commonNavigator,
90
					commonViewer, linkHelperService);
91
			ImageDescriptor syncIcon = getImageDescriptor("elcl16/synced.gif"); //$NON-NLS-1$
92
			toggleLinkingAction.setImageDescriptor(syncIcon);
93
			toggleLinkingAction.setHoverImageDescriptor(syncIcon);
94
			service.activateHandler(toggleLinkingAction.getActionDefinitionId(),
95
					new ActionHandler(toggleLinkingAction));
96
		}
97
89
98
		boolean hideCollapseAllAction = viewerDescriptor
90
		boolean hideCollapseAllAction = viewerDescriptor
99
				.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_COLLAPSE_ALL_ACTION);
91
				.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_COLLAPSE_ALL_ACTION);
Lines 116-122 Link Here
116
	 * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
108
	 * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
117
	 */
109
	 */
118
	public void fillActionBars(IActionBars theActionBars) {
110
	public void fillActionBars(IActionBars theActionBars) {
119
		IMenuManager menu = theActionBars.getMenuManager();
120
111
121
		filterGroup.fillActionBars(theActionBars);
112
		filterGroup.fillActionBars(theActionBars);
122
113
Lines 124-137 Link Here
124
			theActionBars.getToolBarManager().add(collapseAllAction);
115
			theActionBars.getToolBarManager().add(collapseAllAction);
125
		}
116
		}
126
117
127
		if (toggleLinkingAction != null) {
128
			menu
129
					.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS
130
							+ "-end", toggleLinkingAction); //$NON-NLS-1$
131
132
			theActionBars.getToolBarManager().add(toggleLinkingAction);
133
		}
134
135
		theActionBars.updateActionBars();
118
		theActionBars.updateActionBars();
136
	}
119
	}
137
120
Lines 142-150 Link Here
142
	 */
125
	 */
143
	public void dispose() {
126
	public void dispose() {
144
		super.dispose();
127
		super.dispose();
145
		if (toggleLinkingAction != null) {
146
			toggleLinkingAction.dispose();
147
		}
148
		if (collapseAllHandler!=null) {
128
		if (collapseAllHandler!=null) {
149
			collapseAllHandler.dispose();
129
			collapseAllHandler.dispose();
150
		}
130
		}
(-)src/org/eclipse/ui/internal/navigator/messages.properties (+1 lines)
Lines 43-45 Link Here
43
CommonSorterDescriptorManager_A_navigatorContent_extesnion_in_0_=A navigatorContent extesnion in {0} is missing an id.
43
CommonSorterDescriptorManager_A_navigatorContent_extesnion_in_0_=A navigatorContent extesnion in {0} is missing an id.
44
FilterDialogSelectionListener_Enable_the_0_filter_=Enable the {0} filter.
44
FilterDialogSelectionListener_Enable_the_0_filter_=Enable the {0} filter.
45
NavigatorContentServiceLabelProvider_Error_no_label_provider_for_0_=Error: no label provider for {0}
45
NavigatorContentServiceLabelProvider_Error_no_label_provider_for_0_=Error: no label provider for {0}
46
CommonNavigatorOutline_DefaultTitle=Common Navigator Outline
(-)src/org/eclipse/ui/internal/navigator/CommonNavigatorMessages.java (-1 / +4 lines)
Lines 123-129 Link Here
123
123
124
	/** */
124
	/** */
125
	public static String NavigatorContentServiceLabelProvider_Error_no_label_provider_for_0_;
125
	public static String NavigatorContentServiceLabelProvider_Error_no_label_provider_for_0_;
126
126
	
127
	/** */
128
	public static String CommonNavigatorOutline_DefaultTitle;
129
	
127
	static {
130
	static {
128
		NLS.initializeMessages(BUNDLE_NAME, CommonNavigatorMessages.class);
131
		NLS.initializeMessages(BUNDLE_NAME, CommonNavigatorMessages.class);
129
	}
132
	}
(-)src/org/eclipse/ui/navigator/CommonNavigator.java (-51 / +29 lines)
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-99 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
 * 
83
 * <pre>
84
 *   
85
 *          &lt;extension
86
 *          		point=&quot;org.eclipse.ui.views&quot;&gt;
87
 *          	&lt;view
88
 *          		name=&quot;My Custom View&quot;
89
 *          		icon=&quot;relative/path/to/icon.gif&quot;
90
 *          		category=&quot;org.acme.mycategory&quot;
91
 *          		class=&quot;org.eclipse.ui.navigator.CommonNavigator&quot;
92
 *          		id=&quot;org.acme.MyCustomNavigatorID&quot;&gt;
93
 *          	&lt;/view&gt;
94
 *          &lt;/extension&gt; 
95
 *    
96
 * </pre>
97
 * 
55
 * 
98
 * </p> 
56
 * </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
Lines 108-114 Link Here
108
 *  
66
 *  
109
 * @since 3.2
67
 * @since 3.2
110
 */
68
 */
111
public class CommonNavigator extends ViewPart implements ISetSelectionTarget, ISaveablePart, ISaveablesSource, IShowInTarget {
69
public class CommonNavigator extends ViewPart implements ICommonNavigator, ISaveablePart, ISaveablesSource, IShowInTarget {
112
 
70
 
113
	private static final Class INAVIGATOR_CONTENT_SERVICE = INavigatorContentService.class;
71
	private static final Class INAVIGATOR_CONTENT_SERVICE = INavigatorContentService.class;
114
	private static final Class COMMON_VIEWER_CLASS = CommonViewer.class;
72
	private static final Class COMMON_VIEWER_CLASS = CommonViewer.class;
Lines 341-361 Link Here
341
299
342
	/**
300
	/**
343
	 * <p>
301
	 * <p>
344
	 * Provides access to the commonViewer used by the current CommonNavigator.
345
	 * The field will not be valid until after
302
	 * The field will not be valid until after
346
	 * {@link #init(IViewSite, IMemento)}&nbsp;has been called by the
303
	 * {@link #init(IViewSite, IMemento)}&nbsp;has been called by the
347
	 * Workbench.
304
	 * Workbench.
348
	 * </p>
305
	 * </p>
349
	 *  
306
	 *  
350
	 * @return The (already created) instance of Common Viewer.
307
	 * @return The (already created) instance of Common Viewer.
308
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getCommonViewer()
351
	 */
309
	 */
352
	public CommonViewer getCommonViewer() {
310
	public CommonViewer getCommonViewer() {
353
		return commonViewer;
311
		return commonViewer;
354
	}
312
	}
355
313
356
	/**
314
	/**
357
	 * @return The Navigator Content Service which populates this instance of
315
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getNavigatorContentService()
358
	 *         Common Navigator
359
	 */
316
	 */
360
	public INavigatorContentService getNavigatorContentService() {
317
	public INavigatorContentService getNavigatorContentService() {
361
		return getCommonViewer().getNavigatorContentService();
318
		return getCommonViewer().getNavigatorContentService();
Lines 503-509 Link Here
503
	 *         Part.
460
	 *         Part.
504
	 */
461
	 */
505
	protected ActionGroup createCommonActionGroup() {
462
	protected ActionGroup createCommonActionGroup() {
506
		return new CommonNavigatorActionGroup(this, commonViewer, getLinkHelperService());
463
		return new CommonNavigatorViewActionGroup(this, commonViewer, getLinkHelperService());
507
	}
464
	}
508
465
509
	/**
466
	/**
Lines 646-650 Link Here
646
			linkService = new LinkHelperService((NavigatorContentService)getCommonViewer().getNavigatorContentService());
603
			linkService = new LinkHelperService((NavigatorContentService)getCommonViewer().getNavigatorContentService());
647
		return linkService;
604
		return linkService;
648
	}
605
	}
606
607
	/**
608
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getActionBars()
609
	 */
610
	public IActionBars getActionBars() {
611
		return getViewSite().getActionBars();
612
	}
613
614
	/**
615
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getWorkbenchSite()
616
	 */
617
	public IWorkbenchSite getWorkbenchSite() {
618
		return getViewSite();
619
	}
620
621
	/**
622
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getCommonViewerSite()
623
	 */
624
	public ICommonViewerSite getCommonViewerSite() {
625
		return CommonViewerSiteFactory.createCommonViewerSite(getViewSite());
626
	}
649
 
627
 
650
}
628
}
(-)src/org/eclipse/ui/navigator/NavigatorActionService.java (-1 / +1 lines)
Lines 60-66 Link Here
60
 * specify an Action Provider.
60
 * specify an Action Provider.
61
 * </p>
61
 * </p>
62
 * <p>
62
 * <p>
63
 * Clients that reuse this service outside of an instance of {@link CommonNavigator} must be sure
63
 * Clients that reuse this service outside of an instance of {@link ICommonNavigator} must be sure
64
 * that {{@link #fillActionBars(IActionBars)} is called whenever the selection changes. The
64
 * that {{@link #fillActionBars(IActionBars)} is called whenever the selection changes. The
65
 * retargetable actions for each selection could change, based on who contributed the items.
65
 * retargetable actions for each selection could change, based on who contributed the items.
66
 * 
66
 * 
(-)src/org/eclipse/ui/internal/navigator/actions/LinkEditorAction.java (-4 / +4 lines)
Lines 69-75 Link Here
69
						ILinkHelper[] helpers = linkService
69
						ILinkHelper[] helpers = linkService
70
								.getLinkHelpersFor(sSelection.getFirstElement());
70
								.getLinkHelpersFor(sSelection.getFirstElement());
71
						if (helpers.length > 0) {
71
						if (helpers.length > 0) {
72
							helpers[0].activateEditor(commonNavigator.getSite()
72
							helpers[0].activateEditor(commonNavigator.getWorkbenchSite()
73
									.getPage(), sSelection);
73
									.getPage(), sSelection);
74
						}
74
						}
75
					}
75
					}
Lines 87-93 Link Here
87
				SafeRunner.run(new ISafeRunnable() {
87
				SafeRunner.run(new ISafeRunnable() {
88
88
89
					public void run() throws Exception {
89
					public void run() throws Exception {
90
						IWorkbenchPage page = commonNavigator.getSite()
90
						IWorkbenchPage page = commonNavigator.getWorkbenchSite()
91
								.getPage();
91
								.getPage();
92
						if (page != null) {
92
						if (page != null) {
93
							IEditorPart editor = page.getActiveEditor();
93
							IEditorPart editor = page.getActiveEditor();
Lines 245-254 Link Here
245
			updateSelectionJob.schedule(BRIEF_DELAY);
245
			updateSelectionJob.schedule(BRIEF_DELAY);
246
246
247
			commonViewer.addPostSelectionChangedListener(this);
247
			commonViewer.addPostSelectionChangedListener(this);
248
			commonNavigator.getSite().getPage().addPartListener(partListener);
248
			commonNavigator.getWorkbenchSite().getPage().addPartListener(partListener);
249
		} else {
249
		} else {
250
			commonViewer.removePostSelectionChangedListener(this);
250
			commonViewer.removePostSelectionChangedListener(this);
251
			commonNavigator.getSite().getPage()
251
			commonNavigator.getWorkbenchSite().getPage()
252
					.removePartListener(partListener);
252
					.removePartListener(partListener);
253
		}
253
		}
254
	}
254
	}
(-)META-INF/MANIFEST.MF (-1 / +2 lines)
Lines 18-23 Link Here
18
 org.eclipse.ui.workbench;bundle-version="[3.2.1,4.0.0)",
18
 org.eclipse.ui.workbench;bundle-version="[3.2.1,4.0.0)",
19
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
19
 org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
20
 org.eclipse.ui;bundle-version="[3.2.1,4.0.0)",
20
 org.eclipse.ui;bundle-version="[3.2.1,4.0.0)",
21
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)"
21
 org.eclipse.core.expressions;bundle-version="[3.2.0,4.0.0)",
22
 org.eclipse.ui.views;bundle-version="[3.3.0,4.0.0)"
22
Bundle-RequiredExecutionEnvironment: J2SE-1.4
23
Bundle-RequiredExecutionEnvironment: J2SE-1.4
23
Bundle-ActivationPolicy: lazy
24
Bundle-ActivationPolicy: lazy
(-)src/org/eclipse/ui/navigator/ICommonNavigator.java (+122 lines)
Added Link Here
1
/***********************************************************************
2
 * Copyright (c) 2008 Anyware Technologies
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Anyware Technologies - initial API and implementation
11
 *
12
 * $Id$
13
 **********************************************************************/
14
15
package org.eclipse.ui.navigator;
16
17
import org.eclipse.ui.IActionBars;
18
import org.eclipse.ui.IWorkbenchSite;
19
import org.eclipse.ui.part.ISetSelectionTarget;
20
21
/**
22
 * <p>
23
 * This interface defines the API for common navigators. Common navigators can
24
 * be used in views or outlines. The following types are used by this class to
25
 * render a Common Navigator:
26
 * <ul>
27
 * <li>
28
 * <p>
29
 * {@link org.eclipse.ui.navigator.CommonViewer}: The viewer that renders the
30
 * extensible tree. Creates and manages the lifecylce of the Navigator Content
31
 * Service (described below).
32
 * </p>
33
 * </li>
34
 * <li>
35
 * <p>
36
 * {@link org.eclipse.ui.navigator.NavigatorActionService}: Manages instances of
37
 * {@link org.eclipse.ui.navigator.CommonActionProvider}s provided by individual
38
 * extensions and content extensions.
39
 * </p>
40
 * </li>
41
 * <li>
42
 * <p>
43
 * {@link org.eclipse.ui.navigator.INavigatorContentService}: Manages instances
44
 * of Navigator Content Extensions. Instances are created as needed, and
45
 * disposed of upon the disposal of the Navigator Content Service.
46
 * </p>
47
 * </li>
48
 * </ul>
49
 * <p>
50
 * Clients are not expected to subclass CommonNavigator. Clients that wish to
51
 * define their own custom extensible navigator view need to specify an instance
52
 * of the <b>org.eclipse.ui.views</b> extension point:
53
 * 
54
 * <pre>
55
 * 
56
 *          &lt;extension
57
 *          		point=&quot;org.eclipse.ui.views&quot;&gt;
58
 *          	&lt;view
59
 *          		name=&quot;My Custom View&quot;
60
 *          		icon=&quot;relative/path/to/icon.gif&quot;
61
 *          		category=&quot;org.acme.mycategory&quot;
62
 *          		class=&quot;org.eclipse.ui.navigator.CommonNavigator&quot;
63
 *          		id=&quot;org.acme.MyCustomNavigatorID&quot;&gt;
64
 *          	&lt;/view&gt;
65
 *          &lt;/extension&gt;
66
 * 
67
 * </pre>
68
 * 
69
 * @since 3.5
70
 */
71
public interface ICommonNavigator extends ISetSelectionTarget {
72
73
	/**
74
	 * <p>
75
	 * Provides access to the commonViewer used by the current CommonNavigator.
76
	 * </p>
77
	 * 
78
	 * @return The (already created) instance of Common Viewer.
79
	 */
80
	public CommonViewer getCommonViewer();
81
82
	/**
83
	 * @return The Navigator Content Service which populates this instance of
84
	 *         Common Navigator
85
	 */
86
	public INavigatorContentService getNavigatorContentService();
87
88
	/**
89
	 * <p>
90
	 * Provides access to the Workbench Site of the current Common Navigator.
91
	 * The workbench site is used to access to the Workbench Page or services.
92
	 * </p>
93
	 * 
94
	 * @return the Workbench site of the Common Navigator
95
	 */
96
	public IWorkbenchSite getWorkbenchSite();
97
98
	/**
99
	 * <p>
100
	 * Return or creates a valid context for this Common Navigator
101
	 * </p>
102
	 * 
103
	 * @return the context of this Common Navigator
104
	 */
105
	public ICommonViewerSite getCommonViewerSite();
106
107
	/**
108
	 * @return the title of this Common Navigator
109
	 */
110
	public String getTitle();
111
112
	/**
113
	 * <p>
114
	 * Provides access to the ActionBars of this Common Navigator. This method
115
	 * is an abstraction to access to ActionBars from IViewPart,
116
	 * IContentOutlinePage...
117
	 * </p>
118
	 * 
119
	 * @return the ActionBar of this Common Navigator
120
	 */
121
	public IActionBars getActionBars();
122
}
(-)src/org/eclipse/ui/internal/navigator/CommonNavigatorViewActionGroup.java (+114 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2008 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.ui.internal.navigator;
12
13
import org.eclipse.jface.action.IMenuManager;
14
import org.eclipse.jface.commands.ActionHandler;
15
import org.eclipse.jface.resource.ImageDescriptor;
16
import org.eclipse.ui.IActionBars;
17
import org.eclipse.ui.IWorkbenchActionConstants;
18
import org.eclipse.ui.handlers.IHandlerService;
19
import org.eclipse.ui.internal.navigator.actions.LinkEditorAction;
20
import org.eclipse.ui.internal.navigator.extensions.LinkHelperService;
21
import org.eclipse.ui.navigator.CommonNavigator;
22
import org.eclipse.ui.navigator.CommonViewer;
23
import org.eclipse.ui.navigator.INavigatorViewerDescriptor;
24
25
/**
26
 * 
27
 * 
28
 * @since 3.5
29
 */
30
public class CommonNavigatorViewActionGroup extends CommonNavigatorActionGroup {
31
32
	private LinkEditorAction toggleLinkingAction;
33
34
	private final LinkHelperService linkHelperService;
35
36
	/**
37
	 * Create a action group for Collapse All, Link with editor, and Select
38
	 * Filters.
39
	 * 
40
	 * @param aNavigator
41
	 *            The IViewPart for this action group
42
	 * @param aViewer
43
	 *            The Viewer for this action group
44
	 * @param linkHelperService
45
	 *            the link service helper
46
	 */
47
	public CommonNavigatorViewActionGroup(CommonNavigator aNavigator,
48
			CommonViewer aViewer, LinkHelperService linkHelperService) {
49
		super(aNavigator, aViewer);
50
		this.linkHelperService = linkHelperService;
51
		makeViewActions();
52
	}
53
54
	/**
55
	 * 
56
	 */
57
	private void makeViewActions() {
58
		IHandlerService service = (IHandlerService) getCommonNavigator()
59
				.getWorkbenchSite().getService(IHandlerService.class);
60
61
		INavigatorViewerDescriptor viewerDescriptor = getCommonViewer()
62
				.getNavigatorContentService().getViewerDescriptor();
63
		boolean hideLinkWithEditorAction = viewerDescriptor
64
				.getBooleanConfigProperty(INavigatorViewerDescriptor.PROP_HIDE_LINK_WITH_EDITOR_ACTION);
65
		if (!hideLinkWithEditorAction) {
66
			toggleLinkingAction = new LinkEditorAction(
67
					(CommonNavigator) getCommonNavigator(), getCommonViewer(),
68
					linkHelperService);
69
			ImageDescriptor syncIcon = getImageDescriptor("elcl16/synced.gif"); //$NON-NLS-1$
70
			toggleLinkingAction.setImageDescriptor(syncIcon);
71
			toggleLinkingAction.setHoverImageDescriptor(syncIcon);
72
			service.activateHandler(
73
					toggleLinkingAction.getActionDefinitionId(),
74
					new ActionHandler(toggleLinkingAction));
75
		}
76
77
	}
78
79
	/*
80
	 * (non-Javadoc)
81
	 * 
82
	 * @see
83
	 * org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars
84
	 * )
85
	 */
86
	public void fillActionBars(IActionBars theActionBars) {
87
		super.fillActionBars(theActionBars);
88
89
		IMenuManager menu = theActionBars.getMenuManager();
90
91
		if (toggleLinkingAction != null) {
92
			menu
93
					.insertAfter(IWorkbenchActionConstants.MB_ADDITIONS
94
							+ "-end", toggleLinkingAction); //$NON-NLS-1$
95
96
			theActionBars.getToolBarManager().add(toggleLinkingAction);
97
		}
98
99
		theActionBars.updateActionBars();
100
	}
101
102
	/*
103
	 * (non-Javadoc)
104
	 * 
105
	 * @see org.eclipse.ui.actions.ActionGroup#dispose()
106
	 */
107
	public void dispose() {
108
		super.dispose();
109
		if (toggleLinkingAction != null) {
110
			toggleLinkingAction.dispose();
111
		}
112
	}
113
114
}
(-)src/org/eclipse/ui/navigator/CommonNavigatorOutline.java (+406 lines)
Added Link Here
1
/***********************************************************************
2
 * Copyright (c) 2008 Anyware Technologies
3
 * 
4
 * All rights reserved. This program and the accompanying materials
5
 * are made available under the terms of the Eclipse Public License v1.0
6
 * which accompanies this distribution, and is available at
7
 * http://www.eclipse.org/legal/epl-v10.html
8
 *
9
 * Contributors:
10
 *    Anyware Technologies - initial API and implementation
11
 *
12
 * $Id$
13
 **********************************************************************/
14
15
package org.eclipse.ui.navigator;
16
17
import org.eclipse.jface.viewers.DoubleClickEvent;
18
import org.eclipse.jface.viewers.IDoubleClickListener;
19
import org.eclipse.jface.viewers.ISelection;
20
import org.eclipse.jface.viewers.ISelectionChangedListener;
21
import org.eclipse.jface.viewers.IStructuredSelection;
22
import org.eclipse.jface.viewers.TreeViewer;
23
import org.eclipse.jface.viewers.ViewerFilter;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.widgets.Composite;
26
import org.eclipse.swt.widgets.Control;
27
import org.eclipse.ui.IActionBars;
28
import org.eclipse.ui.IMemento;
29
import org.eclipse.ui.IWorkbenchSite;
30
import org.eclipse.ui.actions.ActionGroup;
31
import org.eclipse.ui.internal.navigator.CommonNavigatorActionGroup;
32
import org.eclipse.ui.internal.navigator.CommonNavigatorManager;
33
import org.eclipse.ui.internal.navigator.CommonNavigatorMessages;
34
import org.eclipse.ui.part.Page;
35
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
36
37
/**
38
 * <p>
39
 * This class provides an implementation of Common Navigator hosted in an
40
 * IContentOutlinePage.
41
 * 
42
 * </p>
43
 * Clients that wish to extend the view menu provided via the
44
 * <b>org.eclipse.ui.popupMenu</b>s extension may specify the the
45
 * <i>popupMenuId</i> specified by <b>org.eclipse.ui.navigator.viewer</b> (or a
46
 * nested <b>popupMenu</b> element) of their target viewer as their target menu
47
 * id.
48
 * 
49
 * @since 3.5
50
 */
51
public abstract class CommonNavigatorOutline extends Page implements
52
		IContentOutlinePage, ICommonNavigator {
53
54
	private static final Class INAVIGATOR_CONTENT_SERVICE = INavigatorContentService.class;
55
	private static final Class COMMON_VIEWER_CLASS = CommonViewer.class;
56
57
	private CommonViewer commonViewer;
58
59
	private CommonNavigatorManager commonManager;
60
61
	private ActionGroup commonActionGroup;
62
63
	private IMemento memento;
64
65
	/**
66
	 * 
67
	 */
68
	public CommonNavigatorOutline() {
69
		super();
70
	}
71
72
	/**
73
	 * <p>
74
	 * Returns The id used to initialize the Common Viewer from extensions. It
75
	 * is recommended to use the same id as the editor providing this Outline.
76
	 * </p>
77
	 * 
78
	 * @return The Id of the Common Viewer
79
	 */
80
	protected abstract String getCommonViewerId();
81
82
	/**
83
	 * <p>
84
	 * Constructs and returns an instance of {@link CommonViewer}. The ID from
85
	 * <code>getCommonViewer()</code> will be used to create the viewer. The ID
86
	 * is important as some extensions indicate they should only be used with a
87
	 * particular viewer ID.
88
	 * <p>
89
	 * 
90
	 * @param aParent
91
	 *            A composite parent to contain the Common Viewer
92
	 * @return An initialized instance of CommonViewer
93
	 */
94
	protected CommonViewer createCommonViewer(Composite aParent) {
95
		CommonViewer aViewer = new CommonViewer(getCommonViewerId(), aParent,
96
				SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
97
		initListeners(aViewer);
98
		aViewer.getNavigatorContentService().restoreState(memento);
99
		return aViewer;
100
	}
101
102
	/**
103
	 * <p>
104
	 * Adds the listeners to the Common Viewer.
105
	 * </p>
106
	 * 
107
	 * @param viewer
108
	 *            The viewer
109
	 * @since 2.0
110
	 */
111
	protected void initListeners(TreeViewer viewer) {
112
113
		viewer.addDoubleClickListener(new IDoubleClickListener() {
114
115
			public void doubleClick(DoubleClickEvent event) {
116
				try {
117
					handleDoubleClick(event);
118
				} catch (RuntimeException re) {
119
					re.printStackTrace();
120
				}
121
			}
122
		});
123
	}
124
125
	/**
126
	 * <p>
127
	 * This method can be overridden to customize the behavior of the double
128
	 * click.
129
	 * </p>
130
	 * 
131
	 * @param anEvent
132
	 *            Supplied by the DoubleClick listener.
133
	 */
134
	protected void handleDoubleClick(DoubleClickEvent anEvent) {
135
136
		IStructuredSelection selection = (IStructuredSelection) anEvent
137
				.getSelection();
138
		Object element = selection.getFirstElement();
139
140
		TreeViewer viewer = getCommonViewer();
141
		if (viewer.isExpandable(element)) {
142
			viewer.setExpandedState(element, !viewer.getExpandedState(element));
143
		}
144
	}
145
146
	/**
147
	 * <p>
148
	 * The Common Navigator Manager handles the setup of the Common Navigator
149
	 * Menu, manages updates to the ActionBars from {@link CommonActionProvider}
150
	 * &nbsp; extensions as the user's selection changes, and also updates the
151
	 * status bar based on the current selection.
152
	 * 
153
	 * @return The Common Navigator Manager class which handles menu population
154
	 *         and ActionBars
155
	 */
156
	protected CommonNavigatorManager createCommonManager() {
157
		return new CommonNavigatorManager(this, memento);
158
	}
159
160
	/**
161
	 * <p>
162
	 * The ActionGroup is used to populate the ActionBars of Common Navigator ,
163
	 * and the returned implementation will have an opportunity to fill the
164
	 * ActionBars of the outline as soon as it is created. (
165
	 * {@link ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)}.
166
	 * </p>
167
	 * <p>
168
	 * The default implementation returns an action group which will add the
169
	 * following actions:
170
	 * <ul>
171
	 * <li>
172
	 * <li>
173
	 * <p>
174
	 * Collapse all. Collapses all expanded nodes.
175
	 * </p>
176
	 * <li>
177
	 * <p>
178
	 * Select Filters. Provides access to the "Select Filters" dialog that
179
	 * allows users to enable/disable filters and also the Content Extension
180
	 * activations.
181
	 * </p>
182
	 * </ul>
183
	 * 
184
	 * @return The Action Group to be associated with the Common Navigator View
185
	 *         Part.
186
	 */
187
	protected ActionGroup createCommonActionGroup() {
188
		return new CommonNavigatorActionGroup(this, commonViewer);
189
	}
190
191
	/**
192
	 * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite)
193
	 */
194
	public void createControl(Composite parent) {
195
		commonViewer = createCommonViewer(parent);
196
197
		try {
198
			commonViewer.getControl().setRedraw(false);
199
200
			INavigatorFilterService filterService = commonViewer
201
					.getNavigatorContentService().getFilterService();
202
			ViewerFilter[] visibleFilters = filterService
203
					.getVisibleFilters(true);
204
			for (int i = 0; i < visibleFilters.length; i++) {
205
				commonViewer.addFilter(visibleFilters[i]);
206
			}
207
208
			commonViewer.setSorter(new CommonViewerSorter());
209
210
			/*
211
			 * make sure input is set after sorters and filters to avoid
212
			 * unnecessary refreshes
213
			 */
214
			commonViewer.setInput(getInitialInput());
215
216
			getSite().setSelectionProvider(commonViewer);
217
218
		} finally {
219
			commonViewer.getControl().setRedraw(true);
220
		}
221
222
		/*
223
		 * Create the CommonNavigatorManager last because information about the
224
		 * state of the CommonNavigator is required for the initialization of
225
		 * the CommonNavigatorManager
226
		 */
227
		commonManager = createCommonManager();
228
		if (memento != null) {
229
			commonViewer.getNavigatorContentService().restoreState(memento);
230
		}
231
232
		commonActionGroup = createCommonActionGroup();
233
		commonActionGroup.fillActionBars(getActionBars());
234
235
	}
236
237
	/**
238
	 * <p>
239
	 * Note: This method is for internal use only. Clients should not call this
240
	 * method.
241
	 * </p>
242
	 * <p>
243
	 * This method will be invoked when the DisposeListener is notified of the
244
	 * disposal of the Eclipse view part.
245
	 * </p>
246
	 * 
247
	 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
248
	 */
249
	public void dispose() {
250
		if (commonManager != null) {
251
			commonManager.dispose();
252
		}
253
		if (commonActionGroup != null) {
254
			commonActionGroup.dispose();
255
		}
256
		super.dispose();
257
	}
258
259
	/**
260
	 * @see org.eclipse.ui.part.Page#getControl()
261
	 */
262
	public Control getControl() {
263
		return commonViewer.getControl();
264
	}
265
266
	/**
267
	 * Returns an object which is an instance of the given class associated with
268
	 * this object. Returns <code>null</code> if no such object can be found.
269
	 * 
270
	 * @param adapter
271
	 *            the adapter class to look up
272
	 * @return a object castable to the given class, or <code>null</code> if
273
	 *         this object does not have an adapter for the given class
274
	 */
275
	public Object getAdapter(Class adapter) {
276
		if (adapter == COMMON_VIEWER_CLASS) {
277
			return getCommonViewer();
278
		} else if (adapter == INAVIGATOR_CONTENT_SERVICE) {
279
			return getCommonViewer().getNavigatorContentService();
280
		}
281
		return null;
282
	}
283
284
	/**
285
	 * @see org.eclipse.ui.part.Page#setFocus()
286
	 */
287
	public void setFocus() {
288
		if (commonViewer != null) {
289
			commonViewer.getTree().setFocus();
290
		}
291
	}
292
293
	/**
294
	 * <p>
295
	 * Subclasses should override this method to define the initial input of the
296
	 * Common Navigator Outline.
297
	 * </p>
298
	 * 
299
	 * @return The initial input for the viewer. Defaults to
300
	 *         getSite().getPage().getInput()
301
	 */
302
	protected Object getInitialInput() {
303
		return getSite().getPage().getInput();
304
	}
305
306
	/**
307
	 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
308
	 */
309
	public void addSelectionChangedListener(ISelectionChangedListener listener) {
310
		getCommonViewer().addSelectionChangedListener(listener);
311
	}
312
313
	/**
314
	 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
315
	 */
316
	public ISelection getSelection() {
317
		return getCommonViewer().getSelection();
318
	}
319
320
	/**
321
	 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
322
	 */
323
	public void removeSelectionChangedListener(
324
			ISelectionChangedListener listener) {
325
		getCommonViewer().removeSelectionChangedListener(listener);
326
	}
327
328
	/**
329
	 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
330
	 */
331
	public void setSelection(ISelection selection) {
332
		getCommonViewer().setSelection(selection);
333
	}
334
335
	/**
336
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getActionBars()
337
	 */
338
	public IActionBars getActionBars() {
339
		return getSite().getActionBars();
340
	}
341
342
	/**
343
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getCommonViewer()
344
	 */
345
	public CommonViewer getCommonViewer() {
346
		return commonViewer;
347
	}
348
349
	/**
350
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getCommonViewerSite()
351
	 */
352
	public ICommonViewerSite getCommonViewerSite() {
353
		return CommonViewerSiteFactory.createCommonViewerSite(
354
				getCommonViewerId(), getSite());
355
	}
356
357
	/**
358
	 * @return The Navigator Content Service which populates this instance of
359
	 *         Common Navigator
360
	 */
361
	public INavigatorContentService getNavigatorContentService() {
362
		return getCommonViewer().getNavigatorContentService();
363
	}
364
365
	/**
366
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getTitle()
367
	 */
368
	public String getTitle() {
369
		return CommonNavigatorMessages.CommonNavigatorOutline_DefaultTitle;
370
	}
371
372
	/**
373
	 * @see org.eclipse.ui.navigator.ICommonNavigator#getWorkbenchSite()
374
	 */
375
	public IWorkbenchSite getWorkbenchSite() {
376
		return getSite();
377
	}
378
379
	/**
380
	 * <p>
381
	 * Set the selection to the Common Navigator tree, and expand nodes if
382
	 * necessary. Use caution when invoking this method as it can cause
383
	 * Navigator Content Extensions to load, thus causing plugin activation.
384
	 * </p>
385
	 * 
386
	 * @see org.eclipse.ui.part.ISetSelectionTarget#selectReveal(org.eclipse.jface.viewers.ISelection)
387
	 */
388
	public void selectReveal(ISelection selection) {
389
		if (commonViewer != null) {
390
			if (selection instanceof IStructuredSelection) {
391
				Object[] newSelection = ((IStructuredSelection) selection)
392
						.toArray();
393
				Object[] expandedElements = commonViewer.getExpandedElements();
394
				Object[] newExpandedElements = new Object[newSelection.length
395
						+ expandedElements.length];
396
				System.arraycopy(expandedElements, 0, newExpandedElements, 0,
397
						expandedElements.length);
398
				System.arraycopy(newSelection, 0, newExpandedElements,
399
						expandedElements.length, newSelection.length);
400
				commonViewer.setExpandedElements(newExpandedElements);
401
			}
402
			commonViewer.setSelection(selection, true);
403
		}
404
	}
405
406
}

Return to bug 235768