Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2006-04-12 17:11:14 +0000
committerDoug Schaefer2006-04-12 17:11:14 +0000
commitc394f40e489dd37280520439c09530c1c4a9e61f (patch)
tree93675fecb6128a0d5c6fe2b0101661838bed71bd /core/org.eclipse.cdt.ui/browser
parent160774ed3d29b0766ed646ac6eae690d7ff1ddd4 (diff)
downloadorg.eclipse.cdt-c394f40e489dd37280520439c09530c1c4a9e61f.tar.gz
org.eclipse.cdt-c394f40e489dd37280520439c09530c1c4a9e61f.tar.xz
org.eclipse.cdt-c394f40e489dd37280520439c09530c1c4a9e61f.zip
Testing the scalability of the Commit Files dialog. No really, I've removed the old indexer, search and type cache and have fixed all the compile errors that doing so caused. A number of features are disabled to be re-enabled later.
Diffstat (limited to 'core/org.eclipse.cdt.ui/browser')
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java364
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java26
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java24
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java44
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.java47
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties31
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java1624
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java234
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java20
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java66
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java56
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java61
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java266
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java152
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java246
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java170
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java36
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/OpenProjectAction.java218
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java109
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java266
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java155
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ToggleLinkingAction.java40
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoComparator.java86
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java79
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java243
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java112
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java36
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java160
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/CHierarchyPerspectiveFactory.java67
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/EnableMemberFilterAction.java49
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnSelectionAction.java69
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java133
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeDialog.java39
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java193
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java180
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java58
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java94
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java181
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java26
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java69
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java128
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java135
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java295
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java251
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java175
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java128
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java38
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java200
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java57
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java51
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java56
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java93
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java79
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java41
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java72
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java63
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java296
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java273
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java51
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties105
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java1570
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java174
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java154
-rw-r--r--core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java61
64 files changed, 4 insertions, 10671 deletions
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
deleted file mode 100644
index 9632d2278c1..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingContentProvider.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.util.Collection;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeCacheChangedListener;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.IArchive;
-import org.eclipse.cdt.core.model.IBinary;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.ICElementVisitor;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-public abstract class CBrowsingContentProvider extends BaseCElementContentProvider implements ITreeContentProvider,
- IElementChangedListener, ITypeCacheChangedListener {
-
- public static final Object CONTENT_CANCELLED = new Object();
- public static final Object CONTENT_ERROR = new Object();
- public static final Object CONTENT_EMPTY = new Object();
-
- protected static final Object[] ERROR_NO_CHILDREN = new Object[] { CONTENT_ERROR };
- protected static final Object[] ERROR_CANCELLED = new Object[] { CONTENT_CANCELLED };
- protected static final Object[] EMPTY_CHILDREN = NO_CHILDREN;
- protected static final Object[] INVALID_INPUT = NO_CHILDREN;
-
- protected StructuredViewer fViewer;
- protected Object fInput = null;
- protected IProject fProject = null;
- protected CBrowsingPart fBrowsingPart;
- protected int fReadsInDisplayThread;
-
- public CBrowsingContentProvider(CBrowsingPart browsingPart) {
- fBrowsingPart = browsingPart;
- fViewer = fBrowsingPart.getViewer();
- AllTypesCache.addTypeCacheChangedListener(this);
- CoreModel.getDefault().addElementChangedListener(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
- * java.lang.Object, java.lang.Object)
- */
- public synchronized void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (newInput instanceof Collection) {
- // Get a template object from the collection
- Collection col = (Collection) newInput;
- if (!col.isEmpty())
- newInput = col.iterator().next();
- else
- newInput = null;
- }
- fInput = newInput;
- fProject = getProject(newInput);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- AllTypesCache.removeTypeCacheChangedListener(this);
- CoreModel.getDefault().removeElementChangedListener(this);
- }
-
- public void typeCacheChanged(IProject project) {
- if (fInput != null && (fProject == null || !fProject.isAccessible() || fProject.equals(project))) {
- Object input = null;
- if (project != null && project.isAccessible()) {
- input = getNewInput(project);
- }
- postAdjustInputAndSetSelection(input);
- }
- }
-
- private IProject getProject(Object input) {
- if (input instanceof ICElement) {
- ICProject cProj = ((ICElement) input).getCProject();
- if (cProj != null)
- return cProj.getProject();
- }
- if (input instanceof ITypeInfo) {
- return ((ITypeInfo) input).getEnclosingProject();
- }
- return null;
- }
-
- private Object getNewInput(IProject project) {
- if (fInput == null || fInput instanceof ICModel) {
- return fInput;
- }
- if (fInput instanceof ICProject) {
- ICProject cproject = CoreModel.getDefault().create(project);
- if (!cproject.equals(fInput))
- return cproject;
- return fInput;
- }
- if (fInput instanceof ISourceRoot) {
- ICProject cproject = CoreModel.getDefault().create(project);
- ISourceRoot cSourceRoot = (ISourceRoot) fInput;
- if (!cSourceRoot.getCProject().equals(cproject)) {
- return cSourceRoot;
- }
- try {
- ISourceRoot[] roots = cproject.getSourceRoots();
- for (int i = 0; i < roots.length; ++i) {
- ISourceRoot root = roots[i];
- if (!(root.getResource() instanceof IProject) && root.equals(cSourceRoot)) {
- return root;
- }
- }
- } catch (CModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (fInput instanceof ICElement) {
- ICProject cproject = CoreModel.getDefault().create(project);
- ICElement celem = (ICElement) fInput;
- if (!celem.getCProject().equals(cproject)) {
- return celem;
- }
- final ICElement[] searchInfo = new ICElement[] { celem, null };
- try {
- cproject.accept(new ICElementVisitor() {
- public boolean visit(ICElement element) throws CoreException {
- if (searchInfo[1] != null)
- return false;
- if (element.equals(searchInfo[0])) {
- searchInfo[1] = element;
- return false;
- }
- return true;
- }
- });
- } catch (CoreException e) {
- }
- if (searchInfo[1] != null)
- return searchInfo[1];
- return null;
- }
- if (fInput instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo) fInput;
- if (info.exists())
- return info;
- IProject infoProj = info.getEnclosingProject();
- if (infoProj == null) {
- return null;
- }
- if (!infoProj.equals(project)) {
- return info;
- }
- ITypeInfo globalNS = AllTypesCache.getGlobalNamespace(project);
- if (info.equals(globalNS))
- return globalNS;
- info = AllTypesCache.getType(project, info.getCElementType(), info.getQualifiedTypeName());
- if (info != null) {
- return info;
- }
- return null;
- }
- return null;
- }
-
- public void elementChanged(ElementChangedEvent event) {
- try {
- processDelta(event.getDelta());
- } catch (CModelException e) {
- CUIPlugin.getDefault().log(e.getStatus());
- }
- }
-
- protected boolean isPathEntryChange(ICElementDelta delta) {
- int flags = delta.getFlags();
- return (delta.getKind() == ICElementDelta.CHANGED && ((flags & ICElementDelta.F_BINARY_PARSER_CHANGED) != 0
- || (flags & ICElementDelta.F_ADDED_PATHENTRY_LIBRARY) != 0
- || (flags & ICElementDelta.F_ADDED_PATHENTRY_SOURCE) != 0
- || (flags & ICElementDelta.F_REMOVED_PATHENTRY_LIBRARY) != 0
- || (flags & ICElementDelta.F_PATHENTRY_REORDER) != 0
- || (flags & ICElementDelta.F_REMOVED_PATHENTRY_SOURCE) != 0 || (flags & ICElementDelta.F_CHANGED_PATHENTRY_INCLUDE) != 0));
- }
-
- /**
- * Processes a delta recursively. When more than two children are affected
- * the tree is fully refreshed starting at this node. The delta is processed
- * in the current thread but the viewer updates are posted to the UI thread.
- */
- protected void processDelta(ICElementDelta delta) throws CModelException {
- int kind = delta.getKind();
- int flags = delta.getFlags();
- ICElement element = delta.getElement();
-
- if (element instanceof ITranslationUnit && ((ITranslationUnit) element).isWorkingCopy()) {
- // ignore working copies
- return;
- }
-
- //System.out.println("Processing " + element);
-
- // handle open and closing of a solution or project
- if (((flags & ICElementDelta.F_CLOSED) != 0) || ((flags & ICElementDelta.F_OPENED) != 0)) {
- postRefresh(element);
- }
-
- if (kind == ICElementDelta.REMOVED) {
- postRemove(element);
- }
-
- if (kind == ICElementDelta.ADDED) {
- Object parent = internalGetParent(element);
- postAdd(parent, element);
- }
-
- if (kind == ICElementDelta.CHANGED) {
- if (element instanceof ITranslationUnit || element instanceof IBinary || element instanceof IArchive) {
- postRefresh(element);
- return;
- }
- }
-
- if (isPathEntryChange(delta)) {
- // throw the towel and do a full refresh of the affected C project.
- postRefresh(element.getCProject());
- }
-
- ICElementDelta[] affectedChildren = delta.getAffectedChildren();
- for (int i = 0; i < affectedChildren.length; i++) {
- processDelta(affectedChildren[i]);
- }
- }
-
- private void postAdjustInputAndSetSelection(final Object input) {
- postRunnable(new Runnable() {
- public void run() {
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.setRedraw(false);
- fBrowsingPart.adjustInputAndPreserveSelection(input);
- ctrl.setRedraw(true);
- }
- }
- });
- }
-
- private void postRefresh(final Object element) {
- //System.out.println("UI refresh:" + root);
- postRunnable(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- if (element instanceof IWorkingCopy) {
- if (fViewer.testFindItem(element) != null) {
- fViewer.refresh(element);
- } else {
- fViewer.refresh(((IWorkingCopy) element).getOriginalElement());
- }
- } else {
- fViewer.refresh(element);
- }
- }
- }
- });
- }
-
- private void postAdd(final Object parent, final Object element) {
- //System.out.println("UI add:" + parent + " " + element);
- postRunnable(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- if (parent instanceof IWorkingCopy) {
- if (fViewer.testFindItem(parent) != null) {
- fViewer.refresh(parent);
- } else {
- fViewer.refresh(((IWorkingCopy) parent).getOriginalElement());
- }
- } else {
- fViewer.refresh(parent);
- }
- }
- }
- });
- }
-
- private void postRemove(final Object element) {
- //System.out.println("UI remove:" + element);
- postRunnable(new Runnable() {
- public void run() {
- // 1GF87WR: ITPUI:ALL - SWTEx + NPE closing a workbench window.
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- Object parent = internalGetParent(element);
- if (parent instanceof IWorkingCopy) {
- if (fViewer.testFindItem(parent) != null) {
- fViewer.refresh(parent);
- } else {
- fViewer.refresh(((IWorkingCopy) parent).getOriginalElement());
- }
- } else {
- fViewer.refresh(parent);
- }
- }
- }
- });
- }
-
- private void postRunnable(final Runnable r) {
- Control ctrl = fViewer.getControl();
- if (ctrl != null && !ctrl.isDisposed()) {
- ctrl.getDisplay().asyncExec(r);
- }
- }
-
- protected void startReadInDisplayThread() {
- if (isDisplayThread())
- fReadsInDisplayThread++;
- }
-
- protected void finishedReadInDisplayThread() {
- if (isDisplayThread())
- fReadsInDisplayThread--;
- }
-
- private boolean isDisplayThread() {
- Control ctrl = fViewer.getControl();
- if (ctrl == null)
- return false;
-
- Display currentDisplay = Display.getCurrent();
- return currentDisplay != null && currentDisplay.equals(ctrl.getDisplay());
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java
deleted file mode 100644
index a9289001f6f..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementComparer.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.cview.CViewElementComparer;
-
-public class CBrowsingElementComparer extends CViewElementComparer {
-
- public boolean equals(Object o1, Object o2) {
- //TODO compare ITypeInfos
- return super.equals(o1, o2);
- }
-
- public int hashCode(Object o1) {
- //TODO compare ITypeInfos
- return super.hashCode(o1);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java
deleted file mode 100644
index a6685d4961f..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingElementFilter.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.internal.ui.filters.NonCElementFilter;
-import org.eclipse.jface.viewers.Viewer;
-
-public class CBrowsingElementFilter extends NonCElementFilter {
-
- public boolean select(Viewer viewer, Object parent, Object element) {
- if (element instanceof ITypeInfo)
- return true;
- return super.select(viewer, parent, element);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java
deleted file mode 100644
index 2a543ddccf6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingLabelProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.swt.graphics.Image;
-
-class CBrowsingLabelProvider extends AppearanceAwareLabelProvider {
-
- private static final int TEXTFLAGS = DEFAULT_TEXTFLAGS | CElementLabels.F_APP_TYPE_SIGNATURE;
- private static final int IMAGEFLAGS = DEFAULT_IMAGEFLAGS | CElementImageProvider.SMALL_ICONS;
-
- CBrowsingLabelProvider() {
- super(TEXTFLAGS, IMAGEFLAGS);
- }
-
- public Image getImage(Object element) {
- if (element == CBrowsingContentProvider.CONTENT_ERROR) {
- return null;
- } else if (element == CBrowsingContentProvider.CONTENT_CANCELLED) {
- return null;
- }
- return super.getImage(element);
- }
-
- public String getText(Object element) {
- if (element == CBrowsingContentProvider.CONTENT_ERROR) {
- return CBrowsingMessages.getString("CBrowsingLabelProvider.errorNoItems"); //$NON-NLS-1$
- } else if (element == CBrowsingContentProvider.CONTENT_CANCELLED) {
- return CBrowsingMessages.getString("CBrowsingLabelProvider.errorCancelled"); //$NON-NLS-1$
- }
- return super.getText(element);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.java
deleted file mode 100644
index 9d691285e69..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class CBrowsingMessages {
-
- private static final String RESOURCE_BUNDLE= CBrowsingMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private CBrowsingMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties
deleted file mode 100644
index 127359a81bf..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingMessages.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-###############################################################################
-# Copyright (c) 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# QNX Software Systems - adapted for use in CDT
-###############################################################################
-
-CBrowsingPart.toolTip= Working Set: {0}
-CBrowsingPart.toolTip2= {0} - Working Set: {1}
-
-LexicalSortingAction.label= Sort
-LexicalSortingAction.tooltip= Sort
-LexicalSortingAction.description= Enable Sorting
-
-ClassesView.flatLayoutAction.label= &Flat
-ClassesView.HierarchicalLayoutAction.label= &Hierarchical
-ClassesView.LayoutActionGroup.layout.label= &Layout
-
-# the first argument is the string to which the second one is appended
-StatusBar.concat= {0}, {1}
-
-ClassPathContainer.unbound_label={0} (unbound)
-ClassPathContainer.unknown_label={0} (unknown)
-
-CBrowsingLabelProvider.errorNoItems= Unable to retrieve type information
-CBrowsingLabelProvider.errorCancelled= Cancelled
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
deleted file mode 100644
index bfa53baea51..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPart.java
+++ /dev/null
@@ -1,1624 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.IWorkingCopy;
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.IWorkingCopyManager;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkingSet;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public abstract class CBrowsingPart extends ViewPart implements IMenuListener, ISelectionListener, IViewPartInputProvider {
-
-// private static final String TAG_SELECTED_ELEMENTS= "selectedElements"; //$NON-NLS-1$
-// private static final String TAG_SELECTED_ELEMENT= "selectedElement"; //$NON-NLS-1$
-// private static final String TAG_LOGICAL_PACKAGE= "logicalPackage"; //$NON-NLS-1$
-// private static final String TAG_SELECTED_ELEMENT_PATH= "selectedElementPath"; //$NON-NLS-1$
-
- private LabelProvider fLabelProvider;
- private ILabelProvider fTitleProvider;
- private StructuredViewer fViewer;
- private IMemento fMemento;
- private TypeInfoComparator fTypeComparator;
-
- // Actions
- private WorkingSetFilterActionGroup fWorkingSetFilterActionGroup;
- private boolean fHasWorkingSetFilter= true;
- private boolean fHasCustomFilter= true;
-// private OpenEditorActionGroup fOpenEditorGroup;
-// private CCPActionGroup fCCPActionGroup;
-// private BuildActionGroup fBuildActionGroup;
- private ToggleLinkingAction fToggleLinkingAction;
-// protected CompositeActionGroup fActionGroups;
-
-
-// // Filters
-// private CustomFiltersActionGroup fCustomFiltersActionGroup;
-
- protected IWorkbenchPart fPreviousSelectionProvider;
- protected Object fPreviousSelectedElement;
-
- // Linking
- private boolean fLinkingEnabled;
-
- /*
- * Ensure selection changed events being processed only if
- * initiated by user interaction with this part.
- */
- boolean fProcessSelectionEvents= true;
-
- private IPartListener2 fPartListener= new IPartListener2() {
- public void partActivated(IWorkbenchPartReference ref) {
- setSelectionFromEditor(ref);
- }
- public void partBroughtToTop(IWorkbenchPartReference ref) {
- setSelectionFromEditor(ref);
- }
- public void partInputChanged(IWorkbenchPartReference ref) {
- setSelectionFromEditor(ref);
- }
- public void partClosed(IWorkbenchPartReference ref) {
- }
- public void partDeactivated(IWorkbenchPartReference ref) {
- }
- public void partOpened(IWorkbenchPartReference ref) {
- }
- public void partVisible(IWorkbenchPartReference ref) {
- if (ref != null && ref.getId() == getSite().getId()){
- fProcessSelectionEvents= true;
- IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage();
- if (page != null)
- selectionChanged(page.getActivePart(), page.getSelection());
- }
- }
- public void partHidden(IWorkbenchPartReference ref) {
- if (ref != null && ref.getId() == getSite().getId())
- fProcessSelectionEvents= false;
- }
- };
-
- public CBrowsingPart() {
- super();
- initLinkingEnabled();
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fMemento= memento;
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void saveState(IMemento memento) {
- if (fViewer == null) {
- // part has not been created
- if (fMemento != null) //Keep the old state;
- memento.putMemento(fMemento);
- return;
- }
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.saveState(memento);
-// if (fHasCustomFilter)
-// fCustomFiltersActionGroup.saveState(memento);
- saveSelectionState(memento);
- saveLinkingEnabled(memento);
- }
-
- private void saveLinkingEnabled(IMemento memento) {
- memento.putInteger(getLinkToEditorKey(), fLinkingEnabled ? 1 : 0);
- }
-
- private void saveSelectionState(IMemento memento) {
-/* Object elements[]= ((IStructuredSelection) fViewer.getSelection()).toArray();
- if (elements.length > 0) {
- IMemento selectionMem= memento.createChild(TAG_SELECTED_ELEMENTS);
- for (int i= 0; i < elements.length; i++) {
- IMemento elementMem= selectionMem.createChild(TAG_SELECTED_ELEMENT);
- Object o= elements[i];
- if (o instanceof ICElement)
- elementMem.putString(TAG_SELECTED_ELEMENT_PATH, ((ICElement) elements[i]).getHandleIdentifier());
- else if (o instanceof LogicalPackage) {
- IPackageFragment[] packages=((LogicalPackage)o).getFragments();
- for (int j= 0; j < packages.length; j++) {
- IMemento packageMem= elementMem.createChild(TAG_LOGICAL_PACKAGE);
- packageMem.putString(TAG_SELECTED_ELEMENT_PATH, packages[j].getHandleIdentifier());
- }
- }
- }
- }
-*/
- }
-
- protected void restoreState(IMemento memento) {
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.restoreState(memento);
-// if (fHasCustomFilter)
-// fCustomFiltersActionGroup.restoreState(memento);
-
- if (fHasCustomFilter || fHasWorkingSetFilter) {
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
- }
-
- private ISelection restoreSelectionState(IMemento memento) {
-/*
- if (memento == null)
- return null;
-
- IMemento childMem;
- childMem= memento.getChild(TAG_SELECTED_ELEMENTS);
- if (childMem != null) {
- ArrayList list= new ArrayList();
- IMemento[] elementMem= childMem.getChildren(TAG_SELECTED_ELEMENT);
- for (int i= 0; i < elementMem.length; i++) {
- String javaElementHandle= elementMem[i].getString(TAG_SELECTED_ELEMENT_PATH);
- if (javaElementHandle == null) {
- // logical package
- IMemento[] packagesMem= elementMem[i].getChildren(TAG_LOGICAL_PACKAGE);
- LogicalPackage lp= null;
- for (int j= 0; j < packagesMem.length; j++) {
- javaElementHandle= packagesMem[j].getString(TAG_SELECTED_ELEMENT_PATH);
- Object pack= (IPackageFragment)JavaCore.create(javaElementHandle);
- if (pack instanceof IPackageFragment && ((IPackageFragment)pack).exists()) {
- if (lp == null)
- lp= new LogicalPackage((IPackageFragment)pack);
- else
- lp.add((IPackageFragment)pack);
- }
- }
- if (lp != null)
- list.add(lp);
- } else {
- ICElement element= JavaCore.create(javaElementHandle);
- if (element != null && element.exists())
- list.add(element);
- }
- }
- return new StructuredSelection(list);
- }
-*/
- return null;
- }
-
- private void restoreLinkingEnabled(IMemento memento) {
- Integer val= memento.getInteger(getLinkToEditorKey());
- if (val != null) {
- fLinkingEnabled= val.intValue() != 0;
- }
- }
-
- /**
- * Creates the search list inner viewer.
- */
- public void createPartControl(Composite parent) {
- Assert.isTrue(fViewer == null);
-
-
- fTypeComparator= new TypeInfoComparator();
-
- // Setup viewer
- fViewer= createViewer(parent);
-
- initDragAndDrop();
-
- fLabelProvider= createLabelProvider();
- fViewer.setLabelProvider(fLabelProvider);
-
- fViewer.setSorter(createViewerSorter());
- fViewer.setComparer(createElementComparer());
-
- fViewer.setUseHashlookup(true);
- fTitleProvider= createTitleProvider();
-
- fViewer.setComparer(new CBrowsingElementComparer());
-
- createContextMenu();
- getSite().setSelectionProvider(fViewer);
-
- if (fMemento != null) { // initialize linking state before creating the actions
- restoreLinkingEnabled(fMemento);
- }
-
- createActions(); // call before registering for selection changes
- addKeyListener();
-
- if (fMemento != null)
- restoreState(fMemento);
-
- getSite().setSelectionProvider(fViewer);
-
- // Status line
- IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
- fViewer.addSelectionChangedListener(createStatusBarUpdater(slManager));
-
-
- hookViewerListeners();
-
- // Filters
- addFilters();
-
- // Initialize viewer input
- fViewer.setContentProvider(createContentProvider());
- setInitialInput();
-
- // Initialize selecton
- setInitialSelection();
- fMemento= null;
-
- // Listen to page changes
- getViewSite().getPage().addPostSelectionListener(this);
- getViewSite().getPage().addPartListener(fPartListener);
-
- fillActionBars(getViewSite().getActionBars());
-
- setHelp();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInSource.class) {
- return getShowInSource();
- }
- return super.getAdapter(key);
- }
-
- /**
- * Returns the <code>IShowInSource</code> for this view.
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- null,
- getSite().getSelectionProvider().getSelection());
- }
- };
- }
-
-// protected DecoratingLabelProvider createDecoratingLabelProvider(CUILabelProvider provider) {
-//// XXX: Work in progress for problem decorator being a workbench decorator//
-//// return new ExcludingDecoratingLabelProvider(provider, decorationMgr, "org.eclipse.jdt.ui.problem.decorator"); //$NON-NLS-1$
-// return new DecoratingCLabelProvider(provider);
-// }
-
- protected StatusBarUpdater createStatusBarUpdater(IStatusLineManager slManager) {
- return new StatusBarUpdater(slManager);
- }
-
- protected void createContextMenu() {
- MenuManager menuManager= new MenuManager("#PopupMenu"); //$NON-NLS-1$
- menuManager.setRemoveAllWhenShown(true);
- menuManager.addMenuListener(this);
- Menu contextMenu= menuManager.createContextMenu(fViewer.getControl());
- fViewer.getControl().setMenu(contextMenu);
- getSite().registerContextMenu(menuManager, fViewer);
- }
-
- protected void initDragAndDrop() {
-/* int ops= DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- // drop
- Transfer[] dropTransfers= new Transfer[] {
- LocalSelectionTransfer.getInstance()
- };
- TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
- new SelectionTransferDropAdapter(fViewer)
- };
- fViewer.addDropSupport(ops | DND.DROP_DEFAULT, dropTransfers, new DelegatingDropAdapter(dropListeners));
-
- // Drag
- Transfer[] dragTransfers= new Transfer[] {
- LocalSelectionTransfer.getInstance(),
- ResourceTransfer.getInstance()};
- TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
- new SelectionTransferDragAdapter(fViewer),
- new ResourceTransferDragAdapter(fViewer)
- };
- fViewer.addDragSupport(ops, dragTransfers, new JdtViewerDragAdapter(fViewer, dragListeners));
-*/ }
-
- protected void fillActionBars(IActionBars actionBars) {
- IToolBarManager toolBar= actionBars.getToolBarManager();
- fillToolBar(toolBar);
-
-
- if (fHasWorkingSetFilter)
- fWorkingSetFilterActionGroup.fillActionBars(getViewSite().getActionBars());
-
- actionBars.updateActionBars();
-
-// fActionGroups.fillActionBars(actionBars);
-//
-// if (fHasCustomFilter)
-// fCustomFiltersActionGroup.fillActionBars(actionBars);
-//
- IMenuManager menu= actionBars.getMenuManager();
- menu.add(fToggleLinkingAction);
- }
-
- //---- IWorkbenchPart ------------------------------------------------------
-
-
- public void setFocus() {
- fViewer.getControl().setFocus();
- }
-
- public void dispose() {
- if (fViewer != null) {
- getViewSite().getPage().removePostSelectionListener(this);
- getViewSite().getPage().removePartListener(fPartListener);
- fViewer= null;
- }
-// if (fActionGroups != null)
-// fActionGroups.dispose();
-
- if (fWorkingSetFilterActionGroup != null) {
- fWorkingSetFilterActionGroup.dispose();
- }
-
- super.dispose();
- }
-
- /**
- * Adds the KeyListener
- */
- protected void addKeyListener() {
- fViewer.getControl().addKeyListener(new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- handleKeyReleased(event);
- }
- });
- }
-
- protected void handleKeyReleased(KeyEvent event) {
- if (event.stateMask != 0)
- return;
-
- int key= event.keyCode;
- if (key == SWT.F5) {
-// IAction action= fBuildActionGroup.getRefreshAction();
-// if (action.isEnabled())
-// action.run();
- }
- }
-
- //---- Adding Action to Toolbar -------------------------------------------
-
- protected void fillToolBar(IToolBarManager tbm) {
- }
-
- /**
- * Called when the context menu is about to open.
- * Override to add your own context dependent menu contributions.
- */
- public void menuAboutToShow(IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
-
- IStructuredSelection selection= (IStructuredSelection) fViewer.getSelection();
- int size= selection.size();
- Object element= selection.getFirstElement();
-
- if (size == 1)
- addOpenNewWindowAction(menu, element);
-// fActionGroups.setContext(new ActionContext(selection));
-// fActionGroups.fillContextMenu(menu);
-// fActionGroups.setContext(null);
- }
-
- private void addOpenNewWindowAction(IMenuManager menu, Object element) {
- if (element instanceof ICElement) {
- element= ((ICElement)element).getResource();
- }
- if (!(element instanceof IContainer))
- return;
-// menu.appendToGroup(
-// IContextMenuConstants.GROUP_OPEN,
-// new PatchedOpenInNewWindowAction(getSite().getWorkbenchWindow(), (IContainer)element));
- }
-
- protected void createActions() {
-// fActionGroups= new CompositeActionGroup(new ActionGroup[] {
-// new NewWizardsActionGroup(this.getSite()),
-// fOpenEditorGroup= new OpenEditorActionGroup(this),
-// new OpenViewActionGroup(this),
-// fCCPActionGroup= new CCPActionGroup(this),
-// new GenerateActionGroup(this),
-// new RefactorActionGroup(this),
-// new ImportActionGroup(this),
-// fBuildActionGroup= new BuildActionGroup(this),
-// new JavaSearchActionGroup(this)});
-
-
- if (fHasWorkingSetFilter) {
- String viewId= getConfigurationElement().getAttribute("id"); //$NON-NLS-1$
- Assert.isNotNull(viewId);
- IPropertyChangeListener workingSetListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doWorkingSetChanged(event);
- }
- };
- fWorkingSetFilterActionGroup= new WorkingSetFilterActionGroup(viewId, getShell(), workingSetListener);
- fViewer.addFilter(fWorkingSetFilterActionGroup.getWorkingSetFilter());
- }
-
-// // Custom filter group
-// if (fHasCustomFilter)
-// fCustomFiltersActionGroup= new CustomFiltersActionGroup(this, fViewer);
-//
- fToggleLinkingAction= new ToggleLinkingAction(this);
- }
-
- void doWorkingSetChanged(PropertyChangeEvent event) {
- String property= event.getProperty();
- if (IWorkingSetManager.CHANGE_WORKING_SET_NAME_CHANGE.equals(property))
- updateTitle();
- else if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- updateTitle();
- fViewer.getControl().setRedraw(false);
- fViewer.refresh();
- fViewer.getControl().setRedraw(true);
- }
-
- }
-
-
- /**
- * Returns the shell to use for opening dialogs.
- * Used in this class, and in the actions.
- */
- Shell getShell() {
- return fViewer.getControl().getShell();
- }
-
- protected final Display getDisplay() {
- return fViewer.getControl().getDisplay();
- }
-
- /**
- * Returns the selection provider.
- */
- ISelectionProvider getSelectionProvider() {
- return fViewer;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- abstract protected boolean isValidInput(Object element);
-
- protected boolean exists(Object element) {
- if (element == null)
- return false;
- if (element instanceof ICElement)
- return ((ICElement)element).exists();
- if (element instanceof ITypeInfo)
- return ((ITypeInfo)element).exists();
- return false;
- }
-
- protected ICProject findCProject(ICElement element) {
- return element.getCProject();
- }
-
- protected ICProject findCProject(ITypeInfo info) {
- IProject project = info.getEnclosingProject();
- if (project != null) {
- try {
- ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects();
- if (cProjects != null) {
- for (int i = 0; i < cProjects.length; ++i) {
- ICProject cProject = cProjects[i];
- if (cProject.getProject().equals(project))
- return cProject;
- }
- }
- } catch (CModelException e) {
- }
- }
- return null;
- }
-
- protected ISourceRoot findSourceRoot(ICElement element) {
- while (element != null) {
- if (element instanceof ISourceRoot)
- return (ISourceRoot)element;
- if (element instanceof ICProject)
- return null;
- element = element.getParent();
- }
- return null;
- }
-
- protected ISourceRoot findSourceRoot(ITypeInfo info) {
- ICProject cProject = findCProject(info);
- if (cProject != null) {
- try {
- ISourceRoot[] roots = cProject.getAllSourceRoots();
- if (roots != null) {
- for (int i = 0; i < roots.length; ++i) {
- ISourceRoot root = roots[i];
- if (!isProjectSourceRoot(root)) {
- TypeSearchScope scope = new TypeSearchScope();
- scope.add(root);
- if (info.isEnclosed(scope))
- return root;
- }
- }
- }
- } catch (CModelException e) {
- }
- }
- return null;
- }
-
- protected boolean isProjectSourceRoot(ISourceRoot root) {
- if (root != null) {
- IResource resource = root.getResource();
- return (resource instanceof IProject);
- }
- return false;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- abstract protected boolean isValidElement(Object element);
-
- private boolean isInputResetBy(Object newInput, Object input, IWorkbenchPart part) {
- if (newInput == null)
- return part == fPreviousSelectionProvider;
-
- if (input instanceof ICElement && newInput instanceof ICElement)
- return getTypeComparator().compare(newInput, input) > 0;
-
- if((newInput instanceof List) && (part instanceof NamespacesView))
- return true;
- return false;
- }
-
- private boolean isInputResetBy(IWorkbenchPart part) {
- if (!(part instanceof CBrowsingPart))
- return true;
- Object thisInput= getViewer().getInput();
- Object partInput= ((CBrowsingPart)part).getViewer().getInput();
-
- if(thisInput instanceof Collection)
- thisInput= ((Collection)thisInput).iterator().next();
-
- if(partInput instanceof Collection)
- partInput= ((Collection)partInput).iterator().next();
-
- if ((thisInput instanceof ICElement || thisInput instanceof ITypeInfo)
- && (partInput instanceof ICElement || partInput instanceof ITypeInfo))
- return getTypeComparator().compare(partInput, thisInput) > 0;
- return true;
- }
-
- protected boolean isAncestorOf(Object ancestor, Object element) {
- if (element instanceof ICElement && ancestor instanceof ICElement)
- return !element.equals(ancestor) && internalIsAncestorOf((ICElement)ancestor, (ICElement)element);
- if (element instanceof ITypeInfo) {
- if (ancestor instanceof ISourceRoot || ancestor instanceof ICProject || ancestor instanceof ICModel) {
- ICProject cProject = ((ICElement)ancestor).getCProject();
- if (cProject != null) {
- IProject proj = (((ITypeInfo)element).getEnclosingProject());
- return (proj != null && proj.equals(cProject.getProject()));
- }
- }
- if (ancestor instanceof ITypeInfo) {
- return ((ITypeInfo)ancestor).encloses(((ITypeInfo)element));
- }
- }
- return false;
- }
-
- private boolean internalIsAncestorOf(ICElement ancestor, ICElement element) {
- if (element != null)
- return element.equals(ancestor) || internalIsAncestorOf(ancestor, element.getParent());
- return false;
- }
-
- private boolean isSearchResultView(IWorkbenchPart part) {
-// return SearchUtil.isSearchPlugInActivated() && (part instanceof ISearchResultView);
- return false;
- }
-
- protected boolean needsToProcessSelectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!fProcessSelectionEvents || part == this || isSearchResultView(part)){
- if (part == this)
- fPreviousSelectionProvider= part;
- return false;
- }
- return true;
- }
-
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- if (!needsToProcessSelectionChanged(part, selection))
- return;
-
- if (fToggleLinkingAction.isChecked() && (part instanceof ITextEditor)) {
- setSelectionFromEditor(part, selection);
- return;
- }
-
- if (!(selection instanceof IStructuredSelection))
- return;
-
- // Set selection
- Object selectedElement= getSingleElementFromSelection(selection);
-
- if (selectedElement != null && (part == null || part.equals(fPreviousSelectionProvider)) && selectedElement.equals(fPreviousSelectedElement))
- return;
-
- fPreviousSelectedElement= selectedElement;
-
- Object currentInput= getViewer().getInput();
- if (selectedElement != null && selectedElement.equals(currentInput)) {
- Object elementToSelect= findElementToSelect(selectedElement);
- if (elementToSelect != null && getTypeComparator().compare(selectedElement, elementToSelect) < 0)
- setSelection(new StructuredSelection(elementToSelect), true);
- else if (elementToSelect == null && (this instanceof MembersView)) {
- setSelection(StructuredSelection.EMPTY, true);
- fPreviousSelectedElement= StructuredSelection.EMPTY;
- }
- fPreviousSelectionProvider= part;
- return;
- }
-
- // Clear input if needed
- if (part != fPreviousSelectionProvider && selectedElement != null && !selectedElement.equals(currentInput) && isInputResetBy(selectedElement, currentInput, part)) {
- if (!isAncestorOf(selectedElement, currentInput))
- setInput(null);
- fPreviousSelectionProvider= part;
- return;
- } else if (selection.isEmpty() && !isInputResetBy(part)) {
- fPreviousSelectionProvider= part;
- return;
- } else if (selectedElement == null && part == fPreviousSelectionProvider) {
- setInput(null);
- fPreviousSelectionProvider= part;
- return;
- }
- fPreviousSelectionProvider= part;
-
- // Adjust input and set selection and
- adjustInputAndSetSelection(selectedElement);
- }
-
-
- void setHasWorkingSetFilter(boolean state) {
- fHasWorkingSetFilter= state;
- }
-
- void setHasCustomSetFilter(boolean state) {
- fHasCustomFilter= state;
- }
-
- protected Object getInput() {
- return fViewer.getInput();
- }
-
- protected void setInput(Object input) {
- setViewerInput(input);
- updateTitle();
- }
-
- boolean isLinkingEnabled() {
- return fLinkingEnabled;
- }
-
- private void initLinkingEnabled() {
- fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(getLinkToEditorKey());
- }
-
- private void setViewerInput(Object input) {
- fProcessSelectionEvents= false;
- fViewer.setInput(input);
- fProcessSelectionEvents= true;
- }
-
- protected void updateTitle() {
- setTitleToolTip(getToolTipText(fViewer.getInput()));
- }
-
- /**
- * Returns the tool tip text for the given element.
- */
- String getToolTipText(Object element) {
- String result;
- if (!(element instanceof IResource)) {
- result= CElementLabels.getTextLabel(element, AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS);
- } else {
- IPath path= ((IResource) element).getFullPath();
- if (path.isRoot()) {
- result= getConfigurationElement().getAttribute("name"); //$NON-NLS-1$
- } else {
- result= path.makeRelative().toString();
- }
- }
-
- if (fWorkingSetFilterActionGroup == null || fWorkingSetFilterActionGroup.getWorkingSet() == null)
- return result;
-
- IWorkingSet ws= fWorkingSetFilterActionGroup.getWorkingSet();
- String wsstr= CBrowsingMessages.getFormattedString("CBrowsingPart.toolTip", new String[] { ws.getName() }); //$NON-NLS-1$
- if (result.length() == 0)
- return wsstr;
- return CBrowsingMessages.getFormattedString("CBrowsingPart.toolTip2", new String[] { result, ws.getName() }); //$NON-NLS-1$
- }
-
- public String getTitleToolTip() {
- if (fViewer == null)
- return super.getTitleToolTip();
- return getToolTipText(fViewer.getInput());
- }
-
- protected final StructuredViewer getViewer() {
- return fViewer;
- }
-
- protected final void setViewer(StructuredViewer viewer){
- fViewer= viewer;
- }
-
- protected abstract LabelProvider createLabelProvider();
-
- protected abstract ViewerSorter createViewerSorter();
-
- protected IElementComparer createElementComparer() {
- return new CBrowsingElementComparer();
- }
-
- protected ILabelProvider createTitleProvider() {
- return new CElementLabelProvider(CElementLabelProvider.SHOW_BASICS | CElementLabelProvider.SHOW_SMALL_ICONS);
- }
-
- protected final ILabelProvider getLabelProvider() {
- return fLabelProvider;
- }
-
- protected final ILabelProvider getTitleProvider() {
- return fTitleProvider;
- }
-
- /**
- * Creates the the viewer of this part.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- return new ElementTableViewer(parent, SWT.MULTI);
- }
-
- protected int getLabelProviderFlags() {
- return CElementLabelProvider.SHOW_BASICS | CElementLabelProvider.SHOW_OVERLAY_ICONS |
- CElementLabelProvider.SHOW_SMALL_ICONS | /*CElementLabelProvider.SHOW_VARIABLE |*/ CElementLabelProvider.SHOW_PARAMETERS;
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- // default is to have no filters
- }
-
-// /**
-// * Creates the the content provider of this part.
-// */
- protected abstract IContentProvider createContentProvider();
-
- protected void setInitialInput() {
- // Use the selection, if any
- ISelection selection= getSite().getPage().getSelection();
- Object input= getSingleElementFromSelection(selection);
- if (!(input instanceof ICElement) && !(input instanceof ITypeInfo)) {
- // Use the input of the page
- input= getSite().getPage().getInput();
- if (!(input instanceof ICElement) && input instanceof IAdaptable)
- input= ((IAdaptable)input).getAdapter(ICElement.class);
- }
- setInput(findInputForElement(input));
- }
-
- protected void setInitialSelection() {
- // Use the selection, if any
- Object input;
- IWorkbenchPage page= getSite().getPage();
- ISelection selection= null;
- if (page != null)
- selection= page.getSelection();
- if (selection instanceof ITextSelection) {
- Object part= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
- if (part instanceof IEditorPart) {
- setSelectionFromEditor((IEditorPart)part);
- if (fViewer.getSelection() != null)
- return;
- }
- }
-
- // Use saved selection from memento
- if (selection == null || selection.isEmpty())
- selection= restoreSelectionState(fMemento);
-
- if (selection == null || selection.isEmpty()) {
- // Use the input of the page
- input= getSite().getPage().getInput();
- if (!(input instanceof ICElement)) {
- if (input instanceof IAdaptable)
- input= ((IAdaptable)input).getAdapter(ICElement.class);
- else
- return;
- }
- selection= new StructuredSelection(input);
- }
- selectionChanged(null, selection);
- }
-
- protected final void setHelp() {
-// CUIHelp.setHelp(fViewer, getHelpContextId());
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- abstract protected String getHelpContextId();
-
- /**
- * Returns the preference key for the link to editor setting.
- *
- * @return the string used as key into the preference store
- */
- abstract protected String getLinkToEditorKey();
-
- /**
- * Adds additional listeners to this view.
- * This method can be overridden but should
- * call super.
- */
- protected void hookViewerListeners() {
- fViewer.addPostSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (!fProcessSelectionEvents)
- return;
-
- fPreviousSelectedElement= getSingleElementFromSelection(event.getSelection());
-
- IWorkbenchPage page= getSite().getPage();
- if (page == null)
- return;
-
- if (page.equals(CUIPlugin.getActivePage()) && CBrowsingPart.this.equals(page.getActivePart())) {
- linkToEditor((IStructuredSelection)event.getSelection());
- }
- }
- });
-
- fViewer.addOpenListener(new IOpenListener() {
- public void open(OpenEvent event) {
- ISelection selection = event.getSelection();
- if (selection != null) {
- Object element = getSingleElementFromSelection(selection);
- if (element instanceof ICElement) {
- openInEditor((ICElement)element);
- } else if (element instanceof ITypeInfo) {
- openTypeInEditor((ITypeInfo)element);
- }
- restoreSelection();
- }
-// IAction open= fOpenEditorGroup.getOpenAction();
-// if (open.isEnabled()) {
-// open.run();
-// restoreSelection();
-// }
- }
- });
- }
-
- protected void openTypeInEditor(ITypeInfo info) {
- if (!info.exists())
- return;
-
- if (info == info.getCache().getGlobalNamespace()) {
- return; // nothing to open
- }
- ITypeReference location = info.getResolvedReference();
- if (location == null) {
- final ITypeInfo[] typesToResolve = new ITypeInfo[] { info };
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.resolveTypeLocation(typesToResolve[0], monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
-
- location = info.getResolvedReference();
- }
-
- if (location == null) {
- // could not resolve location
- String title = OpenTypeMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$
- String message = OpenTypeMessages.getFormattedString("OpenTypeAction.errorTypeNotFound", info.getQualifiedTypeName().toString()); //$NON-NLS-1$
- MessageDialog.openError(getShell(), title, message);
- } else if (!openInEditor(location)) {
- // error opening editor
- String title = OpenTypeMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$
- String message = OpenTypeMessages.getFormattedString("OpenTypeAction.errorOpenEditor", location.getPath().toString()); //$NON-NLS-1$
- MessageDialog.openError(getShell(), title, message);
- }
- }
-
- private boolean openInEditor(ITypeReference location) {
- ITranslationUnit unit = location.getTranslationUnit();
- IEditorPart editorPart = null;
-
- try {
- if (unit != null)
- editorPart = EditorUtility.openInEditor(unit);
- if (editorPart == null) {
- // open as external file
- IPath path = location.getLocation();
- if (path != null) {
- IStorage storage = new FileStorage(path);
- editorPart = EditorUtility.openInEditor(storage);
- }
- }
-
- // highlight the type in the editor
- if (editorPart != null && editorPart instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) editorPart;
- if( location.isLineNumber() )
- {
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- try
- {
- int startOffset = document.getLineOffset(location.getOffset()-1);
- int length=document.getLineLength(location.getOffset()-1);
- editor.selectAndReveal(startOffset, length);
- return true;
- }
- catch( BadLocationException ble )
- {
- return false;
- }
- }
- editor.selectAndReveal(location.getOffset(), location.getLength());
- return true;
- }
- } catch (CModelException ex) {
- ex.printStackTrace();
- return false;
- } catch (PartInitException ex) {
- ex.printStackTrace();
- return false;
- }
-
- return false;
- }
-
- protected boolean openInEditor(ICElement cElement) {
- IEditorPart editorPart = null;
-
- try {
- if (cElement != null)
- editorPart = EditorUtility.openInEditor(cElement);
- if (editorPart == null)
- return false;
- } catch (CModelException ex) {
- ex.printStackTrace();
- return false;
- } catch (PartInitException ex) {
- ex.printStackTrace();
- return false;
- }
-
- // highlight the type in the editor
- if (cElement != null && editorPart instanceof CEditor) {
- CEditor editor = (CEditor) editorPart;
- editor.setSelection(cElement);
- return true;
- }
- return false;
- }
-
- void restoreSelection() {
- // Default is to do nothing
- }
-
- void adjustInputAndPreserveSelection(Object o) {
- Object element = getOriginalElement(o);
- if (!(element instanceof ICElement) && !(element instanceof ITypeInfo)) {
- setSelection(StructuredSelection.EMPTY, true);
- return;
- }
-
- Object elementToSelect= getSuitableElement(findElementToSelect(element));
- Object newInput= findInputForElement(element);
- Object oldInput= null;
- Object viewerInput = getInput();
- if (viewerInput instanceof ICElement || viewerInput instanceof ITypeInfo)
- oldInput = viewerInput;
-
- if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(element, oldInput)))
- // Clear input
- setInput(null);
- else { // if (mustSetNewInput(elementToSelect, oldInput, newInput)) {
- // Adjust input to selection
- setInput(newInput);
- // Recompute suitable element since it depends on the viewer's input
- elementToSelect= getSuitableElement(elementToSelect);
- }
-
- if (elementToSelect != null /*&& elementToSelect.exists()*/)
- setSelection(new StructuredSelection(elementToSelect), true);
- else
- setSelection(StructuredSelection.EMPTY, true);
- }
-
- void adjustInputAndSetSelection(Object o) {
- Object element = getOriginalElement(o);
- if (!(element instanceof ICElement) && !(element instanceof ITypeInfo)) {
- setSelection(StructuredSelection.EMPTY, true);
- return;
- }
-
- Object elementToSelect= getSuitableElement(findElementToSelect(element));
- Object newInput= findInputForElement(element);
- Object oldInput= null;
- Object viewerInput = getInput();
- if (viewerInput instanceof ICElement || viewerInput instanceof ITypeInfo)
- oldInput = viewerInput;
-
- if (elementToSelect == null && !isValidInput(newInput) && (newInput == null && !isAncestorOf(element, oldInput)))
- // Clear input
- setInput(null);
- else if (mustSetNewInput(elementToSelect, oldInput, newInput)) {
- // Adjust input to selection
- setInput(newInput);
- // Recompute suitable element since it depends on the viewer's input
- elementToSelect= getSuitableElement(elementToSelect);
- }
-
- if (elementToSelect != null /*&& elementToSelect.exists()*/)
- setSelection(new StructuredSelection(elementToSelect), true);
- else
- setSelection(StructuredSelection.EMPTY, true);
- }
-
- protected Object getOriginalElement(Object obj) {
- if (obj instanceof ICElement) {
- ICElement element = (ICElement)obj;
- // Below is for children of TranslationUnits but we have to make sure
- // we handle the case that the child comes from the a workingCopy in that
- // case it should be equal as the original element.
- ITranslationUnit t = (ITranslationUnit)element.getAncestor(ICElement.C_UNIT);
- if (t != null && t.isWorkingCopy()) {
- ICElement original = ((IWorkingCopy)t).getOriginal(element);
- if (original != null)
- return original;
- }
- }
- return obj;
- }
-
-
- /**
- * Compute if a new input must be set.
- *
- * @return <code>true</code> if the input has to be set
- * @since 3.0
- */
- private boolean mustSetNewInput(Object elementToSelect, Object oldInput, Object newInput) {
- if (newInput == null || oldInput == null || !newInput.equals(oldInput)) {
- return true;
- }
- if (elementToSelect == null) {
- return false;
- }
-// return !findInputForElement(elementToSelect).equals(newInput);
- return false;
-// return !(inputContainsElement(newInput, elementToSelect));
-// return (newInput == null || !newInput.equals(oldInput))
-// && (elementToSelect == null
-// || oldInput == null);
-// return (newInput == null || !newInput.equals(oldInput))
-// && (elementToSelect == null
-// || oldInput == null
-// || (!((elementToSelect instanceof IDeclaration)
-// && (elementToSelect.getParent().equals(oldInput.getParent()))
-// && (!isAncestorOf(getViewPartInput(), elementToSelect)))));
- }
-
- /**
- * Finds the closest C element which can be used as input for
- * this part and has the given C element as child
- *
- * @param element the C element for which to search the closest input
- * @return the closest C element used as input for this part
- */
- abstract protected Object findInputForElement(Object element);
-
- /**
- * Finds the element which has to be selected in this part.
- *
- * @param element the C element which has the focus
- */
- abstract protected Object findElementToSelect(Object element);
-
- /**
- * Converts the given C element to one which is suitable for this
- * view. It takes into account wether the view shows working copies or not.
- *
- * @param element the C element to be converted
- * @return an element suitable for this view
- */
- Object getSuitableElement(Object obj) {
- if (!(obj instanceof ICElement) && !(obj instanceof ITypeInfo))
- return null;
- if (fTypeComparator.compare(obj, ICElement.C_UNIT) > 0)
- return obj;
- return obj;
-// if (element.getElementType() == IJavaElement.CLASS_FILE)
-// return element;
-// if (isInputAWorkingCopy()) {
-// IJavaElement wc= getWorkingCopy(element);
-// if (wc != null)
-// element= wc;
-// return element;
-// }
-// else {
-// return element.getPrimaryElement();
-// }
- }
-
- protected ICElement getTypeForTU(ITranslationUnit tu) {
- tu = (ITranslationUnit) getSuitableElement(tu);
-
-// // Use primary type if possible
-// IType primaryType= cu.findPrimaryType();
-// if (primaryType != null)
-// return primaryType;
-
- // Use first top-level type
- try {
- ICElement[] types = TypeUtil.getTypes(tu);
- if (types.length > 0)
- return types[0];
- return null;
- } catch (CModelException ex) {
- return null;
- }
- }
-
- protected final Object getSingleElementFromSelection(ISelection selection) {
- if (!(selection instanceof StructuredSelection) || selection.isEmpty())
- return null;
-
- Iterator iter= ((StructuredSelection)selection).iterator();
- Object firstElement= iter.next();
- if (!(firstElement instanceof ICElement) && !(firstElement instanceof ITypeInfo)) {
-// if (SearchUtil.isISearchResultViewEntry(firstElement)) {
-// ICElement je= SearchUtil.getJavaElement(firstElement);
-// if (je != null)
-// return je;
-// firstElement= SearchUtil.getResource(firstElement);
-// }
- if (firstElement instanceof IAdaptable) {
- ICElement je= (ICElement)((IAdaptable)firstElement).getAdapter(ICElement.class);
- if (je == null && firstElement instanceof IFile) {
- IContainer parent= ((IFile)firstElement).getParent();
- if (parent != null)
- return (ICElement)parent.getAdapter(ICElement.class);
- return null;
- }
- return je;
- }
- return firstElement;
- }
- Object currentInput= getViewer().getInput();
- if (currentInput == null || !currentInput.equals(findInputForElement(firstElement))) {
- if (iter.hasNext()) {
- // multi selection and view is empty
- return null;
- }
- // ok: single selection and view is empty
- return firstElement;
- }
-
- // be nice to multi selection
- while (iter.hasNext()) {
- Object element= iter.next();
- if (!(element instanceof ICElement) && !(element instanceof ITypeInfo))
-// if (!(element instanceof ICElement))
- return null;
- if (!currentInput.equals(findInputForElement(element)))
- return null;
- }
- return firstElement;
- }
-
- /**
- * Gets the typeComparator.
- * @return Returns a JavaElementTypeComparator
- */
- protected Comparator getTypeComparator() {
- return fTypeComparator;
- }
-
- /**
- * Links to editor (if option enabled)
- */
- void linkToEditor(IStructuredSelection selection) {
- Object obj= selection.getFirstElement();
-
- if (selection.size() == 1) {
- IEditorPart part= EditorUtility.isOpenInEditor(obj);
- if (part != null) {
- IWorkbenchPage page= getSite().getPage();
- page.bringToTop(part);
- if (obj instanceof ICElement)
- EditorUtility.revealInEditor(part, (ICElement) obj);
- }
- }
- }
-
- void setSelectionFromEditor(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- setSelectionFromEditor(part);
- }
-
- void setSelectionFromEditor(IWorkbenchPart part) {
- if (!linkBrowsingViewSelectionToEditor())
- return;
-
- if (part == null)
- return;
- IWorkbenchPartSite site= part.getSite();
- if (site == null)
- return;
- ISelectionProvider provider= site.getSelectionProvider();
- if (provider != null)
- setSelectionFromEditor(part, provider.getSelection());
- }
-
- private void setSelectionFromEditor(IWorkbenchPart part, ISelection selection) {
- if (part instanceof IEditorPart) {
- ICElement element= null;
- if (selection instanceof IStructuredSelection) {
- Object obj= getSingleElementFromSelection(selection);
- if (obj instanceof ICElement)
- element= (ICElement)obj;
- }
- IEditorInput ei= ((IEditorPart)part).getEditorInput();
- if (selection instanceof ITextSelection) {
- int offset= ((ITextSelection)selection).getOffset();
- element= getElementAt(ei, offset);
- }
- if (element != null) {
- adjustInputAndSetSelection(element);
- return;
- }
- if (ei instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)ei).getFile();
- ICElement ce= (ICElement)file.getAdapter(ICElement.class);
- if (ce == null) {
- IContainer container= ((IFileEditorInput)ei).getFile().getParent();
- if (container != null)
- ce= (ICElement)container.getAdapter(ICElement.class);
- }
- if (ce == null) {
- setSelection(null, false);
- return;
- }
- adjustInputAndSetSelection(ce);
-// } else if (ei instanceof IClassFileEditorInput) {
-// IClassFile cf= ((IClassFileEditorInput)ei).getClassFile();
-// adjustInputAndSetSelection(cf);
- }
- }
- }
-
- /**
- * Returns the element contained in the EditorInput
- */
- Object getElementOfInput(IEditorInput input) {
-// if (input instanceof IClassFileEditorInput)
-// return ((IClassFileEditorInput)input).getClassFile();
-// else
- if (input instanceof IFileEditorInput)
- return ((IFileEditorInput)input).getFile();
-// else if (input instanceof JarEntryEditorInput)
-// return ((JarEntryEditorInput)input).getStorage();
- return null;
- }
-
- protected void setSelection(ISelection selection, boolean reveal) {
- if (selection != null && selection.equals(fViewer.getSelection()))
- return;
- fProcessSelectionEvents= false;
- fViewer.setSelection(selection, reveal);
- fProcessSelectionEvents= true;
- }
-
- /**
- * Tries to find the given element in a workingcopy.
- */
- protected static ICElement getWorkingCopy(ICElement input) {
- // MA: with new working copy story original == working copy
- return input;
- }
-
-//
-// boolean isInputAWorkingCopy() {
-// return ((BaseCElementContentProvider)getViewer().getContentProvider()).getProvideWorkingCopy();
-// }
-
- /**
- * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getElementAt(int)
- */
- protected ICElement getElementAt(IEditorInput input, int offset) {
-// if (input instanceof IClassFileEditorInput) {
-// try {
-// return ((IClassFileEditorInput)input).getClassFile().getElementAt(offset);
-// } catch (CModelException ex) {
-// return null;
-// }
-// }
-
- IWorkingCopyManager manager= CUIPlugin.getDefault().getWorkingCopyManager();
- ITranslationUnit unit= manager.getWorkingCopy(input);
- if (unit != null)
- try {
- if (unit.isConsistent()) {
- return unit.getElementAtOffset(offset);
- }
- /*
- * XXX: We should set the selection later when the
- * CU is reconciled.
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
- */
- } catch (CModelException ex) {
- // fall through
- }
- return null;
- }
-
-/* protected ICElement getTypeForCU(ITranslationUnit cu) {
- cu= (ITranslationUnit)getSuitableCElement(cu);
-
-// // Use primary type if possible
-// ICElement primaryType= cu.findPrimaryType();
-// if (primaryType != null)
-// return primaryType;
-
- // Use first top-level type
- try {
- final ICElement[] fTypes = new ICElement[]{ null };
- cu.accept(new ICElementVisitor() {
- public boolean visit(ICElement element) throws CoreException {
- // TODO Auto-generated method stub
- switch(element.getElementType()) {
- case ICElement.C_NAMESPACE:
- case ICElement.C_TEMPLATE_CLASS:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- fTypes[0] = element;
- return false;
- }
- return true;
- }
- });
-// ICElement[] types= cu.getTypes();
-// if (types.length > 0)
-// return types[0];
-// else
-// return null;
- return fTypes[0];
- } catch (CoreException ex) {
- return null;
- }
- }
-*/
- void setProcessSelectionEvents(boolean state) {
- fProcessSelectionEvents= state;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- if (fViewer != null) {
- return fViewer.getInput();
- }
- return null;
- }
-
-// protected void setActionGroups(CompositeActionGroup actionGroups) {
-// fActionGroups= actionGroups;
-// }
-//
-// protected void setBuildActionGroup(BuildActionGroup actionGroup) {
-// fBuildActionGroup= actionGroup;
-// }
-//
-// protected void setCCPActionGroup(CCPActionGroup actionGroup) {
-// fCCPActionGroup= actionGroup;
-// }
-//
-// protected void setCustomFiltersActionGroup(CustomFiltersActionGroup customFiltersActionGroup) {
-// fCustomFiltersActionGroup= customFiltersActionGroup;
-// }
-
- protected boolean hasCustomFilter() {
- return fHasCustomFilter;
- }
-
- protected boolean hasWorkingSetFilter() {
- return fHasWorkingSetFilter;
- }
-
-// protected void setOpenEditorGroup(OpenEditorActionGroup openEditorGroup) {
-// fOpenEditorGroup= openEditorGroup;
-// }
-//
-// protected OpenEditorActionGroup getOpenEditorGroup() {
-// return fOpenEditorGroup;
-// }
-//
-// protected BuildActionGroup getBuildActionGroup() {
-// return fBuildActionGroup;
-// }
-//
-// protected CCPActionGroup getCCPActionGroup() {
-// return fCCPActionGroup;
-// }
-
- private boolean linkBrowsingViewSelectionToEditor() {
- return isLinkingEnabled();
- }
-
- public void setLinkingEnabled(boolean enabled) {
- fLinkingEnabled= enabled;
- PreferenceConstants.getPreferenceStore().setValue(getLinkToEditorKey(), enabled);
- if (enabled) {
- IEditorPart editor = getSite().getPage().getActiveEditor();
- if (editor != null) {
- setSelectionFromEditor(editor);
- }
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java
deleted file mode 100644
index 7fd72a75366..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingPerspectiveFactory.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.console.IConsoleConstants;
-
-public class CBrowsingPerspectiveFactory implements IPerspectiveFactory {
-
- /*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- */
- static ICElement fgCElementFromAction;
-
- /**
- * Constructs a new Default layout engine.
- */
- public CBrowsingPerspectiveFactory() {
- super();
- }
-
- /**
- * @see IPerspectiveFactory#createInitialLayout
- */
- public void createCViewInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
- folder1.addView(CUIPlugin.CVIEW_ID);
- folder1.addView(IPageLayout.ID_RES_NAV);
- folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-
- IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
- folder2.addView(IPageLayout.ID_PROBLEM_VIEW);
- folder2.addView(IConsoleConstants.ID_CONSOLE_VIEW);
- folder2.addView(IPageLayout.ID_PROP_SHEET);
-
- IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea); //$NON-NLS-1$
- folder3.addView(IPageLayout.ID_OUTLINE);
-
- layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
- layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
-
- // views - build console
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - searching
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- layout.addShowViewShortcut(IPageLayout.ID_PROP_SHEET);
-
- // link - things we should do
- layout.addShowInPart(CUIPlugin.CVIEW_ID);
- layout.addShowInPart(IPageLayout.ID_RES_NAV);
-
- addCWizardShortcuts(layout);
- }
-
- public void createInitialLayout(IPageLayout layout) {
- if (stackBrowsingViewsVertically())
- createVerticalLayout(layout);
- else
- createHorizontalLayout(layout);
-
- // action sets
- layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID);
-// layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
-// layout.addActionSet(JavaUI.ID_ACTION_SET);
- layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET);
- layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
-
- // views - java
- layout.addShowViewShortcut(CUIPlugin.ID_TYPE_HIERARCHY);
- layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
- layout.addShowViewShortcut(CUIPlugin.ID_PROJECTS_VIEW);
- layout.addShowViewShortcut(CUIPlugin.ID_NAMESPACES_VIEW);
- layout.addShowViewShortcut(CUIPlugin.ID_TYPES_VIEW);
- layout.addShowViewShortcut(CUIPlugin.ID_MEMBERS_VIEW);
-// layout.addShowViewShortcut(CUIPlugin.ID_SOURCE_VIEW);
-// layout.addShowViewShortcut(CUIPlugin.ID_JAVADOC_VIEW);
-
- // views - search
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - debugging
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
-
- addCWizardShortcuts(layout);
- }
-
- private void addCWizardShortcuts(IPageLayout layout) {
- // new actions - C project creation wizard
- String[] wizIDs = CWizardRegistry.getProjectWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- // new actions - C folder creation wizard
- wizIDs = CWizardRegistry.getFolderWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- // new actions - C file creation wizard
- wizIDs = CWizardRegistry.getFileWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- // new actions - C type creation wizard
- wizIDs = CWizardRegistry.getTypeWizardIDs();
- for (int i = 0; i < wizIDs.length; ++i) {
- layout.addNewWizardShortcut(wizIDs[i]);
- }
- }
-
- private void createVerticalLayout(IPageLayout layout) {
- String relativePartId= IPageLayout.ID_EDITOR_AREA;
- int relativePos= IPageLayout.LEFT;
-
- IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderLeft.addPlaceholder(CUIPlugin.ID_TYPE_HIERARCHY);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
- placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- if (shouldShowProjectsView()) {
- layout.addView(CUIPlugin.ID_PROJECTS_VIEW, IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA);
- relativePartId= CUIPlugin.ID_PROJECTS_VIEW;
- relativePos= IPageLayout.BOTTOM;
- }
- if (shouldShowNamespacesView()) {
- layout.addView(CUIPlugin.ID_NAMESPACES_VIEW, relativePos, (float)0.25, relativePartId);
- relativePartId= CUIPlugin.ID_NAMESPACES_VIEW;
- relativePos= IPageLayout.BOTTOM;
- }
- layout.addView(CUIPlugin.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId);
- layout.addView(CUIPlugin.ID_MEMBERS_VIEW, IPageLayout.BOTTOM, (float)0.50, CUIPlugin.ID_TYPES_VIEW);
-
- IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
- }
-
- private void createHorizontalLayout(IPageLayout layout) {
- String relativePartId= IPageLayout.ID_EDITOR_AREA;
- int relativePos= IPageLayout.TOP;
-
- if (shouldShowProjectsView()) {
- layout.addView(CUIPlugin.ID_PROJECTS_VIEW, IPageLayout.TOP, (float)0.25, IPageLayout.ID_EDITOR_AREA);
- relativePartId= CUIPlugin.ID_PROJECTS_VIEW;
- relativePos= IPageLayout.RIGHT;
- }
- if (shouldShowNamespacesView()) {
- layout.addView(CUIPlugin.ID_NAMESPACES_VIEW, relativePos, (float)0.25, relativePartId);
- relativePartId= CUIPlugin.ID_NAMESPACES_VIEW;
- relativePos= IPageLayout.RIGHT;
- }
- layout.addView(CUIPlugin.ID_TYPES_VIEW, relativePos, (float)0.33, relativePartId);
- layout.addView(CUIPlugin.ID_MEMBERS_VIEW, IPageLayout.RIGHT, (float)0.50, CUIPlugin.ID_TYPES_VIEW);
-
- IPlaceholderFolderLayout placeHolderLeft= layout.createPlaceholderFolder("left", IPageLayout.LEFT, (float)0.25, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderLeft.addPlaceholder(CUIPlugin.ID_TYPE_HIERARCHY);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_OUTLINE);
- placeHolderLeft.addPlaceholder(CUIPlugin.CVIEW_ID);
- placeHolderLeft.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- IPlaceholderFolderLayout placeHolderBottom= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, IPageLayout.ID_EDITOR_AREA); //$NON-NLS-1$
- placeHolderBottom.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- placeHolderBottom.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- placeHolderBottom.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- placeHolderBottom.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
-// placeHolderBottom.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
- }
-
- private boolean shouldShowProjectsView() {
- return true;
-// RETURN FGCELEMENTFROMACTION == NULL || FGCELEMENTFROMACTION.GETELEMENTTYPE() == ICELEMENT.C_MODEL;
- }
-
- private boolean shouldShowNamespacesView() {
- return true;
-// if (fgCElementFromAction == null)
-// return true;
-// int type= fgCElementFromAction.getElementType();
-// return type == ICElement.C_MODEL || type == ICElement.C_PROJECT;
-//// return type == ICElement.C_MODEL || type == ICElement.C_PROJECT || type == ICElement.PACKAGE_FRAGMENT_ROOT;
- }
-
- private boolean stackBrowsingViewsVertically() {
- return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.BROWSING_STACK_VERTICALLY);
- }
-
- /*
- * XXX: This is a workaround for: http://dev.eclipse.org/bugs/show_bug.cgi?id=13070
- */
- static void setInputFromAction(IAdaptable input) {
- if (input instanceof ICElement)
- fgCElementFromAction= (ICElement)input;
- else
- fgCElementFromAction= null;
- }
-}
-
-
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java
deleted file mode 100644
index 9728e2ff211..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/CBrowsingViewerSorter.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.ui.CElementSorter;
-
-public class CBrowsingViewerSorter extends CElementSorter {
-
- public CBrowsingViewerSorter() {
- super();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java
deleted file mode 100644
index a1c8d0dcfc3..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTableViewer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 1, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * @author CWiebe
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class ElementTableViewer extends ProblemTableViewer {
-
- /**
- * @param parent
- */
- public ElementTableViewer(Composite parent) {
- super(parent);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param parent
- * @param style
- */
- public ElementTableViewer(Composite parent, int style) {
- super(parent, style);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param table
- */
- public ElementTableViewer(Table table) {
- super(table);
- // TODO Auto-generated constructor stub
- }
-
- protected void handleInvalidSelection(ISelection invalidSelection,
- ISelection newSelection) {
- updateSelection(newSelection);
- SelectionChangedEvent event = new SelectionChangedEvent(this,
- newSelection);
- firePostSelectionChanged(event);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java
deleted file mode 100644
index 1dc814521e7..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ElementTreeViewer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 1, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-
-/**
- * @author CWiebe
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Style - Code Templates
- */
-public class ElementTreeViewer extends ProblemTreeViewer {
-
- /**
- * @param parent
- */
- public ElementTreeViewer(Composite parent) {
- super(parent);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param parent
- * @param style
- */
- public ElementTreeViewer(Composite parent, int style) {
- super(parent, style);
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param tree
- */
- public ElementTreeViewer(Tree tree) {
- super(tree);
- // TODO Auto-generated constructor stub
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java
deleted file mode 100644
index d8b00b25228..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/LexicalSortingAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/*
- * XXX: This class should become part of the MemberFilterActionGroup
- * which should be renamed to MemberActionsGroup
- */
-public class LexicalSortingAction extends Action {
- CBrowsingViewerSorter fSorter= new CBrowsingViewerSorter();
- StructuredViewer fViewer;
- private String fPreferenceKey;
-
- public LexicalSortingAction(StructuredViewer viewer, String id) {
- super();
- fViewer= viewer;
- fPreferenceKey= "LexicalSortingAction." + id + ".isChecked"; //$NON-NLS-1$ //$NON-NLS-2$
- setText(CBrowsingMessages.getString("LexicalSortingAction.label")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_ALPHA_SORTING); //$NON-NLS-1$ //$NON-NLS-2$
- setToolTipText(CBrowsingMessages.getString("LexicalSortingAction.tooltip")); //$NON-NLS-1$
- setDescription(CBrowsingMessages.getString("LexicalSortingAction.description")); //$NON-NLS-1$
- boolean checked= CUIPlugin.getDefault().getPreferenceStore().getBoolean(fPreferenceKey); //$NON-NLS-1$
- valueChanged(checked, false);
- WorkbenchHelp.setHelp(this, ICHelpContextIds.LEXICAL_SORTING_BROWSING_ACTION);
- }
-
- public void run() {
- valueChanged(isChecked(), true);
- }
-
- private void valueChanged(final boolean on, boolean store) {
- setChecked(on);
- BusyIndicator.showWhile(fViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- if (on)
- fViewer.setSorter(fSorter);
- else
- fViewer.setSorter(null);
- }
- });
-
- if (store)
- CUIPlugin.getDefault().getPreferenceStore().setValue(fPreferenceKey, on);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
deleted file mode 100644
index 733d61bea49..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersView.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.part.IShowInTargetList;
-
-public class MembersView extends CBrowsingPart implements IPropertyChangeListener {
-
-// private MemberFilterActionGroup fMemberFilterActionGroup;
-
-
- public MembersView() {
- setHasWorkingSetFilter(false);
- setHasCustomSetFilter(true);
- CUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- /**
- * Creates and returns the label provider for this part.
- *
- * @return the label provider
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
- protected LabelProvider createLabelProvider() {
- return new CBrowsingLabelProvider();
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return ICHelpContextIds.MEMBERS_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_MEMBERS_TO_EDITOR;
- }
-
- /**
- * Creates the the viewer of this part.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- ElementTreeViewer viewer= new ElementTreeViewer(parent, SWT.MULTI);
-// fMemberFilterActionGroup= new MemberFilterActionGroup(viewer, JavaUI.ID_MEMBERS_VIEW);
- return viewer;
- }
-
- protected ViewerSorter createViewerSorter() {
- return new CBrowsingViewerSorter();
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new CBrowsingElementFilter());
- }
-
- protected void fillToolBar(IToolBarManager tbm) {
- tbm.add(new LexicalSortingAction(getViewer(), CUIPlugin.ID_MEMBERS_VIEW));
-// fMemberFilterActionGroup.contributeToToolBar(tbm);
- super.fillToolBar(tbm);
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- if (element instanceof ITypeInfo) {
- ITypeInfo type= (ITypeInfo)element;
- if (type.getCElementType() != ICElement.C_NAMESPACE && type.exists())
- return true;
- }
- return false;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (element instanceof ICElement) {
- if (element instanceof ICModel
- || element instanceof ICProject
- || element instanceof ISourceRoot
- || element instanceof ITranslationUnit)
- return false;
- return true;
- }
- return false;
- }
-
- /*
- * Implements method from IViewPart.
- */
- public void saveState(IMemento memento) {
- super.saveState(memento);
-// fMemberFilterActionGroup.saveState(memento);
- }
-
- protected void restoreState(IMemento memento) {
- super.restoreState(memento);
-// fMemberFilterActionGroup.restoreState(memento);
- getViewer().getControl().setRedraw(false);
- getViewer().refresh();
- getViewer().getControl().setRedraw(true);
- }
-
- protected void hookViewerListeners() {
- super.hookViewerListeners();
- getViewer().addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- TreeViewer viewer= (TreeViewer)getViewer();
- Object element= ((IStructuredSelection)event.getSelection()).getFirstElement();
- if (viewer.isExpandable(element))
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- });
- }
-
-/* boolean isInputAWorkingCopy() {
- Object input= getViewer().getInput();
- if (input instanceof ICElement) {
- ICompilationUnit cu= (ICompilationUnit)((IJavaElement)input).getAncestor(IJavaElement.COMPILATION_UNIT);
- if (cu != null)
- return cu.isWorkingCopy();
- }
- return false;
- }
-*/
- protected void restoreSelection() {
- IEditorPart editor= getViewSite().getPage().getActiveEditor();
- if (editor != null)
- setSelectionFromEditor(editor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
-// if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
-// getViewer().refresh();
-// }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#dispose()
- */
- public void dispose() {
-// if (fMemberFilterActionGroup != null) {
-// fMemberFilterActionGroup.dispose();
-// fMemberFilterActionGroup= null;
-// }
- super.dispose();
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#createContentProvider()
- */
- protected IContentProvider createContentProvider() {
- return new MembersViewContentProvider(this);
- }
-
- protected Object findInputForElement(Object element) {
- if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
- return null;
- }
-
- if (element instanceof ITypeInfo) {
- return element;
- }
-
- if (element instanceof ICElement) {
- ICElement celem = (ICElement)element;
- if (!celem.exists())
- return null;
-
- if (TypeUtil.isDeclaringType(celem)) {
- ICElement type= TypeUtil.getDeclaringType(celem);
- if (type == null || type instanceof INamespace)
- return AllTypesCache.getTypeForElement(celem, true, true, null);
- return findInputForElement(type);
- } else if (TypeUtil.isMemberType(celem)) {
- return findInputForElement(TypeUtil.getDeclaringType(celem));
- } else {
- ITranslationUnit tu = TypeUtil.getTranslationUnit(celem);
- if (tu != null)
- return getTypeForTU(tu);
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object)
- */
- protected Object findElementToSelect(Object element) {
- if (isValidElement(element)) {
- return element;
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java
deleted file mode 100644
index 79d67e024cc..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/MembersViewContentProvider.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.IParent;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.swt.widgets.Shell;
-
-class MembersViewContentProvider extends CBrowsingContentProvider {
-
- MembersViewContentProvider(CBrowsingPart browsingPart) {
- super(browsingPart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
- return false;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo) element;
- return (info.getCElementType() != ICElement.C_TYPEDEF);
- }
-
- if (element instanceof IParent) {
- return ((IParent)element).hasChildren();
- }
-
- return false;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object element) {
- if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
- return INVALID_INPUT;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo) element;
- if (info.getCElementType() == ICElement.C_NAMESPACE) {
- return INVALID_INPUT; // shouldn't get here...
- }
- if (info.getCElementType() == ICElement.C_TYPEDEF) {
- return EMPTY_CHILDREN;
- }
- ICElement elem = AllTypesCache.getElementForType(info, true, true, null);
- if (elem == null) {
- return ERROR_NO_CHILDREN;
- }
- if (elem instanceof IParent) {
- ICElement[] children = ((IParent)elem).getChildren();
- if (children != null && children.length > 0)
- return children;
- }
- return EMPTY_CHILDREN;
- }
-
- if (element instanceof IParent) {
- ICElement[] children = ((IParent)element).getChildren();
- if (children != null && children.length > 0)
- return children;
- return EMPTY_CHILDREN;
- }
-
- return INVALID_INPUT;
- } catch (CModelException e) {
- return ERROR_CANCELLED;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
- return null;
- }
-
- if (element instanceof ITypeInfo) {
- return null;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ICElement) {
- ICElement celem = (ICElement)element;
- if (TypeUtil.isMemberType(celem)) {
- ICElement parent = TypeUtil.getDeclaringType(celem);
- if (parent == null || parent instanceof INamespace) {
- ITypeInfo info = AllTypesCache.getTypeForElement(celem, true, true, null);
- if (info != null)
- return info.getEnclosingType();
- }
- return parent;
- }
- }
-
- return null;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- protected Shell getShell() {
- return CUIPlugin.getActiveWorkbenchShell();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
deleted file mode 100644
index 4499544cfbd..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesView.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IEnumeration;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.ITypeDef;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.part.IShowInTargetList;
-
-public class NamespacesView extends CBrowsingPart {
-
-// private SelectAllAction fSelectAllAction;
-
- /**
- * Creates and returns the label provider for this part.
- *
- * @return the label provider
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
- protected LabelProvider createLabelProvider() {
- return new NamespacesViewLabelProvider();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- /**
- * Creates the viewer of this part dependent on the current
- * layout.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- StructuredViewer viewer;
-// if(isInListState())
- viewer= createTableViewer(parent);
-// else
-// viewer= createTreeViewer(parent);
-
-// fWrappedViewer.setViewer(viewer);
-// return fWrappedViewer;
- return viewer;
- }
- private ElementTableViewer createTableViewer(Composite parent) {
- return new ElementTableViewer(parent, SWT.MULTI);
- }
-
- /**
- * Creates the the content provider of this part.
- */
- protected IContentProvider createContentProvider() {
- return new NamespacesViewContentProvider(this);
- }
-
- protected ViewerSorter createViewerSorter() {
- return new TypeInfoSorter();
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new CBrowsingElementFilter());
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- return (element instanceof ICProject || element instanceof ISourceRoot);
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- if (info.exists() && info.getCElementType() == ICElement.C_NAMESPACE) {
- // make sure it has types other than namespaces
- ITypeInfo[] types = info.getEnclosedTypes();
- if (types != null) {
- for (int i = 0; i < types.length; ++i) {
- if (types[i].getCElementType() != ICElement.C_NAMESPACE) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return ICHelpContextIds.TYPES_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR;
- }
-
- protected void createActions() {
- super.createActions();
-// fSelectAllAction= new SelectAllAction((TableViewer)getViewer());
- }
-
- protected void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
-
- // Add selectAll action handlers.
-// actionBars.setGlobalActionHandler(IWorkbenchActionConstants.SELECT_ALL, fSelectAllAction);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object)
- */
- protected Object findInputForElement(Object element) {
- if (element instanceof ICModel) {
- return null;
- }
-
- if (element instanceof ICProject || element instanceof ISourceRoot) {
- if (exists(element))
- return element;
- }
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- ISourceRoot root = findSourceRoot(info);
- if (exists(root) && !isProjectSourceRoot(root))
- return root;
- ICProject cProject = findCProject(info);
- if (exists(cProject))
- return cProject;
- }
-
- if (element instanceof ICElement) {
- ICElement cElem = (ICElement)element;
- ISourceRoot root = findSourceRoot(cElem);
- if (exists(root) && !isProjectSourceRoot(root))
- return root;
- ICProject cProject = findCProject(cElem);
- if (exists(cProject))
- return cProject;
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object)
- */
- protected Object findElementToSelect(Object element) {
- if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
- return null;
- }
-
- if (element instanceof ICElement) {
- ICElement celem = (ICElement)element;
- if (celem instanceof ITranslationUnit) {
- IProject project = celem.getCProject().getProject();
- return AllTypesCache.getGlobalNamespace(project);
- } else if (celem.getElementType() == ICElement.C_NAMESPACE) {
- return AllTypesCache.getTypeForElement(celem, true, true, null);
- } else {
- ICElement parent = (ICElement)element;
- while (parent != null) {
- if ((parent instanceof IStructure
- || parent instanceof IEnumeration
- || parent instanceof ITypeDef)
- && parent.exists()) {
- ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
- if (info != null) {
- return info.getEnclosingNamespace(true);
- }
- }
- parent = parent.getParent();
- }
- }
- return null;
- }
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo) element;
- if (info.getCElementType() == ICElement.C_NAMESPACE && info.exists()) {
- return info;
- }
- return info.getEnclosingNamespace(true);
- }
-
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java
deleted file mode 100644
index b88d6038ee0..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewContentProvider.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
-
-class NamespacesViewContentProvider extends CBrowsingContentProvider {
-
- NamespacesViewContentProvider(CBrowsingPart browsingPart) {
- super(browsingPart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
- return false;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ICProject) {
- return true;
-// TypeSearchScope scope = new TypeSearchScope();
-// scope.add((ICProject)element);
-// return AllTypesCache.getNamespaces(scope, true);
- }
-
- if (element instanceof ISourceRoot) {
- return true;
-// TypeSearchScope scope = new TypeSearchScope();
-// scope.add((ISourceRoot)element);
-// return AllTypesCache.getNamespaces(scope, true);
- }
-
- return false;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object element) {
- if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
- return INVALID_INPUT;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ICProject) {
- TypeSearchScope scope = new TypeSearchScope();
- scope.add((ICProject)element);
- return getNamespaces(scope);
- }
-
- if (element instanceof ISourceRoot) {
- TypeSearchScope scope = new TypeSearchScope();
- scope.add((ISourceRoot)element);
- return getNamespaces(scope);
- }
-
- return INVALID_INPUT;
-// } catch (CModelException e) {
-// return NO_CHILDREN;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
- return null;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- if (info.isEnclosedType()) {
- return info.getEnclosingType();
- }
-// return info.getEnclosingProject();
- return null;
- }
-
- return null;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- private Object[] getNamespaces(final ITypeSearchScope scope) {
- if (!AllTypesCache.isCacheUpToDate(scope)) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.updateCache(scope, monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return ERROR_CANCELLED;
- } catch (InterruptedException e) {
- // cancelled by user
- return ERROR_CANCELLED;
- }
- }
- ITypeInfo[] namespaces = AllTypesCache.getNamespaces(scope, true);
- if (namespaces != null && namespaces.length > 0) {
- return namespaces;
- }
- return EMPTY_CHILDREN;
- }
-
- protected Shell getShell() {
- return CUIPlugin.getActiveWorkbenchShell();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java
deleted file mode 100644
index c00410d9b85..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/NamespacesViewLabelProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class NamespacesViewLabelProvider extends CBrowsingLabelProvider {
-
- protected static final TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_FULLY_QUALIFIED);
-
- public NamespacesViewLabelProvider() {
- super();
- }
-
- public Image getImage(Object element) {
- if (element instanceof ITypeInfo)
- return fTypeInfoLabelProvider.getImage(element);
- return super.getImage(element);
- }
-
- public String getText(Object element) {
- if (element instanceof ITypeInfo)
- return fTypeInfoLabelProvider.getText(element);
- return super.getText(element);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/OpenProjectAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/OpenProjectAction.java
deleted file mode 100644
index 05b4ad84a9d..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/OpenProjectAction.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.actions.ActionMessages;
-import org.eclipse.cdt.internal.ui.actions.WorkbenchRunnableAdapter;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.SubProgressMonitor;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.OpenResourceAction;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to open a closed project. Action either opens the closed projects
- * provided by the strucutured selection or present a dialog from which the
- * user can select the projects to be opened.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- * @since 2.0
- */
-public class OpenProjectAction extends SelectionDispatchAction implements IResourceChangeListener {
-
- private static final int EMPTY_SELECTION= 1;
- private static final int ELEMENT_SELECTION= 2;
-
- private int fMode;
- private OpenResourceAction fWorkbenchAction;
-
- /**
- * Creates a new <code>OpenProjectAction</code>. The action requires
- * that the selection provided by the site's selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the site providing context information for this action
- */
- public OpenProjectAction(IWorkbenchSite site) {
- super(site);
- fWorkbenchAction= new OpenResourceAction(site.getShell());
- setText(fWorkbenchAction.getText());
- setToolTipText(fWorkbenchAction.getToolTipText());
- setEnabled(hasCloseProjects());
- WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_PROJECT_ACTION);
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- fWorkbenchAction.resourceChanged(event);
- switch (fMode) {
- case ELEMENT_SELECTION:
- setEnabled(fWorkbenchAction.isEnabled());
- break;
- case EMPTY_SELECTION:
- internalResourceChanged(event);
- break;
- }
- }
-
- private void internalResourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta != null) {
- IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED);
- for (int i = 0; i < projDeltas.length; ++i) {
- IResourceDelta projDelta = projDeltas[i];
- if ((projDelta.getFlags() & IResourceDelta.OPEN) != 0) {
- setEnabled(hasCloseProjects());
- return;
- }
- }
- }
- }
-
- //---- normal selection -------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(ISelection selection) {
- setEnabled(hasCloseProjects());
- fMode= EMPTY_SELECTION;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.ISelection)
- */
- public void run(ISelection selection) {
- internalRun();
- }
-
- //---- structured selection ---------------------------------------
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void selectionChanged(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- setEnabled(hasCloseProjects());
- fMode= EMPTY_SELECTION;
- return;
- }
- fWorkbenchAction.selectionChanged(selection);
- setEnabled(fWorkbenchAction.isEnabled());
- fMode= ELEMENT_SELECTION;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.ui.actions.SelectionDispatchAction#run(org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void run(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- internalRun();
- return;
- }
- fWorkbenchAction.run();
- }
-
- private void internalRun() {
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new CElementLabelProvider());
- dialog.setTitle(ActionMessages.getString("OpenProjectAction.dialog.title")); //$NON-NLS-1$
- dialog.setMessage(ActionMessages.getString("OpenProjectAction.dialog.message")); //$NON-NLS-1$
- dialog.setElements(getClosedProjects());
- dialog.setMultipleSelection(true);
- int result= dialog.open();
- if (result != Window.OK)
- return;
- final Object[] projects= dialog.getResult();
- IWorkspaceRunnable runnable= createRunnable(projects);
- try {
- PlatformUI.getWorkbench().getProgressService().run(true, true, new WorkbenchRunnableAdapter(runnable));
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getShell(),
- ActionMessages.getString("OpenProjectAction.dialog.title"), //$NON-NLS-1$
- ActionMessages.getString("OpenProjectAction.error.message")); //$NON-NLS-1$
- } catch (InterruptedException e) {
- }
- }
-
- private IWorkspaceRunnable createRunnable(final Object[] projects) {
- return new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask("", projects.length); //$NON-NLS-1$
- MultiStatus errorStatus= null;
- for (int i = 0; i < projects.length; i++) {
- IProject project= (IProject)projects[i];
- try {
- project.open(new SubProgressMonitor(monitor, 1));
- } catch (CoreException e) {
- if (errorStatus == null)
- errorStatus = new MultiStatus(CUIPlugin.getPluginId(), IStatus.ERROR, ActionMessages.getString("OpenProjectAction.error.message"), e); //$NON-NLS-1$
- errorStatus.merge(e.getStatus());
- }
- }
- monitor.done();
- if (errorStatus != null)
- throw new CoreException(errorStatus);
- }
- };
- }
-
- private Object[] getClosedProjects() {
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- List result= new ArrayList(5);
- for (int i = 0; i < projects.length; i++) {
- IProject project= projects[i];
- if (!project.isOpen())
- result.add(project);
- }
- return result.toArray();
- }
-
- private boolean hasCloseProjects() {
- IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- if (!projects[i].isOpen())
- return true;
- }
- return false;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java
deleted file mode 100644
index cf8b467a607..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectActionGroup.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.actions.CloseResourceAction;
-import org.eclipse.ui.ide.IDEActionFactory;
-
-/**
- * Adds actions to open and close a project to the global menu bar.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- * @since 2.0
- */
-public class ProjectActionGroup extends ActionGroup {
-
- private IWorkbenchSite fSite;
-
- private OpenProjectAction fOpenAction;
- private CloseResourceAction fCloseAction;
-
- /**
- * Creates a new <code>ProjectActionGroup</code>. The group requires
- * that the selection provided by the site's selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param part the view part that owns this action group
- */
- public ProjectActionGroup(IViewPart part) {
- fSite = part.getSite();
- Shell shell= fSite.getShell();
- ISelectionProvider provider= fSite.getSelectionProvider();
- ISelection selection= provider.getSelection();
-
- fCloseAction= new CloseResourceAction(shell);
- fCloseAction.setActionDefinitionId("org.eclipse.ui.project.closeProject"); //$NON-NLS-1$
- fOpenAction= new OpenProjectAction(fSite);
- fOpenAction.setActionDefinitionId("org.eclipse.ui.project.openProject"); //$NON-NLS-1$
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection s= (IStructuredSelection)selection;
- fOpenAction.selectionChanged(s);
- fCloseAction.selectionChanged(s);
- }
- provider.addSelectionChangedListener(fOpenAction);
- provider.addSelectionChangedListener(fCloseAction);
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- workspace.addResourceChangeListener(fOpenAction);
- workspace.addResourceChangeListener(fCloseAction);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
- actionBars.setGlobalActionHandler(IDEActionFactory.CLOSE_PROJECT.getId(), fCloseAction);
- actionBars.setGlobalActionHandler(IDEActionFactory.OPEN_PROJECT.getId(), fOpenAction);
- }
-
- /* (non-Javadoc)
- * Method declared in ActionGroup
- */
- public void fillContextMenu(IMenuManager menu) {
- super.fillContextMenu(menu);
- if (fOpenAction.isEnabled())
- menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fOpenAction);
- if (fCloseAction.isEnabled())
- menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fCloseAction);
- }
-
-
- /*
- * @see ActionGroup#dispose()
- */
- public void dispose() {
- ISelectionProvider provider= fSite.getSelectionProvider();
- provider.removeSelectionChangedListener(fOpenAction);
- provider.removeSelectionChangedListener(fCloseAction);
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- workspace.removeResourceChangeListener(fOpenAction);
- workspace.removeResourceChangeListener(fCloseAction);
- super.dispose();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
deleted file mode 100644
index 455d09b934a..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsView.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICContainer;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.IEnumeration;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.model.ITypeDef;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.part.IShowInTargetList;
-
-public class ProjectsView extends CBrowsingPart {
-
-// private FilterUpdater fFilterUpdater;
-
- /**
- * Creates the the viewer of this part.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- ElementTreeViewer result= new ElementTreeViewer(parent, SWT.MULTI);
-// fFilterUpdater= new FilterUpdater(result);
-// ResourcesPlugin.getWorkspace().addResourceChangeListener(fFilterUpdater);
- return result;
- }
-
- protected LabelProvider createLabelProvider() {
- return new CBrowsingLabelProvider();
- }
-
- protected ViewerSorter createViewerSorter() {
- return new CBrowsingViewerSorter();
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new CBrowsingElementFilter());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart#dispose()
- */
- public void dispose() {
-// if (fFilterUpdater != null)
-// ResourcesPlugin.getWorkspace().removeResourceChangeListener(fFilterUpdater);
- super.dispose();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
-
- /**
- * Creates the the content provider of this part.
- */
- protected IContentProvider createContentProvider() {
- return new ProjectsViewContentProvider(this);
- }
-
- /**
- * Returns the context ID for the Help system.
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return ICHelpContextIds.PROJECTS_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_PROJECTS_TO_EDITOR;
- }
-
-
- /**
- * Adds additional listeners to this view.
- */
- protected void hookViewerListeners() {
- super.hookViewerListeners();
- getViewer().addDoubleClickListener(new IDoubleClickListener() {
- public void doubleClick(DoubleClickEvent event) {
- TreeViewer viewer= (TreeViewer)getViewer();
- Object element= ((IStructuredSelection)event.getSelection()).getFirstElement();
- if (viewer.isExpandable(element))
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- });
- }
-
- protected void setInitialInput() {
- ICElement root= CoreModel.create(CUIPlugin.getWorkspace().getRoot());
- getViewer().setInput(root);
- updateTitle();
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- return element instanceof ICModel;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- return element instanceof ICProject || element instanceof ICContainer;
- }
-
- /*
- * @see JavaBrowsingPart#setInput(Object)
- */
- protected void setInput(Object input) {
- // Don't allow to clear input for this view
- if (input != null)
- super.setInput(input);
- else
- getViewer().setSelection(null);
- }
-
- protected void createActions() {
- super.createActions();
-// fActionGroups.addGroup(new ProjectActionGroup(this));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object)
- */
- protected Object findInputForElement(Object element) {
- if (element instanceof ICModel) {
- if (exists(element))
- return element;
- }
-
- if (element instanceof ICElement) { //ICProject || element instanceof ISourceRoot) {
- ICModel model = ((ICElement)element).getCModel();
- if (exists(model))
- return model;
- }
-
- if (element instanceof ITypeInfo) {
- ICProject cProject = findCProject((ITypeInfo)element);
- if (cProject != null) {
- ICModel model = cProject.getCModel();
- if (exists(model))
- return model;
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object)
- */
- protected Object findElementToSelect(Object element) {
- if (element instanceof ICModel) {
- return null;
- }
-
- if (element instanceof ICProject || element instanceof ISourceRoot) {
- if (exists(element))
- return element;
- return null;
- }
-
- if (element instanceof ITranslationUnit) {
- ICElement e = (ICElement)element;
- ISourceRoot root = findSourceRoot(e);
- if (exists(root) && !isProjectSourceRoot(root))
- return root;
- ICProject cProject = findCProject(e);
- if (exists(cProject))
- return cProject;
- return null;
- }
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- ISourceRoot root = findSourceRoot(info);
- if (exists(root) && !isProjectSourceRoot(root))
- return root;
- ICProject cProject = findCProject(info);
- if (exists(cProject))
- return cProject;
- return null;
- }
-
- if (element instanceof ICElement) {
- ICElement parent = (ICElement)element;
- while (parent != null) {
- if ((parent instanceof IStructure
- || parent instanceof IEnumeration
- || parent instanceof ITypeDef)
- && parent.exists()) {
- ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
- if (info != null) {
- ISourceRoot root = findSourceRoot(info);
- if (exists(root) && !isProjectSourceRoot(root))
- return root;
- ICProject cProject = findCProject(info);
- if (exists(cProject))
- return cProject;
- return null;
- }
- }
- parent = parent.getParent();
- }
- return null;
- }
-
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java
deleted file mode 100644
index 0a6e927653c..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ProjectsViewContentProvider.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-
-class ProjectsViewContentProvider extends CBrowsingContentProvider {
-
- ProjectsViewContentProvider(CBrowsingPart browsingPart) {
- super(browsingPart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
- return false;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ICModel) {
- ICModel cModel = (ICModel)element;
- return cModel.hasChildren();
- }
-
- if (element instanceof ICProject) {
- ICProject cProject = (ICProject)element;
- if (cProject.exists() && cProject.isOpen())
- return cProject.hasChildren();
- return false;
- }
-
- if (element instanceof ISourceRoot) {
- return false;
- }
-
- return false;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object element) {
- if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
- return INVALID_INPUT;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ICModel) {
- ICModel cModel = (ICModel)element;
- return cModel.getCProjects();
- }
-
- if (element instanceof ICProject)
- return getSourceRoots((ICProject)element);
-
- if (element instanceof ISourceRoot)
- return NO_CHILDREN;
-
- return INVALID_INPUT;
- } catch (CModelException e) {
- return ERROR_CANCELLED;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- if (element == null || (element instanceof ICElement && !((ICElement)element).exists())) {
- return null;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ICModel) {
- return null;
- }
-
- if (element instanceof ICProject) {
- ICProject cProject = (ICProject)element;
- return cProject.getCModel();
- }
-
- if (element instanceof ISourceRoot) {
- ISourceRoot cSourceRoot = (ISourceRoot)element;
- return cSourceRoot.getCProject();
- }
-
- return null;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- protected Object[] getSourceRoots(ICProject project) throws CModelException {
- if (!project.getProject().isOpen())
- return NO_CHILDREN;
-
- ISourceRoot[] roots= project.getSourceRoots();
- List list= new ArrayList(roots.length);
- // filter out package fragments that correspond to projects and
- // replace them with the package fragments directly
- for (int i= 0; i < roots.length; i++) {
- ISourceRoot root= roots[i];
- if (!isProjectSourceRoot(root))
- list.add(root);
- }
- return list.toArray();
- }
-
- protected boolean isProjectSourceRoot(ISourceRoot root) {
- IResource resource= root.getResource();
- return (resource instanceof IProject);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ToggleLinkingAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ToggleLinkingAction.java
deleted file mode 100644
index 7384009b5f8..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/ToggleLinkingAction.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
-
-/**
- * This action toggles whether this package explorer links its selection to the active
- * editor.
- *
- * @since 2.1
- */
-public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- CBrowsingPart fCBrowsingPart;
-
- /**
- * Constructs a new action.
- */
- public ToggleLinkingAction(CBrowsingPart part) {
- setChecked(part.isLinkingEnabled());
- fCBrowsingPart= part;
- }
-
- /**
- * Runs the action.
- */
- public void run() {
- fCBrowsingPart.setLinkingEnabled(isChecked());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoComparator.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoComparator.java
deleted file mode 100644
index 634e6216bd5..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoComparator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import java.util.Comparator;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.ICElement;
-
-public class TypeInfoComparator implements Comparator {
- /**
- * Compares two ITypeInfo/ICElement types. A type is considered to be
- * greater if it may contain the other.
- *
- * @return an int less than 0 if object1 is less than object2,
- * 0 if they are equal, and > 0 if object1 is greater
- *
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, Object o2) {
- int t1 = getElementType(o1);
- int t2 = getElementType(o2);
- return getIdForElementType(t1) - getIdForElementType(t2);
- }
-
- /**
- * Compares two C element types. A type is considered to be
- * greater if it may contain the other.
- *
- * @return an int < 0 if object1 is less than object2,
- * 0 if they are equal, and > 0 if object1 is greater
- *
- * @see Comparator#compare(Object, Object)
- */
- public int compare(Object o1, int elementType) {
- int t1 = getElementType(o1);
- if (t1 == 0)
- throw new ClassCastException();
- return getIdForElementType(t1) - getIdForElementType(elementType);
- }
-
- int getElementType(Object obj) {
- if (obj instanceof ICElement) {
- return ((ICElement)obj).getElementType();
- } else if (obj instanceof ITypeInfo) {
- return ((ITypeInfo)obj).getCElementType();
- } else {
- return 0;
- }
- }
-
- int getIdForElementType(int elementType) {
- switch (elementType) {
- case ICElement.C_MODEL:
- return 100;
- case ICElement.C_PROJECT:
- return 90;
- case ICElement.C_CCONTAINER:
- return 80;
- case ICElement.C_UNIT:
- return 70;
- case ICElement.C_NAMESPACE:
- return 60;
- case ICElement.C_CLASS:
- return 50;
- case ICElement.C_STRUCT:
- return 40;
- case ICElement.C_UNION:
- return 30;
- case ICElement.C_ENUMERATION:
- return 20;
- case ICElement.C_TYPEDEF:
- return 10;
- default :
- return 1;
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java
deleted file mode 100644
index 5d0af6de217..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypeInfoSorter.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.jface.viewers.Viewer;
-
-public class TypeInfoSorter extends CBrowsingViewerSorter {
-
- public TypeInfoSorter() {
- super();
- }
-
- public int category (Object element) {
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- String name = info.getName();
- if (info.getCElementType() == ICElement.C_NAMESPACE) {
- if (name.startsWith("__")) { //$NON-NLS-1$
- return NAMESPACES_SYSTEM;
- }
- if (name.charAt(0) == '_') {
- return NAMESPACES_RESERVED;
- }
- return NAMESPACES;
- }
- if (name.startsWith("__")) { //$NON-NLS-1$
- return CELEMENTS_SYSTEM;
- }
- if (name.charAt(0) == '_') {
- return CELEMENTS_RESERVED;
- }
- return CELEMENTS;
- }
- return super.category(element);
- }
-
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (e1 instanceof ITypeInfo || e2 instanceof ITypeInfo) {
- int cat1 = category(e1);
- int cat2 = category(e2);
-
- if (cat1 != cat2)
- return cat1 - cat2;
-
- // cat1 == cat2
-
- if (cat1 == NAMESPACES || cat1 == CELEMENTS || cat1 == CELEMENTS_SYSTEM || cat1 == CELEMENTS_RESERVED) {
- String name1;
- String name2;
- if (e1 instanceof ICElement) {
- name1 = ((ICElement)e1).getElementName();
- } else if (e1 instanceof ITypeInfo) {
- name1 = ((ITypeInfo)e1).getName();
- } else {
- name1 = e1.toString();
- }
- if (e2 instanceof ICElement) {
- name2 = ((ICElement)e2).getElementName();
- } else if (e2 instanceof ITypeInfo) {
- name2 = ((ITypeInfo)e2).getName();
- } else {
- name2 = e2.toString();
- }
- return getCollator().compare(name1, name2);
- }
- }
- return super.compare(viewer, e1, e2);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
deleted file mode 100644
index 01a6cb6cb72..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesView.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICModel;
-import org.eclipse.cdt.core.model.ICProject;
-import org.eclipse.cdt.core.model.INamespace;
-import org.eclipse.cdt.core.model.ISourceRoot;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.part.IShowInTargetList;
-
-public class TypesView extends CBrowsingPart {
-
-// private SelectAllAction fSelectAllAction;
-
- /**
- * Creates and returns the label provider for this part.
- *
- * @return the label provider
- * @see org.eclipse.jface.viewers.ILabelProvider
- */
- protected LabelProvider createLabelProvider() {
- return new TypesViewLabelProvider();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- /**
- * Creates the viewer of this part dependent on the current
- * layout.
- *
- * @param parent the parent for the viewer
- */
- protected StructuredViewer createViewer(Composite parent) {
- StructuredViewer viewer;
-// if(isInListState())
- viewer= createTableViewer(parent);
-// else
-// viewer= createTreeViewer(parent);
-
-// fWrappedViewer.setViewer(viewer);
-// return fWrappedViewer;
- return viewer;
- }
- private ElementTableViewer createTableViewer(Composite parent) {
- return new ElementTableViewer(parent, SWT.MULTI);
- }
-
- /**
- * Creates the the content provider of this part.
- */
- protected IContentProvider createContentProvider() {
- return new TypesViewContentProvider(this);
- }
-
- protected ViewerSorter createViewerSorter() {
- return new TypeInfoSorter();
- }
-
- /**
- * Adds filters the viewer of this part.
- */
- protected void addFilters() {
- super.addFilters();
- getViewer().addFilter(new CBrowsingElementFilter());
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * input for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid input
- */
- protected boolean isValidInput(Object element) {
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- return (info.exists() && info.getCElementType() == ICElement.C_NAMESPACE);
- }
- return false;
- }
-
- /**
- * Answers if the given <code>element</code> is a valid
- * element for this part.
- *
- * @param element the object to test
- * @return <true> if the given element is a valid element
- */
- protected boolean isValidElement(Object element) {
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- if (info.exists()) {
- switch (info.getCElementType()) {
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Returns the context ID for the Help system
- *
- * @return the string used as ID for the Help context
- */
- protected String getHelpContextId() {
- return ICHelpContextIds.TYPES_VIEW;
- }
-
- protected String getLinkToEditorKey() {
- return PreferenceConstants.LINK_BROWSING_TYPES_TO_EDITOR;
- }
-
- protected void createActions() {
- super.createActions();
-// fSelectAllAction= new SelectAllAction((TableViewer)getViewer());
- }
-
- protected void fillActionBars(IActionBars actionBars) {
- super.fillActionBars(actionBars);
-
- // Add selectAll action handlers.
-// actionBars.setGlobalActionHandler(IWorkbenchActionConstants.SELECT_ALL, fSelectAllAction);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findInputForElement(java.lang.Object)
- */
- protected Object findInputForElement(Object element) {
- if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
- return null;
- }
-
- if (element instanceof ICElement) {
- ICElement celem = (ICElement) element;
- if (celem instanceof ITranslationUnit) {
- IProject project = celem.getCProject().getProject();
- return AllTypesCache.getGlobalNamespace(project);
- } else if (celem.getElementType() == ICElement.C_NAMESPACE) {
- return AllTypesCache.getTypeForElement(celem, true, true, null);
- } else {
- ICElement parent = TypeUtil.getDeclaringType(celem);
- if (parent instanceof INamespace) {
- return AllTypesCache.getTypeForElement(parent, true, true, null);
- } else if (parent != null) {
- ITypeInfo info = AllTypesCache.getTypeForElement(parent, true, true, null);
- if (info != null)
- return info.getEnclosingNamespace(true);
- }
- IProject project = celem.getCProject().getProject();
- return AllTypesCache.getGlobalNamespace(project);
- }
- }
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo) element;
- if (info.getCElementType() == ICElement.C_NAMESPACE) {
- if (exists(info))
- return info;
- return null;
- }
- return info.getEnclosingNamespace(true);
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPart#findElementToSelect(java.lang.Object)
- */
- protected Object findElementToSelect(Object element) {
- if (element instanceof ICModel || element instanceof ICProject || element instanceof ISourceRoot) {
- return null;
- }
-
- if (element instanceof ICElement) {
- ICElement celem = (ICElement) element;
- if (celem instanceof ITranslationUnit) {
- return null;
- } else if (celem.getElementType() == ICElement.C_NAMESPACE) {
- return null;
- } else {
- while (celem != null) {
- ICElement parent = TypeUtil.getDeclaringType(celem);
- if (parent == null || parent instanceof INamespace) {
- return AllTypesCache.getTypeForElement(celem, true, true, null);
- }
- celem = parent;
- }
- }
- }
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo) element;
- if (info.getCElementType() != ICElement.C_NAMESPACE) {
- return info;
- }
- return null;
- }
-
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java
deleted file mode 100644
index 4adfb74ae04..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewContentProvider.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.model.ICElement;
-
-class TypesViewContentProvider extends CBrowsingContentProvider {
-
- TypesViewContentProvider(CBrowsingPart browsingPart) {
- super(browsingPart);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- public boolean hasChildren(Object element) {
- if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
- return false;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- return info.hasEnclosedTypes();
- }
-
- return false;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object element) {
- if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
- return INVALID_INPUT;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- final int kinds[] = { ICElement.C_CLASS, ICElement.C_STRUCT,
- ICElement.C_UNION, ICElement.C_ENUMERATION,
- ICElement.C_TYPEDEF};
- //TODO this should be a prefs option
- ITypeInfo[] children = info.getEnclosedTypes(kinds);
- if (children != null && children.length > 0) {
- return children;
- }
- return EMPTY_CHILDREN;
- }
-
- return INVALID_INPUT;
-// } catch (CModelException e) {
-// return NO_CHILDREN;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- public Object getParent(Object element) {
- if (element == null || (element instanceof ITypeInfo && !((ITypeInfo)element).exists())) {
- return null;
- }
-
- try {
- startReadInDisplayThread();
-
- if (element instanceof ITypeInfo) {
- ITypeInfo info = (ITypeInfo)element;
- if (info.isEnclosedType()) {
- return info.getEnclosingType();
- }
-// return info.getEnclosingProject();
- return null;
- }
-
- return null;
-// } catch (CModelException e) {
-// return false;
- } finally {
- finishedReadInDisplayThread();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java
deleted file mode 100644
index 9db7b1444ef..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/cbrowsing/TypesViewLabelProvider.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.cbrowsing;
-
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class TypesViewLabelProvider extends CBrowsingLabelProvider {
-
- protected static final TypeInfoLabelProvider fTypeInfoLabelProvider = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY);
-
- public TypesViewLabelProvider() {
- super();
- }
-
- public Image getImage(Object element) {
- if (element instanceof ITypeInfo)
- return fTypeInfoLabelProvider.getImage(element);
- return super.getImage(element);
- }
-
- public String getText(Object element) {
- if (element instanceof ITypeInfo)
- return fTypeInfoLabelProvider.getText(element);
- return super.getText(element);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
index 6a878f42241..bb3952a5c29 100644
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/opentype/OpenTypeAction.java
@@ -10,36 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.browser.opentype;
-import java.lang.reflect.InvocationTargetException;
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.core.resources.FileStorage;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
-import org.eclipse.ui.texteditor.ITextEditor;
public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
@@ -53,148 +29,12 @@ public class OpenTypeAction implements IWorkbenchWindowActionDelegate {
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
- final ITypeSearchScope fScope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(fScope)) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.updateCache(fScope, monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
- }
-
- ITypeInfo[] elements = AllTypesCache.getAllTypes();
- if (elements.length == 0) {
- String title = OpenTypeMessages.getString("OpenTypeAction.notypes.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.notypes.message"); //$NON-NLS-1$
- MessageDialog.openInformation(getShell(), title, message);
- return;
- }
-
- OpenTypeDialog dialog = new OpenTypeDialog(getShell());
- dialog.setElements(elements);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
- if (info == null)
- return;
-
- ITypeReference location = info.getResolvedReference();
- if (location == null) {
- final ITypeInfo[] typesToResolve = new ITypeInfo[] { info };
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.resolveTypeLocation(typesToResolve[0], monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
-
- location = info.getResolvedReference();
- }
-
- if (location == null) {
- // could not resolve location
- String title = OpenTypeMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$
- String message = OpenTypeMessages.getFormattedString("OpenTypeAction.errorTypeNotFound", info.getQualifiedTypeName().toString()); //$NON-NLS-1$
- MessageDialog.openError(getShell(), title, message);
- } else if (!openTypeInEditor(location)) {
- // error opening editor
- String title = OpenTypeMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$
- String message = OpenTypeMessages.getFormattedString("OpenTypeAction.errorOpenEditor", location.getPath().toString()); //$NON-NLS-1$
- MessageDialog.openError(getShell(), title, message);
- }
}
protected Shell getShell() {
return CUIPlugin.getActiveWorkbenchShell();
}
- /**
- * Opens an editor and displays the selected type.
- *
- * @param info Type to display.
- * @return true if succesfully displayed.
- */
- private boolean openTypeInEditor(ITypeReference location) {
- ITranslationUnit unit = location.getTranslationUnit();
- IEditorPart editorPart = null;
-
- try {
- if (unit != null)
- editorPart = EditorUtility.openInEditor(unit);
- if (editorPart == null) {
- // open as external file
- IPath path = location.getLocation();
- if (path != null) {
- IStorage storage = new FileStorage(path);
- editorPart = EditorUtility.openInEditor(storage);
- }
- }
-
- // highlight the type in the editor
- if (editorPart != null && editorPart instanceof ITextEditor) {
- ITextEditor editor = (ITextEditor) editorPart;
- if( location.isLineNumber() )
- {
- IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
- try
- {
- int startOffset = document.getLineOffset(location.getOffset()-1);
- int length=document.getLineLength(location.getOffset()-1);
- editor.selectAndReveal(startOffset, length);
- return true;
- }
- catch( BadLocationException ble )
- {
- return false;
- }
- }
- editor.selectAndReveal(location.getOffset(), location.getLength());
- return true;
- }
- } catch (CModelException ex) {
- ex.printStackTrace();
- return false;
- } catch (PartInitException ex) {
- ex.printStackTrace();
- return false;
- }
-
- return false;
- }
-
/*
* (non-Javadoc)
*
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/CHierarchyPerspectiveFactory.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/CHierarchyPerspectiveFactory.java
deleted file mode 100644
index 30c9471f820..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/CHierarchyPerspectiveFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.console.IConsoleConstants;
-
-public class CHierarchyPerspectiveFactory implements IPerspectiveFactory {
-
- /**
- * Constructs a new Java hierarchy layout engine.
- */
- public CHierarchyPerspectiveFactory() {
- super();
- }
-
- public void createInitialLayout(IPageLayout layout) {
- String editorArea = layout.getEditorArea();
-
- IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
- folder.addView(CUIPlugin.ID_TYPE_HIERARCHY);
- folder.addPlaceholder(IPageLayout.ID_OUTLINE);
- folder.addPlaceholder(CUIPlugin.CVIEW_ID);
- folder.addPlaceholder(IPageLayout.ID_RES_NAV);
-
- IPlaceholderFolderLayout outputfolder= layout.createPlaceholderFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
- outputfolder.addPlaceholder(IPageLayout.ID_PROBLEM_VIEW);
- outputfolder.addPlaceholder(NewSearchUI.SEARCH_VIEW_ID);
- outputfolder.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
- outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
-// outputfolder.addPlaceholder(CUIPlugin.ID_SOURCE_VIEW);
-// outputfolder.addPlaceholder(CUIPlugin.ID_JAVADOC_VIEW);
-// outputfolder.addPlaceholder(CPerspectiveFactory.ID_PROGRESS_VIEW);
-
-// layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
-// layout.addActionSet(JavaUI.ID_ACTION_SET);
-// layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
-
- // views - java
- layout.addShowViewShortcut(CUIPlugin.CVIEW_ID);
- layout.addShowViewShortcut(CUIPlugin.ID_TYPE_HIERARCHY);
-
- layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID);
-
- // views - debugging
- layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
-
- // views - standard workbench
- layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
- layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
- layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/EnableMemberFilterAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/EnableMemberFilterAction.java
deleted file mode 100644
index c3d1c3f5bc6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/EnableMemberFilterAction.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action enable / disable member filtering
- */
-public class EnableMemberFilterAction extends Action {
-
- TypeHierarchyViewPart fView;
-
- public EnableMemberFilterAction(TypeHierarchyViewPart v, boolean initValue) {
- super(TypeHierarchyMessages.getString("EnableMemberFilterAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("EnableMemberFilterAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("EnableMemberFilterAction.tooltip")); //$NON-NLS-1$
-
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "impl_co.gif"); //$NON-NLS-1$
-
- fView= v;
- setChecked(initValue);
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.ENABLE_METHODFILTER_ACTION);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fView.getSite().getShell().getDisplay(), new Runnable() {
- public void run() {
- fView.enableMemberFilter(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnSelectionAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnSelectionAction.java
deleted file mode 100644
index 0ddc16fbd74..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnSelectionAction.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.util.SelectionUtil;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Refocuses the type hierarchy on the currently selection type.
- */
-public class FocusOnSelectionAction extends Action {
-
- private TypeHierarchyViewPart fViewPart;
-
- public FocusOnSelectionAction(TypeHierarchyViewPart part) {
- super(TypeHierarchyMessages.getString("FocusOnSelectionAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("FocusOnSelectionAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("FocusOnSelectionAction.tooltip")); //$NON-NLS-1$
- fViewPart= part;
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.FOCUS_ON_SELECTION_ACTION);
- }
-
- private ISelection getSelection() {
- ISelectionProvider provider= fViewPart.getSite().getSelectionProvider();
- if (provider != null) {
- return provider.getSelection();
- }
- return null;
- }
-
-
- /*
- * @see Action#run
- */
- public void run() {
- Object element= SelectionUtil.getSingleElement(getSelection());
- if (element instanceof ICElement) {
- fViewPart.setInputElement((ICElement)element);
- }
- }
-
- public boolean canActionBeAdded() {
- Object element= SelectionUtil.getSingleElement(getSelection());
- if (element instanceof ICElement) {
- ICElement type= (ICElement)element;
- setText(TypeHierarchyMessages.getFormattedString(
- "FocusOnSelectionAction.label", //$NON-NLS-1$
- CElementLabels.getTextLabel(type, 0)));
- return true;
- }
- return false;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java
deleted file mode 100644
index 4f3223dd725..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.progress.IProgressService;
-
-/**
- * Refocuses the type hierarchy on a type selection from a all types dialog.
- */
-public class FocusOnTypeAction extends Action {
-
- private TypeHierarchyViewPart fViewPart;
-
- public FocusOnTypeAction(TypeHierarchyViewPart part) {
- super(TypeHierarchyMessages.getString("FocusOnTypeAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("FocusOnTypeAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("FocusOnTypeAction.tooltip")); //$NON-NLS-1$
-
- fViewPart= part;
- WorkbenchHelp.setHelp(this, ICHelpContextIds.FOCUS_ON_TYPE_ACTION);
- }
-
- /*
- * @see Action#run
- */
- public void run() {
-
- final ITypeSearchScope fScope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(fScope)) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.updateCache(fScope, monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
- }
-
- final int[] kinds = {ICElement.C_CLASS, ICElement.C_STRUCT};
- ITypeInfo[] elements = AllTypesCache.getTypes(fScope, kinds);
- if (elements.length == 0) {
- String title = OpenTypeMessages.getString("OpenTypeAction.notypes.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.notypes.message"); //$NON-NLS-1$
- MessageDialog.openInformation(getShell(), title, message);
- return;
- }
-
- FocusOnTypeDialog dialog = new FocusOnTypeDialog(getShell());
- dialog.setElements(elements);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
- if (info == null)
- return;
-
- final ITypeInfo[] typesToResolve = new ITypeInfo[] { info };
- final ICElement[] foundElement = new ICElement[] { null };
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- foundElement[0] = AllTypesCache.getElementForType(typesToResolve[0], true, true, monitor);
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
-
- if (foundElement[0] == null) {
- // could not resolve location
- String title = OpenTypeMessages.getString("OpenTypeAction.errorTitle"); //$NON-NLS-1$
- String message = OpenTypeMessages.getFormattedString("OpenTypeAction.errorTypeNotFound", info.getQualifiedTypeName().toString()); //$NON-NLS-1$
- MessageDialog.openError(getShell(), title, message);
- } else {
- fViewPart.setInputElement(foundElement[0]);
- }
- }
-
- protected Shell getShell() {
- return CUIPlugin.getActiveWorkbenchShell();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeDialog.java
deleted file mode 100644
index 200ec830e4e..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeDialog.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software Systems - adapted for use in CDT
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A dialog to select a type from a list of types. The selected type will be
- * opened in the editor.
- */
-public class FocusOnTypeDialog extends TypeSelectionDialog {
-
- private static final String DIALOG_SETTINGS = FocusOnTypeDialog.class.getName();
-
- private final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
-
- /**
- * Constructs an instance of <code>OpenTypeDialog</code>.
- * @param parent the parent shell.
- */
- public FocusOnTypeDialog(Shell parent) {
- super(parent);
- setTitle(TypeHierarchyMessages.getString("FocusOnTypeAction.dialog.title")); //$NON-NLS-1$
- setMessage(TypeHierarchyMessages.getString("FocusOnTypeAction.dialog.message")); //$NON-NLS-1$
- setVisibleTypes(VISIBLE_TYPES);
- setDialogSettings(DIALOG_SETTINGS);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java
deleted file mode 100644
index 541e5476376..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
-import org.eclipse.cdt.ui.CElementImageDescriptor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.resource.CompositeImageDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Label provider for the hierarchy viewers. Types in the hierarchy that are not belonging to the
- * input scope are rendered differntly.
- */
-public class HierarchyLabelProvider extends StandardCElementLabelProvider // AppearanceAwareLabelProvider {
-{
- private static class FocusDescriptor extends CompositeImageDescriptor {
- private ImageDescriptor fBase;
- public FocusDescriptor(ImageDescriptor base) {
- fBase= base;
- }
- protected void drawCompositeImage(int width, int height) {
- drawImage(getImageData(fBase), 0, 0);
- drawImage(getImageData(CPluginImages.DESC_OVR_FOCUS), 0, 0);
- }
-
- private ImageData getImageData(ImageDescriptor descriptor) {
- ImageData data= descriptor.getImageData(); // see bug 51965: getImageData can return null
- if (data == null) {
- data= DEFAULT_IMAGE_DATA;
- CUIPlugin.getDefault().logErrorMessage("Image data not available: " + descriptor.toString()); //$NON-NLS-1$
- }
- return data;
- }
-
- protected Point getSize() {
- return CElementImageProvider.BIG_SIZE;
- }
- public int hashCode() {
- return fBase.hashCode();
- }
- public boolean equals(Object object) {
- return object != null && FocusDescriptor.class.equals(object.getClass()) && ((FocusDescriptor)object).fBase.equals(fBase);
- }
- }
-
- private Color fGrayedColor;
- private Color fSpecialColor;
-
- private ViewerFilter fFilter;
-
- private TypeHierarchyLifeCycle fHierarchy;
-
- public HierarchyLabelProvider(TypeHierarchyLifeCycle lifeCycle) {
-// super(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
- super();
- fHierarchy= lifeCycle;
- fFilter= null;
- }
-
-
- /**
- * @return Returns the filter.
- */
- public ViewerFilter getFilter() {
- return fFilter;
- }
-
- /**
- * @param filter The filter to set.
- */
- public void setFilter(ViewerFilter filter) {
- fFilter= filter;
- }
-
- protected boolean isDifferentScope(ICElement type) {
- if (fFilter != null && !fFilter.select(null, null, type)) {
- return true;
- }
-
- ICElement input= fHierarchy.getInputElement();
- if (input == null || TypeUtil.isClassOrStruct(input)) {
- return false;
- }
-
- ICElement parent= type.getAncestor(input.getElementType());
- if (input.getElementType() == ICElement.C_CCONTAINER) {
- if (parent == null || parent.getElementName().equals(input.getElementName())) {
- return false;
- }
- } else if (input.equals(parent)) {
- return false;
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see ILabelProvider#getImage
- */
- public Image getImage(Object element) {
- Image result= null;
- if (element instanceof ICElement) {
- ImageDescriptor desc= getTypeImageDescriptor((ICElement) element);
- if (desc != null) {
- if (element.equals(fHierarchy.getInputElement())) {
- desc= new FocusDescriptor(desc);
- }
- result= CUIPlugin.getImageDescriptorRegistry().get(desc);
- }
- } else {
- result= fImageLabelProvider.getImageLabel(element, getImageFlags());
- }
- return result;
- }
-
- private ImageDescriptor getTypeImageDescriptor(ICElement type) {
- ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
- if (hierarchy == null) {
- return new CElementImageDescriptor(CPluginImages.DESC_OBJS_CLASS, 0, CElementImageProvider.BIG_SIZE);
- }
-
- ImageDescriptor desc;
- if (isDifferentScope(type)) {
- desc = CElementImageProvider.getClassImageDescriptor();
- } else {
- desc= fImageLabelProvider.getBaseImageDescriptor(type, 0);
- }
-
- int adornmentFlags= 0;
- if (type instanceof IMethodDeclaration) {
- IMethodDeclaration method = (IMethodDeclaration) type;
- try {
- if (method.isStatic())
- adornmentFlags |= CElementImageDescriptor.STATIC;
-// if (method.isVirtual())
-// adornmentFlags |= CElementImageDescriptor.VIRTUAL;
- } catch (CModelException e) {
- }
- }
-
- if (type instanceof IStructure) {
-// hierarchy.getSupertypes(type);
-// TypeCacheManager.getInstance().getCache(type.getCProject().getProject()).getSupertypeAccess();
- }
-
- return new CElementImageDescriptor(desc, adornmentFlags, CElementImageProvider.BIG_SIZE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (element instanceof IMethod) {
- if (fSpecialColor == null) {
- fSpecialColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
- }
- return fSpecialColor;
- } else if (element instanceof ICElement && isDifferentScope((ICElement) element)) {
- if (fGrayedColor == null) {
- fGrayedColor= Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY);
- }
- return fGrayedColor;
- }
- return null;
- }
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java
deleted file mode 100644
index 77d35d1c18b..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.ui.CElementSorter;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-
-/**
- */
-public class HierarchyViewerSorter extends ViewerSorter {
-
- private static final int OTHER= 0;
- private static final int CLASS= 1;
- private static final int FIELD= 2;
- private static final int METHOD= 3;
-
- private TypeHierarchyLifeCycle fHierarchy;
- private boolean fSortByDefiningType;
- private CElementSorter fNormalSorter;
-
- public HierarchyViewerSorter(TypeHierarchyLifeCycle cycle) {
- fHierarchy= cycle;
- fNormalSorter= new CElementSorter();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
- */
-// public int category(Object element) {
-// if (element instanceof ICElement) {
-// ICElement type= (ICElement) element;
-// ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
-// if (hierarchy != null) {
-// return CLASS;
-// }
-// }
-// return OTHER;
-// }
-
-// public boolean isSorterProperty(Object element, Object property) {
-// return true;
-// }
-
- public int category(Object obj) {
- if (obj instanceof ICElement) {
- ICElement elem= (ICElement)obj;
- switch (elem.getElementType()) {
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- return CLASS;
-// case ICElement.C_UNION:
-// return 3;
- case ICElement.C_FIELD:
- return FIELD;
-
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- return METHOD;
-// {
-// IMethodDeclaration method = (IMethodDeclaration) elem;
-// try {
-// // sort constructor and destructor first
-// if (method.isConstructor() || method.isDestructor())
-// return 10;
-// } catch (CModelException e) {
-// }
-// return 20;
-// }
- }
-
- }
- return OTHER;
- }
-
- public boolean isSortByDefiningType() {
- return fSortByDefiningType;
- }
-
- public void setSortByDefiningType(boolean sortByDefiningType) {
- fSortByDefiningType= sortByDefiningType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ViewerSorter#compare(null, null, null)
- */
- public int compare(Viewer viewer, Object e1, Object e2) {
- int cat1= category(e1);
- int cat2= category(e2);
-
- if (cat1 != cat2)
- return cat1 - cat2;
-
- ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
- if (hierarchy == null) {
- return fNormalSorter.compare(viewer, e1, e2);
- }
-
- if (cat1 == FIELD || cat1 == METHOD) { // method or field
- if (fSortByDefiningType) {
- try {
- ICElement def1= (e1 instanceof IMethodDeclaration) ? getDefiningType(hierarchy, (IMethodDeclaration) e1) : null;
- ICElement def2= (e2 instanceof IMethodDeclaration) ? getDefiningType(hierarchy, (IMethodDeclaration) e2) : null;
- if (def1 != null) {
- if (def2 != null) {
- if (!def2.equals(def1)) {
- return compareInHierarchy(hierarchy, def1, def2);
- }
- } else {
- return -1;
- }
- } else {
- if (def2 != null) {
- return 1;
- }
- }
- } catch (CModelException e) {
- // ignore, default to normal comparison
- }
- }
- return fNormalSorter.compare(viewer, e1, e2); // use appearance pref page settings
- }
- String name1= ((ICElement) e1).getElementName(); //$NON-NLS-1$
- String name2= ((ICElement) e2).getElementName(); //$NON-NLS-1$
- return getCollator().compare(name1, name2);
- }
-
- private ICElement getDefiningType(ITypeHierarchy hierarchy, IMethodDeclaration method) throws CModelException {
- ICElement declaringType= TypeUtil.getDeclaringClass(method);
- if ((method.getVisibility() == ASTAccessVisibility.PRIVATE) || method.isStatic() || method.isConstructor() || method.isDestructor()) {
- return null;
- }
-
- ICElement res= TypeUtil.findMethodDeclarationInHierarchy(hierarchy, declaringType, method.getElementName(), method.getParameterTypes(), false, false);
- if (res == null || method.equals(res)) {
- return null;
- }
- return TypeUtil.getDeclaringClass(res);
- }
-
-
- private int compareInHierarchy(ITypeHierarchy hierarchy, ICElement def1, ICElement def2) {
- if (isSuperType(hierarchy, def1, def2)) {
- return 1;
- } else if (isSuperType(hierarchy, def2, def1)) {
- return -1;
- }
- String name1= def1.getElementName();
- String name2= def2.getElementName();
-
- return getCollator().compare(name1, name2);
- }
-
- private boolean isSuperType(ITypeHierarchy hierarchy, ICElement def1, ICElement def2) {
- ICElement[] superTypes= hierarchy.getSupertypes(def1);
- if (superTypes != null) {
- for (int i = 0; i < superTypes.length; ++i) {
- if (superTypes[i].equals(def2) || isSuperType(hierarchy, superTypes[i], def2)) {
- return true;
- }
- }
- }
- return false;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java
deleted file mode 100644
index 6bed875b8c4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action used for the type hierarchy forward / backward buttons
- */
-public class HistoryAction extends Action {
-
- private TypeHierarchyViewPart fViewPart;
- private ICElement fElement;
-
- public HistoryAction(TypeHierarchyViewPart viewPart, ICElement element) {
- super();
- fViewPart= viewPart;
- fElement= element;
-
- String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED | CElementLabels.M_PARAMETER_TYPES);
- setText(elementName);
- setImageDescriptor(getImageDescriptor(element));
-
- setDescription(TypeHierarchyMessages.getFormattedString("HistoryAction.description", elementName)); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getFormattedString("HistoryAction.tooltip", elementName)); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.HISTORY_ACTION);
- }
-
- private ImageDescriptor getImageDescriptor(ICElement elem) {
- CElementImageProvider imageProvider= new CElementImageProvider();
- ImageDescriptor desc= imageProvider.getBaseImageDescriptor(elem, 0);
- imageProvider.dispose();
- return desc;
- }
-
- /*
- * @see Action#run()
- */
- public void run() {
- fViewPart.gotoHistoryEntry(fElement);
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java
deleted file mode 100644
index 63d83f90fc9..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IMenuCreator;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class HistoryDropDownAction extends Action implements IMenuCreator {
-
-
- public static final int RESULTS_IN_DROP_DOWN= 10;
-
- private TypeHierarchyViewPart fHierarchyView;
- private Menu fMenu;
-
- public HistoryDropDownAction(TypeHierarchyViewPart view) {
- fHierarchyView= view;
- fMenu= null;
- setToolTipText(TypeHierarchyMessages.getString("HistoryDropDownAction.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.TYPEHIERARCHY_HISTORY_ACTION);
- setMenuCreator(this);
- }
-
- public void dispose() {
- // action is reused, can be called several times.
- if (fMenu != null) {
- fMenu.dispose();
- fMenu= null;
- }
- }
-
- public Menu getMenu(Menu parent) {
- return null;
- }
-
- public Menu getMenu(Control parent) {
- if (fMenu != null) {
- fMenu.dispose();
- }
- fMenu= new Menu(parent);
- ICElement[] elements= fHierarchyView.getHistoryEntries();
- boolean checked= addEntries(fMenu, elements);
- if (elements.length > RESULTS_IN_DROP_DOWN) {
- new MenuItem(fMenu, SWT.SEPARATOR);
- Action others= new HistoryListAction(fHierarchyView);
- others.setChecked(checked);
- addActionToMenu(fMenu, others);
- }
- return fMenu;
- }
-
- private boolean addEntries(Menu menu, ICElement[] elements) {
- boolean checked= false;
-
- int min= Math.min(elements.length, RESULTS_IN_DROP_DOWN);
- for (int i= 0; i < min; i++) {
- HistoryAction action= new HistoryAction(fHierarchyView, elements[i]);
- action.setChecked(elements[i].equals(fHierarchyView.getInputElement()));
- checked= checked || action.isChecked();
- addActionToMenu(menu, action);
- }
- return checked;
- }
-
-
- protected void addActionToMenu(Menu parent, Action action) {
- ActionContributionItem item= new ActionContributionItem(action);
- item.fill(parent, -1);
- }
-
- public void run() {
- (new HistoryListAction(fHierarchyView)).run();
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java
deleted file mode 100644
index 30e30614575..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.dialogs.StatusDialog;
-import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.IListAdapter;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.LayoutUtil;
-import org.eclipse.cdt.internal.ui.wizards.dialogfields.ListDialogField;
-import org.eclipse.cdt.ui.CElementLabelProvider;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-public class HistoryListAction extends Action {
-
- private class HistoryListDialog extends StatusDialog {
-
- private ListDialogField fHistoryList;
- private IStatus fHistoryStatus;
- private ICElement fResult;
-
- private HistoryListDialog(Shell shell, ICElement[] elements) {
- super(shell);
- setTitle(TypeHierarchyMessages.getString("HistoryListDialog.title")); //$NON-NLS-1$
-
- String[] buttonLabels= new String[] {
- /* 0 */ TypeHierarchyMessages.getString("HistoryListDialog.remove.button"), //$NON-NLS-1$
- };
-
- IListAdapter adapter= new IListAdapter() {
- public void customButtonPressed(ListDialogField field, int index) {
- doCustomButtonPressed();
- }
- public void selectionChanged(ListDialogField field) {
- doSelectionChanged();
- }
-
- public void doubleClicked(ListDialogField field) {
- doDoubleClicked();
- }
- };
-
- CElementLabelProvider labelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_QUALIFIED /*| CElementLabelProvider.SHOW_ROOT*/);
-
- fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
- fHistoryList.setLabelText(TypeHierarchyMessages.getString("HistoryListDialog.label")); //$NON-NLS-1$
- fHistoryList.setElements(Arrays.asList(elements));
-
- ISelection sel;
- if (elements.length > 0) {
- sel= new StructuredSelection(elements[0]);
- } else {
- sel= new StructuredSelection();
- }
-
- fHistoryList.selectElements(sel);
- }
-
-
- /*
- * @see Dialog#createDialogArea(Composite)
- */
- protected Control createDialogArea(Composite parent) {
- initializeDialogUnits(parent);
-
- Composite composite= (Composite) super.createDialogArea(parent);
-
- Composite inner= new Composite(composite, SWT.NONE);
- inner.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
- LayoutUtil.setHeigthHint(fHistoryList.getListControl(null), convertHeightInCharsToPixels(12));
- LayoutUtil.setHorizontalGrabbing(fHistoryList.getListControl(null));
-
- applyDialogFont(composite);
- return composite;
- }
-
- /**
- * Method doCustomButtonPressed.
- */
- void doCustomButtonPressed() {
- fHistoryList.removeElements(fHistoryList.getSelectedElements());
- }
-
- void doDoubleClicked() {
- if (fHistoryStatus.isOK()) {
- okPressed();
- }
- }
-
-
- void doSelectionChanged() {
- StatusInfo status= new StatusInfo();
- List selected= fHistoryList.getSelectedElements();
- if (selected.size() != 1) {
- status.setError(""); //$NON-NLS-1$
- fResult= null;
- } else {
- fResult= (ICElement) selected.get(0);
- }
- fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0);
- fHistoryStatus= status;
- updateStatus(status);
- }
-
- public ICElement getResult() {
- return fResult;
- }
-
- public ICElement[] getRemaining() {
- List elems= fHistoryList.getElements();
- return (ICElement[]) elems.toArray(new ICElement[elems.size()]);
- }
-
- /*
- * @see org.eclipse.jface.window.Window#configureShell(Shell)
- */
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- WorkbenchHelp.setHelp(newShell, ICHelpContextIds.HISTORY_LIST_DIALOG);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#create()
- */
- public void create() {
- setShellStyle(getShellStyle() | SWT.RESIZE);
- super.create();
- }
-
- }
-
- private TypeHierarchyViewPart fView;
-
- public HistoryListAction(TypeHierarchyViewPart view) {
- fView= view;
- setText(TypeHierarchyMessages.getString("HistoryListAction.label")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.HISTORY_LIST_ACTION);
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- ICElement[] historyEntries= fView.getHistoryEntries();
- HistoryListDialog dialog= new HistoryListDialog(CUIPlugin.getActiveWorkbenchShell(), historyEntries);
- if (dialog.open() == Window.OK) {
- fView.setHistoryEntries(dialog.getRemaining());
- fView.setInputElement(dialog.getResult());
- }
- }
-
-}
-
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java
deleted file mode 100644
index c21589314d8..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-
-/**
- * Used by the TypeHierarchyLifeCycle to inform listeners about a change in the
- * type hierarchy
- */
-public interface ITypeHierarchyLifeCycleListener {
-
- /**
- * A Java element changed.
- */
- void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchyProvider, ICElement[] changedTypes);
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java
deleted file mode 100644
index 04a93e376f4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.ui.IViewPart;
-
-/**
- * The standard type hierarchy view presents a type hierarchy for a given input class
- * or interface. Visually, this view consists of a pair of viewers, one showing the type
- * hierarchy, the other showing the members of the type selected in the first.
- * <p>
- * This interface is not intended to be implemented by clients.
- * </p>
- *
- * @see JavaUI#ID_TYPE_HIERARCHY
- */
-public interface ITypeHierarchyViewPart extends IViewPart {
-
- /**
- * Sets the input element of this type hierarchy view to a type.
- *
- * @param type the input element of this type hierarchy view, or <code>null</code>
- * to clear any input element
- * @deprecated use setInputElement instead
- */
- public void setInput(ICElement type);
-
- /**
- * Sets the input element of this type hierarchy view. The following input types are possible
- * <code>IMember</code> (types, methods, fields..), <code>IPackageFragment</code>, <code>IPackageFragmentRoot</code>
- * and <code>IJavaProject</code>.
- *
- * @param element the input element of this type hierarchy view, or <code>null</code>
- * to clear any input
- *
- * @since 2.0
- */
- public void setInputElement(ICElement element);
-
- /**
- * Returns the input element of this type hierarchy view.
- *
- * @return the input element, or <code>null</code> if no input element is set
- * @see #setInput(IType)
- * @deprecated use getInputElement instead
- */
- public ICElement getInput();
-
-
- /**
- * Returns the input element of this type hierarchy view.
- *
- * @return the input element, or <code>null</code> if no input element is set
- * @see #setInputElement(IJavaElement)
- *
- * @since 2.0
- */
- public ICElement getInputElement();
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java
deleted file mode 100644
index 1370a46d5ee..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.CElementContentProvider;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Content provider used for the method view.
- * Allows also seeing methods inherited from base classes.
- */
-public class MethodsContentProvider extends CElementContentProvider //implements IStructuredContentProvider //, IWorkingCopyProvider
-{
- private static final Object[] NO_ELEMENTS = new Object[0];
-
- private boolean fShowInheritedMethods;
- private TypeHierarchyLifeCycle fHierarchyLifeCycle;
- private TableViewer fViewer;
-
- public MethodsContentProvider(TypeHierarchyLifeCycle lifecycle) {
- fHierarchyLifeCycle= lifecycle;
- fShowInheritedMethods= false;
- fViewer= null;
- }
-
- /**
- * Turn on / off showing of inherited methods
- */
- public void showInheritedMethods(boolean show) {
- if (show != fShowInheritedMethods) {
- fShowInheritedMethods= show;
- if (fViewer != null) {
- fViewer.refresh();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see IStructuredContentProvider#providesWorkingCopies()
- */
- public boolean providesWorkingCopies() {
- return true;
- }
-
- /**
- * Returns true if inherited methods are shown
- */
- public boolean isShowInheritedMethods() {
- return fShowInheritedMethods;
- }
-
-
- private void addAll(Object[] arr, List res) {
- if (arr != null) {
- for (int j= 0; j < arr.length; j++) {
- res.add(arr[j]);
- }
- }
- }
-
- /*
- * @see IStructuredContentProvider#getElements
- */
- public Object[] getElements(Object element) {
- if (element instanceof ICElement) {
- ICElement type= (ICElement)element;
-
- List res= new ArrayList();
-// try {
- ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
- if (fShowInheritedMethods && hierarchy != null) {
- ICElement[] allSupertypes= hierarchy.getAllSupertypes(type);
- // sort in from last to first: elements with same name
- // will show up in hierarchy order
- for (int i= allSupertypes.length - 1; i >= 0; i--) {
- ICElement superType= allSupertypes[i];
- if (superType.exists()) {
- addAll(TypeUtil.getMethods(superType), res);
- //addAll(TypeUtil.getInitializers(superType), res);
- addAll(TypeUtil.getFields(superType), res);
- }
- }
- }
- if (type.exists()) {
- addAll(TypeUtil.getMethods(type), res);
- //addAll(TypeUtil.getInitializers(type), res);
- addAll(TypeUtil.getFields(type), res);
- }
-// } catch (CModelException e) {
-// CUIPlugin.getDefault().log(e);
-// }
- return res.toArray();
- }
- return NO_ELEMENTS;
- }
-
-
- /*
- * @see IContentProvider#inputChanged
- */
- public void inputChanged(Viewer input, Object oldInput, Object newInput) {
- Assert.isTrue(input instanceof TableViewer);
-
- fViewer= (TableViewer) input;
- }
-
- /*
- * @see IContentProvider#dispose
- */
- public void dispose() {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java
deleted file mode 100644
index 9ee430af59a..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMethod;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * Label provider for the hierarchy method viewers.
- */
-public class MethodsLabelProvider extends StandardCElementLabelProvider //extends AppearanceAwareLabelProvider
-{
- private Color fResolvedBackground;
-
- private boolean fShowDefiningType;
- private TypeHierarchyLifeCycle fHierarchy;
- private MethodsViewer fMethodsViewer;
-
- public MethodsLabelProvider(TypeHierarchyLifeCycle lifeCycle, MethodsViewer methodsViewer) {
-// super(DEFAULT_TEXTFLAGS, DEFAULT_IMAGEFLAGS);
- super();
- fHierarchy= lifeCycle;
- fShowDefiningType= false;
- fMethodsViewer= methodsViewer;
- fResolvedBackground= null;
- }
-
- public void setShowDefiningType(boolean showDefiningType) {
- fShowDefiningType= showDefiningType;
- }
-
- public boolean isShowDefiningType() {
- return fShowDefiningType;
- }
-
-
- private ICElement getDefiningType(Object element) throws CModelException {
- if (!(element instanceof ICElement))
- return null;
-
- ICElement elem = (ICElement) element;
- int kind= elem.getElementType();
- if (kind != ICElement.C_METHOD_DECLARATION && kind != ICElement.C_FIELD) {
- return null;
- }
- ICElement declaringType= TypeUtil.getDeclaringClass(elem);
- if (kind != ICElement.C_METHOD_DECLARATION) {
- return declaringType;
- }
- ITypeHierarchy hierarchy= fHierarchy.getHierarchy();
- if (hierarchy == null) {
- return declaringType;
- }
- IMethodDeclaration method= (IMethodDeclaration) element;
- if ((method.getVisibility() == ASTAccessVisibility.PRIVATE) || method.isStatic() || method.isConstructor() || method.isDestructor()) {
- return declaringType;
- }
- IMethodDeclaration res= TypeUtil.findMethodDeclarationInHierarchy(hierarchy, declaringType, method.getElementName(), method.getParameterTypes(), false, false);
- if (res == null || method.equals(res)) {
- return declaringType;
- }
- return TypeUtil.getDeclaringClass(res);
- }
-
- /* (non-Javadoc)
- * @see ILabelProvider#getText
- */
- public String getText(Object element) {
- String text= super.getText(element);
- if ((getTextFlags() & CElementLabels.M_POST_QUALIFIED) != 0) {
- if (element instanceof ICElement) {
- ICElement parent = ((ICElement)element).getParent();
- if (parent != null) {
- StringBuffer name = new StringBuffer();
- name.append(text);
- name.append(CElementLabels.CONCAT_STRING);
- name.append(TypeUtil.getFullyQualifiedName(parent).toString());
- text = name.toString();
- }
- }
- }
-
- if (fShowDefiningType) {
- try {
- ICElement type= getDefiningType(element);
- if (type != null) {
- StringBuffer buf= new StringBuffer(super.getText(type));
- buf.append(CElementLabels.CONCAT_STRING);
- buf.append(text);
- return buf.toString();
- }
- } catch (CModelException e) {
- }
- }
- return text;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
- */
- public Color getForeground(Object element) {
- if (fMethodsViewer.isShowInheritedMethods() && element instanceof IMethod) {
- IMethod curr= (IMethod) element;
- ICElement declaringType= TypeUtil.getDeclaringClass(curr);
-
- if (declaringType.equals(fMethodsViewer.getInput())) {
- if (fResolvedBackground == null) {
- Display display= Display.getCurrent();
- fResolvedBackground= display.getSystemColor(SWT.COLOR_DARK_BLUE);
- }
- return fResolvedBackground;
- }
- }
- return null;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java
deleted file mode 100644
index f1040498259..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.cdt.internal.ui.util.ProblemTableViewer;
-import org.eclipse.cdt.internal.ui.util.SelectionUtil;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-/**
- * Method viewer shows a list of methods of a input type.
- * Offers filter actions.
- * No dependency to the type hierarchy view
- */
-public class MethodsViewer extends ProblemTableViewer {
-
- private static final String TAG_SHOWINHERITED= "showinherited"; //$NON-NLS-1$
- private static final String TAG_SORTBYDEFININGTYPE= "sortbydefiningtype"; //$NON-NLS-1$
- private static final String TAG_VERTICAL_SCROLL= "mv_vertical_scroll"; //$NON-NLS-1$
-
- private MethodsLabelProvider fLabelProvider;
-
- private MemberFilterActionGroup fMemberFilterActionGroup;
-
-// private OpenAction fOpen;
- private ShowInheritedMembersAction fShowInheritedMembersAction;
- private SortByDefiningTypeAction fSortByDefiningTypeAction;
-
- public MethodsViewer(Composite parent, final TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(new Table(parent, SWT.MULTI));
-
- fLabelProvider= new MethodsLabelProvider(lifeCycle, this);
-
-// setLabelProvider(new DecoratingCLabelProvider(fLabelProvider, true));
- setLabelProvider(fLabelProvider);
- setContentProvider(new MethodsContentProvider(lifeCycle));
-
- HierarchyViewerSorter sorter= new HierarchyViewerSorter(lifeCycle);
- sorter.setSortByDefiningType(false);
- setSorter(sorter);
-
-// fOpen= new OpenAction(part.getSite());
-// addOpenListener(new IOpenListener() {
-// public void open(OpenEvent event) {
-// fOpen.run();
-// }
-// });
-
- fMemberFilterActionGroup= new MemberFilterActionGroup(this, "HierarchyMethodView", false, MemberFilterActionGroup.ALL_FILTERS & ~MemberFilterActionGroup.FILTER_LOCALTYPES); //$NON-NLS-1$
-
- fShowInheritedMembersAction= new ShowInheritedMembersAction(this, false);
- fSortByDefiningTypeAction= new SortByDefiningTypeAction(this, false);
-
- showInheritedMethodsNoRedraw(false);
- sortByDefiningTypeNoRedraw(false);
-
-// CUIHelp.setHelp(this, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
- }
-
- private void showInheritedMethodsNoRedraw(boolean on) {
- MethodsContentProvider cprovider= (MethodsContentProvider) getContentProvider();
- cprovider.showInheritedMethods(on);
- fShowInheritedMembersAction.setChecked(on);
- if (on) {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() | CElementLabels.T_POST_QUALIFIED);
- } else {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() & ~CElementLabels.T_POST_QUALIFIED);
- }
- if (on) {
- sortByDefiningTypeNoRedraw(false);
- }
- fSortByDefiningTypeAction.setEnabled(!on);
-
- }
-
- /**
- * Show inherited methods
- */
- public void showInheritedMethods(boolean on) {
- if (on == isShowInheritedMethods()) {
- return;
- }
- try {
- getTable().setRedraw(false);
- showInheritedMethodsNoRedraw(on);
- refresh();
- } finally {
- getTable().setRedraw(true);
- }
- }
-
- private void sortByDefiningTypeNoRedraw(boolean on) {
- fSortByDefiningTypeAction.setChecked(on);
- fLabelProvider.setShowDefiningType(on);
- ((HierarchyViewerSorter) getSorter()).setSortByDefiningType(on);
- }
-
- /**
- * Show the name of the defining type
- */
- public void sortByDefiningType(boolean on) {
- if (on == isShowDefiningTypes()) {
- return;
- }
- try {
- getTable().setRedraw(false);
- sortByDefiningTypeNoRedraw(on);
- refresh();
- } finally {
- getTable().setRedraw(true);
- }
- }
-
- /*
- * @see Viewer#inputChanged(Object, Object)
- */
- protected void inputChanged(Object input, Object oldInput) {
- super.inputChanged(input, oldInput);
- }
-
- /**
- * Returns <code>true</code> if inherited methods are shown.
- */
- public boolean isShowInheritedMethods() {
- return ((MethodsContentProvider) getContentProvider()).isShowInheritedMethods();
- }
-
- /**
- * Returns <code>true</code> if defining types are shown.
- */
- public boolean isShowDefiningTypes() {
- return fLabelProvider.isShowDefiningType();
- }
-
- /**
- * Saves the state of the filter actions
- */
- public void saveState(IMemento memento) {
- fMemberFilterActionGroup.saveState(memento);
-
- memento.putString(TAG_SHOWINHERITED, String.valueOf(isShowInheritedMethods()));
- memento.putString(TAG_SORTBYDEFININGTYPE, String.valueOf(isShowDefiningTypes()));
-
- ScrollBar bar= getTable().getVerticalBar();
- int position= bar != null ? bar.getSelection() : 0;
- memento.putString(TAG_VERTICAL_SCROLL, String.valueOf(position));
- }
-
- /**
- * Restores the state of the filter actions
- */
- public void restoreState(IMemento memento) {
- fMemberFilterActionGroup.restoreState(memento);
- getControl().setRedraw(false);
- refresh();
- getControl().setRedraw(true);
-
- boolean showInherited= Boolean.valueOf(memento.getString(TAG_SHOWINHERITED)).booleanValue();
- showInheritedMethods(showInherited);
-
- boolean showDefiningTypes= Boolean.valueOf(memento.getString(TAG_SORTBYDEFININGTYPE)).booleanValue();
- sortByDefiningType(showDefiningTypes);
-
- ScrollBar bar= getTable().getVerticalBar();
- if (bar != null) {
- Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
- if (vScroll != null) {
- bar.setSelection(vScroll.intValue());
- }
- }
- }
-
- /**
- * Attaches a contextmenu listener to the table
- */
- public void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(menuListener);
- Menu menu= menuMgr.createContextMenu(getTable());
- getTable().setMenu(menu);
- viewSite.registerContextMenu(popupId, menuMgr, this);
- }
-
-
- /**
- * Fills up the context menu with items for the method viewer
- * Should be called by the creator of the context menu
- */
- public void contributeToContextMenu(IMenuManager menu) {
- }
-
- /**
- * Fills up the tool bar with items for the method viewer
- * Should be called by the creator of the tool bar
- */
- public void contributeToToolBar(ToolBarManager tbm) {
- tbm.add(fShowInheritedMembersAction);
- tbm.add(fSortByDefiningTypeAction);
- tbm.add(new Separator());
- fMemberFilterActionGroup.contributeToToolBar(tbm);
- }
-
- public void dispose() {
- if (fMemberFilterActionGroup != null) {
- fMemberFilterActionGroup.dispose();
- fMemberFilterActionGroup= null;
- }
- }
-
- /*
- * @see StructuredViewer#handleInvalidSelection(ISelection, ISelection)
- */
- protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
- // on change of input, try to keep selected methods stable by selecting a method with the same
- // signature: See #5466
- List oldSelections= SelectionUtil.toList(invalidSelection);
- List newSelections= SelectionUtil.toList(newSelection);
- if (!oldSelections.isEmpty()) {
- ArrayList newSelectionElements= new ArrayList(newSelections);
- try {
- Object[] currElements= getFilteredChildren(getInput());
- for (int i= 0; i < oldSelections.size(); i++) {
- Object curr= oldSelections.get(i);
- if (curr instanceof IMethodDeclaration && !newSelections.contains(curr)) {
- IMethodDeclaration method= (IMethodDeclaration) curr;
- if (method.exists()) {
- IMethodDeclaration similar= findSimilarMethod(method, currElements);
- if (similar != null) {
- newSelectionElements.add(similar);
- }
- }
- }
- }
- if (!newSelectionElements.isEmpty()) {
- newSelection= new StructuredSelection(newSelectionElements);
- } else if (currElements.length > 0) {
- newSelection= new StructuredSelection(currElements[0]);
- }
- } catch (CModelException e) {
- CUIPlugin.getDefault().log(e);
- }
- }
- setSelection(newSelection);
- updateSelection(newSelection);
- }
-
- private IMethodDeclaration findSimilarMethod(IMethodDeclaration meth, Object[] elements) throws CModelException {
- String name= meth.getElementName();
- String[] paramTypes= meth.getParameterTypes();
- boolean isConstructor= meth.isConstructor();
- boolean isDestructor= meth.isDestructor();
-
- for (int i= 0; i < elements.length; i++) {
- Object curr= elements[i];
- if (curr instanceof IMethodDeclaration && TypeUtil.isSameMethodSignature(name, paramTypes, isConstructor, isDestructor, (IMethodDeclaration) curr)) {
- return (IMethodDeclaration) curr;
- }
- }
- return null;
- }
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
deleted file mode 100644
index 4df1fadc382..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.ICStatusConstants;
-import org.eclipse.cdt.internal.ui.actions.ActionMessages;
-import org.eclipse.cdt.internal.ui.actions.ActionUtil;
-import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * This action opens a type hierarchy on the selected type.
- * <p>
- * The action is applicable to selections containing elements of type
- * <code>IType</code>.
- *
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * </p>
- *
- * @since 2.0
- */
-public class OpenTypeHierarchyAction extends SelectionDispatchAction {
-
- private CEditor fEditor;
-
- /**
- * Creates a new <code>OpenTypeHierarchyAction</code>. The action requires
- * that the selection provided by the site's selection provider is of type <code>
- * org.eclipse.jface.viewers.IStructuredSelection</code>.
- *
- * @param site the site providing context information for this action
- */
- public OpenTypeHierarchyAction(IWorkbenchSite site) {
- super(site);
- setText(ActionMessages.getString("OpenTypeHierarchyAction.label")); //$NON-NLS-1$
- setToolTipText(ActionMessages.getString("OpenTypeHierarchyAction.tooltip")); //$NON-NLS-1$
- setDescription(ActionMessages.getString("OpenTypeHierarchyAction.description")); //$NON-NLS-1$
- WorkbenchHelp.setHelp(this, ICHelpContextIds.OPEN_TYPE_HIERARCHY_ACTION);
- }
-
- /**
- * Note: This constructor is for internal use only. Clients should not call this constructor.
- */
- public OpenTypeHierarchyAction(CEditor editor) {
- this(editor.getEditorSite());
- fEditor= editor;
- setEnabled(SelectionConverter.canOperateOn(fEditor));
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(ITextSelection selection) {
-/* boolean enable = true;
- ICElement selectedElement = null;
- try {
- ICElement[] elements = SelectionConverter.getElementsAtOffset(fEditor);
- if (elements == null || elements.length == 0) {
- setEnabled(false);
- return;
- }
- // find class or struct
- for (int i = 0; i < elements.length; ++i) {
- if (TypeUtil.isClassOrStruct(elements[i])) {
- selectedElement = elements[i];
- break;
- }
- }
-
- if (selectedElement == null) {
- setEnabled(false);
- return;
- }
- } catch (CModelException e) {
- setEnabled(false);
- return;
- }
-
- ITextSelection textSelection= (ITextSelection)fEditor.getSelectionProvider().getSelection();
-
- if (textSelection == null) {
- setEnabled(false);
- return;
- }
-
- if( (((CElement)selectedElement).getIdStartPos() != textSelection.getOffset())
- || (((CElement)selectedElement).getIdLength() != textSelection.getLength())) {
- enable = false;
- }
- setEnabled(enable);
-*/ }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void selectionChanged(IStructuredSelection selection) {
- setEnabled(isEnabled(selection));
- }
-
- private boolean isEnabled(IStructuredSelection selection) {
- if (selection.size() != 1)
- return false;
- Object input= selection.getFirstElement();
- if (input instanceof ICElement) {
- ICElement elem = (ICElement)input;
- return TypeUtil.isClassOrStruct(elem);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(ITextSelection selection) {
- ICElement input= SelectionConverter.getInput(fEditor);
- if (!ActionUtil.isProcessable(getShell(), input))
- return;
-
- ICElement[] elements= SelectionConverter.codeResolveOrInputHandled(fEditor, getShell(), getDialogTitle());
- if (elements == null)
- return;
- List candidates= new ArrayList(elements.length);
- for (int i= 0; i < elements.length; i++) {
- ICElement elem = elements[i];
- if (elem instanceof ITranslationUnit) {
- ICElement[] realElems = findTypeDeclarations(selection.getText(), (ITranslationUnit)elem, selection.getOffset(), selection.getLength(), new NullProgressMonitor());
- if (realElems != null) {
- for (int j = 0; j < realElems.length; ++j) {
- ICElement[] resolvedElements= OpenTypeHierarchyUtil.getCandidates(realElems[j]);
- if (resolvedElements != null)
- candidates.addAll(Arrays.asList(resolvedElements));
- }
- }
- } else {
- ICElement[] resolvedElements= OpenTypeHierarchyUtil.getCandidates(elem);
- if (resolvedElements != null)
- candidates.addAll(Arrays.asList(resolvedElements));
- }
- }
- run((ICElement[])candidates.toArray(new ICElement[candidates.size()]));
- }
-
- private ICElement[] findTypeDeclarations(String name, ITranslationUnit unit, int offset, int length, IProgressMonitor monitor) {
- final ITypeSearchScope wsScope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(wsScope)) {
- AllTypesCache.updateCache(wsScope, monitor);
- }
- ITypeSearchScope projectScope = new TypeSearchScope();
- projectScope.add(unit.getCProject());
- int[] kinds = {ICElement.C_CLASS, ICElement.C_STRUCT};
- ITypeInfo[] types = AllTypesCache.getTypes(projectScope, new QualifiedTypeName(name), kinds, true);
- if (types != null) {
- List elements = new ArrayList(types.length);
- for (int i = 0; i < types.length; ++i) {
- ICElement e = AllTypesCache.getElementForType(types[i], true, true, monitor);
- if (e != null && !elements.contains(e))
- elements.add(e);
- }
- if (!elements.isEmpty())
- return (ICElement[])elements.toArray(new ICElement[elements.size()]);
- }
- return null;
- }
-
- /* (non-Javadoc)
- * Method declared on SelectionDispatchAction.
- */
- public void run(IStructuredSelection selection) {
- if (selection.size() != 1)
- return;
- Object input= selection.getFirstElement();
-
- if (!(input instanceof ICElement)) {
- IStatus status= createStatus(ActionMessages.getString("OpenTypeHierarchyAction.messages.no_c_element")); //$NON-NLS-1$
- ErrorDialog.openError(getShell(), getDialogTitle(), ActionMessages.getString("OpenTypeHierarchyAction.messages.title"), status); //$NON-NLS-1$
- return;
- }
- ICElement element= (ICElement) input;
- if (!ActionUtil.isProcessable(getShell(), element))
- return;
-
- List result= new ArrayList(1);
- IStatus status= compileCandidates(result, element);
- if (status.isOK()) {
- run((ICElement[]) result.toArray(new ICElement[result.size()]));
- } else {
- ErrorDialog.openError(getShell(), getDialogTitle(), ActionMessages.getString("OpenTypeHierarchyAction.messages.title"), status); //$NON-NLS-1$
- }
- }
-
- public void run(ICElement[] elements) {
- if (elements.length == 0) {
- getShell().getDisplay().beep();
- return;
- }
- OpenTypeHierarchyUtil.open(elements, getSite().getWorkbenchWindow());
- }
-
- private static String getDialogTitle() {
- return ActionMessages.getString("OpenTypeHierarchyAction.dialog.title"); //$NON-NLS-1$
- }
-
- private static IStatus compileCandidates(List result, ICElement elem) {
- IStatus ok = new Status(IStatus.OK, CUIPlugin.getPluginId(), 0, "", null); //$NON-NLS-1$
- switch (elem.getElementType()) {
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- case ICElement.C_PROJECT:
- result.add(elem);
- return ok;
- }
- return createStatus(ActionMessages.getString("OpenTypeHierarchyAction.messages.no_valid_c_element")); //$NON-NLS-1$
- }
-
- private static IStatus createStatus(String message) {
- return new Status(IStatus.INFO, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR, message, null);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
deleted file mode 100644
index 196b49258b7..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.WorkbenchException;
-
-public class OpenTypeHierarchyUtil {
-
- private OpenTypeHierarchyUtil() {
- }
-
- public static TypeHierarchyViewPart open(ICElement element, IWorkbenchWindow window) {
- ICElement[] candidates= getCandidates(element);
- if (candidates != null) {
- return open(candidates, window);
- }
- return null;
- }
-
- public static TypeHierarchyViewPart open(ICElement[] candidates, IWorkbenchWindow window) {
- Assert.isTrue(candidates != null && candidates.length != 0);
-
- ICElement input= null;
- if (candidates.length > 1) {
- String title= CUIMessages.getString("OpenTypeHierarchyUtil.selectionDialog.title"); //$NON-NLS-1$
- String message= CUIMessages.getString("OpenTypeHierarchyUtil.selectionDialog.message"); //$NON-NLS-1$
- input= OpenActionUtil.selectCElement(candidates, window.getShell(), title, message);
- } else {
- input= candidates[0];
- }
- if (input == null)
- return null;
-
- try {
- if (PreferenceConstants.OPEN_TYPE_HIERARCHY_IN_PERSPECTIVE.equals(PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.OPEN_TYPE_HIERARCHY))) {
- return openInPerspective(window, input);
- }
- return openInViewPart(window, input);
-
- } catch (WorkbenchException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CUIMessages.getString("OpenTypeHierarchyUtil.error.open_perspective"), //$NON-NLS-1$
- e.getMessage());
- } catch (CModelException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CUIMessages.getString("OpenTypeHierarchyUtil.error.open_editor"), //$NON-NLS-1$
- e.getMessage());
- }
- return null;
- }
-
- private static TypeHierarchyViewPart openInViewPart(IWorkbenchWindow window, ICElement input) {
- IWorkbenchPage page= window.getActivePage();
- try {
- TypeHierarchyViewPart result= (TypeHierarchyViewPart) page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
- if (result != null) {
- result.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
- }
- result= (TypeHierarchyViewPart) page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
- result.setInputElement(input);
-
- if (input instanceof IMember) {
- result.selectMember(input);
- }
- return result;
- } catch (CoreException e) {
- ExceptionHandler.handle(e, window.getShell(),
- CUIMessages.getString("OpenTypeHierarchyUtil.error.open_view"), e.getMessage()); //$NON-NLS-1$
- }
- return null;
- }
-
- private static TypeHierarchyViewPart openInPerspective(IWorkbenchWindow window, ICElement input) throws WorkbenchException, CModelException {
- IWorkbench workbench= CUIPlugin.getDefault().getWorkbench();
- // The problem is that the input element can be a working copy. So we first convert it to the original element if
- // it exists.
- ICElement perspectiveInput= input;
-
- if (input instanceof IMember) {
-// if (input.getElementType() != ITypeElement.TYPE) {
- if (TypeUtil.isClassOrStruct(input)) {
-// perspectiveInput= ((IMember)input).getDeclaringType();
- perspectiveInput= TypeUtil.getDeclaringClass(input);
- } else {
- perspectiveInput= input;
- }
- }
- IWorkbenchPage page= workbench.showPerspective(CUIPlugin.ID_CHIERARCHY_PERSPECTIVE, window, perspectiveInput);
-
- TypeHierarchyViewPart part= (TypeHierarchyViewPart) page.findView(CUIPlugin.ID_TYPE_HIERARCHY);
- if (part != null) {
- part.clearNeededRefresh(); // avoid refresh of old hierarchy on 'becomes visible'
- }
- part= (TypeHierarchyViewPart) page.showView(CUIPlugin.ID_TYPE_HIERARCHY);
- part.setInputElement(perspectiveInput);
- if (input instanceof IMember) {
- part.selectMember(input);
-
- if (page.getEditorReferences().length == 0) {
- openEditor(input, false); // only open when the perspecive has been created
- }
- }
- return part;
- }
-
- private static void openEditor(Object input, boolean activate) throws PartInitException, CModelException {
- IEditorPart part= EditorUtility.openInEditor(input, activate);
- if (input instanceof ICElement)
- EditorUtility.revealInEditor(part, (ICElement) input);
- }
-
- /**
- * Converts the input to a possible input candidates
- */
- public static ICElement[] getCandidates(Object input) {
- if (!(input instanceof ICElement)) {
- return null;
- }
- try {
- ICElement elem= (ICElement) input;
- switch (elem.getElementType()) {
- case ICElement.C_METHOD:
- case ICElement.C_METHOD_DECLARATION:
- case ICElement.C_FIELD:
- case ICElement.C_UNION:
- case ICElement.C_ENUMERATION:
- case ICElement.C_TYPEDEF:
- return new ICElement[] { TypeUtil.getDeclaringClass(elem) };
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- return new ICElement[] { elem };
- case ICElement.C_NAMESPACE:
- return TypeUtil.getTypes(elem);
- case ICElement.C_UNIT: {
- ITranslationUnit cu= (ITranslationUnit) elem.getAncestor(ICElement.C_UNIT);
- if (cu != null) {
- return TypeUtil.getTypes(cu);
- }
- break;
- }
- case ICElement.C_PROJECT:
- default:
- }
- } catch (CModelException e) {
- CUIPlugin.getDefault().log(e);
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java
deleted file mode 100644
index d24e9017f45..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * QNX Software Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeSearchScope;
-import org.eclipse.cdt.core.browser.TypeSearchScope;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeMessages;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.progress.IProgressService;
-
-public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate {
-
- private IWorkbenchWindow fWindow;
-
- public OpenTypeInHierarchyAction() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- final ITypeSearchScope fScope = new TypeSearchScope(true);
- if (!AllTypesCache.isCacheUpToDate(fScope)) {
- IRunnableWithProgress runnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- AllTypesCache.updateCache(fScope, monitor);
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
- };
-
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
- try {
- service.busyCursorWhile(runnable);
- } catch (InvocationTargetException e) {
- String title = OpenTypeMessages.getString("OpenTypeAction.exception.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.exception.message"); //$NON-NLS-1$
- ExceptionHandler.handle(e, title, message);
- return;
- } catch (InterruptedException e) {
- // cancelled by user
- return;
- }
- }
-
- ITypeInfo[] elements = AllTypesCache.getAllTypes();
- if (elements.length == 0) {
- String title = OpenTypeMessages.getString("OpenTypeAction.notypes.title"); //$NON-NLS-1$
- String message = OpenTypeMessages.getString("OpenTypeAction.notypes.message"); //$NON-NLS-1$
- MessageDialog.openInformation(getShell(), title, message);
- return;
- }
-
- OpenTypeInHierarchyDialog dialog = new OpenTypeInHierarchyDialog(getShell());
- dialog.setElements(elements);
- int result = dialog.open();
- if (result != IDialogConstants.OK_ID)
- return;
-
- ITypeInfo info = (ITypeInfo) dialog.getFirstResult();
- if (info == null)
- return;
-
- ICElement celem = AllTypesCache.getElementForType(info, false, true, null);
- if (celem != null) {
- OpenTypeHierarchyUtil.open(new ICElement[] { celem }, fWindow);
- }
- }
-
- protected Shell getShell() {
- return CUIPlugin.getActiveWorkbenchShell();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- fWindow= null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java
deleted file mode 100644
index 2ca3d200f54..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyDialog.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software Systems - adapted for use in CDT
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.ui.browser.typeinfo.TypeSelectionDialog;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A dialog to select a type from a list of types. The selected type will be
- * opened in the editor.
- */
-public class OpenTypeInHierarchyDialog extends TypeSelectionDialog {
-
- private static final String DIALOG_SETTINGS= OpenTypeInHierarchyDialog.class.getName();
- private final int[] VISIBLE_TYPES = { ICElement.C_CLASS, ICElement.C_STRUCT };
-
- /**
- * Constructs an instance of <code>OpenTypeDialog</code>.
- * @param parent the parent shell.
- */
- public OpenTypeInHierarchyDialog(Shell parent) {
- super(parent);
- setTitle(TypeHierarchyMessages.getString("OpenTypeInHierarchyDialog.title")); //$NON-NLS-1$
- setMessage(TypeHierarchyMessages.getString("OpenTypeInHierarchyDialog.message")); //$NON-NLS-1$
- setVisibleTypes(VISIBLE_TYPES);
- setDialogSettings(DIALOG_SETTINGS);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java
deleted file mode 100644
index 634e95db028..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-
-/**
- * A selection provider for viewparts with more that one viewer.
- * Tracks the focus of the viewers to provide the correct selection.
- */
-public class SelectionProviderMediator implements IPostSelectionProvider {
-
- private class InternalListener implements ISelectionChangedListener, FocusListener {
- /*
- * @see ISelectionChangedListener#selectionChanged
- */
- public void selectionChanged(SelectionChangedEvent event) {
- doSelectionChanged(event);
- }
-
- /*
- * @see FocusListener#focusGained
- */
- public void focusGained(FocusEvent e) {
- doFocusChanged(e.widget);
- }
-
- /*
- * @see FocusListener#focusLost
- */
- public void focusLost(FocusEvent e) {
- // do not reset due to focus behaviour on GTK
- //fViewerInFocus= null;
- }
- }
-
- private class InternalPostSelectionListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- doPostSelectionChanged(event);
- }
-
- }
-
- private StructuredViewer[] fViewers;
-
- private StructuredViewer fViewerInFocus;
- private ListenerList fSelectionChangedListeners;
- private ListenerList fPostSelectionChangedListeners;
-
- /**
- * @param viewers All viewers that can provide a selection
- */
- public SelectionProviderMediator(StructuredViewer[] viewers) {
- Assert.isNotNull(viewers);
- fViewers= viewers;
- InternalListener listener= new InternalListener();
- fSelectionChangedListeners= new ListenerList(4);
- fPostSelectionChangedListeners= new ListenerList(4);
- fViewerInFocus= null;
-
- for (int i= 0; i < fViewers.length; i++) {
- StructuredViewer viewer= fViewers[i];
- viewer.addSelectionChangedListener(listener);
- viewer.addPostSelectionChangedListener(new InternalPostSelectionListener());
- Control control= viewer.getControl();
- control.addFocusListener(listener);
- }
- }
-
- void doFocusChanged(Widget control) {
- for (int i= 0; i < fViewers.length; i++) {
- if (fViewers[i].getControl() == control) {
- propagateFocusChanged(fViewers[i]);
- return;
- }
- }
- }
-
- final void doPostSelectionChanged(SelectionChangedEvent event) {
- ISelectionProvider provider= event.getSelectionProvider();
- if (provider == fViewerInFocus) {
- firePostSelectionChanged();
- }
- }
-
- final void doSelectionChanged(SelectionChangedEvent event) {
- ISelectionProvider provider= event.getSelectionProvider();
- if (provider == fViewerInFocus) {
- fireSelectionChanged();
- }
- }
-
- final void propagateFocusChanged(StructuredViewer viewer) {
- if (viewer != fViewerInFocus) { // Ok to compare by idendity
- fViewerInFocus= viewer;
- fireSelectionChanged();
- firePostSelectionChanged();
- }
- }
-
- private void fireSelectionChanged() {
- if (fSelectionChangedListeners != null) {
- SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
-
- Object[] listeners= fSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
- listener.selectionChanged(event);
- }
- }
- }
-
- private void firePostSelectionChanged() {
- if (fPostSelectionChangedListeners != null) {
- SelectionChangedEvent event= new SelectionChangedEvent(this, getSelection());
-
- Object[] listeners= fPostSelectionChangedListeners.getListeners();
- for (int i= 0; i < listeners.length; i++) {
- ISelectionChangedListener listener= (ISelectionChangedListener) listeners[i];
- listener.selectionChanged(event);
- }
- }
- }
-
- /*
- * @see ISelectionProvider#addSelectionChangedListener
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListeners.add(listener);
- }
-
- /*
- * @see ISelectionProvider#removeSelectionChangedListener
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- fSelectionChangedListeners.remove(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- fPostSelectionChangedListeners.add(listener);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- */
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- fPostSelectionChangedListeners.remove(listener);
- }
-
- /*
- * @see ISelectionProvider#getSelection
- */
- public ISelection getSelection() {
- if (fViewerInFocus != null) {
- return fViewerInFocus.getSelection();
- }
- return StructuredSelection.EMPTY;
- }
-
- /*
- * @see ISelectionProvider#setSelection
- */
- public void setSelection(ISelection selection) {
- if (fViewerInFocus != null) {
- fViewerInFocus.setSelection(selection);
- }
- }
-
- /**
- * Returns the viewer in focus or null if no viewer has the focus
- */
- public StructuredViewer getViewerInFocus() {
- return fViewerInFocus;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java
deleted file mode 100644
index 9d3aa85a8e4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to show / hide inherited members in the method view
- * Depending in the action state a different label provider is installed in the viewer
- */
-public class ShowInheritedMembersAction extends Action {
-
- MethodsViewer fMethodsViewer;
-
- /**
- * Creates the action.
- */
- public ShowInheritedMembersAction(MethodsViewer viewer, boolean initValue) {
- super(TypeHierarchyMessages.getString("ShowInheritedMembersAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ShowInheritedMembersAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ShowInheritedMembersAction.tooltip")); //$NON-NLS-1$
-
-// CPluginImages.setLocalImageDescriptors(this, "inher_co.gif"); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "inher_co.gif"); //$NON-NLS-1$
-
- fMethodsViewer= viewer;
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.SHOW_INHERITED_ACTION);
-
- setChecked(initValue);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fMethodsViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- fMethodsViewer.showInheritedMethods(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java
deleted file mode 100644
index 45dcd935e8c..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-
-/**
- * Action enable / disable showing qualified type names
- */
-public class ShowQualifiedTypeNamesAction extends Action {
-
- TypeHierarchyViewPart fView;
-
- public ShowQualifiedTypeNamesAction(TypeHierarchyViewPart v, boolean initValue) {
- super(TypeHierarchyMessages.getString("ShowQualifiedTypeNamesAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ShowQualifiedTypeNamesAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ShowQualifiedTypeNamesAction.tooltip")); //$NON-NLS-1$
-
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_showqualified.gif"); //$NON-NLS-1$
-
- fView= v;
- setChecked(initValue);
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.SHOW_QUALIFIED_NAMES_ACTION);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fView.getSite().getShell().getDisplay(), new Runnable() {
- public void run() {
- fView.showQualifiedTypeNames(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java
deleted file mode 100644
index bd4bd21d6d3..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.swt.custom.BusyIndicator;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to let the label provider show the defining type of the method
- */
-public class SortByDefiningTypeAction extends Action {
-
- MethodsViewer fMethodsViewer;
-
- /**
- * Creates the action.
- */
- public SortByDefiningTypeAction(MethodsViewer viewer, boolean initValue) {
- super(TypeHierarchyMessages.getString("SortByDefiningTypeAction.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("SortByDefiningTypeAction.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("SortByDefiningTypeAction.tooltip")); //$NON-NLS-1$
-
-// CPluginImages.setLocalImageDescriptors(this, "definingtype_sort_co.gif"); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "definingtype_sort_co.gif"); //$NON-NLS-1$
-
- fMethodsViewer= viewer;
-
- WorkbenchHelp.setHelp(this, ICHelpContextIds.SORT_BY_DEFINING_TYPE_ACTION);
-
- setChecked(initValue);
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- BusyIndicator.showWhile(fMethodsViewer.getControl().getDisplay(), new Runnable() {
- public void run() {
- fMethodsViewer.sortByDefiningType(isChecked());
- }
- });
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java
deleted file mode 100644
index 947dcc37db6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * A viewer including the content provider for the subtype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
- */
-public class SubTypeHierarchyViewer extends TypeHierarchyViewer {
-
- public SubTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(parent, new SubTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
- }
-
- /*
- * @see TypeHierarchyViewer#getTitle
- */
- public String getTitle() {
- if (isMethodFiltering()) {
- return TypeHierarchyMessages.getString("SubTypeHierarchyViewer.filtered.title"); //$NON-NLS-1$
- }
- return TypeHierarchyMessages.getString("SubTypeHierarchyViewer.title"); //$NON-NLS-1$
- }
-
- /*
- * @see TypeHierarchyViewer#updateContent
- */
- public void updateContent(boolean expand) {
- getTree().setRedraw(false);
- refresh();
-
- if (expand) {
- int expandLevel= 2;
- if (isMethodFiltering()) {
- expandLevel++;
- }
- expandToLevel(expandLevel);
- }
- getTree().setRedraw(true);
- }
-
- /**
- * Content provider for the subtype hierarchy
- */
- public static class SubTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SubTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
- super(lifeCycle);
- }
-
- protected final void getTypesInHierarchy(ICElement type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- ICElement[] types= hierarchy.getSubtypes(type);
- if (types != null) {
- for (int i= 0; i < types.length; i++) {
- res.add(types[i]);
- }
- }
- }
-
- }
-
- protected ICElement[] getParentTypes(ICElement type) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- return hierarchy.getSupertypes(type);
- // dont handle interfaces
- }
- return null;
- }
-
-}
-
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java
deleted file mode 100644
index 30ceb991caa..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.swt.widgets.Composite;
-
-import org.eclipse.ui.IWorkbenchPart;
-
-/**
- * A viewer including the content provider for the supertype hierarchy.
- * Used by the TypeHierarchyViewPart which has to provide a TypeHierarchyLifeCycle
- * on construction (shared type hierarchy)
- */
-public class SuperTypeHierarchyViewer extends TypeHierarchyViewer {
-
- public SuperTypeHierarchyViewer(Composite parent, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(parent, new SuperTypeHierarchyContentProvider(lifeCycle), lifeCycle, part);
- }
-
- /*
- * @see TypeHierarchyViewer#getTitle
- */
- public String getTitle() {
- if (isMethodFiltering()) {
- return TypeHierarchyMessages.getString("SuperTypeHierarchyViewer.filtered.title"); //$NON-NLS-1$
- }
- return TypeHierarchyMessages.getString("SuperTypeHierarchyViewer.title"); //$NON-NLS-1$
- }
-
- /*
- * @see TypeHierarchyViewer#updateContent
- */
- public void updateContent(boolean expand) {
- getTree().setRedraw(false);
- refresh();
- if (expand) {
- expandAll();
- }
- getTree().setRedraw(true);
- }
-
- /*
- * Content provider for the supertype hierarchy
- */
- public static class SuperTypeHierarchyContentProvider extends TypeHierarchyContentProvider {
- public SuperTypeHierarchyContentProvider(TypeHierarchyLifeCycle lifeCycle) {
- super(lifeCycle);
- }
-
- protected final void getTypesInHierarchy(ICElement type, List res) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- ICElement[] types= hierarchy.getSupertypes(type);
- for (int i= 0; i < types.length; i++) {
- res.add(types[i]);
- }
- }
- }
-
- protected ICElement[] getParentTypes(ICElement type) {
- // cant handle
- return null;
- }
-
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java
deleted file mode 100644
index e3d2f4ca1c6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
-
-
-/**
- * This action toggles whether the type hierarchy links its selection to the active
- * editor.
- *
- * @since 3.0
- */
-public class ToggleLinkingAction extends AbstractToggleLinkingAction {
-
- TypeHierarchyViewPart fHierarchyViewPart;
-
- /**
- * Constructs a new action.
- */
- public ToggleLinkingAction(TypeHierarchyViewPart part) {
- setChecked(part.isLinkingEnabled());
- fHierarchyViewPart= part;
- }
-
- /**
- * Runs the action.
- */
- public void run() {
- fHierarchyViewPart.setLinkingEnabled(isChecked());
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java
deleted file mode 100644
index fbfabb3bba6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Toggles the orientationof the layout of the type hierarchy
- */
-public class ToggleOrientationAction extends Action {
-
- private TypeHierarchyViewPart fView;
- private int fActionOrientation;
-
- public ToggleOrientationAction(TypeHierarchyViewPart v, int orientation) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_HORIZONTAL) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.horizontal.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.horizontal.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.horizontal.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_horizontal.gif"); //$NON-NLS-1$
- } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_VERTICAL) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.vertical.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.vertical.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.vertical.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_vertical.gif"); //$NON-NLS-1$
- } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_AUTOMATIC) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.automatic.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.automatic.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.automatic.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_automatic.gif"); //$NON-NLS-1$
- } else if (orientation == TypeHierarchyViewPart.VIEW_ORIENTATION_SINGLE) {
- setText(TypeHierarchyMessages.getString("ToggleOrientationAction.single.label")); //$NON-NLS-1$
- setDescription(TypeHierarchyMessages.getString("ToggleOrientationAction.single.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleOrientationAction.single.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "th_single.gif"); //$NON-NLS-1$
- } else {
- Assert.isTrue(false);
- }
- fView= v;
- fActionOrientation= orientation;
- WorkbenchHelp.setHelp(this, ICHelpContextIds.TOGGLE_ORIENTATION_ACTION);
- }
-
- public int getOrientation() {
- return fActionOrientation;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- if (isChecked()) {
- fView.fOrientation= fActionOrientation;
- fView.computeOrientation();
- }
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java
deleted file mode 100644
index 1fe64cd02f3..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Action to switch between the different hierarchy views.
- */
-public class ToggleViewAction extends Action {
-
- private TypeHierarchyViewPart fViewPart;
- private int fViewerIndex;
-
- public ToggleViewAction(TypeHierarchyViewPart v, int viewerIndex) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- String contextHelpId= null;
- if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_SUPER) {
- setText(TypeHierarchyMessages.getString("ToggleViewAction.supertypes.label")); //$NON-NLS-1$
- contextHelpId= ICHelpContextIds.SHOW_SUPERTYPES;
- setDescription(TypeHierarchyMessages.getString("ToggleViewAction.supertypes.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleViewAction.supertypes.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "super_co.gif"); //$NON-NLS-1$
- } else if (viewerIndex == TypeHierarchyViewPart.VIEW_ID_SUB) {
- setText(TypeHierarchyMessages.getString("ToggleViewAction.subtypes.label")); //$NON-NLS-1$
- contextHelpId= ICHelpContextIds.SHOW_SUBTYPES;
- setDescription(TypeHierarchyMessages.getString("ToggleViewAction.subtypes.description")); //$NON-NLS-1$
- setToolTipText(TypeHierarchyMessages.getString("ToggleViewAction.subtypes.tooltip")); //$NON-NLS-1$
- CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "sub_co.gif"); //$NON-NLS-1$
- } else {
- Assert.isTrue(false);
- }
-
- fViewPart= v;
- fViewerIndex= viewerIndex;
-
- WorkbenchHelp.setHelp(this, contextHelpId);
- }
-
- public int getViewerIndex() {
- return fViewerIndex;
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- fViewPart.setView(fViewerIndex);
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java
deleted file mode 100644
index 72e11994653..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.IMethodDeclaration;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-
-/**
- * Base class for content providers for type hierarchy viewers.
- * Implementors must override 'getTypesInHierarchy'.
- * Java delta processing is also performed by the content provider
- */
-public abstract class TypeHierarchyContentProvider implements ITreeContentProvider //, IWorkingCopyProvider {
-{
- protected static final Object[] NO_ELEMENTS= new Object[0];
-
- protected TypeHierarchyLifeCycle fTypeHierarchy;
- protected IMember[] fMemberFilter;
-
- protected TreeViewer fViewer;
-
- private ViewerFilter fWorkingSetFilter;
-
- public TypeHierarchyContentProvider(TypeHierarchyLifeCycle lifecycle) {
- fTypeHierarchy= lifecycle;
- fMemberFilter= null;
- fWorkingSetFilter= null;
- }
-
- /**
- * Sets members to filter the hierarchy for. Set to <code>null</code> to disable member filtering.
- * When member filtering is enabled, the hierarchy contains only types that contain
- * an implementation of one of the filter members and the members themself.
- * The hierarchy can be empty as well.
- */
- public final void setMemberFilter(IMember[] memberFilter) {
- fMemberFilter= memberFilter;
- }
-
- /**
- * The members to filter or <code>null</code> if member filtering is disabled.
- */
- public IMember[] getMemberFilter() {
- return fMemberFilter;
- }
-
- /**
- * Sets a filter representing a working set or <code>null</code> if working sets are disabled.
- */
- public void setWorkingSetFilter(ViewerFilter filter) {
- fWorkingSetFilter= filter;
- }
-
-
- protected final ITypeHierarchy getHierarchy() {
- return fTypeHierarchy.getHierarchy();
- }
-
-
- /* (non-Javadoc)
- * @see IReconciled#providesWorkingCopies()
- */
- public boolean providesWorkingCopies() {
- return true;
- }
-
-
- /*
- * Called for the root element
- * @see IStructuredContentProvider#getElements
- */
- public Object[] getElements(Object parent) {
- ArrayList types= new ArrayList();
- getRootTypes(types);
- for (int i= types.size() - 1; i >= 0; i--) {
- ICElement curr= (ICElement) types.get(i);
- try {
- if (!isInTree(curr)) {
- types.remove(i);
- }
- } catch (CModelException e) {
- // ignore
- }
- }
- return types.toArray();
- }
-
- protected void getRootTypes(List res) {
- ITypeHierarchy hierarchy= getHierarchy();
- if (hierarchy != null) {
- ICElement input= hierarchy.getType();
- if (input != null) {
- res.add(input);
- }
- // opened on a region: dont show
- }
- }
-
- /**
- * Hook to overwrite. Filter will be applied on the returned types
- */
- protected abstract void getTypesInHierarchy(ICElement type, List res);
-
- /**
- * Hook to overwrite. Return null if parent is ambiguous.
- */
- protected abstract ICElement[] getParentTypes(ICElement type);
-
-
- private boolean isInScope(ICElement type) {
- if (fWorkingSetFilter != null && !fWorkingSetFilter.select(null, null, type)) {
- return false;
- }
-
-// ICElement input= fTypeHierarchy.getInputElement();
-// int inputType= input.getElementType();
-// if (inputType == ICElement.TYPE) {
-// return true;
-// }
-//
-// ICElement parent= type.getAncestor(input.getElementType());
-// if (inputType == ICElement.PACKAGE_FRAGMENT) {
-// if (parent == null || parent.getElementName().equals(input.getElementName())) {
-// return true;
-// }
-// } else if (input.equals(parent)) {
-// return true;
-// }
- return true;
- }
-
- /*
- * Called for the tree children.
- * @see ITreeContentProvider#getChildren
- */
- public Object[] getChildren(Object element) {
- if (element instanceof ICElement) {
- try {
- ICElement type= (ICElement)element;
-
- List children= new ArrayList();
- if (fMemberFilter != null) {
- addFilteredMemberChildren(type, children);
- }
-
- addTypeChildren(type, children);
-
- return children.toArray();
- } catch (CModelException e) {
- // ignore
- }
- }
- return NO_ELEMENTS;
- }
-
- /*
- * @see ITreeContentProvider#hasChildren
- */
- public boolean hasChildren(Object element) {
- if (element instanceof ICElement) {
- try {
- ICElement type= (ICElement) element;
- return hasTypeChildren(type) || (fMemberFilter != null && hasMemberFilterChildren(type));
- } catch (CModelException e) {
- return false;
- }
- }
- return false;
- }
-
- private void addFilteredMemberChildren(ICElement parent, List children) throws CModelException {
- IMethodDeclaration[] methods= TypeUtil.getMethods(parent);
- if (methods != null && methods.length > 0) {
- for (int i= 0; i < fMemberFilter.length; i++) {
- IMember member= fMemberFilter[i];
- if (parent.equals(TypeUtil.getDeclaringClass(member))) {
- if (!children.contains(member)) {
- children.add(member);
- }
- } else if (member instanceof IMethodDeclaration) {
- IMethodDeclaration curr= (IMethodDeclaration)member;
- IMethodDeclaration meth= TypeUtil.findMethod(curr.getElementName(), curr.getParameterTypes(), curr.isConstructor(), curr.isDestructor(), methods);
- if (meth != null && !children.contains(meth)) {
- children.add(meth);
- }
- }
- }
- }
- }
-
- private void addTypeChildren(ICElement type, List children) throws CModelException {
- ArrayList types= new ArrayList();
- getTypesInHierarchy(type, types);
- int len= types.size();
- for (int i= 0; i < len; i++) {
- ICElement curr= (ICElement) types.get(i);
- if (isInTree(curr)) {
- children.add(curr);
- }
- }
- }
-
- protected final boolean isInTree(ICElement type) throws CModelException {
- if (isInScope(type)) {
- if (fMemberFilter != null) {
- return hasMemberFilterChildren(type) || hasTypeChildren(type);
- }
- return true;
- }
- return hasTypeChildren(type);
- }
-
- private boolean hasMemberFilterChildren(ICElement type) throws CModelException {
- IMethodDeclaration[] methods= TypeUtil.getMethods(type);
- if (methods != null && methods.length > 0) {
- for (int i= 0; i < fMemberFilter.length; i++) {
- IMember member= fMemberFilter[i];
- if (type.equals(TypeUtil.getDeclaringClass(member))) {
- return true;
- } else if (member instanceof IMethodDeclaration) {
- IMethodDeclaration curr= (IMethodDeclaration)member;
- IMethodDeclaration meth= TypeUtil.findMethod(curr.getElementName(), curr.getParameterTypes(), curr.isConstructor(), curr.isDestructor(), methods);
- if (meth != null) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
-
- private boolean hasTypeChildren(ICElement type) throws CModelException {
- ArrayList types= new ArrayList();
- getTypesInHierarchy(type, types);
- int len= types.size();
- for (int i= 0; i < len; i++) {
- ICElement curr= (ICElement) types.get(i);
- if (isInTree(curr)) {
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see IContentProvider#inputChanged
- */
- public void inputChanged(Viewer part, Object oldInput, Object newInput) {
- Assert.isTrue(part instanceof TreeViewer);
- fViewer= (TreeViewer)part;
- }
-
- /*
- * @see IContentProvider#dispose
- */
- public void dispose() {
- }
-
- /*
- * @see ITreeContentProvider#getParent
- */
- public Object getParent(Object element) {
- if (element instanceof IMember) {
- IMember member= (IMember) element;
-// if (member.getElementType() == ICElement.TYPE) {
- if (TypeUtil.isClassOrStruct(member)) {
- ICElement[] parents= getParentTypes(member);
- if (parents != null && parents.length == 1)
- return parents[0];
- }
- return TypeUtil.getDeclaringClass(member);
- }
- return null;
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java
deleted file mode 100644
index 98a4bb97fe9..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.AllTypesCache;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchyChangedListener;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ElementChangedEvent;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ICElementDelta;
-import org.eclipse.cdt.core.model.IElementChangedListener;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-/**
- * Manages a type hierarchy, to keep it refreshed, and to allow it to be shared.
- */
-public class TypeHierarchyLifeCycle implements ITypeHierarchyChangedListener, IElementChangedListener {
-
- private boolean fHierarchyRefreshNeeded;
- private ITypeHierarchy fHierarchy;
- private ICElement fInputElement;
-
- private List fChangeListeners;
-
- public TypeHierarchyLifeCycle() {
- this(true);
- }
-
- public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {
- fHierarchy= null;
- fInputElement= null;
- fChangeListeners= new ArrayList(2);
- }
-
- public ITypeHierarchy getHierarchy() {
- return fHierarchy;
- }
-
- public ICElement getInputElement() {
- return fInputElement;
- }
-
-
- public void freeHierarchy() {
- if (fHierarchy != null) {
- fHierarchy.removeTypeHierarchyChangedListener(this);
- CoreModel.getDefault().removeElementChangedListener(this);
- fHierarchy= null;
- fInputElement= null;
- }
- }
-
- public void removeChangedListener(ITypeHierarchyLifeCycleListener listener) {
- fChangeListeners.remove(listener);
- }
-
- public void addChangedListener(ITypeHierarchyLifeCycleListener listener) {
- if (!fChangeListeners.contains(listener)) {
- fChangeListeners.add(listener);
- }
- }
-
- private void fireChange(ICElement[] changedTypes) {
- for (int i= fChangeListeners.size()-1; i>=0; i--) {
- ITypeHierarchyLifeCycleListener curr= (ITypeHierarchyLifeCycleListener) fChangeListeners.get(i);
- curr.typeHierarchyChanged(this, changedTypes);
- }
- }
-
- public void ensureRefreshedTypeHierarchy(final ICElement element, IRunnableContext context) throws InvocationTargetException, InterruptedException {
- if (element == null || !element.exists()) {
- freeHierarchy();
- return;
- }
- boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
-
- if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {
-
- IRunnableWithProgress op= new IRunnableWithProgress() {
- public void run(IProgressMonitor pm) throws InvocationTargetException, InterruptedException {
- try {
- doHierarchyRefresh(element, pm);
- } catch (CModelException e) {
- throw new InvocationTargetException(e);
- } catch (OperationCanceledException e) {
- throw new InterruptedException();
- }
- }
- };
- fHierarchyRefreshNeeded= true;
- context.run(true, true, op);
- fHierarchyRefreshNeeded= false;
- }
- }
-
- private ITypeHierarchy createTypeHierarchy(ICElement element, IProgressMonitor pm) throws CModelException {
- if (element.getElementType() == ICElement.C_CLASS
- || element.getElementType() == ICElement.C_STRUCT) {
- return AllTypesCache.createTypeHierarchy(element, pm);
- } else {
-// IRegion region= JavaCore.newRegion();
-// if (element.getElementType() == ICElement.JAVA_PROJECT) {
-// // for projects only add the contained source folders
-// IPackageFragmentRoot[] roots= ((IJavaProject) element).getPackageFragmentRoots();
-// for (int i= 0; i < roots.length; i++) {
-// if (!roots[i].isExternal()) {
-// region.add(roots[i]);
-// }
-// }
-// } else if (element.getElementType() == ICElement.PACKAGE_FRAGMENT) {
-// IPackageFragmentRoot[] roots= element.getJavaProject().getPackageFragmentRoots();
-// String name= element.getElementName();
-// for (int i= 0; i < roots.length; i++) {
-// IPackageFragment pack= roots[i].getPackageFragment(name);
-// if (pack.exists()) {
-// region.add(pack);
-// }
-// }
-// } else {
-// region.add(element);
-// }
-// ICProject jproject= element.getCProject();
-// return jproject.newTypeHierarchy(region, pm);
- return null;
- }
- }
-
-
- public synchronized void doHierarchyRefresh(ICElement element, IProgressMonitor pm) throws CModelException {
- boolean hierachyCreationNeeded= (fHierarchy == null || !element.equals(fInputElement));
- // to ensure the order of the two listeners always remove / add listeners on operations
- // on type hierarchies
- if (fHierarchy != null) {
- fHierarchy.removeTypeHierarchyChangedListener(this);
- CoreModel.getDefault().removeElementChangedListener(this);
- }
- if (hierachyCreationNeeded) {
- fHierarchy= createTypeHierarchy(element, pm);
- if (pm != null && pm.isCanceled()) {
- throw new OperationCanceledException();
- }
- fInputElement= element;
- } else if (fHierarchy != null) {
- fHierarchy.refresh(pm);
- }
- if (fHierarchy != null) {
- fHierarchy.addTypeHierarchyChangedListener(this);
- }
- CoreModel.getDefault().addElementChangedListener(this);
- fHierarchyRefreshNeeded= false;
- }
-
- /*
- * @see ITypeHierarchyChangedListener#typeHierarchyChanged
- */
- public void typeHierarchyChanged(ITypeHierarchy typeHierarchy) {
- fHierarchyRefreshNeeded= true;
- fireChange(null);
- }
-
- /*
- * @see IElementChangedListener#elementChanged(ElementChangedEvent)
- */
- public void elementChanged(ElementChangedEvent event) {
- if (fChangeListeners.isEmpty()) {
- return;
- }
-
- if (fHierarchyRefreshNeeded) {
- return;
- }
- ArrayList changedTypes= new ArrayList();
- processDelta(event.getDelta(), changedTypes);
- if (changedTypes.size() > 0) {
- fireChange((ICElement[]) changedTypes.toArray(new ICElement[changedTypes.size()]));
- }
- }
-
- /*
- * Assume that the hierarchy is intact (no refresh needed)
- */
- private void processDelta(ICElementDelta delta, ArrayList changedTypes) {
- ICElement element= delta.getElement();
- switch (element.getElementType()) {
-// case ICElement.TYPE:
- case ICElement.C_CLASS:
- case ICElement.C_STRUCT:
- processTypeDelta(element, changedTypes);
- processChildrenDelta(delta, changedTypes); // (inner types)
- break;
- case ICElement.C_MODEL:
- case ICElement.C_PROJECT:
-// case ICElement.PACKAGE_FRAGMENT_ROOT:
-// case ICElement.PACKAGE_FRAGMENT:
- processChildrenDelta(delta, changedTypes);
- break;
- case ICElement.C_UNIT:
- ITranslationUnit cu= (ITranslationUnit)element;
-// if (!CModelUtil.isPrimary(cu)) {
-// return;
-// }
-
- if (delta.getKind() == ICElementDelta.CHANGED && isPossibleStructuralChange(delta.getFlags())) {
-// try {
- if (cu.exists()) {
-// IType[] types= cu.getAllTypes();
- ICElement[] types= getAllTypesForTranslationUnit(cu); for (int i= 0; i < types.length; i++) {
- processTypeDelta(types[i], changedTypes);
- }
- }
-// } catch (CModelException e) {
-// CUIPlugin.getDefault().log(e);
-// }
- } else {
- processChildrenDelta(delta, changedTypes);
- }
- break;
-// case ICElement.CLASS_FILE:
-// if (delta.getKind() == ICElementDelta.CHANGED) {
-// try {
-// IType type= ((IClassFile) element).getType();
-// processTypeDelta(type, changedTypes);
-// } catch (CModelException e) {
-// CUIPlugin.getDefault().log(e);
-// }
-// } else {
-// processChildrenDelta(delta, changedTypes);
-// }
-// break;
- }
- }
-
- private boolean isPossibleStructuralChange(int flags) {
- return (flags & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED)) == ICElementDelta.F_CONTENT;
- }
-
- private void processTypeDelta(ICElement type, ArrayList changedTypes) {
- if (getHierarchy().contains(type)) {
- changedTypes.add(type);
- }
- }
-
- private void processChildrenDelta(ICElementDelta delta, ArrayList changedTypes) {
- ICElementDelta[] children= delta.getAffectedChildren();
- for (int i= 0; i < children.length; i++) {
- processDelta(children[i], changedTypes); // recursive
- }
- }
-
- private static ICElement[] getAllTypesForTranslationUnit(ITranslationUnit unit) {
- return null;
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java
deleted file mode 100644
index d86960efd2f..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class TypeHierarchyMessages {
-
- private static final String RESOURCE_BUNDLE= TypeHierarchyMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TypeHierarchyMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object arg) {
- return MessageFormat.format(getString(key), new Object[] { arg });
- }
-
-
- /**
- * Gets a string from the resource bundle and formats it with arguments
- */
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties
deleted file mode 100644
index fd87439f7a6..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.properties
+++ /dev/null
@@ -1,105 +0,0 @@
-###############################################################################
-# Copyright (c) 2003, 2005 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# QNX Software Systems - adapted for use in CDT
-###############################################################################
-
-EnableMemberFilterAction.label=Members in Hierarchy
-EnableMemberFilterAction.tooltip=Lock View and Show Members in Hierarchy
-EnableMemberFilterAction.description=Lock view and show members in hierarchy
-
-ToggleOrientationAction.horizontal.label=Horizontal View Orientation
-ToggleOrientationAction.horizontal.tooltip=Horizontal View Orientation
-ToggleOrientationAction.horizontal.description=Horizontal View Orientation
-
-ToggleOrientationAction.vertical.label=Vertical View Orientation
-ToggleOrientationAction.vertical.tooltip=Vertical View Orientation
-ToggleOrientationAction.vertical.description=Vertical View Orientation
-
-ToggleOrientationAction.automatic.label=Automatic View Orientation
-ToggleOrientationAction.automatic.tooltip=Automatic View Orientation
-ToggleOrientationAction.automatic.description=Automatic View Orientation
-
-ToggleOrientationAction.single.label=Hierarchy View Only
-ToggleOrientationAction.single.tooltip=Hierarchy View Only
-ToggleOrientationAction.single.description=Hierarchy View Only
-
-FocusOnSelectionAction.label=Fo&cus On ''{0}''
-FocusOnSelectionAction.tooltip=Focus the Type Hierarchy on the Selected Element
-FocusOnSelectionAction.description=Focus the Type Hierarchy on the selected element
-
-FocusOnTypeAction.label=&Focus On...
-FocusOnTypeAction.tooltip=Focus the Type Hierarchy on a New Type
-FocusOnTypeAction.description=Focus the Type Hierarchy on a new type
-FocusOnTypeAction.dialog.title=Focus On Type
-FocusOnTypeAction.dialog.message=&Select the type to be shown in the Type Hierarchy view:
-
-HistoryDropDownAction.tooltip=Previous Type Hierarchies
-
-HistoryAction.description=Open ''{0}'' in Hierarchy
-HistoryAction.tooltip=Open ''{0}'' in Hierarchy
-
-HistoryListDialog.title=Type Hierarchy History
-HistoryListDialog.label=&Select the element to open in the type hierarchy:
-HistoryListDialog.remove.button=&Remove
-
-HistoryListAction.label=More...
-
-ShowInheritedMembersAction.label=All Inherited Members
-ShowInheritedMembersAction.tooltip=Show All Inherited Members
-ShowInheritedMembersAction.description=Show all inherited members
-
-ShowQualifiedTypeNamesAction.label=Show Qualified Type Names
-ShowQualifiedTypeNamesAction.tooltip=Show Qualified Type Names
-ShowQualifiedTypeNamesAction.description=Show qualified type names
-
-SortByDefiningTypeAction.label=Sort by the Defining Type
-SortByDefiningTypeAction.tooltip=Sort Methods by the Defining Type
-SortByDefiningTypeAction.description=Sort methods by the defining type
-
-SubTypeHierarchyViewer.title=Hierarchy
-SubTypeHierarchyViewer.filtered.title=Hierarchy
-
-SuperTypeHierarchyViewer.title=Hierarchy
-SuperTypeHierarchyViewer.filtered.title=Hierarchy
-
-TraditionalHierarchyViewer.title=Hierarchy
-TraditionalHierarchyViewer.filtered.title=Hierarchy
-
-TypeHierarchyViewPart.error.title=Open Type Hierarchy
-TypeHierarchyViewPart.error.message=The selected element only exists in the editor. To perform this operation you have to save the editor first.
-TypeHierarchyViewPart.empty=To display the type hierarchy, select a structure or class (for example in the outline view or in the editor), and select the \'Open Type Hierarchy\' menu option.
-TypeHierarchyViewPart.nodecl=No declarations of selected members\nin the chosen hierarchy of ''{0}''
-TypeHierarchyViewPart.exception.title=Type Hierarchy
-TypeHierarchyViewPart.exception.message=Creating hierarchy failed. Check log for details.
-
-TypeHierarchyViewPart.title={0} : {1}
-TypeHierarchyViewPart.tooltip={0} of ''{1}''
-
-TypeHierarchyViewPart.layout.submenu=&Layout
-
-OpenTypeInHierarchyDialog.title=Open Type In Hierarchy
-OpenTypeInHierarchyDialog.message=&Choose a type (? = any character, * = any string):
-
-ToggleViewAction.subtypes.label=Subtype Hierarchy
-ToggleViewAction.subtypes.tooltip=Show the Subtype Hierarchy
-ToggleViewAction.subtypes.description=Show the subtype hierarchy
-
-ToggleViewAction.supertypes.label=Supertype Hierarchy
-ToggleViewAction.supertypes.tooltip=Show the Supertype Hierarchy
-ToggleViewAction.supertypes.description=Show the supertype hierarchy
-
-ToggleViewAction.vajhierarchy.label=Type Hierarchy
-ToggleViewAction.vajhierarchy.tooltip=Show the Type Hierarchy
-ToggleViewAction.vajhierarchy.description=Show the type hierarchy
-
-HierarchyInformationControl.methodhierarchy.label=Types implementing or defining ''{0}.{1}''
-HierarchyInformationControl.hierarchy.label=Type hierarchy of ''{0}'':
-HierarchyInformationControl.toggle.traditionalhierarchy.label=Press ''{0}'' to see the Subtype hierarchy
-HierarchyInformationControl.toggle.superhierarchy.label=Press ''{0}'' to see the Supertype hierarchy
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
deleted file mode 100644
index 29f3ad55098..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
+++ /dev/null
@@ -1,1570 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.cdt.core.browser.TypeUtil;
-import org.eclipse.cdt.core.browser.typehierarchy.ITypeHierarchy;
-import org.eclipse.cdt.core.model.CModelException;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.core.model.IStructure;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.cdt.internal.ui.ICHelpContextIds;
-import org.eclipse.cdt.internal.ui.IContextMenuConstants;
-import org.eclipse.cdt.internal.ui.actions.CompositeActionGroup;
-import org.eclipse.cdt.internal.ui.actions.SelectAllAction;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
-import org.eclipse.cdt.internal.ui.viewsupport.StatusBarUpdater;
-import org.eclipse.cdt.internal.ui.workingsets.WorkingSetFilterActionGroup;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IBasicPropertyConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.ViewForm;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
-import org.eclipse.ui.IWorkingSetManager;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.ActionContext;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.part.IShowInSource;
-import org.eclipse.ui.part.IShowInTargetList;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.part.ShowInContext;
-import org.eclipse.ui.part.ViewPart;
-
-/**
- * view showing the super types/sub types of its input.
- */
-public class TypeHierarchyViewPart extends ViewPart implements ITypeHierarchyViewPart, IViewPartInputProvider {
-
- public static final int VIEW_ID_SUPER= 0;
- public static final int VIEW_ID_SUB= 1;
-
- public static final int VIEW_ORIENTATION_VERTICAL= 0;
- public static final int VIEW_ORIENTATION_HORIZONTAL= 1;
- public static final int VIEW_ORIENTATION_SINGLE= 2;
- public static final int VIEW_ORIENTATION_AUTOMATIC= 3;
-
- private static final String DIALOGSTORE_HIERARCHYVIEW= "TypeHierarchyViewPart.hierarchyview"; //$NON-NLS-1$
- private static final String DIALOGSTORE_VIEWORIENTATION= "TypeHierarchyViewPart.orientation"; //$NON-NLS-1$
-
- //private static final String TAG_INPUT= "input"; //$NON-NLS-1$
- private static final String TAG_VIEW= "view"; //$NON-NLS-1$
- private static final String TAG_ORIENTATION= "orientation"; //$NON-NLS-1$
- private static final String TAG_RATIO= "ratio"; //$NON-NLS-1$
- //private static final String TAG_SELECTION= "selection"; //$NON-NLS-1$
- private static final String TAG_VERTICAL_SCROLL= "vertical_scroll"; //$NON-NLS-1$
-
- private static final String GROUP_FOCUS= "group.focus"; //$NON-NLS-1$
-
-
- // the selected type in the hierarchy view
- private ICElement fSelectedType;
- // input element or null
- private ICElement fInputElement;
-
- // history of input elements. No duplicates
- private ArrayList fInputHistory;
-
- private IMemento fMemento;
- private IDialogSettings fDialogSettings;
-
- protected TypeHierarchyLifeCycle fHierarchyLifeCycle;
- private ITypeHierarchyLifeCycleListener fTypeHierarchyLifeCycleListener;
-
- private IPropertyChangeListener fPropertyChangeListener;
-
- private SelectionProviderMediator fSelectionProviderMediator;
- private ISelectionChangedListener fSelectionChangedListener;
- private IPartListener2 fPartListener;
-
- private int fCurrentOrientation;
- int fOrientation= VIEW_ORIENTATION_AUTOMATIC;
- boolean fInComputeOrientation= false;
-
- private boolean fLinkingEnabled;
- private boolean fSelectInEditor;
-
- private boolean fIsVisible;
- private boolean fNeedRefresh;
- private boolean fIsEnableMemberFilter;
- protected boolean fIsRefreshRunnablePosted;
-
- private int fCurrentViewerIndex;
- private TypeHierarchyViewer[] fAllViewers;
-
- protected MethodsViewer fMethodsViewer;
-
- private SashForm fTypeMethodsSplitter;
- private PageBook fViewerbook;
- protected PageBook fPagebook;
-
- private Label fNoHierarchyShownLabel;
- private Label fEmptyTypesViewer;
-
- private ViewForm fTypeViewerViewForm;
- private ViewForm fMethodViewerViewForm;
-
- private CLabel fMethodViewerPaneLabel;
- private CUILabelProvider fPaneLabelProvider;
- private Composite fParent;
-
- private ToggleViewAction[] fViewActions;
- private ToggleLinkingAction fToggleLinkingAction;
- private HistoryDropDownAction fHistoryDropDownAction;
- private ToggleOrientationAction[] fToggleOrientationActions;
- private EnableMemberFilterAction fEnableMemberFilterAction;
- private ShowQualifiedTypeNamesAction fShowQualifiedTypeNamesAction;
-// private AddMethodStubAction fAddStubAction;
- private FocusOnTypeAction fFocusOnTypeAction;
- private FocusOnSelectionAction fFocusOnSelectionAction;
- private CompositeActionGroup fActionGroups;
- protected SelectAllAction fSelectAllAction;
-
- private WorkingSetFilterActionGroup fWorkingSetActionGroup;
- private Job fRestoreStateJob;
-
- public TypeHierarchyViewPart() {
- fSelectedType= null;
- fInputElement= null;
- fIsVisible= false;
- fIsRefreshRunnablePosted= false;
- fSelectInEditor= true;
- fRestoreStateJob= null;
-
- fHierarchyLifeCycle= new TypeHierarchyLifeCycle();
- fTypeHierarchyLifeCycleListener= new ITypeHierarchyLifeCycleListener() {
- public void typeHierarchyChanged(TypeHierarchyLifeCycle typeHierarchy, ICElement[] changedTypes) {
- doTypeHierarchyChanged(typeHierarchy, changedTypes);
- }
- };
- fHierarchyLifeCycle.addChangedListener(fTypeHierarchyLifeCycleListener);
-
- fPropertyChangeListener= new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- doPropertyChange(event);
- }
- };
- PreferenceConstants.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
-
- fIsEnableMemberFilter= false;
-
- fInputHistory= new ArrayList();
- fAllViewers= null;
-
- fViewActions= new ToggleViewAction[] {
- new ToggleViewAction(this, VIEW_ID_SUPER),
- new ToggleViewAction(this, VIEW_ID_SUB)
- };
-
- fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
-
- fHistoryDropDownAction= new HistoryDropDownAction(this);
- fHistoryDropDownAction.setEnabled(false);
-
- fToggleOrientationActions= new ToggleOrientationAction[] {
- new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
- new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
- };
-
- fEnableMemberFilterAction= new EnableMemberFilterAction(this, false);
- fShowQualifiedTypeNamesAction= new ShowQualifiedTypeNamesAction(this, false);
-
- fFocusOnTypeAction= new FocusOnTypeAction(this);
-
- fPaneLabelProvider= new CUILabelProvider();
-//
-// fAddStubAction= new AddMethodStubAction();
- fFocusOnSelectionAction= new FocusOnSelectionAction(this);
-
- fPartListener= new IPartListener2() {
- public void partVisible(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part == TypeHierarchyViewPart.this) {
- visibilityChanged(true);
- }
- }
-
- public void partHidden(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part == TypeHierarchyViewPart.this) {
- visibilityChanged(false);
- }
- }
-
- public void partActivated(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part instanceof IEditorPart)
- editorActivated((IEditorPart) part);
- }
-
- public void partInputChanged(IWorkbenchPartReference ref) {
- IWorkbenchPart part= ref.getPart(false);
- if (part instanceof IEditorPart)
- editorActivated((IEditorPart) part);
- }
-
- public void partBroughtToTop(IWorkbenchPartReference ref) {}
- public void partClosed(IWorkbenchPartReference ref) {}
- public void partDeactivated(IWorkbenchPartReference ref) {}
- public void partOpened(IWorkbenchPartReference ref) {}
- };
-
- fSelectionChangedListener= new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- doSelectionChanged(event);
- }
- };
-
- fLinkingEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR);
- }
-
- /**
- * Method doPropertyChange.
- * @param event
- */
- protected void doPropertyChange(PropertyChangeEvent event) {
- String property= event.getProperty();
- if (fMethodsViewer != null) {
-// if (MembersOrderPreferenceCache.isMemberOrderProperty(event.getProperty())) {
-// fMethodsViewer.refresh();
-// }
- }
- if (IWorkingSetManager.CHANGE_WORKING_SET_CONTENT_CHANGE.equals(property)) {
- updateHierarchyViewer(true);
- }
- }
-
- /**
- * Adds the entry if new. Inserted at the beginning of the history entries list.
- */
- private void addHistoryEntry(ICElement entry) {
- if (fInputHistory.contains(entry)) {
- fInputHistory.remove(entry);
- }
- fInputHistory.add(0, entry);
- fHistoryDropDownAction.setEnabled(true);
- }
-
- private void updateHistoryEntries() {
- for (int i= fInputHistory.size() - 1; i >= 0; i--) {
- ICElement type= (ICElement) fInputHistory.get(i);
- if (!type.exists()) {
- fInputHistory.remove(i);
- }
- }
- fHistoryDropDownAction.setEnabled(!fInputHistory.isEmpty());
- }
-
- /**
- * Goes to the selected entry, without updating the order of history entries.
- */
- public void gotoHistoryEntry(ICElement entry) {
- if (fInputHistory.contains(entry)) {
- updateInput(entry);
- }
- }
-
- /**
- * Gets all history entries.
- */
- public ICElement[] getHistoryEntries() {
- if (fInputHistory.size() > 0) {
- updateHistoryEntries();
- }
- return (ICElement[]) fInputHistory.toArray(new ICElement[fInputHistory.size()]);
- }
-
- /**
- * Sets the history entries
- */
- public void setHistoryEntries(ICElement[] elems) {
- fInputHistory.clear();
- for (int i= 0; i < elems.length; i++) {
- fInputHistory.add(elems[i]);
- }
- updateHistoryEntries();
- }
-
- /**
- * Selects an member in the methods list or in the current hierarchy.
- */
- public void selectMember(ICElement member) {
- fSelectInEditor= false;
- if (!TypeUtil.isClassOrStruct(member)) {
- Control methodControl= fMethodsViewer.getControl();
- if (methodControl != null && !methodControl.isDisposed()) {
- methodControl.setFocus();
- }
-
- fMethodsViewer.setSelection(new StructuredSelection(member), true);
- } else {
- Control viewerControl= getCurrentViewer().getControl();
- if (viewerControl != null && !viewerControl.isDisposed()) {
- viewerControl.setFocus();
- }
-
- if (!member.equals(fSelectedType)) {
- getCurrentViewer().setSelection(new StructuredSelection(member), true);
- }
- }
- fSelectInEditor= true;
- }
-
- /**
- * @deprecated
- */
- public ICElement getInput() {
- return fInputElement;
- }
-
- /**
- * Sets the input to a new type
- * @deprecated
- */
- public void setInput(ICElement type) {
- setInputElement(type);
- }
-
- /**
- * Returns the input element of the type hierarchy.
- * Can be of type <code>ICElement</code> or <code>IPackageFragment</code>
- */
- public ICElement getInputElement() {
- return fInputElement;
- }
-
-
- /**
- * Sets the input to a new element.
- */
- public void setInputElement(ICElement element) {
- if (element != null) {
- if (!(element instanceof IStructure)) {
- element = TypeUtil.getDeclaringClass(element);
- }
- if (element == null || !element.exists()) {
- MessageDialog.openError(getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.error.message")); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
- } else {
- CUIPlugin.getDefault().logErrorMessage("Invalid type hierarchy input type.");//$NON-NLS-1$
- }
- if (element != null && !element.equals(fInputElement)) {
- addHistoryEntry(element);
- }
-
- updateInput(element);
- }
-
- /**
- * Changes the input to a new type
- */
- private void updateInput(ICElement inputElement) {
- ICElement prevInput= fInputElement;
-
- synchronized (this) {
- if (fRestoreStateJob != null) {
- fRestoreStateJob.cancel();
- try {
- fRestoreStateJob.join();
- } catch (InterruptedException e) {
- // ignore
- } finally {
- fRestoreStateJob= null;
- }
- }
- }
-
- // Make sure the UI got repainted before we execute a long running
- // operation. This can be removed if we refresh the hierarchy in a
- // separate thread.
- // Work-araound for http://dev.eclipse.org/bugs/show_bug.cgi?id=30881
- processOutstandingEvents();
- if (inputElement == null) {
- clearInput();
- } else {
- fInputElement= inputElement;
- try {
- fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(inputElement, CUIPlugin.getActiveWorkbenchWindow());
- // fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(inputElement, getSite().getWorkbenchWindow());
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.message")); //$NON-NLS-1$ //$NON-NLS-2$
- clearInput();
- return;
- } catch (InterruptedException e) {
- return;
- }
-
- if (!TypeUtil.isClassOrStruct(inputElement)) {
- setView(VIEW_ID_SUPER);
- }
- // turn off member filtering
- fSelectInEditor= false;
- setMemberFilter(null);
- internalSelectType(null, false); // clear selection
- fIsEnableMemberFilter= false;
- if (!inputElement.equals(prevInput)) {
- updateHierarchyViewer(true);
- }
- ICElement root= getSelectableType(inputElement);
- internalSelectType(root, true);
- updateMethodViewer(root);
- updateToolbarButtons();
- updateTitle();
- enableMemberFilter(false);
- fPagebook.showPage(fTypeMethodsSplitter);
- fSelectInEditor= true;
- }
- }
-
- private void processOutstandingEvents() {
- Display display= getDisplay();
- if (display != null && !display.isDisposed())
- display.update();
- }
-
- private void clearInput() {
- fInputElement= null;
- fHierarchyLifeCycle.freeHierarchy();
-
- updateHierarchyViewer(false);
- updateToolbarButtons();
- }
-
- /*
- * @see IWorbenchPart#setFocus
- */
- public void setFocus() {
- fPagebook.setFocus();
- }
-
- /*
- * @see IWorkbenchPart#dispose
- */
- public void dispose() {
- fHierarchyLifeCycle.freeHierarchy();
- fHierarchyLifeCycle.removeChangedListener(fTypeHierarchyLifeCycleListener);
- fPaneLabelProvider.dispose();
-
- if (fMethodsViewer != null) {
- fMethodsViewer.dispose();
- }
-
- if (fPropertyChangeListener != null) {
- CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyChangeListener);
- fPropertyChangeListener= null;
- }
-
- getSite().getPage().removePartListener(fPartListener);
-
- if (fActionGroups != null)
- fActionGroups.dispose();
-
- if (fWorkingSetActionGroup != null) {
- fWorkingSetActionGroup.dispose();
- }
-
- super.dispose();
- }
-
- /**
- * Answer the property defined by key.
- */
- public Object getAdapter(Class key) {
- if (key == IShowInSource.class) {
- return getShowInSource();
- }
- if (key == IShowInTargetList.class) {
- return new IShowInTargetList() {
- public String[] getShowInTargetIds() {
- return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_RES_NAV };
- }
-
- };
- }
- return super.getAdapter(key);
- }
-
- private Control createTypeViewerControl(Composite parent) {
- fViewerbook= new PageBook(parent, SWT.NULL);
-
- KeyListener keyListener= createKeyListener();
-
- // Create the viewers
- TypeHierarchyViewer superTypesViewer= new SuperTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
- initializeTypesViewer(superTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUPERTYPES_VIEW);
-
- TypeHierarchyViewer subTypesViewer= new SubTypeHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
- initializeTypesViewer(subTypesViewer, keyListener, IContextMenuConstants.TARGET_ID_SUBTYPES_VIEW);
-
- fAllViewers= new TypeHierarchyViewer[2];
- fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
- fAllViewers[VIEW_ID_SUB]= subTypesViewer;
-
- int currViewerIndex;
- try {
- currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
- if (currViewerIndex < 0 || currViewerIndex > 2) {
- currViewerIndex= VIEW_ID_SUPER;
- }
- } catch (NumberFormatException e) {
- currViewerIndex= VIEW_ID_SUPER;
- }
-
- fEmptyTypesViewer= new Label(fViewerbook, SWT.LEFT);
-
- for (int i= 0; i < fAllViewers.length; i++) {
- fAllViewers[i].setInput(fAllViewers[i]);
- }
-
- // force the update
- fCurrentViewerIndex= -1;
- setView(currViewerIndex);
-
- return fViewerbook;
- }
-
- private KeyListener createKeyListener() {
- return new KeyAdapter() {
- public void keyReleased(KeyEvent event) {
- if (event.stateMask == 0) {
- if (event.keyCode == SWT.F5) {
- ITypeHierarchy hierarchy= fHierarchyLifeCycle.getHierarchy();
- if (hierarchy != null) {
- fHierarchyLifeCycle.typeHierarchyChanged(hierarchy);
- doTypeHierarchyChangedOnViewers(null);
- }
- updateHierarchyViewer(false);
- return;
- }
- }
- }
- };
- }
-
-
- private void initializeTypesViewer(final TypeHierarchyViewer typesViewer, KeyListener keyListener, String cotextHelpId) {
- typesViewer.getControl().setVisible(false);
- typesViewer.getControl().addKeyListener(keyListener);
- typesViewer.initContextMenu(new IMenuListener() {
- public void menuAboutToShow(IMenuManager menu) {
- fillTypesViewerContextMenu(typesViewer, menu);
- }
- }, cotextHelpId, getSite());
- typesViewer.addPostSelectionChangedListener(fSelectionChangedListener);
- typesViewer.setQualifiedTypeName(isShowQualifiedTypeNames());
- typesViewer.setWorkingSetFilter(fWorkingSetActionGroup.getWorkingSetFilter());
- }
-
- private Control createMethodViewerControl(Composite parent) {
- fMethodsViewer= new MethodsViewer(parent, fHierarchyLifeCycle, this);
- fMethodsViewer.initContextMenu(new IMenuListener() {
- public void menuAboutToShow(IMenuManager menu) {
- fillMethodsViewerContextMenu(menu);
- }
- }, IContextMenuConstants.TARGET_ID_MEMBERS_VIEW, getSite());
- fMethodsViewer.addPostSelectionChangedListener(fSelectionChangedListener);
-
- Control control= fMethodsViewer.getTable();
- control.addKeyListener(createKeyListener());
- control.addFocusListener(new FocusListener() {
- public void focusGained(FocusEvent e) {
- fSelectAllAction.setEnabled(true);
- }
-
- public void focusLost(FocusEvent e) {
- fSelectAllAction.setEnabled(false);
- }
- });
-
- return control;
- }
-
- private void initDragAndDrop() {
-// Transfer[] transfers= new Transfer[] { LocalSelectionTransfer.getInstance() };
-// int ops= DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
-//
-// for (int i= 0; i < fAllViewers.length; i++) {
-// addDragAdapters(fAllViewers[i], ops, transfers);
-// addDropAdapters(fAllViewers[i], ops | DND.DROP_DEFAULT, transfers);
-// }
-// addDragAdapters(fMethodsViewer, ops, transfers);
-//
-// //DND on empty hierarchy
-// DropTarget dropTarget = new DropTarget(fNoHierarchyShownLabel, ops | DND.DROP_DEFAULT);
-// dropTarget.setTransfer(transfers);
-// dropTarget.addDropListener(new TypeHierarchyTransferDropAdapter(this, fAllViewers[0]));
- }
-
-// private void addDropAdapters(AbstractTreeViewer viewer, int ops, Transfer[] transfers){
-// TransferDropTargetListener[] dropListeners= new TransferDropTargetListener[] {
-// new TypeHierarchyTransferDropAdapter(this, viewer)
-// };
-// viewer.addDropSupport(ops, transfers, new DelegatingDropAdapter(dropListeners));
-// }
-
-// private void addDragAdapters(StructuredViewer viewer, int ops, Transfer[] transfers) {
-// TransferDragSourceListener[] dragListeners= new TransferDragSourceListener[] {
-// new SelectionTransferDragAdapter(viewer)
-// };
-// viewer.addDragSupport(ops, transfers, new JdtViewerDragAdapter(viewer, dragListeners));
-// }
-
- /**
- * Returns the inner component in a workbench part.
- * @see IWorkbenchPart#createPartControl(Composite)
- */
- public void createPartControl(Composite container) {
- fParent= container;
- addResizeListener(container);
-
- fPagebook= new PageBook(container, SWT.NONE);
- fWorkingSetActionGroup= new WorkingSetFilterActionGroup(CUIPlugin.ID_TYPE_HIERARCHY, container.getShell(), fPropertyChangeListener);
-
- // page 1 of page book (no hierarchy label)
-
- fNoHierarchyShownLabel= new Label(fPagebook, SWT.TOP + SWT.LEFT + SWT.WRAP);
- fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
-
- // page 2 of page book (viewers)
-
- fTypeMethodsSplitter= new SashForm(fPagebook, SWT.VERTICAL);
- fTypeMethodsSplitter.setVisible(false);
-
- fTypeViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
-
- Control typeViewerControl= createTypeViewerControl(fTypeViewerViewForm);
- fTypeViewerViewForm.setContent(typeViewerControl);
-
- fMethodViewerViewForm= new ViewForm(fTypeMethodsSplitter, SWT.NONE);
- fTypeMethodsSplitter.setWeights(new int[] {35, 65});
-
- Control methodViewerPart= createMethodViewerControl(fMethodViewerViewForm);
- fMethodViewerViewForm.setContent(methodViewerPart);
-
- fMethodViewerPaneLabel= new CLabel(fMethodViewerViewForm, SWT.NONE);
- fMethodViewerViewForm.setTopLeft(fMethodViewerPaneLabel);
-
- ToolBar methodViewerToolBar= new ToolBar(fMethodViewerViewForm, SWT.FLAT | SWT.WRAP);
- fMethodViewerViewForm.setTopCenter(methodViewerToolBar);
-
- initDragAndDrop();
-
- MenuManager menu= new MenuManager();
- menu.add(fFocusOnTypeAction);
- fNoHierarchyShownLabel.setMenu(menu.createContextMenu(fNoHierarchyShownLabel));
-
- fPagebook.showPage(fNoHierarchyShownLabel);
-
- try {
- fOrientation= fDialogSettings.getInt(DIALOGSTORE_VIEWORIENTATION);
- if (fOrientation < 0 || fOrientation > 3) {
- fOrientation= VIEW_ORIENTATION_VERTICAL;
- }
- } catch (NumberFormatException e) {
- fOrientation= VIEW_ORIENTATION_AUTOMATIC;
- }
-
- // force the update
- fCurrentOrientation= -1;
- // will fill the main tool bar
- setOrientation(fOrientation);
-
- if (fMemento != null) { // restore state before creating action
- restoreLinkingEnabled(fMemento);
- }
- fToggleLinkingAction= new ToggleLinkingAction(this);
-
- // set the filter menu items
- IActionBars actionBars= getViewSite().getActionBars();
- IMenuManager viewMenu= actionBars.getMenuManager();
- for (int i= 0; i < fViewActions.length; i++) {
- ToggleViewAction action= fViewActions[i];
- viewMenu.add(action);
- action.setEnabled(false);
- }
- viewMenu.add(new Separator());
-
- fWorkingSetActionGroup.contributeToMenu(viewMenu);
-
- viewMenu.add(new Separator());
-
- IMenuManager layoutSubMenu= new MenuManager(TypeHierarchyMessages.getString("TypeHierarchyViewPart.layout.submenu")); //$NON-NLS-1$
- viewMenu.add(layoutSubMenu);
- for (int i= 0; i < fToggleOrientationActions.length; i++) {
- layoutSubMenu.add(fToggleOrientationActions[i]);
- }
- viewMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- viewMenu.add(fShowQualifiedTypeNamesAction);
- viewMenu.add(fToggleLinkingAction);
-
-
- // fill the method viewer tool bar
- ToolBarManager lowertbmanager= new ToolBarManager(methodViewerToolBar);
- lowertbmanager.add(fEnableMemberFilterAction);
- lowertbmanager.add(new Separator());
- fMethodsViewer.contributeToToolBar(lowertbmanager);
- lowertbmanager.update(true);
-
- // selection provider
- int nHierarchyViewers= fAllViewers.length;
- StructuredViewer[] trackedViewers= new StructuredViewer[nHierarchyViewers + 1];
- for (int i= 0; i < nHierarchyViewers; i++) {
- trackedViewers[i]= fAllViewers[i];
- }
- trackedViewers[nHierarchyViewers]= fMethodsViewer;
- fSelectionProviderMediator= new SelectionProviderMediator(trackedViewers);
- IStatusLineManager slManager= getViewSite().getActionBars().getStatusLineManager();
- fSelectionProviderMediator.addSelectionChangedListener(new StatusBarUpdater(slManager));
-
- getSite().setSelectionProvider(fSelectionProviderMediator);
- getSite().getPage().addPartListener(fPartListener);
-
- // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33657
- ICElement input= null; //determineInputElement();
- if (fMemento != null) {
- restoreState(fMemento, input);
- } else if (input != null) {
- setInputElement(input);
- } else {
- setViewerVisibility(false);
- }
-
- WorkbenchHelp.setHelp(fPagebook, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
-
-
- fActionGroups= new CompositeActionGroup(new ActionGroup[] {
-// new NewWizardsActionGroup(this.getSite()),
-// new OpenEditorActionGroup(this),
- new OpenViewActionGroup(this),
-// new CCPActionGroup(this),
-// new GenerateActionGroup(this),
-// new RefactorActionGroup(this),
-// new CSearchActionGroup(this)
- });
-
- fActionGroups.fillActionBars(actionBars);
- fSelectAllAction= new SelectAllAction(fMethodsViewer);
-
- actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), fSelectAllAction);
- }
-
- private void addResizeListener(Composite parent) {
- parent.addControlListener(new ControlListener() {
- public void controlMoved(ControlEvent e) {
- }
- public void controlResized(ControlEvent e) {
- computeOrientation();
- }
- });
- }
-
- void computeOrientation() {
- // fix for bug: 63268 error while activating view
- // avoid recursive calls of compute orientation
- if (fInComputeOrientation) {
- return;
- }
- fInComputeOrientation= true;
- try {
- if (fOrientation != VIEW_ORIENTATION_AUTOMATIC) {
- setOrientation(fOrientation);
- }
- else {
- if (fOrientation == VIEW_ORIENTATION_SINGLE)
- return;
- Point size= fParent.getSize();
- if (size.x != 0 && size.y != 0) {
- if (size.x > size.y)
- setOrientation(VIEW_ORIENTATION_HORIZONTAL);
- else
- setOrientation(VIEW_ORIENTATION_VERTICAL);
- }
- }
- } finally {
- fInComputeOrientation= false;
- }
- }
-
- /**
- * called from ToggleOrientationAction.
- * @param orientation VIEW_ORIENTATION_SINGLE, VIEW_ORIENTATION_HORIZONTAL or VIEW_ORIENTATION_VERTICAL
- */
- public void setOrientation(int orientation) {
- if (fCurrentOrientation != orientation) {
- boolean methodViewerNeedsUpdate= false;
-
- if (fMethodViewerViewForm != null && !fMethodViewerViewForm.isDisposed()
- && fTypeMethodsSplitter != null && !fTypeMethodsSplitter.isDisposed()) {
- if (orientation == VIEW_ORIENTATION_SINGLE) {
- fMethodViewerViewForm.setVisible(false);
- enableMemberFilter(false);
- updateMethodViewer(null);
- } else {
- if (fCurrentOrientation == VIEW_ORIENTATION_SINGLE) {
- fMethodViewerViewForm.setVisible(true);
- methodViewerNeedsUpdate= true;
- }
- boolean horizontal= orientation == VIEW_ORIENTATION_HORIZONTAL;
- fTypeMethodsSplitter.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
- }
- updateMainToolbar(orientation);
- fTypeMethodsSplitter.layout();
- }
- updateCheckedState();
- if (methodViewerNeedsUpdate) {
- updateMethodViewer(fSelectedType);
- }
- fDialogSettings.put(DIALOGSTORE_VIEWORIENTATION, orientation);
- fCurrentOrientation= orientation;
- }
- }
-
-
- private void updateCheckedState() {
- for (int i= 0; i < fToggleOrientationActions.length; i++) {
- fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
- }
- }
-
- private void updateMainToolbar(int orientation) {
- IActionBars actionBars= getViewSite().getActionBars();
- IToolBarManager tbmanager= actionBars.getToolBarManager();
-
- if (orientation == VIEW_ORIENTATION_HORIZONTAL) {
- clearMainToolBar(tbmanager);
- ToolBar typeViewerToolBar= new ToolBar(fTypeViewerViewForm, SWT.FLAT | SWT.WRAP);
- fillMainToolBar(new ToolBarManager(typeViewerToolBar));
- fTypeViewerViewForm.setTopLeft(typeViewerToolBar);
- } else {
- fTypeViewerViewForm.setTopLeft(null);
- fillMainToolBar(tbmanager);
- }
- }
-
- private void fillMainToolBar(IToolBarManager tbmanager) {
- tbmanager.removeAll();
- for (int i= 0; i < fViewActions.length; i++) {
- tbmanager.add(fViewActions[i]);
- }
- tbmanager.add(fHistoryDropDownAction);
- tbmanager.update(false);
- }
-
- private void clearMainToolBar(IToolBarManager tbmanager) {
- tbmanager.removeAll();
- tbmanager.update(false);
- }
-
-
- /**
- * Creates the context menu for the hierarchy viewers
- */
- protected void fillTypesViewerContextMenu(TypeHierarchyViewer viewer, IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
-
- menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS));
- // viewer entries
- viewer.contributeToContextMenu(menu);
-
- if (fFocusOnSelectionAction.canActionBeAdded())
- menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction);
- menu.appendToGroup(GROUP_FOCUS, fFocusOnTypeAction);
-
- fActionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
- fActionGroups.fillContextMenu(menu);
- fActionGroups.setContext(null);
- }
-
- /**
- * Creates the context menu for the method viewer
- */
- protected void fillMethodsViewerContextMenu(IMenuManager menu) {
- CUIPlugin.createStandardGroups(menu);
- // viewer entries
- fMethodsViewer.contributeToContextMenu(menu);
- fActionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
- fActionGroups.fillContextMenu(menu);
- fActionGroups.setContext(null);
-// if (fSelectedType != null && fAddStubAction.init(fSelectedType, fMethodsViewer.getSelection())) {
-// IMenuManager source= menu.findMenuUsingPath(GenerateActionGroup.MENU_ID);
-// if (source != null)
-// source.appendToGroup(GenerateActionGroup.GROUP_GENERATE, fAddStubAction);
-// }
- }
-
- /**
- * Toggles between the empty viewer page and the hierarchy
- */
- private void setViewerVisibility(boolean showHierarchy) {
- if (showHierarchy) {
- fViewerbook.showPage(getCurrentViewer().getControl());
- } else {
- fViewerbook.showPage(fEmptyTypesViewer);
- }
- }
-
- /**
- * Sets the member filter. <code>null</code> disables member filtering.
- */
- private void setMemberFilter(IMember[] memberFilter) {
- Assert.isNotNull(fAllViewers);
- for (int i= 0; i < fAllViewers.length; i++) {
- fAllViewers[i].setMemberFilter(memberFilter);
- }
- }
-
- private ICElement getSelectableType(ICElement elem) {
- if (!TypeUtil.isClassOrStruct(elem)) {
- return getCurrentViewer().getTreeRootType();
- }
- return elem;
- }
-
- private void internalSelectType(ICElement elem, boolean reveal) {
- TypeHierarchyViewer viewer= getCurrentViewer();
- if (viewer != null) {
- viewer.removePostSelectionChangedListener(fSelectionChangedListener);
- viewer.setSelection(elem != null ? new StructuredSelection(elem) : StructuredSelection.EMPTY, reveal);
- viewer.addPostSelectionChangedListener(fSelectionChangedListener);
- }
- }
-
- /**
- * When the input changed or the hierarchy pane becomes visible,
- * <code>updateHierarchyViewer<code> brings up the correct view and refreshes
- * the current tree
- */
- protected void updateHierarchyViewer(final boolean doExpand) {
- if (fInputElement == null) {
- fNoHierarchyShownLabel.setText(TypeHierarchyMessages.getString("TypeHierarchyViewPart.empty")); //$NON-NLS-1$
- fPagebook.showPage(fNoHierarchyShownLabel);
- } else {
- final TypeHierarchyViewer viewer = getCurrentViewer();
- if (viewer != null && viewer.containsElements() != null) {
- Runnable runnable= new Runnable() {
- public void run() {
- viewer.updateContent(doExpand); // refresh
- }
- };
- BusyIndicator.showWhile(getDisplay(), runnable);
- if (!isChildVisible(fViewerbook, viewer.getControl())) {
- setViewerVisibility(true);
- }
- } else {
- fEmptyTypesViewer.setText(TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.nodecl", fInputElement.getElementName())); //$NON-NLS-1$
- setViewerVisibility(false);
- }
- }
- }
-
- private void updateMethodViewer(final ICElement input) {
- if (!fIsEnableMemberFilter && fCurrentOrientation != VIEW_ORIENTATION_SINGLE) {
- if (input == fMethodsViewer.getInput()) {
- if (input != null) {
- Runnable runnable= new Runnable() {
- public void run() {
- fMethodsViewer.refresh(); // refresh
- }
- };
- BusyIndicator.showWhile(getDisplay(), runnable);
- }
- } else {
- if (input != null) {
- fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(input));
- fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(input));
- } else {
- fMethodViewerPaneLabel.setText(""); //$NON-NLS-1$
- fMethodViewerPaneLabel.setImage(null);
- }
- Runnable runnable= new Runnable() {
- public void run() {
- fMethodsViewer.setInput(input); // refresh
- }
- };
- BusyIndicator.showWhile(getDisplay(), runnable);
- }
- }
- }
-
- protected void doSelectionChanged(SelectionChangedEvent e) {
- if (e.getSelectionProvider() == fMethodsViewer) {
- methodSelectionChanged(e.getSelection());
- } else {
- typeSelectionChanged(e.getSelection());
- }
- }
-
-
-
- private void methodSelectionChanged(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- List selected= ((IStructuredSelection)sel).toList();
- int nSelected= selected.size();
- if (fIsEnableMemberFilter) {
- IMember[] memberFilter= null;
- if (nSelected > 0) {
- memberFilter= new IMember[nSelected];
- selected.toArray(memberFilter);
- }
- setMemberFilter(memberFilter);
- updateHierarchyViewer(true);
- updateTitle();
- internalSelectType(fSelectedType, true);
- }
- if (nSelected == 1 && fSelectInEditor) {
- revealElementInEditor(selected.get(0), fMethodsViewer);
- }
- }
- }
-
- private void typeSelectionChanged(ISelection sel) {
- if (sel instanceof IStructuredSelection) {
- List selected= ((IStructuredSelection)sel).toList();
- int nSelected= selected.size();
- if (nSelected != 0) {
- List types= new ArrayList(nSelected);
- for (int i= nSelected-1; i >= 0; i--) {
- Object elem= selected.get(i);
- if (elem instanceof ICElement && !types.contains(elem)) {
- types.add(elem);
- }
- }
- if (types.size() == 1) {
- fSelectedType= (ICElement) types.get(0);
- updateMethodViewer(fSelectedType);
- } else if (types.size() == 0) {
- // method selected, no change
- }
- if (nSelected == 1 && fSelectInEditor) {
- revealElementInEditor(selected.get(0), getCurrentViewer());
- }
- } else {
- fSelectedType= null;
- updateMethodViewer(null);
- }
- }
- }
-
- private void revealElementInEditor(Object elem, StructuredViewer originViewer) {
- // only allow revealing when the type hierarchy is the active page
- // no revealing after selection events due to model changes
-
- if (getSite().getPage().getActivePart() != this) {
- return;
- }
-
- if (fSelectionProviderMediator.getViewerInFocus() != originViewer) {
- return;
- }
-
- IEditorPart editorPart= EditorUtility.isOpenInEditor(elem);
- if (editorPart != null && (elem instanceof ICElement)) {
- getSite().getPage().removePartListener(fPartListener);
- getSite().getPage().bringToTop(editorPart);
- EditorUtility.revealInEditor(editorPart, (ICElement) elem);
- getSite().getPage().addPartListener(fPartListener);
- }
- }
-
- private Display getDisplay() {
- if (fPagebook != null && !fPagebook.isDisposed()) {
- return fPagebook.getDisplay();
- }
- return null;
- }
-
- private boolean isChildVisible(Composite pb, Control child) {
- Control[] children= pb.getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i] == child && children[i].isVisible())
- return true;
- }
- return false;
- }
-
- private void updateTitle() {
- String tooltip;
- String title;
- String viewerTitle;
- TypeHierarchyViewer viewer = getCurrentViewer();
- if (viewer != null) {
- viewerTitle= viewer.getTitle();
- } else {
- viewerTitle = TypeHierarchyMessages.getString("TraditionalHierarchyViewer.title"); //$NON-NLS-1$
- }
-
- if (fInputElement != null) {
- String[] args= new String[] { viewerTitle, CElementLabels.getElementLabel(fInputElement, CElementLabels.ALL_DEFAULT) };
- title= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.title", args); //$NON-NLS-1$
- tooltip= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.tooltip", args); //$NON-NLS-1$
- } else {
- title= viewerTitle;
- tooltip= viewerTitle;
- }
- setPartName(title);
- setContentDescription(""); //$NON-NLS-1$
- setTitleToolTip(tooltip);
- }
-
- private void updateToolbarButtons() {
- for (int i= 0; i < fViewActions.length; i++) {
- ToggleViewAction action= fViewActions[i];
- action.setEnabled(true);
- }
- }
-
- /**
- * Sets the current view (see view id)
- * called from ToggleViewAction. Must be called after creation of the view part.
- */
- public void setView(int viewerIndex) {
- Assert.isNotNull(fAllViewers);
- if (viewerIndex < fAllViewers.length && fCurrentViewerIndex != viewerIndex) {
- fCurrentViewerIndex= viewerIndex;
-
- updateHierarchyViewer(true);
- if (fInputElement != null) {
- ISelection currSelection= getCurrentViewer().getSelection();
- if (currSelection == null || currSelection.isEmpty()) {
- internalSelectType(getSelectableType(fInputElement), false);
- currSelection= getCurrentViewer().getSelection();
- }
- if (!fIsEnableMemberFilter) {
- typeSelectionChanged(currSelection);
- }
- }
- updateTitle();
-
- fDialogSettings.put(DIALOGSTORE_HIERARCHYVIEW, viewerIndex);
- getCurrentViewer().getTree().setFocus();
- }
- for (int i= 0; i < fViewActions.length; i++) {
- ToggleViewAction action= fViewActions[i];
- action.setChecked(fCurrentViewerIndex == action.getViewerIndex());
- }
- }
-
- /**
- * Gets the current active view index.
- */
- public int getViewIndex() {
- return fCurrentViewerIndex;
- }
-
- private TypeHierarchyViewer getCurrentViewer() {
- if (fCurrentViewerIndex != -1)
- return fAllViewers[fCurrentViewerIndex];
- return null;
- }
-
- /**
- * called from EnableMemberFilterAction.
- * Must be called after creation of the view part.
- */
- public void enableMemberFilter(boolean on) {
- if (on != fIsEnableMemberFilter) {
- fIsEnableMemberFilter= on;
- if (!on) {
- ICElement methodViewerInput= (ICElement) fMethodsViewer.getInput();
- setMemberFilter(null);
- updateHierarchyViewer(true);
- updateTitle();
-
- if (methodViewerInput != null && getCurrentViewer().isElementShown(methodViewerInput)) {
- // avoid that the method view changes content by selecting the previous input
- internalSelectType(methodViewerInput, true);
- } else if (fSelectedType != null) {
- // choose a input that exists
- internalSelectType(fSelectedType, true);
- updateMethodViewer(fSelectedType);
- }
- } else {
- methodSelectionChanged(fMethodsViewer.getSelection());
- }
- }
- fEnableMemberFilterAction.setChecked(on);
- }
-
- /**
- * called from ShowQualifiedTypeNamesAction. Must be called after creation
- * of the view part.
- */
- public void showQualifiedTypeNames(boolean on) {
- if (fAllViewers == null) {
- return;
- }
- for (int i= 0; i < fAllViewers.length; i++) {
- fAllViewers[i].setQualifiedTypeName(on);
- }
- }
-
- private boolean isShowQualifiedTypeNames() {
- return fShowQualifiedTypeNamesAction.isChecked();
- }
-
- /**
- * Called from ITypeHierarchyLifeCycleListener.
- * Can be called from any thread
- */
- protected void doTypeHierarchyChanged(final TypeHierarchyLifeCycle typeHierarchy, final ICElement[] changedTypes) {
- if (!fIsVisible) {
- fNeedRefresh= true;
- return;
- }
- if (fIsRefreshRunnablePosted) {
- return;
- }
-
- Display display= getDisplay();
- if (display != null) {
- fIsRefreshRunnablePosted= true;
- display.asyncExec(new Runnable() {
- public void run() {
- try {
- if (fPagebook != null && !fPagebook.isDisposed()) {
- doTypeHierarchyChangedOnViewers(changedTypes);
- }
- } finally {
- fIsRefreshRunnablePosted= false;
- }
- }
- });
- }
- }
-
- protected void doTypeHierarchyChangedOnViewers(ICElement[] changedTypes) {
- if (fHierarchyLifeCycle.getHierarchy() == null || !fHierarchyLifeCycle.getHierarchy().exists()) {
- clearInput();
- } else {
- if (changedTypes == null) {
- // hierarchy change
- try {
- fHierarchyLifeCycle.ensureRefreshedTypeHierarchy(fInputElement, getSite().getWorkbenchWindow());
- } catch (InvocationTargetException e) {
- ExceptionHandler.handle(e, getSite().getShell(), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.title"), TypeHierarchyMessages.getString("TypeHierarchyViewPart.exception.message")); //$NON-NLS-1$ //$NON-NLS-2$
- clearInput();
- return;
- } catch (InterruptedException e) {
- return;
- }
- fMethodsViewer.refresh();
- updateHierarchyViewer(false);
- } else {
- // elements in hierarchy modified
- Object methodViewerInput= fMethodsViewer.getInput();
- fMethodsViewer.refresh();
- fMethodViewerPaneLabel.setText(fPaneLabelProvider.getText(methodViewerInput));
- fMethodViewerPaneLabel.setImage(fPaneLabelProvider.getImage(methodViewerInput));
- if (getCurrentViewer().isMethodFiltering()) {
- if (changedTypes.length == 1) {
- getCurrentViewer().refresh(changedTypes[0]);
- } else {
- updateHierarchyViewer(false);
- }
- } else {
- getCurrentViewer().update(changedTypes, new String[] { IBasicPropertyConstants.P_TEXT, IBasicPropertyConstants.P_IMAGE } );
- }
- }
- }
- }
-
- /*
- * @see IViewPart#init
- */
- public void init(IViewSite site, IMemento memento) throws PartInitException {
- super.init(site, memento);
- fMemento= memento;
- }
-
- /*
- * @see ViewPart#saveState(IMemento)
- */
- public void saveState(IMemento memento) {
- if (fPagebook == null) {
- // part has not been created
- if (fMemento != null) { //Keep the old state;
- memento.putMemento(fMemento);
- }
- return;
- }
-// if (fInputElement != null) {
-// String handleIndentifier= fInputElement.getHandleIdentifier();
-// memento.putString(TAG_INPUT, handleIndentifier);
-// }
- memento.putInteger(TAG_VIEW, getViewIndex());
- memento.putInteger(TAG_ORIENTATION, fOrientation);
- int weigths[]= fTypeMethodsSplitter.getWeights();
- int ratio= (weigths[0] * 1000) / (weigths[0] + weigths[1]);
- memento.putInteger(TAG_RATIO, ratio);
-
- ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
- int position= bar != null ? bar.getSelection() : 0;
- memento.putInteger(TAG_VERTICAL_SCROLL, position);
-
-// ICElement selection= (ICElement)((IStructuredSelection) getCurrentViewer().getSelection()).getFirstElement();
-// if (selection != null) {
-// memento.putString(TAG_SELECTION, selection.getHandleIdentifier());
-// }
-
- fWorkingSetActionGroup.saveState(memento);
-
- fMethodsViewer.saveState(memento);
-
- saveLinkingEnabled(memento);
- }
-
- private void saveLinkingEnabled(IMemento memento) {
- memento.putInteger(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, fLinkingEnabled ? 1 : 0);
- }
-
- /**
- * Restores the type hierarchy settings from a memento.
- */
- private void restoreState(final IMemento memento, ICElement defaultInput) {
- ICElement input= defaultInput;
-// String elementId= memento.getString(TAG_INPUT);
-// if (elementId != null) {
-// input= CoreModel.create(elementId);
-// if (input != null && !input.exists()) {
-// input= null;
-// }
-// }
- if (input == null) {
- doRestoreState(memento, input);
- } else {
- final ICElement hierarchyInput= input;
-
- synchronized (this) {
- String label= TypeHierarchyMessages.getFormattedString("TypeHierarchyViewPart.restoreinput", hierarchyInput.getElementName()); //$NON-NLS-1$
- fNoHierarchyShownLabel.setText(label);
-
- fRestoreStateJob= new Job(label) {
- protected IStatus run(IProgressMonitor monitor) {
- try {
- doRestoreInBackground(memento, hierarchyInput, monitor);
- } catch (CModelException e) {
- return e.getStatus();
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
- return Status.OK_STATUS;
- }
- };
- fRestoreStateJob.schedule();
- }
- }
- }
-
- protected void doRestoreInBackground(final IMemento memento, final ICElement hierarchyInput, IProgressMonitor monitor) throws CModelException {
- fHierarchyLifeCycle.doHierarchyRefresh(hierarchyInput, monitor);
- if (!monitor.isCanceled()) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- // running async: check first if view still exists
- if (fPagebook != null && !fPagebook.isDisposed()) {
- doRestoreState(memento, hierarchyInput);
- }
- }
- });
- }
- }
-
-
- final void doRestoreState(IMemento memento, ICElement input) {
- synchronized (this) {
- if (fRestoreStateJob == null) {
- return;
- }
- fRestoreStateJob= null;
- }
-
- fWorkingSetActionGroup.restoreState(memento);
- setInputElement(input);
-
- Integer viewerIndex= memento.getInteger(TAG_VIEW);
- if (viewerIndex != null) {
- setView(viewerIndex.intValue());
- }
- Integer orientation= memento.getInteger(TAG_ORIENTATION);
- if (orientation != null) {
- fOrientation= orientation.intValue();
- }
- computeOrientation();
- updateCheckedState();
-
- Integer ratio= memento.getInteger(TAG_RATIO);
- if (ratio != null) {
- fTypeMethodsSplitter.setWeights(new int[] { ratio.intValue(), 1000 - ratio.intValue() });
- }
- ScrollBar bar= getCurrentViewer().getTree().getVerticalBar();
- if (bar != null) {
- Integer vScroll= memento.getInteger(TAG_VERTICAL_SCROLL);
- if (vScroll != null) {
- bar.setSelection(vScroll.intValue());
- }
- }
- fMethodsViewer.restoreState(memento);
- }
-
- private void restoreLinkingEnabled(IMemento memento) {
- Integer val= memento.getInteger(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR);
- if (val != null) {
- fLinkingEnabled= val.intValue() != 0;
- }
- }
-
-
- /**
- * view part becomes visible
- */
- protected void visibilityChanged(boolean isVisible) {
- fIsVisible= isVisible;
- if (isVisible && fNeedRefresh) {
- doTypeHierarchyChangedOnViewers(null);
- }
- fNeedRefresh= false;
- }
-
-
- /**
- * Link selection to active editor.
- */
- protected void editorActivated(IEditorPart editor) {
- if (!isLinkingEnabled()) {
- return;
- }
- if (fInputElement == null) {
- // no type hierarchy shown
- return;
- }
-
- ICElement elem= (ICElement)editor.getEditorInput().getAdapter(ICElement.class);
- TypeHierarchyViewer currentViewer= getCurrentViewer();
- if (elem instanceof ITranslationUnit) {
- try {
- ICElement[] allTypes= TypeUtil.getAllTypes((ITranslationUnit)elem);
- for (int i= 0; i < allTypes.length; i++) {
- if (currentViewer.isElementShown(allTypes[i])) {
- internalSelectType(allTypes[i], true);
- updateMethodViewer(allTypes[i]);
- return;
- }
- }
- } catch (CModelException e) {
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
- */
- public Object getViewPartInput() {
- return fInputElement;
- }
-
-
- /**
- * Returns the <code>IShowInSource</code> for this view.
- */
- protected IShowInSource getShowInSource() {
- return new IShowInSource() {
- public ShowInContext getShowInContext() {
- return new ShowInContext(
- null,
- getSite().getSelectionProvider().getSelection());
- }
- };
- }
-
- boolean isLinkingEnabled() {
- return fLinkingEnabled;
- }
-
- public void setLinkingEnabled(boolean enabled) {
- fLinkingEnabled= enabled;
- PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.LINK_TYPEHIERARCHY_TO_EDITOR, enabled);
-
- if (enabled) {
- IEditorPart editor = getSite().getPage().getActiveEditor();
- if (editor != null) {
- editorActivated(editor);
- }
- }
- }
-
- public void clearNeededRefresh() {
- fNeedRefresh= false;
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java
deleted file mode 100644
index 5a114f47f92..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.internal.ui.browser.typehierarchy;
-
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.IMember;
-import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
-import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartSite;
-
-public abstract class TypeHierarchyViewer extends ProblemTreeViewer {
-
-// private OpenAction fOpen;
- private HierarchyLabelProvider fLabelProvider;
-
- public TypeHierarchyViewer(Composite parent, IContentProvider contentProvider, TypeHierarchyLifeCycle lifeCycle, IWorkbenchPart part) {
- super(new Tree(parent, SWT.SINGLE));
-
- fLabelProvider= new HierarchyLabelProvider(lifeCycle);
-
-// setLabelProvider(new DecoratingCLabelProvider(fLabelProvider, true));
- setLabelProvider(fLabelProvider);
- setUseHashlookup(true);
-
- setContentProvider(contentProvider);
- setSorter(new HierarchyViewerSorter(lifeCycle));
-
-// fOpen= new OpenAction(part.getSite());
-// addOpenListener(new IOpenListener() {
-// public void open(OpenEvent event) {
-// fOpen.run();
-// }
-// });
-
-// CUIHelp.setHelp(this, ICHelpContextIds.TYPE_HIERARCHY_VIEW);
- }
-
- public void setQualifiedTypeName(boolean on) {
- if (on) {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() | CElementLabels.T_POST_QUALIFIED);
- } else {
- fLabelProvider.setTextFlags(fLabelProvider.getTextFlags() & ~CElementLabels.T_POST_QUALIFIED);
- }
- refresh();
- }
-
- /**
- * Attaches a contextmenu listener to the tree
- */
- public void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(menuListener);
- Menu menu= menuMgr.createContextMenu(getTree());
- getTree().setMenu(menu);
- viewSite.registerContextMenu(popupId, menuMgr, this);
- }
-
- /**
- * Fills up the context menu with items for the hierarchy viewer
- * Should be called by the creator of the context menu
- */
- public void contributeToContextMenu(IMenuManager menu) {
- }
-
- /**
- * Set the member filter
- */
- public void setMemberFilter(IMember[] memberFilter) {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- contentProvider.setMemberFilter(memberFilter);
- }
- }
-
- /**
- * Returns if method filtering is enabled.
- */
- public boolean isMethodFiltering() {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- return contentProvider.getMemberFilter() != null;
- }
- return false;
- }
-
- public void setWorkingSetFilter(ViewerFilter filter) {
- fLabelProvider.setFilter(filter);
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- contentProvider.setWorkingSetFilter(filter);
- }
- }
-
- /**
- * Returns true if the hierarchy contains elements. Returns one of them
- * With member filtering it is possible that no elements are visible
- */
- public Object containsElements() {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- Object[] elements= contentProvider.getElements(null);
- if (elements.length > 0) {
- return elements[0];
- }
- }
- return null;
- }
-
- /**
- * Returns true if the hierarchy contains elements. Returns one of them
- * With member filtering it is possible that no elements are visible
- */
- public ICElement getTreeRootType() {
- TypeHierarchyContentProvider contentProvider= getHierarchyContentProvider();
- if (contentProvider != null) {
- Object[] elements= contentProvider.getElements(null);
- if (elements.length > 0 && elements[0] instanceof ICElement) {
- return (ICElement) elements[0];
- }
- }
- return null;
- }
-
- /**
- * Returns true if the hierarchy contains element the element.
- */
- public boolean isElementShown(Object element) {
- return findItem(element) != null;
- }
-
- /**
- * Updates the content of this viewer: refresh and expanding the tree in the way wanted.
- */
- public abstract void updateContent(boolean doExpand);
-
- /**
- * Returns the title for the current view
- */
- public abstract String getTitle();
-
- /*
- * @see StructuredViewer#setContentProvider
- * Content provider must be of type TypeHierarchyContentProvider
- */
- public void setContentProvider(IContentProvider cp) {
- Assert.isTrue(cp instanceof TypeHierarchyContentProvider);
- super.setContentProvider(cp);
- }
-
- protected TypeHierarchyContentProvider getHierarchyContentProvider() {
- return (TypeHierarchyContentProvider)getContentProvider();
- }
-
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java
deleted file mode 100644
index 6a6e1564cd4..00000000000
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeInfoLabelProvider.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * QNX Software Systems - adapted for use in CDT
- *******************************************************************************/
-package org.eclipse.cdt.ui.browser.typeinfo;
-
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.ITypeReference;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class TypeInfoLabelProvider extends LabelProvider {
-
- public static final int SHOW_TYPE_ONLY= 0x01;
- public static final int SHOW_ENCLOSING_TYPE_ONLY= 0x02;
- public static final int SHOW_FULLY_QUALIFIED= 0x04;
- public static final int SHOW_PATH= 0x08;
-
- private static final Image HEADER_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT_HEADER);
- private static final Image SOURCE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TUNIT);
- private static final Image NAMESPACE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_NAMESPACE);
- private static final Image TEMPLATE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TEMPLATE);
- private static final Image CLASS_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_CLASS);
- private static final Image STRUCT_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_STRUCT);
- private static final Image TYPEDEF_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_TYPEDEF);
- private static final Image UNION_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_UNION);
- private static final Image ENUM_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_ENUMERATION);
- private static final Image UNKNOWN_TYPE_ICON= CPluginImages.get(CPluginImages.IMG_OBJS_UNKNOWN_TYPE);
-
- private int fFlags;
-
- public TypeInfoLabelProvider(int flags) {
- fFlags= flags;
- }
-
- private boolean isSet(int flag) {
- return (fFlags & flag) != 0;
- }
-
- /* non java-doc
- * @see ILabelProvider#getText
- */
- public String getText(Object element) {
- if (! (element instanceof ITypeInfo))
- return super.getText(element);
-
- ITypeInfo typeRef= (ITypeInfo) element;
- IQualifiedTypeName qualifiedName = typeRef.getQualifiedTypeName();
-
- StringBuffer buf= new StringBuffer();
- if (isSet(SHOW_TYPE_ONLY)) {
- String name= typeRef.getName();
- if (name != null && name.length() > 0)
- buf.append(name);
- } else if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
- IQualifiedTypeName parentName= qualifiedName.getEnclosingTypeName();
- if (parentName != null) {
- buf.append(parentName.getFullyQualifiedName());
- } else {
- buf.append(TypeInfoMessages.getString("TypeInfoLabelProvider.globalScope")); //$NON-NLS-1$
- }
- } else if (isSet(SHOW_FULLY_QUALIFIED)) {
- buf.append(qualifiedName.getFullyQualifiedName());
- }
-
- if (isSet(SHOW_PATH)) {
- IPath path = null;
- ITypeReference ref = typeRef.getResolvedReference();
- if (ref != null) {
- path = ref.getPath();
- } else {
- IProject project = typeRef.getEnclosingProject();
- if (project != null) {
- path = project.getFullPath();
- }
- }
- if (path != null) {
- buf.append(TypeInfoMessages.getString("TypeInfoLabelProvider.dash"));//$NON-NLS-1$
- buf.append(path.toString());
- }
- }
- return buf.toString();
- }
-
- /* non java-doc
- * @see ILabelProvider#getImage
- */
- public Image getImage(Object element) {
- if (!(element instanceof ITypeInfo))
- return super.getImage(element);
-
- ITypeInfo typeRef= (ITypeInfo) element;
- if (isSet(SHOW_ENCLOSING_TYPE_ONLY)) {
- ITypeInfo parentInfo = typeRef.getEnclosingType();
- if (parentInfo != null) {
- return getTypeIcon(parentInfo.getCElementType());
- }
- IPath path = null;
- ITypeReference ref = typeRef.getResolvedReference();
- if (ref != null) {
- path = ref.getPath();
- if (CoreModel.isValidHeaderUnitName(typeRef.getEnclosingProject(), path.lastSegment())) {
- return HEADER_ICON;
- }
- }
- return SOURCE_ICON;
- }
-
- return getTypeIcon(typeRef.getCElementType());
- }
-
- public static Image getTypeIcon(int type)
- {
- switch (type)
- {
- case ICElement.C_NAMESPACE:
- return NAMESPACE_ICON;
-
- case ICElement.C_TEMPLATE_CLASS:
- return TEMPLATE_ICON;
-
- case ICElement.C_CLASS:
- return CLASS_ICON;
-
- case ICElement.C_STRUCT:
- return STRUCT_ICON;
-
- case ICElement.C_UNION:
- return UNION_ICON;
-
- case ICElement.C_ENUMERATION:
- return ENUM_ICON;
-
- case ICElement.C_TYPEDEF:
- return TYPEDEF_ICON;
-
- default:
- return UNKNOWN_TYPE_ICON;
- }
- }
-}
diff --git a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
index d2ce05a9276..8b7982576b1 100644
--- a/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/ui/browser/typeinfo/TypeSelectionDialog.java
@@ -11,17 +11,13 @@
*******************************************************************************/
package org.eclipse.cdt.ui.browser.typeinfo;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
-import org.eclipse.cdt.core.browser.IQualifiedTypeName;
-import org.eclipse.cdt.core.browser.ITypeInfo;
-import org.eclipse.cdt.core.browser.QualifiedTypeName;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.util.QualifiedTypeName;
import org.eclipse.cdt.internal.ui.util.StringMatcher;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -121,46 +117,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
* @see FilteredList.FilterMatcher#match(Object)
*/
public boolean match(Object element) {
- if (!(element instanceof ITypeInfo))
- return false;
-
- ITypeInfo info = (ITypeInfo) element;
- IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
-
- if (fVisibleTypes != null && !fVisibleTypes.contains(new Integer(info.getCElementType())))
- return false;
-
- if (!fShowLowLevelTypes && qualifiedName.isLowLevel())
- return false;
-
- if (fSegmentMatchers.length == 1 && !fMatchGlobalNamespace)
- return fNameMatcher.match(qualifiedName.getName());
-
- return matchQualifiedName(info);
- }
-
- private boolean matchQualifiedName(ITypeInfo info) {
- IQualifiedTypeName qualifiedName = info.getQualifiedTypeName();
- if (fSegmentMatchers.length != qualifiedName.segmentCount())
- return false;
-
- if (fMatchGlobalNamespace) {
- // must match global namespace (eg ::foo)
- if (info.getRootNamespace(false) != null)
- return false;
- }
-
- boolean matchFound = true;
- int max = Math.min(fSegmentMatchers.length, qualifiedName.segmentCount());
- for (int i = 0; i < max; ++i) {
- StringMatcher matcher = fSegmentMatchers[i];
- String name = qualifiedName.segment(i);
- if (name == null || !matcher.match(name)) {
- matchFound = false;
- break;
- }
- }
- return matchFound;
+ return false;
}
private static String adjustPattern(String pattern) {
@@ -203,9 +160,6 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
private static final String SETTINGS_SHOW_UNIONS = "show_unions"; //$NON-NLS-1$
private static final String SETTINGS_SHOW_LOWLEVEL = "show_lowlevel"; //$NON-NLS-1$
- private static final TypeInfoLabelProvider fElementRenderer = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_TYPE_ONLY);
- private static final TypeInfoLabelProvider fQualifierRenderer = new TypeInfoLabelProvider(TypeInfoLabelProvider.SHOW_ENCLOSING_TYPE_ONLY + TypeInfoLabelProvider.SHOW_PATH);
-
static final TypeFilterMatcher fFilterMatcher = new TypeFilterMatcher();
private static final StringComparator fStringComparator = new StringComparator();
@@ -226,7 +180,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
* @param parent the parent shell.
*/
public TypeSelectionDialog(Shell parent) {
- super(parent, fElementRenderer, fQualifierRenderer);
+ super(parent, null, null);//fElementRenderer, fQualifierRenderer);
setMatchEmptyString(false);
setUpperListLabel(TypeInfoMessages.getString("TypeSelectionDialog.upperLabel")); //$NON-NLS-1$
setLowerListLabel(TypeInfoMessages.getString("TypeSelectionDialog.lowerLabel")); //$NON-NLS-1$
@@ -341,7 +295,7 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
default:
return;
}
- Image icon = TypeInfoLabelProvider.getTypeIcon(type);
+ Image icon = null; //TypeInfoLabelProvider.getTypeIcon(type);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout(2, false);
@@ -570,12 +524,5 @@ public class TypeSelectionDialog extends TwoPaneElementSelector {
* @see org.eclipse.ui.dialogs.SelectionStatusDialog#computeResult()
*/
protected void computeResult() {
- ITypeInfo selection = (ITypeInfo) getLowerSelectedElement();
- if (selection == null)
- return;
-
- List result = new ArrayList(1);
- result.add(selection);
- setResult(result);
}
}

Back to the top