diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 15439f1e9b5..1f1d4807d0f 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,9 @@
+2004-07-15 Chris Wiebe
+
+ Initial draft for the type hierarchy view.
+ * browser/*
+ * icons/*
+
2004-07-15 Hoda Amer
Fix for PR 68500: [Outline View] After doing a rename of a class, the outline viewer does not display the new name (just the old name)
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
index 89fe9b8c88e..62c0b833e0b 100644
--- 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
@@ -20,6 +20,7 @@ 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;
@@ -758,7 +759,7 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
for (int j = 0; j < enclosedTypes.length; ++j) {
ITypeInfo enclosedType = enclosedTypes[j];
if (enclosedType.getResolvedReference() != null) {
- ICElement typeElem = enclosedType.getCElement();
+ ICElement typeElem = TypeUtil.getElementForType(enclosedType);
if (typeElem != null && (typeElem.equals(cElem) || (typeElem instanceof IParent && hasChild(typeElem, cElem)))) {
return namespaces[i];
}
@@ -819,7 +820,7 @@ public abstract class CBrowsingPart extends ViewPart implements IMenuListener, I
for (int j = 0; j < enclosedTypes.length; ++j) {
ITypeInfo enclosedType = enclosedTypes[j];
if (enclosedType.getResolvedReference() != null) {
- ICElement typeElem = enclosedType.getCElement();
+ ICElement typeElem = TypeUtil.getElementForType(enclosedType);
if (typeElem != null && (typeElem.equals(cElem) || (typeElem instanceof IParent && hasChild(typeElem, cElem)))) {
return enclosedType;
}
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
index c2b7ab5fde2..9509f085a40 100644
--- 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
@@ -16,6 +16,7 @@ import java.util.Iterator;
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.TypeUtil;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IParent;
@@ -184,7 +185,7 @@ class MembersViewContentProvider extends CBrowsingContentProvider {
ICElement elem = null;
if (location != null)
- elem = info.getCElement();
+ elem = TypeUtil.getElementForType(info);
if (location == null) {
// could not resolve location
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
new file mode 100644
index 00000000000..2a03e19d74c
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/EnableMemberFilterAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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 enable / disable member filtering
+ */
+public class EnableMemberFilterAction extends Action {
+
+ private 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
new file mode 100644
index 00000000000..cc81347c05e
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnSelectionAction.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
new file mode 100644
index 00000000000..38546815af0
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeAction.java
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.swt.widgets.Shell;
+
+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.browser.TypeUtil;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeDialog;
+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.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+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] = TypeUtil.getElementForType(typesToResolve[0], 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
new file mode 100644
index 00000000000..7168bcc084a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/FocusOnTypeDialog.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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 OpenTypeDialog
.
+ * @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
new file mode 100644
index 00000000000..dbb587bbc79
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyLabelProvider.java
@@ -0,0 +1,208 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.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;
+
+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.Flags;
+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.core.browser.cache.TypeCacheManager;
+import org.eclipse.cdt.internal.ui.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.CPluginImages;
+import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
+import org.eclipse.cdt.internal.ui.browser.cbrowsing.AppearanceAwareLabelProvider;
+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;
+
+/**
+ * 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#getText
+ */
+ public String getText(Object element) {
+ String text= super.getText(element);
+// return decorateText(text, element);
+ return text;
+ }
+
+
+ /* (non-Javadoc)
+ * @see ILabelProvider#getImage
+ */
+ public Image getImage(Object element) {
+// return super.getImage(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, evaluateImageFlags(element));
+ }
+ return decorateImage(result, element);
+ }
+
+ 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 = fImageLabelProvider.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
new file mode 100644
index 00000000000..d0333380359
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HierarchyViewerSorter.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.Flags;
+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.corext.util.CModelUtil;
+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
+ } else {
+ 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.getDeclaringType(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.getDeclaringType(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
new file mode 100644
index 00000000000..95f4d2a260d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryAction.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.CElementImageProvider;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+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
new file mode 100644
index 00000000000..43604cbdd50
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryDropDownAction.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
new file mode 100644
index 00000000000..30f0f6e17f3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/HistoryListAction.java
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.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.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.window.Window;
+
+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.
+ */
+ private void doCustomButtonPressed() {
+ fHistoryList.removeElements(fHistoryList.getSelectedElements());
+ }
+
+ private void doDoubleClicked() {
+ if (fHistoryStatus.isOK()) {
+ okPressed();
+ }
+ }
+
+
+ private 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
new file mode 100644
index 00000000000..c6ad8e8e859
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyLifeCycleListener.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
new file mode 100644
index 00000000000..98837532e60
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ITypeHierarchyViewPart.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.
+ *
+ * This interface is not intended to be implemented by clients. + *
+ * + * @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, ornull
+ * 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
+ * IMember
(types, methods, fields..), IPackageFragment
, IPackageFragmentRoot
+ * and IJavaProject
.
+ *
+ * @param element the input element of this type hierarchy view, or null
+ * 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 null
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 null
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
new file mode 100644
index 00000000000..0343cac679b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsContentProvider.java
@@ -0,0 +1,134 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.IWorkingCopyProvider;
+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.ui.CElementContentProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/**
+ * 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
new file mode 100644
index 00000000000..f903bf5af39
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsLabelProvider.java
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.IMember;
+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.corext.util.CModelUtil;
+import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
+import org.eclipse.cdt.internal.ui.browser.cbrowsing.AppearanceAwareLabelProvider;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+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.getDeclaringType(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.getDeclaringType(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.getDeclaringType(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
new file mode 100644
index 00000000000..2023ee811ee
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/MethodsViewer.java
@@ -0,0 +1,302 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.IMethod;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.StandardCElementLabelProvider;
+import org.eclipse.cdt.internal.ui.browser.cbrowsing.DecoratingCLabelProvider;
+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.CElementLabelProvider;
+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.IOpenListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.OpenEvent;
+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.turnOn(CElementLabelProvider.SHOW_POST_QUALIFIED);
+ } else {
+ fLabelProvider.turnOff(CElementLabelProvider.SHOW_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 true
if inherited methods are shown.
+ */
+ public boolean isShowInheritedMethods() {
+ return ((MethodsContentProvider) getContentProvider()).isShowInheritedMethods();
+ }
+
+ /**
+ * Returns true
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
new file mode 100644
index 00000000000..5fcff0f6149
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyAction.java
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.
+ *
+ * The action is applicable to selections containing elements of type
+ * IType
.
+ *
+ *
+ * This class may be instantiated; it is not intended to be subclassed. + *
+ * + * @since 2.0 + */ +public class OpenTypeHierarchyAction extends SelectionDispatchAction { + + private CEditor fEditor; + + /** + * Creates a newOpenTypeHierarchyAction
. The action requires
+ * that the selection provided by the site's selection provider is of type
+ * org.eclipse.jface.viewers.IStructuredSelection
.
+ *
+ * @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);
+ if (types != null) {
+ List elements = new ArrayList(types.length);
+ for (int i = 0; i < types.length; ++i) {
+ ICElement e = TypeUtil.getElementForType(types[i], 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
new file mode 100644
index 00000000000..1ed97876c0d
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeHierarchyUtil.java
@@ -0,0 +1,180 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.internal.ui.browser.typehierarchy;
+
+import java.security.Signature;
+
+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.IParent;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+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);
+ } else {
+ 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((IMember) 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.getDeclaringType(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((IMember) 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.getDeclaringType(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
new file mode 100644
index 00000000000..eb729bc010b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/OpenTypeInHierarchyAction.java
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.OpenTypeDialog;
+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;
+ }
+
+ 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;
+
+ Object[] types= dialog.getResult();
+ if (types != null && types.length > 0) {
+ ICElement type= (ICElement)types[0];
+ OpenTypeHierarchyUtil.open(new ICElement[] { type }, 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/SelectionProviderMediator.java b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java
new file mode 100644
index 00000000000..535ec748f3f
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SelectionProviderMediator.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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);
+ }
+ }
+
+ private 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
new file mode 100644
index 00000000000..c0d73b03abb
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowInheritedMembersAction.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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 {
+
+ private 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
new file mode 100644
index 00000000000..9a3fee13a93
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ShowQualifiedTypeNamesAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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 {
+
+ private 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
new file mode 100644
index 00000000000..9c621df8140
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SortByDefiningTypeAction.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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 {
+
+ private 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
new file mode 100644
index 00000000000..8f268da67d8
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SubTypeHierarchyViewer.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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$
+ } else {
+ 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
new file mode 100644
index 00000000000..b8c05eed9e7
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/SuperTypeHierarchyViewer.java
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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$
+ } else {
+ 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
new file mode 100644
index 00000000000..7a1bc876204
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleLinkingAction.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
new file mode 100644
index 00000000000..906ae2b796b
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleOrientationAction.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
new file mode 100644
index 00000000000..0c355af3fa5
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/ToggleViewAction.java
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
new file mode 100644
index 00000000000..e10c0fbdd37
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyContentProvider.java
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.IWorkingCopyProvider;
+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.IMethod;
+import org.eclipse.cdt.core.model.IMethodDeclaration;
+import org.eclipse.cdt.internal.corext.util.CModelUtil;
+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 null
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 null
if member filtering is disabled.
+ */
+ public IMember[] getMemberFilter() {
+ return fMemberFilter;
+ }
+
+ /**
+ * Sets a filter representing a working set or null
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.getDeclaringType(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);
+ } else {
+ 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.getDeclaringType(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.getDeclaringType(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
new file mode 100644
index 00000000000..7c0796887ed
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyLifeCycle.java
@@ -0,0 +1,285 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.ICProject;
+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 boolean fIsSuperTypesOnly;
+
+ private List fChangeListeners;
+
+ public TypeHierarchyLifeCycle() {
+ this(true);
+ }
+
+ public TypeHierarchyLifeCycle(boolean isSuperTypesOnly) {
+ fHierarchy= null;
+ fInputElement= null;
+ fIsSuperTypesOnly= isSuperTypesOnly;
+ 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);
+ }
+// if (element.getElementType() == ICElement.TYPE) {
+// IType type= (IType) element;
+// if (fIsSuperTypesOnly) {
+// return type.newSupertypeHierarchy(pm);
+// } else {
+// return type.newTypeHierarchy(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;
+ } else {
+ 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((ICElement) 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
new file mode 100644
index 00000000000..c8016cf95fd
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyMessages.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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
index c1fa704b44f..20bf0aa4415 100644
--- 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
@@ -7,18 +7,8 @@
#
# Contributors:
# IBM Corporation - initial API and implementation
-###############################################################################
-#*******************************************************************************
-# Copyright (c) 2004 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-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
@@ -32,6 +22,10 @@ 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
@@ -82,7 +76,6 @@ 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 type (for example in the outline view or in the editor), and select the \'Open Type Hierarchy\' menu option. Alternatively, you can drag and drop an element (e.g. project, package, type) onto this view.
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.
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
new file mode 100644
index 00000000000..f9f086736d1
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewPart.java
@@ -0,0 +1,1601 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.IContextMenuConstants;
+import org.eclipse.cdt.internal.ui.actions.CompositeActionGroup;
+import org.eclipse.cdt.internal.ui.actions.SelectAllAction;
+import org.eclipse.cdt.internal.ui.browser.cbrowsing.CUILabelProvider;
+import org.eclipse.cdt.internal.ui.browser.cbrowsing.StatusBarUpdater;
+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.IViewPartInputProvider;
+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.MessageDialog;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+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.dnd.Transfer;
+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.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_TYPE= 2;
+ 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;
+
+ private 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;
+ private boolean fIsRefreshRunnablePosted;
+
+ private int fCurrentViewerIndex;
+ private TypeHierarchyViewer[] fAllViewers;
+
+ private MethodsViewer fMethodsViewer;
+
+ private SashForm fTypeMethodsSplitter;
+ private PageBook fViewerbook;
+ private 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;
+ private 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_TYPE),
+ new ToggleViewAction(this, VIEW_ID_SUPER),
+ new ToggleViewAction(this, VIEW_ID_SUB)
+ };
+
+// fDialogSettings= CPlugin.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 (member.getElementType() != ICElement.TYPE) {
+ if (!(member instanceof IStructure)) {
+ 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() {
+ if (fInputElement instanceof ICElement) {
+ return (ICElement) fInputElement;
+ }
+ return null;
+ }
+
+ /**
+ * 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 ICElement
or IPackageFragment
+ */
+ 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.getDeclaringType(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 (inputElement.getElementType() != ICElement.TYPE) {
+ if (!(inputElement instanceof IStructure)) {
+// setView(VIEW_ID_TYPE);
+ 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);
+
+// TypeHierarchyViewer vajViewer= new TraditionalHierarchyViewer(fViewerbook, fHierarchyLifeCycle, this);
+// initializeTypesViewer(vajViewer, keyListener, IContextMenuConstants.TARGET_ID_HIERARCHY_VIEW);
+
+// fAllViewers= new TypeHierarchyViewer[3];
+ fAllViewers= new TypeHierarchyViewer[2];
+ fAllViewers[VIEW_ID_SUPER]= superTypesViewer;
+ fAllViewers[VIEW_ID_SUB]= subTypesViewer;
+// fAllViewers[VIEW_ID_TYPE]= vajViewer;
+
+ int currViewerIndex;
+// try {
+// currViewerIndex= fDialogSettings.getInt(DIALOGSTORE_HIERARCHYVIEW);
+// if (currViewerIndex < 0 || currViewerIndex > 2) {
+// currViewerIndex= VIEW_ID_TYPE;
+// }
+// } catch (NumberFormatException e) {
+// currViewerIndex= VIEW_ID_TYPE;
+// }
+ 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;
+// }
+ 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
+ */
+ private 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
+ */
+ private 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. null
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 (elem.getElementType() != ICElement.TYPE) {
+ if (!(elem instanceof IStructure)) {
+ return getCurrentViewer().getTreeRootType();
+ } else {
+ 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,
+ * updateHierarchyViewer brings up the correct view and refreshes
+ * the current tree
+ */
+ private 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;
+ }
+ setTitle(title);
+ setTitleToolTip(tooltip);
+ }
+
+ private void updateToolbarButtons() {
+ boolean isType= fInputElement instanceof ICElement;
+ for (int i= 0; i < fViewActions.length; i++) {
+ ToggleViewAction action= fViewActions[i];
+// if (action.getViewerIndex() == VIEW_ID_TYPE) {
+// action.setEnabled(fInputElement != null);
+// } else {
+ action.setEnabled(isType);
+// }
+ }
+ }
+
+ /**
+ * 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= CCore.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();
+ }
+ }
+ }
+
+ private 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);
+// try {
+ TypeHierarchyViewer currentViewer= getCurrentViewer();
+// if (elem instanceof IClassFile) {
+// ICElement type= ((IClassFile)elem).getType();
+// if (currentViewer.isElementShown(type)) {
+// internalSelectType(type, true);
+// updateMethodViewer(type);
+// }
+// } else
+ if (elem instanceof ITranslationUnit) {
+// ICElement[] allTypes= ((ITranslationUnit)elem).getAllTypes();
+ ICElement[] allTypes= TypeUtil.getTypes((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) {
+// CUIPlugin.getDefault().log(e);
+// }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.ui.viewsupport.IViewPartInputProvider#getViewPartInput()
+ */
+ public Object getViewPartInput() {
+ return fInputElement;
+ }
+
+
+ /**
+ * Returns the IShowInSource
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
new file mode 100644
index 00000000000..266f5d5f3ec
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/browser/org/eclipse/cdt/internal/ui/browser/typehierarchy/TypeHierarchyViewer.java
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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 Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-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.Composite;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Tree;
+
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IMember;
+import org.eclipse.cdt.internal.ui.ICHelpContextIds;
+import org.eclipse.cdt.internal.ui.browser.cbrowsing.DecoratingCLabelProvider;
+import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
+import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+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.IOpenListener;
+import org.eclipse.jface.viewers.OpenEvent;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+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.turnOn(CElementLabelProvider.SHOW_POST_QUALIFIED);
+ } else {
+ fLabelProvider.turnOff(CElementLabelProvider.SHOW_POST_QUALIFIED);
+ }
+// 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/icons/full/clcl16/definingtype_sort_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/definingtype_sort_co.gif
new file mode 100644
index 00000000000..166eaba9031
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/definingtype_sort_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/history_list.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/history_list.gif
new file mode 100644
index 00000000000..364c0e70b1d
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/history_list.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/impl_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/impl_co.gif
new file mode 100644
index 00000000000..98d914a4484
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/impl_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/inher_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/inher_co.gif
new file mode 100644
index 00000000000..a326000dae6
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/inher_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/sub_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/sub_co.gif
new file mode 100644
index 00000000000..54871df5aa6
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/sub_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/super_co.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/super_co.gif
new file mode 100644
index 00000000000..59ac11633f2
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/super_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/th_automatic.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_automatic.gif
new file mode 100644
index 00000000000..45469ad67c4
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_automatic.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/th_horizontal.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_horizontal.gif
new file mode 100644
index 00000000000..d590470446f
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_horizontal.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/th_showqualified.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_showqualified.gif
new file mode 100644
index 00000000000..2556b457bca
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_showqualified.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/th_single.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_single.gif
new file mode 100644
index 00000000000..42fca3fcc9a
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_single.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/clcl16/th_vertical.gif b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_vertical.gif
new file mode 100644
index 00000000000..dee0cbca025
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/clcl16/th_vertical.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/definingtype_sort_co.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/definingtype_sort_co.gif
new file mode 100644
index 00000000000..ff83256d83b
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/definingtype_sort_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/history_list.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/history_list.gif
new file mode 100644
index 00000000000..131063ce97d
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/history_list.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/impl_co.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/impl_co.gif
new file mode 100644
index 00000000000..a727403c3ac
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/impl_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/inher_co.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/inher_co.gif
new file mode 100644
index 00000000000..23338d74aa7
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/inher_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/sub_co.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/sub_co.gif
new file mode 100644
index 00000000000..3848a251dad
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/sub_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/super_co.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/super_co.gif
new file mode 100644
index 00000000000..45808d1d261
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/super_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_automatic.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_automatic.gif
new file mode 100644
index 00000000000..1b93aaca769
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_automatic.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_horizontal.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_horizontal.gif
new file mode 100644
index 00000000000..05da6248e43
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_horizontal.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_showqualified.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_showqualified.gif
new file mode 100644
index 00000000000..f288b596513
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_showqualified.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_single.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_single.gif
new file mode 100644
index 00000000000..530345b360c
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_single.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_vertical.gif b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_vertical.gif
new file mode 100644
index 00000000000..0a52f1de2a3
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/dlcl16/th_vertical.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/definingtype_sort_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/definingtype_sort_co.gif
new file mode 100644
index 00000000000..166eaba9031
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/definingtype_sort_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/history_list.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/history_list.gif
new file mode 100644
index 00000000000..364c0e70b1d
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/history_list.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/impl_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/impl_co.gif
new file mode 100644
index 00000000000..98d914a4484
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/impl_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/inher_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/inher_co.gif
new file mode 100644
index 00000000000..a326000dae6
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/inher_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/sub_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/sub_co.gif
new file mode 100644
index 00000000000..54871df5aa6
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/sub_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/super_co.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/super_co.gif
new file mode 100644
index 00000000000..59ac11633f2
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/super_co.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/th_automatic.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_automatic.gif
new file mode 100644
index 00000000000..45469ad67c4
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_automatic.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/th_horizontal.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_horizontal.gif
new file mode 100644
index 00000000000..d590470446f
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_horizontal.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/th_showqualified.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_showqualified.gif
new file mode 100644
index 00000000000..2556b457bca
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_showqualified.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/th_single.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_single.gif
new file mode 100644
index 00000000000..42fca3fcc9a
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_single.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/elcl16/th_vertical.gif b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_vertical.gif
new file mode 100644
index 00000000000..dee0cbca025
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/elcl16/th_vertical.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/eview16/chierch_pers.gif b/core/org.eclipse.cdt.ui/icons/full/eview16/chierch_pers.gif
new file mode 100644
index 00000000000..905c3387956
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/eview16/chierch_pers.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/eview16/class_hi.gif b/core/org.eclipse.cdt.ui/icons/full/eview16/class_hi.gif
new file mode 100644
index 00000000000..17f927e9a4e
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/eview16/class_hi.gif differ
diff --git a/core/org.eclipse.cdt.ui/icons/full/ovr16/focus_ovr.gif b/core/org.eclipse.cdt.ui/icons/full/ovr16/focus_ovr.gif
new file mode 100644
index 00000000000..6bd54e391c1
Binary files /dev/null and b/core/org.eclipse.cdt.ui/icons/full/ovr16/focus_ovr.gif differ
diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties
index acee703d315..7366a78d00f 100644
--- a/core/org.eclipse.cdt.ui/plugin.properties
+++ b/core/org.eclipse.cdt.ui/plugin.properties
@@ -20,7 +20,6 @@ editorRulerActionsName=Editor Ruler Actions
completionContributorName=Completion Contribution
nature.name=C Nature
perspective.name=C/C++
-CBrowsing.perspective.name=C/C++ Browsing
viewsCategory.name=&C
CView.name=C/C++ Projects
@@ -181,7 +180,7 @@ CEditorPresentation.label= Editor
CDTIndexerMarker.label= C/C++ Indexer Markers
#Browsing
-CBrowsing.perspectiveName= C/C++ Browsing
+CBrowsing.perspective.name=C/C++ Browsing
CBrowsing.viewCategoryName= C/C++ Browsing
CBrowsing.projectsViewName= Projects
CBrowsing.namespacesViewName= Namespaces
@@ -189,6 +188,24 @@ CBrowsing.typesViewName= Types
CBrowsing.membersViewName= Members
CBrowsing.preferencePageName= Browsing
+#Type Hierarchy
+CHierarchy.viewCategoryName= C/C++ Type Hierarchy
+CHierarchy.perspective.name=C/C++ Type Hierarchy
+CHierarchy.hierarchyViewName= Hierarchy
+ActionDefinition.open.hierarchy.name= Open Hierarchy
+ActionDefinition.open.hierarchy.description= Open the hierarchy of the selected element
+OpenTypeInHierarchyAction.label=Open Type in Hierarch&y...
+OpenTypeInHierarchyAction.description=Opens a type selected from the all types dialog in a type hierarchy
+OpenTypeInHierarchyAction.tooltip=Opens a Type in a Type Hierarchy
+ActionDefinition.openTypeInHierarchy.name= Open Type in Hierarchy
+ActionDefinition.openTypeInHierarchy.description= Open a type in the type hierarchy view
+ActionDefinition.openTypeHierarchy.name= Open Type Hierarchy
+ActionDefinition.openTypeHierarchy.description= Open a type hierarchy on the selected element
+OpenTypeHierarchyAction.label=Open Type Hie&rarchy
+OpenTypeHierarchyAction.tooltip=Opens a Type Hierarchy for the Selected Element
+ViewCommand.typeHierarchy.name= C Type Hierarchy
+ViewCommand.typeHierarchy.description= Show the Type Hierarchy view
+
# hovering contribution
CEditorTextHoversName=C Editor Text Hovers
sourceHover= Source
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 9c5a4e0d2df..0dc341103c6 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -171,6 +171,12 @@
class="org.eclipse.cdt.internal.ui.browser.cbrowsing.CBrowsingPerspectiveFactory"
id="org.eclipse.cdt.ui.CBrowsingPerspective">
+
+
@@ -259,6 +265,17 @@
class="org.eclipse.cdt.internal.ui.browser.cbrowsing.MembersView"
id="org.eclipse.cdt.ui.MembersView">
+
+
+
+
@@ -618,6 +635,18 @@
string="Ctrl+G"
scope="org.eclipse.cdt.ui.cEditorScope"
configuration="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+
+
+
+
+
+
+
+