KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > browsing > JavaBrowsingPart


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.jdt.internal.ui.browsing;
12
13 import java.util.ArrayList JavaDoc;
14 import java.util.Collection JavaDoc;
15 import java.util.Comparator JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.List JavaDoc;
18
19 import org.eclipse.core.runtime.Assert;
20 import org.eclipse.core.runtime.IAdaptable;
21 import org.eclipse.core.runtime.IPath;
22
23 import org.eclipse.core.resources.IContainer;
24 import org.eclipse.core.resources.IFile;
25 import org.eclipse.core.resources.IMarker;
26 import org.eclipse.core.resources.IResource;
27
28 import org.eclipse.swt.SWT;
29 import org.eclipse.swt.dnd.DND;
30 import org.eclipse.swt.dnd.Transfer;
31 import org.eclipse.swt.events.KeyAdapter;
32 import org.eclipse.swt.events.KeyEvent;
33 import org.eclipse.swt.widgets.Composite;
34 import org.eclipse.swt.widgets.Display;
35 import org.eclipse.swt.widgets.Menu;
36 import org.eclipse.swt.widgets.Shell;
37
38 import org.eclipse.help.IContextProvider;
39
40 import org.eclipse.jface.action.IAction;
41 import org.eclipse.jface.action.IMenuListener;
42 import org.eclipse.jface.action.IMenuManager;
43 import org.eclipse.jface.action.IStatusLineManager;
44 import org.eclipse.jface.action.IToolBarManager;
45 import org.eclipse.jface.action.MenuManager;
46 import org.eclipse.jface.util.IPropertyChangeListener;
47 import org.eclipse.jface.util.PropertyChangeEvent;
48 import org.eclipse.jface.util.TransferDragSourceListener;
49 import org.eclipse.jface.util.TransferDropTargetListener;
50 import org.eclipse.jface.viewers.IContentProvider;
51 import org.eclipse.jface.viewers.ILabelProvider;
52 import org.eclipse.jface.viewers.IOpenListener;
53 import org.eclipse.jface.viewers.ISelection;
54 import org.eclipse.jface.viewers.ISelectionChangedListener;
55 import org.eclipse.jface.viewers.ISelectionProvider;
56 import org.eclipse.jface.viewers.IStructuredSelection;
57 import org.eclipse.jface.viewers.OpenEvent;
58 import org.eclipse.jface.viewers.SelectionChangedEvent;
59 import org.eclipse.jface.viewers.StructuredSelection;
60 import org.eclipse.jface.viewers.StructuredViewer;
61
62 import org.eclipse.jface.text.ITextSelection;
63
64 import org.eclipse.ui.IActionBars;
65 import org.eclipse.ui.IEditorInput;
66 import org.eclipse.ui.IEditorPart;
67 import org.eclipse.ui.IFileEditorInput;
68 import org.eclipse.ui.IMemento;
69 import org.eclipse.ui.IPartListener2;
70 import org.eclipse.ui.ISelectionListener;
71 import org.eclipse.ui.IViewSite;
72 import org.eclipse.ui.IWorkbenchPage;
73 import org.eclipse.ui.IWorkbenchPart;
74 import org.eclipse.ui.IWorkbenchPartReference;
75 import org.eclipse.ui.IWorkbenchPartSite;
76 import org.eclipse.ui.IWorkingSet;
77 import org.eclipse.ui.IWorkingSetManager;
78 import org.eclipse.ui.PartInitException;
79 import org.eclipse.ui.PlatformUI;
80 import org.eclipse.ui.actions.ActionContext;
81 import org.eclipse.ui.actions.ActionGroup;
82 import org.eclipse.ui.part.IShowInSource;
83 import org.eclipse.ui.part.ResourceTransfer;
84 import org.eclipse.ui.part.ShowInContext;
85 import org.eclipse.ui.part.ViewPart;
86 import org.eclipse.ui.texteditor.ITextEditor;
87
88 import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
89
90 import org.eclipse.search.ui.ISearchResultViewPart;
91
92 import org.eclipse.jdt.core.IClassFile;
93 import org.eclipse.jdt.core.ICompilationUnit;
94 import org.eclipse.jdt.core.IJavaElement;
95 import org.eclipse.jdt.core.IPackageDeclaration;
96 import org.eclipse.jdt.core.IPackageFragment;
97 import org.eclipse.jdt.core.IType;
98 import org.eclipse.jdt.core.JavaCore;
99 import org.eclipse.jdt.core.JavaModelException;
100
101 import org.eclipse.jdt.internal.corext.util.Messages;
102
103 import org.eclipse.jdt.ui.IContextMenuConstants;
104 import org.eclipse.jdt.ui.IWorkingCopyManager;
105 import org.eclipse.jdt.ui.JavaElementComparator;
106 import org.eclipse.jdt.ui.JavaElementLabelProvider;
107 import org.eclipse.jdt.ui.JavaElementLabels;
108 import org.eclipse.jdt.ui.JavaUI;
109 import org.eclipse.jdt.ui.PreferenceConstants;
110 import org.eclipse.jdt.ui.actions.BuildActionGroup;
111 import org.eclipse.jdt.ui.actions.CCPActionGroup;
112 import org.eclipse.jdt.ui.actions.CustomFiltersActionGroup;
113 import org.eclipse.jdt.ui.actions.GenerateActionGroup;
114 import org.eclipse.jdt.ui.actions.ImportActionGroup;
115 import org.eclipse.jdt.ui.actions.JavaSearchActionGroup;
116 import org.eclipse.jdt.ui.actions.OpenEditorActionGroup;
117 import org.eclipse.jdt.ui.actions.OpenViewActionGroup;
118 import org.eclipse.jdt.ui.actions.RefactorActionGroup;
119
120 import org.eclipse.jdt.internal.ui.JavaPlugin;
121 import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
122 import org.eclipse.jdt.internal.ui.actions.NewWizardsActionGroup;
123 import org.eclipse.jdt.internal.ui.dnd.DelegatingDropAdapter;
124 import org.eclipse.jdt.internal.ui.dnd.JdtViewerDragAdapter;
125 import org.eclipse.jdt.internal.ui.dnd.ResourceTransferDragAdapter;
126 import org.eclipse.jdt.internal.ui.infoviews.AbstractInfoView;
127 import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
128 import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput;
129 import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDragAdapter;
130 import org.eclipse.jdt.internal.ui.packageview.SelectionTransferDropAdapter;
131 import org.eclipse.jdt.internal.ui.search.SearchUtil;
132 import org.eclipse.jdt.internal.ui.util.JavaUIHelp;
133 import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
134 import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
135 import org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider;
136 import org.eclipse.jdt.internal.ui.viewsupport.JavaElementImageProvider;
137 import org.eclipse.jdt.internal.ui.viewsupport.JavaUILabelProvider;
138 import org.eclipse.jdt.internal.ui.viewsupport.ProblemTableViewer;
139 import org.eclipse.jdt.internal.ui.viewsupport.StatusBarUpdater;
140 import org.eclipse.jdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
141
142
143 abstract class JavaBrowsingPart extends ViewPart implements IMenuListener, ISelectionListener, IViewPartInputProvider {
144
145     private static final String JavaDoc TAG_SELECTED_ELEMENTS= "selectedElements"; //$NON-NLS-1$
146
private static final String JavaDoc TAG_SELECTED_ELEMENT= "selectedElement"; //$NON-NLS-1$
147
private static final String JavaDoc TAG_LOGICAL_PACKAGE= "logicalPackage"; //$NON-NLS-1$
148
private static final String JavaDoc TAG_SELECTED_ELEMENT_PATH= "selectedElementPath"; //$NON-NLS-1$
149

150     private JavaUILabelProvider fLabelProvider;
151     private ILabelProvider fTitleProvider;
152     private StructuredViewer fViewer;
153     private IMemento fMemento;
154     private JavaElementTypeComparator fTypeComparator;
155
156     // Actions
157
private WorkingSetFilterActionGroup fWorkingSetFilterActionGroup;
158     private boolean fHasWorkingSetFilter= true;
159     private boolean fHasCustomFilter= true;
160     private OpenEditorActionGroup fOpenEditorGroup;
161     private CCPActionGroup fCCPActionGroup;
162     private BuildActionGroup fBuildActionGroup;
163     private ToggleLinkingAction fToggleLinkingAction;
164     protected CompositeActionGroup fActionGroups;
165
166
167     // Filters
168
private CustomFiltersActionGroup fCustomFiltersActionGroup;
169
170     protected IWorkbenchPart fPreviousSelectionProvider;
171     protected Object JavaDoc fPreviousSelectedElement;
172
173     // Linking
174
private boolean fLinkingEnabled;
175
176     /*
177      * Ensure selection changed events being processed only if
178      * initiated by user interaction with this part.
179      */

180     private boolean fProcessSelectionEvents= true;
181
182     private IPartListener2 fPartListener= new IPartListener2() {
183         public void partActivated(IWorkbenchPartReference ref) {
184         }
185         public void partBroughtToTop(IWorkbenchPartReference ref) {
186         }
187         public void partInputChanged(IWorkbenchPartReference ref) {
188         }
189         public void partClosed(IWorkbenchPartReference ref) {
190         }
191         public void partDeactivated(IWorkbenchPartReference ref) {
192         }
193         public void partOpened(IWorkbenchPartReference ref) {
194         }
195         public void partVisible(IWorkbenchPartReference ref) {
196             if (ref != null && ref.getId() == getSite().getId()){
197                 fProcessSelectionEvents= true;
198                 IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage();
199                 if (page != null)
200                     selectionChanged(page.getActivePart(), page.getSelection());
201         }
202         }
203         public void partHidden(IWorkbenchPartReference ref) {
204             if (ref != null && ref.getId() == getSite().getId())
205                 fProcessSelectionEvents= false;
206         }
207     };
208
209     public JavaBrowsingPart() {
210         super();
211         initLinkingEnabled();
212     }
213
214     /*
215      * Implements method from IViewPart.
216      */

217     public void init(IViewSite site, IMemento memento) throws PartInitException {
218         super.init(site, memento);
219         fMemento= memento;
220     }
221
222     /*
223      * Implements method from IViewPart.
224      */

225     public void saveState(IMemento memento) {
226         if (fViewer == null) {
227             // part has not been created
228
if (fMemento != null) //Keep the old state;
229
memento.putMemento(fMemento);
230             return;
231         }
232         if (fHasWorkingSetFilter)
233             fWorkingSetFilterActionGroup.saveState(memento);
234         if (fHasCustomFilter)
235             fCustomFiltersActionGroup.saveState(memento);
236         saveSelectionState(memento);
237         saveLinkingEnabled(memento);
238     }
239
240     private void saveLinkingEnabled(IMemento memento) {
241         memento.putInteger(getLinkToEditorKey(), fLinkingEnabled ? 1 : 0);
242     }
243
244     private void saveSelectionState(IMemento memento) {
245         Object JavaDoc elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray();
246         if (elements.length > 0) {
247             IMemento selectionMem= memento.createChild(TAG_SELECTED_ELEMENTS);
248             for (int i= 0; i < elements.length; i++) {
249                 IMemento elementMem= selectionMem.createChild(TAG_SELECTED_ELEMENT);
250                 Object JavaDoc o= elements[i];
251                 if (o instanceof IJavaElement)
252                     elementMem.putString(TAG_SELECTED_ELEMENT_PATH, ((IJavaElement) elements[i]).getHandleIdentifier());
253                 else if (o instanceof LogicalPackage) {
254                     IPackageFragment[] packages=((LogicalPackage)o).getFragments();
255                     for (int j= 0; j < packages.length; j++) {
256                         IMemento packageMem= elementMem.createChild(TAG_LOGICAL_PACKAGE);
257                         packageMem.putString(TAG_SELECTED_ELEMENT_PATH, packages[j].getHandleIdentifier());
258                     }
259                 }
260             }
261         }
262     }
263
264     protected void restoreState(IMemento memento) {
265         if (fHasWorkingSetFilter)
266             fWorkingSetFilterActionGroup.restoreState(memento);
267         if (fHasCustomFilter)
268             fCustomFiltersActionGroup.restoreState(memento);
269
270         if (fHasCustomFilter || fHasWorkingSetFilter) {
271             fViewer.getControl().setRedraw(false);
272             fViewer.refresh();
273             fViewer.getControl().setRedraw(true);
274         }
275     }
276
277     private ISelection restoreSelectionState(IMemento memento) {
278         if (memento == null)
279             return null;
280
281         IMemento childMem;
282         childMem= memento.getChild(TAG_SELECTED_ELEMENTS);
283         if (childMem != null) {
284             ArrayList JavaDoc list= new ArrayList JavaDoc();
285             IMemento[] elementMem= childMem.getChildren(TAG_SELECTED_ELEMENT);
286             for (int i= 0; i < elementMem.length; i++) {
287                 String JavaDoc javaElementHandle= elementMem[i].getString(TAG_SELECTED_ELEMENT_PATH);
288                 if (javaElementHandle == null) {
289                     // logical package
290
IMemento[] packagesMem= elementMem[i].getChildren(TAG_LOGICAL_PACKAGE);
291                     LogicalPackage lp= null;
292                     for (int j= 0; j < packagesMem.length; j++) {
293                         javaElementHandle= packagesMem[j].getString(TAG_SELECTED_ELEMENT_PATH);
294                         Object JavaDoc pack= JavaCore.create(javaElementHandle);
295                         if (pack instanceof IPackageFragment && ((IPackageFragment)pack).exists()) {
296                             if (lp == null)
297                                 lp= new LogicalPackage((IPackageFragment)pack);
298                             else
299                                 lp.add((IPackageFragment)pack);
300                         }
301                     }
302                     if (lp != null)
303                         list.add(lp);
304                 } else {
305                     IJavaElement element= JavaCore.create(javaElementHandle);
306                     if (element != null && element.exists())
307                         list.add(element);
308                 }
309             }
310             return new StructuredSelection(list);
311         }
312         return null;
313     }
314
315     private void restoreLinkingEnabled(IMemento memento) {
316         Integer JavaDoc val= memento.getInteger(getLinkToEditorKey());
317         if (val != null) {
318             fLinkingEnabled= val.intValue() != 0;
319         }
320     }
321
322     /* (non-Javadoc)
323      * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
324      */

325     public void createPartControl(Composite parent) {
326         Assert.isTrue(fViewer == null);
327
328
329         fTypeComparator= new JavaElementTypeComparator();
330
331         // Setup viewer
332
fViewer= createViewer(parent);
333
334         initDragAndDrop();
335
336         fLabelProvider= createLabelProvider();
337         fViewer.setLabelProvider(createDecoratingLabelProvider(fLabelProvider));
338
339         fViewer.setComparator(createJavaElementComparator());
340         fViewer.setUseHashlookup(true);
341         fTitleProvider= createTitleProvider();
342
343         createContextMenu();
344         getSite().setSelectionProvider(fViewer);
345
346         if (fMemento != null) { // initialize linking state before creating the actions
347
restoreLinkingEnabled(fMemento);
348         }
349
350         createActions(); // call before registering for selection changes
351
addKeyListener();
352
353         if (fMemento != null)
354             restoreState(fMemento);
355
356         getSite().setSelectionProvider(fViewer);
357
358         // Status line
359
IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
360         fViewer.addSelectionChangedListener(createStatusBarUpdater(slManager));
361
362
363         hookViewerListeners();
364
365         // Filters
366
addFilters();
367
368         // Initialize viewer input
369
fViewer.setContentProvider(createContentProvider());
370         setInitialInput();
371
372         // Initialize selection
373
setInitialSelection();
374         fMemento= null;
375
376         // Listen to page changes
377
getViewSite().getPage().addPostSelectionListener(this);
378         getViewSite().getPage().addPartListener(fPartListener);
379
380         fillActionBars(getViewSite().getActionBars());
381         
382         setHelp();
383     }
384
385     /* (non-Javadoc)
386      * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
387      */

388     public Object JavaDoc getAdapter(Class JavaDoc key) {
389         if (key == IShowInSource.class) {
390             return getShowInSource();
391         }
392         if (key == IContextProvider.class)
393             return JavaUIHelp.getHelpContextProvider(this, getHelpContextId());
394
395         return super.getAdapter(key);
396     }
397
398     /**
399      * Returns the <code>IShowInSource</code> for this view.
400      * @return returns the <code>IShowInSource</code>
401      */

402     protected IShowInSource getShowInSource() {
403         return new IShowInSource() {
404             public ShowInContext getShowInContext() {
405                 return new ShowInContext(
406                     null,
407                 getSite().getSelectionProvider().getSelection());
408             }
409         };
410     }
411
412     protected DecoratingJavaLabelProvider createDecoratingLabelProvider(JavaUILabelProvider provider) {
413 // XXX: Work in progress for problem decorator being a workbench decorator//
414
// return new ExcludingDecoratingLabelProvider(provider, decorationMgr, "org.eclipse.jdt.ui.problem.decorator"); //$NON-NLS-1$
415
return new DecoratingJavaLabelProvider(provider);
416     }
417
418     protected JavaElementComparator createJavaElementComparator() {
419         return new JavaElementComparator();
420     }
421
422     protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
423         return new StatusBarUpdater(slManager);
424     }
425
426     protected void createContextMenu() {
427         MenuManager menuManager= new MenuManager("#PopupMenu"); //$NON-NLS-1$
428
menuManager.setRemoveAllWhenShown(true);
429         menuManager.addMenuListener(this);
430         Menu contextMenu= menuManager.createContextMenu(fViewer.getControl());
431         fViewer.getControl().setMenu(contextMenu);
432         getSite().registerContextMenu(menuManager, fViewer);
433     }
434
435     protected void initDragAndDrop() {
436         int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
437         // drop
438
Transfer[] dropTransfers= new Transfer[] {
439             LocalSelectionTransfer.getInstance()
440         };
441         TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
442             new SelectionTransferDropAdapter(fViewer)
443         };
444         fViewer.addDropSupport(ops | DND.DROP_DEFAULT, dropTransfers, new DelegatingDropAdapter(dropListeners));
445
446         // Drag
447
Transfer[] dragTransfers= new Transfer[] {
448             LocalSelectionTransfer.getInstance(),
449             ResourceTransfer.getInstance()};
450         TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
451             new SelectionTransferDragAdapter(fViewer),
452             new ResourceTransferDragAdapter(fViewer)
453         };
454         fViewer.addDragSupport(ops, dragTransfers, new JdtViewerDragAdapter(fViewer, dragListeners));
455     }
456
457     protected void fillActionBars(IActionBars actionBars) {
458         IToolBarManager toolBar= actionBars.getToolBarManager();
459         fillToolBar(toolBar);
460
461
462         if (fHasWorkingSetFilter)
463             fWorkingSetFilterActionGroup.fillActionBars(getViewSite().getActionBars());
464
465         actionBars.updateActionBars();
466
467         fActionGroups.fillActionBars(actionBars);
468
469         if (fHasCustomFilter)
470             fCustomFiltersActionGroup.fillActionBars(actionBars);
471
472         IMenuManager menu= actionBars.getMenuManager();
473         menu.add(fToggleLinkingAction);
474     }
475
476     //---- IWorkbenchPart ------------------------------------------------------
477

478
479     public void setFocus() {
480         fViewer.getControl().setFocus();
481     }
482
483     public void dispose() {
484         if (fViewer != null) {
485             getViewSite().getPage().removePostSelectionListener(this);
486             getViewSite().getPage().removePartListener(fPartListener);
487             fViewer= null;
488         }
489         if (fActionGroups != null)
490             fActionGroups.dispose();
491
492         if (fWorkingSetFilterActionGroup != null) {
493             fWorkingSetFilterActionGroup.dispose();
494         }
495
496         super.dispose();
497     }
498
499     /**
500      * Adds the KeyListener
501      */

502     protected void addKeyListener() {
503         fViewer.getControl().addKeyListener(new KeyAdapter() {
504             public void keyReleased(KeyEvent event) {
505                 handleKeyReleased(event);
506             }
507         });
508     }
509
510     protected void handleKeyReleased(KeyEvent event) {
511         if (event.stateMask != 0)
512             return;
513
514         int key= event.keyCode;
515         if (key == SWT.F5) {
516             IAction action= fBuildActionGroup.getRefreshAction();
517             if (action.isEnabled())
518                 action.run();
519         }
520     }
521
522     //---- Adding Action to Toolbar -------------------------------------------
523

524     protected void fillToolBar(IToolBarManager tbm) {
525     }
526
527     /* (non-Javadoc)
528      * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
529      */

530     public void menuAboutToShow(IMenuManager menu) {
531         JavaPlugin.createStandardGroups(menu);
532
533         IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection();
534         int size= selection.size();
535         Object JavaDoc element= selection.getFirstElement();
536
537         if (size == 1)
538             addOpenNewWindowAction(menu, element);
539         fActionGroups.setContext(new ActionContext(selection));
540         fActionGroups.fillContextMenu(menu);
541         fActionGroups.setContext(null);
542     }
543
544     private void addOpenNewWindowAction(IMenuManager menu, Object JavaDoc element) {
545         if (element instanceof IJavaElement) {
546             element= ((IJavaElement)element).getResource();
547         }
548         if (!(element instanceof IContainer))
549             return;
550         menu.appendToGroup(
551             IContextMenuConstants.GROUP_OPEN,
552             new PatchedOpenInNewWindowAction(getSite().getWorkbenchWindow(), (IContainer)element));
553     }
554
555     protected void createActions() {
556         fActionGroups= new CompositeActionGroup(new ActionGroup[] {
557                 new NewWizardsActionGroup(this.getSite()),
558                 fOpenEditorGroup= new OpenEditorActionGroup(this),
559                 new OpenViewActionGroup(this),
560                 fCCPActionGroup= new CCPActionGroup(this),
561                 new GenerateActionGroup(this),
562                 new RefactorActionGroup(this),
563                 new ImportActionGroup(this),
564                 fBuildActionGroup= new BuildActionGroup(this),
565                 new JavaSearchActionGroup(this)});
566
567
568         if (fHasWorkingSetFilter) {
569             String JavaDoc viewId= getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
570
Assert.isNotNull(viewId);
571             IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
572                 public void propertyChange(PropertyChangeEvent event) {
573                     doWorkingSetChanged(event);
574                 }
575             };
576             fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(getSite(), workingSetListener);
577             fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
578         }
579
580         // Custom filter group
581
if (fHasCustomFilter)
582             fCustomFiltersActionGroup= new CustomFiltersActionGroup(this, fViewer);
583
584         fToggleLinkingAction= new ToggleLinkingAction(this);
585     }
586
587     private void doWorkingSetChanged(PropertyChangeEvent event) {
588         String JavaDoc property= event.getProperty();
589         if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property))
590             updateTitle();
591         else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
592             updateTitle();
593             fViewer.getControl().setRedraw(false);
594             fViewer.refresh();
595             fViewer.getControl().setRedraw(true);
596         }
597
598     }
599
600
601     /**
602      * Returns the shell to use for opening dialogs.
603      * Used in this class, and in the actions.
604      * @return returns the shell
605      */

606     Shell getShell() {
607         return fViewer.getControl().getShell();
608     }
609
610     protected final Display getDisplay() {
611         return fViewer.getControl().getDisplay();
612     }
613
614     /**
615      * Returns the selection provider.
616      * @return the selection provider
617      */

618     ISelectionProvider getSelectionProvider() {
619         return fViewer;
620     }
621
622     /**
623      * Answers if the given <code>element</code> is a valid
624      * input for this part.
625      *
626      * @param element the object to test
627      * @return <code>true</code> if the given element is a valid input
628      */

629     abstract protected boolean isValidInput(Object JavaDoc element);
630
631     /**
632      * Answers if the given <code>element</code> is a valid
633      * element for this part.
634      *
635      * @param element the object to test
636      * @return <code>true</code> if the given element is a valid element
637      */

638     protected boolean isValidElement(Object JavaDoc element) {
639         if (!(element instanceof IJavaElement)) {
640             return false;
641         }
642         Object JavaDoc input= getViewer().getInput();
643         if (input == null)
644             return false;
645         if (input instanceof Collection JavaDoc)
646             return ((Collection JavaDoc)input).contains(element);
647         else
648             return input.equals(element);
649
650     }
651
652     private boolean isInputResetBy(Object JavaDoc newInput, Object JavaDoc input, IWorkbenchPart part) {
653         if (newInput == null)
654             return part == fPreviousSelectionProvider;
655
656         if (input instanceof IJavaElement && newInput instanceof IJavaElement)
657             return getTypeComparator().compare(newInput, input) > 0;
658
659         if((newInput instanceof List JavaDoc) && (part instanceof PackagesView))
660             return true;
661
662         else
663             return false;
664     }
665
666     private boolean isInputResetBy(IWorkbenchPart part) {
667         if (!(part instanceof JavaBrowsingPart))
668             return true;
669         Object JavaDoc thisInput= getViewer().getInput();
670         Object JavaDoc partInput= ((JavaBrowsingPart)part).getViewer().getInput();
671
672         if(thisInput instanceof Collection JavaDoc)
673             thisInput= ((Collection JavaDoc)thisInput).iterator().next();
674
675         if(partInput instanceof Collection JavaDoc)
676             partInput= ((Collection JavaDoc)partInput).iterator().next();
677
678         if (thisInput instanceof IJavaElement && partInput instanceof IJavaElement)
679             return getTypeComparator().compare(partInput, thisInput) > 0;
680         else
681             return true;
682     }
683
684     protected boolean isAncestorOf(Object JavaDoc ancestor, Object JavaDoc element) {
685         if (element instanceof IJavaElement && ancestor instanceof IJavaElement)
686             return !element.equals(ancestor) && internalIsAncestorOf((IJavaElement)ancestor, (IJavaElement)element);
687         return false;
688     }
689
690     private boolean internalIsAncestorOf(IJavaElement ancestor, IJavaElement element) {
691         if (element != null)
692             return element.equals(ancestor) || internalIsAncestorOf(ancestor, element.getParent());
693         else
694             return false;
695     }
696
697     private boolean isSearchResultView(IWorkbenchPart part) {
698         return SearchUtil.isSearchPlugInActivated() && part instanceof ISearchResultViewPart;
699     }
700
701     protected boolean needsToProcessSelectionChanged(IWorkbenchPart part, ISelection selection) {
702         if (!fProcessSelectionEvents || part == this || isSearchResultView(part) || part instanceof AbstractInfoView){
703             if (part == this)
704                 fPreviousSelectionProvider= part;
705             return false;
706         }
707         return true;
708     }
709
710     public void selectionChanged(IWorkbenchPart part, ISelection selection) {
711         if (!needsToProcessSelectionChanged(part, selection))
712             return;
713
714         if (fToggleLinkingAction.isChecked() && (part instanceof ITextEditor)) {
715             setSelectionFromEditor(part, selection);
716             return;
717         }
718
719         if (!(selection instanceof IStructuredSelection))
720             return;
721
722         // Set selection
723
Object JavaDoc selectedElement= getSingleElementFromSelection(selection);
724
725         if (selectedElement != null && (part == null || part.equals(fPreviousSelectionProvider)) && selectedElement.equals(fPreviousSelectedElement))
726             return;
727
728         fPreviousSelectedElement= selectedElement;
729
730         Object JavaDoc currentInput= getViewer().getInput();
731         if (selectedElement != null && selectedElement.equals(currentInput)) {
732             IJavaElement elementToSelect= findElementToSelect(selectedElement);
733             if (elementToSelect != null && getTypeComparator().compare(selectedElement, elementToSelect) < 0)
734                 setSelection(new StructuredSelection(elementToSelect), true);
735             else if (elementToSelect == null && (this instanceof MembersView)) {
736                 setSelection(StructuredSelection.EMPTY, true);
737                 fPreviousSelectedElement= StructuredSelection.EMPTY;
738             }
739             fPreviousSelectionProvider= part;
740             return;
741         }
742
743         // Clear input if needed
744
if (part != fPreviousSelectionProvider && selectedElement != null && !selectedElement.equals(currentInput) && isInputResetBy(selectedElement, currentInput, part)) {
745             if (!isAncestorOf(selectedElement, currentInput))
746                 setInput(null);
747             fPreviousSelectionProvider= part;
748             return;
749         } else if (selection.isEmpty() && !isInputResetBy(part)) {
750             fPreviousSelectionProvider= part;
751             return;
752         } else if (selectedElement == null && part == fPreviousSelectionProvider) {
753             setInput(null);
754             fPreviousSelectionProvider= part;
755             return;
756         }
757         fPreviousSelectionProvider= part;
758
759         // Adjust input and set selection and
760
adjustInputAndSetSelection(selectedElement);
761     }
762
763
764     void setHasWorkingSetFilter(boolean state) {
765         fHasWorkingSetFilter= state;
766     }
767
768     void setHasCustomSetFilter(boolean state) {
769         fHasCustomFilter= state;
770     }
771
772     protected Object JavaDoc getInput() {
773         return fViewer.getInput();
774     }
775
776     protected void setInput(Object JavaDoc input) {
777         setViewerInput(input);
778         updateTitle();
779     }
780
781     boolean isLinkingEnabled() {
782         return fLinkingEnabled;
783     }
784
785     private void initLinkingEnabled() {
786         fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(getLinkToEditorKey());
787     }
788
789     private void setViewerInput(Object JavaDoc input) {
790         fProcessSelectionEvents= false;
791         fViewer.setInput(input);
792         fProcessSelectionEvents= true;
793     }
794
795     void updateTitle() {
796         setTitleToolTip(getToolTipText(fViewer.getInput()));
797     }
798
799     /**
800      * Returns the tool tip text for the given element.
801      * @param element the element
802      * @return the tooltip for the element
803      */

804     String JavaDoc getToolTipText(Object JavaDoc element) {
805         String JavaDoc result;
806         if (!(element instanceof IResource)) {
807             result= JavaElementLabels.getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
808         } else {
809             IPath path= ((IResource) element).getFullPath();
810             if (path.isRoot()) {
811                 result= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
812
} else {
813                 result= path.makeRelative().toString();
814             }
815         }
816
817         if (fWorkingSetFilterActionGroup == null || fWorkingSetFilterActionGroup.getWorkingSet() == null)
818             return result;
819
820         IWorkingSet ws= fWorkingSetFilterActionGroup.getWorkingSet();
821         String JavaDoc wsstr= Messages.format(JavaBrowsingMessages.JavaBrowsingPart_toolTip, new String JavaDoc[] { ws.getLabel() });
822         if (result.length() == 0)
823             return wsstr;
824         return Messages.format(JavaBrowsingMessages.JavaBrowsingPart_toolTip2, new String JavaDoc[] { result, ws.getLabel() });
825     }
826
827     /* (non-Javadoc)
828      * @see org.eclipse.ui.part.WorkbenchPart#getTitleToolTip()
829      */

830     public String JavaDoc getTitleToolTip() {
831         if (fViewer == null)
832             return super.getTitleToolTip();
833         return getToolTipText(fViewer.getInput());
834     }
835
836     protected final StructuredViewer getViewer() {
837         return fViewer;
838     }
839
840     protected final void setViewer(StructuredViewer viewer){
841         fViewer= viewer;
842     }
843
844     protected JavaUILabelProvider createLabelProvider() {
845         return new AppearanceAwareLabelProvider(
846                         AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
847                         AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | JavaElementImageProvider.SMALL_ICONS
848                         );
849     }
850
851     protected ILabelProvider createTitleProvider() {
852         return new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_SMALL_ICONS);
853     }
854
855     protected final ILabelProvider getLabelProvider() {
856         return fLabelProvider;
857     }
858
859     protected final ILabelProvider getTitleProvider() {
860         return fTitleProvider;
861     }
862
863     /**
864      * Creates the viewer of this part.
865      *
866      * @param parent the parent for the viewer
867      * @return the created viewer
868      */

869     protected StructuredViewer createViewer(Composite parent) {
870         return new ProblemTableViewer(parent, SWT.MULTI);
871     }
872
873     protected int getLabelProviderFlags() {
874         return JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS |
875                 JavaElementLabelProvider.SHOW_SMALL_ICONS | JavaElementLabelProvider.SHOW_VARIABLE | JavaElementLabelProvider.SHOW_PARAMETERS;
876     }
877
878     /**
879      * Adds filters the viewer of this part.
880      */

881     protected void addFilters() {
882         // default is to have no filters
883
}
884
885     /**
886      * Creates the content provider of this part.
887      * @return the content provider
888      */

889     protected IContentProvider createContentProvider() {
890         return new JavaBrowsingContentProvider(true, this);
891     }
892
893     protected void setInitialInput() {
894         // Use the selection, if any
895
ISelection selection= getSite().getPage().getSelection();
896         Object JavaDoc input= getSingleElementFromSelection(selection);
897         if (!(input instanceof IJavaElement)) {
898             // Use the input of the page
899
input= getSite().getPage().getInput();
900             if (!(input instanceof IJavaElement) && input instanceof IAdaptable)
901                 input= ((IAdaptable)input).getAdapter(IJavaElement.class);
902         }
903         setInput(findInputForJavaElement((IJavaElement)input));
904     }
905
906     protected void setInitialSelection() {
907         // Use the selection, if any
908
Object JavaDoc input;
909         IWorkbenchPage page= getSite().getPage();
910         ISelection selection= null;
911         if (page != null)
912             selection= page.getSelection();
913         if (selection instanceof ITextSelection) {
914             Object JavaDoc part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
915             if (part instanceof IEditorPart) {
916                 setSelectionFromEditor((IEditorPart)part);
917                 if (fViewer.getSelection() != null)
918                     return;
919             }
920         }
921
922         // Use saved selection from memento
923
if (selection == null || selection.isEmpty())
924             selection= restoreSelectionState(fMemento);
925
926         if (selection == null || selection.isEmpty()) {
927             // Use the input of the page
928
input= getSite().getPage().getInput();
929             if (!(input instanceof IJavaElement)) {
930                 if (input instanceof IAdaptable)
931                     input= ((IAdaptable)input).getAdapter(IJavaElement.class);
932                 else
933                     return;
934             }
935             selection= new StructuredSelection(input);
936         }
937         selectionChanged(null, selection);
938     }
939
940     protected final void setHelp() {
941         JavaUIHelp.setHelp(fViewer, getHelpContextId());
942     }
943
944     /**
945      * Returns the context ID for the Help system
946      *
947      * @return the string used as ID for the Help context
948      */

949     abstract protected String JavaDoc getHelpContextId();
950
951     /**
952      * Returns the preference key for the link to editor setting.
953      *
954      * @return the string used as key into the preference store
955      */

956     abstract protected String JavaDoc getLinkToEditorKey();
957
958     /**
959      * Adds additional listeners to this view.
960      * This method can be overridden but should
961      * call super.
962      */

963     protected void hookViewerListeners() {
964         fViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
965             public void selectionChanged(SelectionChangedEvent event) {
966                 if (!fProcessSelectionEvents)
967                     return;
968
969                 fPreviousSelectedElement= getSingleElementFromSelection(event.getSelection());
970
971                 IWorkbenchPage page= getSite().getPage();
972                 if (page == null)
973                     return;
974
975                 if (page.equals(JavaPlugin.getActivePage()) && JavaBrowsingPart.this.equals(page.getActivePart())) {
976                     linkToEditor((IStructuredSelection)event.getSelection());
977                 }
978             }
979         });
980
981         fViewer.addOpenListener(new IOpenListener() {
982             public void open(OpenEvent event) {
983                 IAction open= fOpenEditorGroup.getOpenAction();
984                 if (open.isEnabled()) {
985                     open.run();
986                     restoreSelection();
987                 }
988             }
989         });
990     }
991
992     void restoreSelection() {
993         // Default is to do nothing
994
}
995
996     void adjustInputAndSetSelection(Object JavaDoc o) {
997         if (!(o instanceof IJavaElement)) {
998             if (o == null)
999                 setInput(null);
1000            setSelection(StructuredSelection.EMPTY, true);
1001            return;
1002        }
1003
1004        IJavaElement je= (IJavaElement)o;
1005        IJavaElement elementToSelect= findElementToSelect(je);
1006        IJavaElement newInput= findInputForJavaElement(je);
1007        IJavaElement oldInput= null;
1008        if (getInput() instanceof IJavaElement)
1009            oldInput= (IJavaElement)getInput();
1010
1011        if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(je, oldInput)))
1012            // Clear input
1013
setInput(null);
1014        else if (mustSetNewInput(elementToSelect, oldInput, newInput)) {
1015            // Adjust input to selection
1016
setInput(newInput);
1017        }
1018
1019        if (elementToSelect != null && elementToSelect.exists())
1020            setSelection(new StructuredSelection(elementToSelect), true);
1021        else
1022            setSelection(StructuredSelection.EMPTY, true);
1023    }
1024
1025    /**
1026     * Compute if a new input must be set.
1027     *
1028     * @param elementToSelect the element to select
1029     * @param oldInput old input
1030     * @param newInput new input
1031     * @return <code>true</code> if the input has to be set
1032     * @since 3.0
1033     */

1034    private boolean mustSetNewInput(IJavaElement elementToSelect, IJavaElement oldInput, IJavaElement newInput) {
1035        return (newInput == null || !newInput.equals(oldInput))
1036            && (elementToSelect == null
1037                || oldInput == null
1038                || (!((elementToSelect instanceof IPackageDeclaration)
1039                    && (elementToSelect.getParent().equals(oldInput.getParent()))
1040                    && (!isAncestorOf(getViewPartInput(), elementToSelect)))));
1041    }
1042
1043    /**
1044     * Finds the closest Java element which can be used as input for
1045     * this part and has the given Java element as child
1046     *
1047     * @param je the Java element for which to search the closest input
1048     * @return the closest Java element used as input for this part
1049     */

1050    protected IJavaElement findInputForJavaElement(IJavaElement je) {
1051        if (je == null || !je.exists())
1052            return null;
1053        if (isValidInput(je))
1054            return je;
1055        return findInputForJavaElement(je.getParent());
1056    }
1057
1058    protected final IJavaElement findElementToSelect(Object JavaDoc obj) {
1059        if (obj instanceof IJavaElement)
1060            return findElementToSelect((IJavaElement)obj);
1061        return null;
1062    }
1063
1064    /**
1065     * Finds the element which has to be selected in this part.
1066     *
1067     * @param je the Java element which has the focus
1068     * @return returns the element to select
1069     */

1070    abstract protected IJavaElement findElementToSelect(IJavaElement je);
1071
1072
1073    protected final Object JavaDoc getSingleElementFromSelection(ISelection selection) {
1074        if (!(selection instanceof IStructuredSelection) || selection.isEmpty())
1075            return null;
1076
1077        Iterator JavaDoc iter= ((IStructuredSelection)selection).iterator();
1078        Object JavaDoc firstElement= iter.next();
1079        if (!(firstElement instanceof IJavaElement)) {
1080            if (firstElement instanceof IMarker)
1081                firstElement= ((IMarker)firstElement).getResource();
1082            if (firstElement instanceof IAdaptable) {
1083                IJavaElement je= (IJavaElement)((IAdaptable)firstElement).getAdapter(IJavaElement.class);
1084                if (je == null && firstElement instanceof IFile) {
1085                    IContainer parent= ((IFile)firstElement).getParent();
1086                    if (parent != null)
1087                        return parent.getAdapter(IJavaElement.class);
1088                    else return null;
1089                } else
1090                    return je;
1091
1092            } else
1093                return firstElement;
1094        }
1095        Object JavaDoc currentInput= getViewer().getInput();
1096        if (currentInput == null || !currentInput.equals(findInputForJavaElement((IJavaElement)firstElement)))
1097            if (iter.hasNext())
1098                // multi-selection and view is empty
1099
return null;
1100            else
1101                // OK: single selection and view is empty
1102
return firstElement;
1103
1104        // be nice to multi-selection
1105
while (iter.hasNext()) {
1106            Object JavaDoc element= iter.next();
1107            if (!(element instanceof IJavaElement))
1108                return null;
1109            if (!currentInput.equals(findInputForJavaElement((IJavaElement)element)))
1110                return null;
1111        }
1112        return firstElement;
1113    }
1114
1115    /**
1116     * Gets the typeComparator.
1117     * @return Returns a JavaElementTypeComparator
1118     */

1119    protected Comparator JavaDoc getTypeComparator() {
1120        return fTypeComparator;
1121    }
1122
1123    /**
1124     * Links to editor (if option enabled)
1125     * @param selection the selection
1126     */

1127    private void linkToEditor(IStructuredSelection selection) {
1128        Object JavaDoc obj= selection.getFirstElement();
1129
1130        if (selection.size() == 1) {
1131            IEditorPart part= EditorUtility.isOpenInEditor(obj);
1132            if (part != null) {
1133                IWorkbenchPage page= getSite().getPage();
1134                page.bringToTop(part);
1135                if (obj instanceof IJavaElement)
1136                    EditorUtility.revealInEditor(part, (IJavaElement) obj);
1137            }
1138        }
1139    }
1140
1141    void setSelectionFromEditor(IWorkbenchPart part) {
1142        if (!fProcessSelectionEvents || !linkBrowsingViewSelectionToEditor() || !(part instanceof IEditorPart))
1143            return;
1144        
1145        IWorkbenchPartSite site= part.getSite();
1146        if (site == null)
1147            return;
1148        ISelectionProvider provider= site.getSelectionProvider();
1149        if (provider != null)
1150            setSelectionFromEditor(part, provider.getSelection());
1151    }
1152
1153    private void setSelectionFromEditor(IWorkbenchPart part, ISelection selection) {
1154        if (part instanceof IEditorPart) {
1155            IJavaElement element= null;
1156            if (selection instanceof IStructuredSelection) {
1157                Object JavaDoc obj= getSingleElementFromSelection(selection);
1158                if (obj instanceof IJavaElement)
1159                    element= (IJavaElement)obj;
1160            }
1161            IEditorInput ei= ((IEditorPart)part).getEditorInput();
1162            if (selection instanceof ITextSelection) {
1163                int offset= ((ITextSelection)selection).getOffset();
1164                element= getElementAt(ei, offset);
1165            }
1166            if (element != null) {
1167                adjustInputAndSetSelection(element);
1168                return;
1169            }
1170            if (ei instanceof IFileEditorInput) {
1171                IFile file= ((IFileEditorInput)ei).getFile();
1172                IJavaElement je= (IJavaElement)file.getAdapter(IJavaElement.class);
1173                if (je == null) {
1174                    IContainer container= ((IFileEditorInput)ei).getFile().getParent();
1175                    if (container != null)
1176                        je= (IJavaElement)container.getAdapter(IJavaElement.class);
1177                }
1178                if (je == null) {
1179                    setSelection(null, false);
1180                    return;
1181                }
1182                adjustInputAndSetSelection(je);
1183            } else if (ei instanceof IClassFileEditorInput) {
1184                IClassFile cf= ((IClassFileEditorInput)ei).getClassFile();
1185                adjustInputAndSetSelection(cf);
1186            }
1187        }
1188    }
1189
1190    /**
1191     * Returns the element contained in the EditorInput
1192     * @param input the editor input
1193     * @return the input element
1194     */

1195    Object JavaDoc getElementOfInput(IEditorInput input) {
1196        if (input instanceof IFileEditorInput)
1197            return ((IFileEditorInput)input).getFile();
1198        if (input != null)
1199            return JavaUI.getEditorInputJavaElement(input);
1200        return null;
1201    }
1202
1203    void setSelection(ISelection selection, boolean reveal) {
1204        if (selection != null && selection.equals(fViewer.getSelection()))
1205            return;
1206        fProcessSelectionEvents= false;
1207        fViewer.setSelection(selection, reveal);
1208        fProcessSelectionEvents= true;
1209    }
1210
1211    /**
1212     * @param input the editor input
1213     * @param offset the offset in the file
1214     * @return the element at the given offset
1215     */

1216    protected IJavaElement getElementAt(IEditorInput input, int offset) {
1217        if (input instanceof IClassFileEditorInput) {
1218            try {
1219                return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset);
1220            } catch (JavaModelException ex) {
1221                return null;
1222            }
1223        }
1224
1225        IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
1226        ICompilationUnit unit= manager.getWorkingCopy(input);
1227        if (unit != null)
1228            try {
1229                if (unit.isConsistent())
1230                    return unit.getElementAt(offset);
1231                else {
1232                    /*
1233                     * XXX: We should set the selection later when the
1234                     * CU is reconciled.
1235                     * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
1236                     */

1237                }
1238            } catch (JavaModelException ex) {
1239                // fall through
1240
}
1241        return null;
1242    }
1243
1244    protected IType getTypeForCU(ICompilationUnit cu) {
1245        // Use primary type if possible
1246
IType primaryType= cu.findPrimaryType();
1247        if (primaryType != null)
1248            return primaryType;
1249
1250        // Use first top-level type
1251
try {
1252            IType[] types= cu.getTypes();
1253            if (types.length > 0)
1254                return types[0];
1255            else
1256                return null;
1257        } catch (JavaModelException ex) {
1258            return null;
1259        }
1260    }
1261
1262    void setProcessSelectionEvents(boolean state) {
1263        fProcessSelectionEvents= state;
1264    }
1265
1266    /* (non-Javadoc)
1267     * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
1268     */

1269    public Object JavaDoc getViewPartInput() {
1270        if (fViewer != null) {
1271            return fViewer.getInput();
1272        }
1273        return null;
1274    }
1275
1276    protected void setActionGroups(CompositeActionGroup actionGroups) {
1277        fActionGroups= actionGroups;
1278    }
1279
1280    protected void setBuildActionGroup(BuildActionGroup actionGroup) {
1281        fBuildActionGroup= actionGroup;
1282    }
1283
1284    protected void setCCPActionGroup(CCPActionGroup actionGroup) {
1285        fCCPActionGroup= actionGroup;
1286    }
1287
1288    protected void setCustomFiltersActionGroup(CustomFiltersActionGroup customFiltersActionGroup) {
1289        fCustomFiltersActionGroup= customFiltersActionGroup;
1290    }
1291
1292    protected boolean hasCustomFilter() {
1293        return fHasCustomFilter;
1294    }
1295
1296    protected boolean hasWorkingSetFilter() {
1297        return fHasWorkingSetFilter;
1298    }
1299
1300    protected void setOpenEditorGroup(OpenEditorActionGroup openEditorGroup) {
1301        fOpenEditorGroup= openEditorGroup;
1302    }
1303
1304    protected OpenEditorActionGroup getOpenEditorGroup() {
1305        return fOpenEditorGroup;
1306    }
1307
1308    protected BuildActionGroup getBuildActionGroup() {
1309        return fBuildActionGroup;
1310    }
1311
1312    protected CCPActionGroup getCCPActionGroup() {
1313        return fCCPActionGroup;
1314    }
1315
1316    private boolean linkBrowsingViewSelectionToEditor() {
1317        return isLinkingEnabled();
1318    }
1319
1320    public void setLinkingEnabled(boolean enabled) {
1321        fLinkingEnabled= enabled;
1322        PreferenceConstants.getPreferenceStore().setValue(getLinkToEditorKey(), enabled);
1323        if (enabled) {
1324            IEditorPart editor = getSite().getPage().getActiveEditor();
1325            if (editor != null) {
1326                setSelectionFromEditor(editor);
1327            }
1328        }
1329    }
1330
1331}
1332
Popular Tags