mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Type Hierarchy: filters for method pane
This commit is contained in:
parent
ef4b5ec3b6
commit
a89ed5cff7
17 changed files with 351 additions and 33 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -18,8 +18,10 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICElementVisitor;
|
||||
|
@ -202,10 +204,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVolatile() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
@ -238,10 +236,6 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
return false;
|
||||
}
|
||||
|
||||
public ASTAccessVisibility getVisibility() throws CModelException {
|
||||
return ASTAccessVisibility.PUBLIC;
|
||||
}
|
||||
|
||||
public boolean isMutable() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
|
@ -274,4 +268,23 @@ abstract class CElementHandle implements ICElementHandle, ISourceReference {
|
|||
}
|
||||
return parameterTypes;
|
||||
}
|
||||
|
||||
protected ASTAccessVisibility getVisibility(IBinding binding) {
|
||||
if (binding instanceof ICPPMember) {
|
||||
ICPPMember member= (ICPPMember) binding;
|
||||
try {
|
||||
switch (member.getVisibility()) {
|
||||
case ICPPMember.v_private:
|
||||
return ASTAccessVisibility.PRIVATE;
|
||||
case ICPPMember.v_protected:
|
||||
return ASTAccessVisibility.PROTECTED;
|
||||
case ICPPMember.v_public:
|
||||
return ASTAccessVisibility.PUBLIC;
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return ASTAccessVisibility.PUBLIC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -12,6 +12,7 @@
|
|||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
public class EnumerationHandle extends CElementHandle implements org.eclipse.cdt.core.model.IEnumeration, ICElementHandle {
|
||||
|
@ -19,4 +20,8 @@ public class EnumerationHandle extends CElementHandle implements org.eclipse.cdt
|
|||
public EnumerationHandle(ICElement parent, IEnumeration enumeration) {
|
||||
super(parent, ICElement.C_ENUMERATION, enumeration.getName());
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,12 +11,34 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
|
||||
public class FieldHandle extends CElementHandle implements org.eclipse.cdt.core.model.IField {
|
||||
|
||||
private ASTAccessVisibility fVisibility;
|
||||
private boolean fIsStatic;
|
||||
|
||||
public FieldHandle(ICElement parent, IField field) {
|
||||
super(parent, ICElement.C_FIELD, field.getName());
|
||||
fVisibility= getVisibility(field);
|
||||
try {
|
||||
fIsStatic= field.isStatic();
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
fIsStatic= false;
|
||||
}
|
||||
}
|
||||
|
||||
public ASTAccessVisibility getVisibility() throws CModelException {
|
||||
return fVisibility;
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return fIsStatic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
|
@ -21,10 +22,17 @@ import org.eclipse.cdt.internal.core.model.FunctionDeclaration;
|
|||
public class FunctionHandle extends CElementHandle implements org.eclipse.cdt.core.model.IFunction {
|
||||
|
||||
private String[] fParameterTypes;
|
||||
private boolean fIsStatic;
|
||||
|
||||
public FunctionHandle(ICElement parent, IFunction func) throws DOMException {
|
||||
super(parent, ICElement.C_FUNCTION, func.getName());
|
||||
fParameterTypes= extractParameterTypes(func);
|
||||
try {
|
||||
fIsStatic= func.isStatic();
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
fIsStatic= false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -45,4 +53,8 @@ public class FunctionHandle extends CElementHandle implements org.eclipse.cdt.co
|
|||
public String getSignature() throws CModelException {
|
||||
return FunctionDeclaration.getSignature(this);
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return fIsStatic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,21 +11,33 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IMethod;
|
||||
import org.eclipse.cdt.core.model.IMethodDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.internal.core.model.FunctionDeclaration;
|
||||
import org.eclipse.cdt.internal.core.model.MethodDeclaration;
|
||||
|
||||
public class MethodHandle extends CElementHandle implements IMethod {
|
||||
private String[] fParameterTypes;
|
||||
private ASTAccessVisibility fVisibility;
|
||||
private boolean fIsStatic;
|
||||
|
||||
public MethodHandle(ICElement parent, ICPPMethod method) throws DOMException {
|
||||
super(parent, ICElement.C_METHOD, method.getName());
|
||||
fParameterTypes= extractParameterTypes(method);
|
||||
fVisibility= getVisibility(method);
|
||||
try {
|
||||
fIsStatic= method.isStatic();
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
fIsStatic= false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -46,4 +58,12 @@ public class MethodHandle extends CElementHandle implements IMethod {
|
|||
public String getSignature() throws CModelException {
|
||||
return FunctionDeclaration.getSignature(this);
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return fIsStatic;
|
||||
}
|
||||
|
||||
public ASTAccessVisibility getVisibility() throws CModelException {
|
||||
return fVisibility;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -64,4 +64,8 @@ public class StructureHandle extends CElementHandle implements IStructure {
|
|||
public boolean isUnion() throws CModelException {
|
||||
return getElementType() == ICElement.C_UNION;
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -11,11 +11,26 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.model.ext;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
public class VariableHandle extends CElementHandle implements org.eclipse.cdt.core.model.IVariable {
|
||||
private boolean fIsStatic;
|
||||
|
||||
public VariableHandle(ICElement parent, IVariable var) {
|
||||
super(parent, ICElement.C_VARIABLE, var.getName());
|
||||
try {
|
||||
fIsStatic= var.isStatic();
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
fIsStatic= false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStatic() throws CModelException {
|
||||
return fIsStatic;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,6 +218,7 @@ public class CPluginImages {
|
|||
public static final String IMG_LCL_TYPE_HIERARCHY= NAME_PREFIX + "hierarchy_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_SUB_TYPE_HIERARCHY= NAME_PREFIX + "sub_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_SUPER_TYPE_HIERARCHY= NAME_PREFIX + "super_co.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_LCL_SHOW_INHERITED_MEMBERS= NAME_PREFIX + "inher_co.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final ImageDescriptor DESC_OBJS_TEMPLATE= createManaged(T_OBJ, IMG_OBJS_TEMPLATE);
|
||||
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
###############################################################################
|
||||
# Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||
# All rights reserved. This program and the accompanying materials
|
||||
# are made available under the terms of the Eclipse Public License v1.0
|
||||
# which accompanies this distribution, and is available at
|
||||
# http://www.eclipse.org/legal/epl-v10.html
|
||||
#
|
||||
# Contributors:
|
||||
# Markus Schorn (Wind River Systems)
|
||||
###############################################################################
|
||||
CHViewPart_emptyPageMessage=To display the call hierarchy, select a function or method and select the 'Open Call Hierarchy' menu option.
|
||||
CHViewPart_ShowCallers_label=Show Callers
|
||||
CHViewPart_ShowCallers_tooltip=Show Callers
|
||||
|
@ -6,7 +16,7 @@ CHViewPart_ShowCallees_tooltip=Show Callees
|
|||
CHViewPart_ShowReference_label=Show Reference
|
||||
CHViewPart_ShowReference_tooltip=Show Reference
|
||||
CHViewPart_FilterVariables_label=Filter Variables
|
||||
CHViewPart_FilterVariables_tooltip=Hide Variables, Constents and Enumerators
|
||||
CHViewPart_FilterVariables_tooltip=Hide Variables, Constants and Enumerators
|
||||
CHViewPart_HideMacros_label=Hide Macros
|
||||
CHViewPart_HideMacros_tooltip=Hides Macros
|
||||
CHViewPart_ShowFiles_label=Show File Names
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -2340,6 +2340,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IR
|
|||
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDeclarations"); //$NON-NLS-1$
|
||||
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenDefinition"); //$NON-NLS-1$
|
||||
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenTypeHierarchy"); //$NON-NLS-1$
|
||||
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenCallHierarchy"); //$NON-NLS-1$
|
||||
|
||||
addAction(menu, IContextMenuConstants.GROUP_OPEN, "OpenOutline"); //$NON-NLS-1$
|
||||
}
|
||||
|
|
|
@ -30,6 +30,12 @@ public class Messages extends NLS {
|
|||
public static String THViewPart_CompleteTypeHierarchy;
|
||||
public static String THViewPart_CompleteTypeHierarchy_tooltip;
|
||||
public static String THViewPart_FocusOn;
|
||||
public static String THViewPart_HideFields_label;
|
||||
public static String THViewPart_HideFields_tooltip;
|
||||
public static String THViewPart_HideNonPublic_label;
|
||||
public static String THViewPart_HideNonPublic_tooltip;
|
||||
public static String THViewPart_HideStatic_label;
|
||||
public static String THViewPart_HideStatic_tooltip;
|
||||
public static String THViewPart_HorizontalOrientation;
|
||||
public static String THViewPart_instruction;
|
||||
public static String THViewPart_LayoutMenu;
|
||||
|
@ -40,6 +46,8 @@ public class Messages extends NLS {
|
|||
public static String THViewPart_Refresh_tooltip;
|
||||
public static String THViewPart_ShowFileNames;
|
||||
public static String THViewPart_ShowFileNames_tooltip;
|
||||
public static String THViewPart_ShowInherited_label;
|
||||
public static String THViewPart_ShowInherited_tooltip;
|
||||
public static String THViewPart_SinglePaneOrientation;
|
||||
public static String THViewPart_SubtypeHierarchy;
|
||||
public static String THViewPart_SubtypeHierarchy_tooltip;
|
||||
|
|
|
@ -12,7 +12,10 @@
|
|||
package org.eclipse.cdt.internal.ui.typehierarchy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -64,7 +67,23 @@ class THGraphNode {
|
|||
fMembers= array;
|
||||
}
|
||||
|
||||
public Object[] getMembers() {
|
||||
return fMembers;
|
||||
public Object[] getMembers(boolean addInherited) {
|
||||
if (!addInherited) {
|
||||
return fMembers;
|
||||
}
|
||||
ArrayList list= new ArrayList();
|
||||
collectMembers(new HashSet(), list);
|
||||
return list.toArray();
|
||||
}
|
||||
|
||||
private void collectMembers(HashSet visited, List list) {
|
||||
if (visited.add(this)) {
|
||||
list.addAll(Arrays.asList(fMembers));
|
||||
List bases= getOutgoing();
|
||||
for (Iterator iterator = bases.iterator(); iterator.hasNext();) {
|
||||
THGraphEdge edge = (THGraphEdge) iterator.next();
|
||||
edge.getEndNode().collectMembers(visited, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ public class THHierarchyModel {
|
|||
|
||||
private ICElement fInput;
|
||||
private int fHierarchyKind;
|
||||
private boolean fShowInheritedMembers;
|
||||
|
||||
private THGraph fGraph;
|
||||
private Object[] fRootNodes;
|
||||
|
@ -92,6 +93,14 @@ public class THHierarchyModel {
|
|||
computeNodes();
|
||||
}
|
||||
|
||||
public boolean isShowInheritedMembers() {
|
||||
return fShowInheritedMembers;
|
||||
}
|
||||
|
||||
public void setShowInheritedMembers(boolean showInheritedMembers) {
|
||||
fShowInheritedMembers = showInheritedMembers;
|
||||
}
|
||||
|
||||
public Object[] getHierarchyRootElements() {
|
||||
if (fRootNodes == null) {
|
||||
return new Object[] {"..."}; //$NON-NLS-1$
|
||||
|
@ -172,6 +181,9 @@ public class THHierarchyModel {
|
|||
stack.add(fInput);
|
||||
handled.add(fInput);
|
||||
while (!stack.isEmpty()) {
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
ICElement elem= (ICElement) stack.remove(stack.size()-1);
|
||||
THGraphNode graphNode= graph.addNode(elem);
|
||||
try {
|
||||
|
@ -181,6 +193,9 @@ public class THHierarchyModel {
|
|||
addMembers(index, graphNode, ct);
|
||||
ICPPBase[] bases= ct.getBases();
|
||||
for (int i = 0; i < bases.length; i++) {
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
ICPPBase base= bases[i];
|
||||
IBinding basecl= base.getBaseClass();
|
||||
ICElement[] baseElems= IndexUI.findRepresentative(index, basecl);
|
||||
|
@ -204,7 +219,7 @@ public class THHierarchyModel {
|
|||
}
|
||||
|
||||
private void addMembers(IIndex index, THGraphNode graphNode, IBinding binding) throws DOMException, CoreException {
|
||||
if (graphNode.getMembers() == null) {
|
||||
if (graphNode.getMembers(false) == null) {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
ICPPClassType ct= (ICPPClassType) binding;
|
||||
ArrayList memberList= new ArrayList();
|
||||
|
@ -359,7 +374,7 @@ public class THHierarchyModel {
|
|||
public Object[] getMembers() {
|
||||
if (fHierarchySelection != null) {
|
||||
THGraphNode gnode= fGraph.getNode(fHierarchySelection.getRepresentedDeclaration());
|
||||
return gnode.getMembers();
|
||||
return gnode.getMembers(fShowInheritedMembers);
|
||||
}
|
||||
return NO_CHILDREN;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,9 @@ public class THLabelProvider extends LabelProvider implements IColorProvider {
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (element instanceof ICElement) {
|
||||
return fCLabelProvider.getImage(element);
|
||||
}
|
||||
return super.getImage(element);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ import org.eclipse.jface.viewers.StructuredSelection;
|
|||
import org.eclipse.jface.viewers.StructuredViewer;
|
||||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.jface.viewers.ViewerFilter;
|
||||
import org.eclipse.jface.viewers.ViewerSorter;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.custom.CLabel;
|
||||
|
@ -45,6 +47,7 @@ import org.eclipse.swt.dnd.DropTarget;
|
|||
import org.eclipse.swt.dnd.Transfer;
|
||||
import org.eclipse.swt.events.ControlEvent;
|
||||
import org.eclipse.swt.events.ControlListener;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.graphics.Point;
|
||||
import org.eclipse.swt.layout.FillLayout;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
|
@ -69,6 +72,9 @@ import com.ibm.icu.text.MessageFormat;
|
|||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IDeclaration;
|
||||
import org.eclipse.cdt.core.model.IMember;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility;
|
||||
import org.eclipse.cdt.refactoring.actions.CRefactoringActionGroup;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
|
||||
|
@ -77,6 +83,7 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
|
|||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.AdaptingSelectionProvider;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CUILabelProvider;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
||||
|
@ -90,6 +97,10 @@ public class THViewPart extends ViewPart {
|
|||
private static final String TRUE = String.valueOf(true);
|
||||
// private static final String KEY_WORKING_SET_FILTER = "workingSetFilter"; //$NON-NLS-1$
|
||||
private static final String KEY_SHOW_FILES= "showFilesInLabels"; //$NON-NLS-1$
|
||||
private static final String KEY_SHOW_INHERITED_MEMBERS= "showInheritedMembers"; //$NON-NLS-1$
|
||||
private static final String KEY_FILTER_FIELDS= "filterFields"; //$NON-NLS-1$
|
||||
private static final String KEY_FILTER_STATIC= "filterStatic"; //$NON-NLS-1$
|
||||
private static final String KEY_FILTER_NON_PUBLIC= "filterNonPublic"; //$NON-NLS-1$
|
||||
private static final String KEY_MODE= "hierarchyMode"; //$NON-NLS-1$
|
||||
private static final String KEY_ORIENTATION= "viewOrientation"; //$NON-NLS-1$
|
||||
private static final String KEY_SPLITTER_W1 = "splitterWeight1"; //$NON-NLS-1$
|
||||
|
@ -101,7 +112,8 @@ public class THViewPart extends ViewPart {
|
|||
private static final int ORIENTATION_VERTICAL = 2;
|
||||
private static final int ORIENTATION_SINGLE = 3;
|
||||
private static final int METHOD_LABEL_OPTIONS_SIMPLE = CElementLabels.M_PARAMETER_TYPES;
|
||||
// private static final int METHOD_LABEL_OPTIONS_QUALIFIED = METHOD_LABEL_OPTIONS_SIMPLE | CElementLabels.M_FULLY_QUALIFIED;
|
||||
private static final int METHOD_LABEL_OPTIONS_QUALIFIED = METHOD_LABEL_OPTIONS_SIMPLE | CElementLabels.ALL_POST_QUALIFIED;
|
||||
private static final int METHOD_ICON_OPTIONS = CElementImageProvider.OVERLAY_ICONS;
|
||||
|
||||
private IMemento fMemento;
|
||||
private boolean fShowsMessage= true;
|
||||
|
@ -134,6 +146,7 @@ public class THViewPart extends ViewPart {
|
|||
private Action fShowSuperTypeHierarchyAction;
|
||||
private Action fShowSubTypeHierarchyAction;
|
||||
private Action fShowTypeHierarchyAction;
|
||||
private Action fShowInheritedMembersAction;
|
||||
private Action fShowFilesInLabelsAction;
|
||||
private Action fRefreshAction;
|
||||
private Action fCancelAction;
|
||||
|
@ -144,6 +157,14 @@ public class THViewPart extends ViewPart {
|
|||
private Action fAutomaticOrientation;
|
||||
private Action fSingleOrientation;
|
||||
|
||||
private Action fFieldFilterAction;
|
||||
private Action fStaticFilterAction;
|
||||
private Action fNonPublicFilterAction;
|
||||
|
||||
private ViewerFilter fFieldFilter;
|
||||
private ViewerFilter fStaticFilter;
|
||||
private ViewerFilter fNonPublicFilter;
|
||||
|
||||
// action groups
|
||||
private OpenViewActionGroup fOpenViewActionGroup;
|
||||
private SelectionSearchGroup fSelectionSearchGroup;
|
||||
|
@ -228,10 +249,18 @@ public class THViewPart extends ViewPart {
|
|||
int mode= THHierarchyModel.TYPE_HIERARCHY;
|
||||
int orientation= ORIENTATION_AUTOMATIC;
|
||||
boolean showFiles= false;
|
||||
boolean showInheritedMembers= false;
|
||||
boolean hideFields= false;
|
||||
boolean hideStatic= false;
|
||||
boolean hideNonPublic= false;
|
||||
int[] weights= {35,65};
|
||||
|
||||
if (fMemento != null) {
|
||||
showFiles= TRUE.equals(fMemento.getString(KEY_SHOW_FILES));
|
||||
showInheritedMembers= TRUE.equals(fMemento.getString(KEY_SHOW_INHERITED_MEMBERS));
|
||||
hideFields= TRUE.equals(fMemento.getString(KEY_FILTER_FIELDS));
|
||||
hideStatic= TRUE.equals(fMemento.getString(KEY_FILTER_STATIC));
|
||||
hideNonPublic= TRUE.equals(fMemento.getString(KEY_FILTER_NON_PUBLIC));
|
||||
Integer intval= fMemento.getInteger(KEY_MODE);
|
||||
if (intval != null) {
|
||||
mode= intval.intValue();
|
||||
|
@ -251,6 +280,16 @@ public class THViewPart extends ViewPart {
|
|||
restoreHierarchyKind(mode);
|
||||
fSplitter.setWeights(weights);
|
||||
|
||||
fShowInheritedMembersAction.setChecked(showInheritedMembers);
|
||||
fShowInheritedMembersAction.run();
|
||||
|
||||
fFieldFilterAction.setChecked(hideFields);
|
||||
fFieldFilterAction.run();
|
||||
fStaticFilterAction.setChecked(hideStatic);
|
||||
fStaticFilterAction.run();
|
||||
fNonPublicFilterAction.setChecked(hideNonPublic);
|
||||
fNonPublicFilterAction.run();
|
||||
|
||||
fHierarchyLabelProvider.setShowFiles(showFiles);
|
||||
fShowFilesInLabelsAction.setChecked(showFiles);
|
||||
|
||||
|
@ -267,7 +306,11 @@ public class THViewPart extends ViewPart {
|
|||
// if (fWorkingSetFilterUI != null) {
|
||||
// fWorkingSetFilterUI.saveState(memento, KEY_WORKING_SET_FILTER);
|
||||
// }
|
||||
memento.putString(KEY_SHOW_INHERITED_MEMBERS, String.valueOf(fShowInheritedMembersAction.isChecked()));
|
||||
memento.putString(KEY_SHOW_FILES, String.valueOf(fShowFilesInLabelsAction.isChecked()));
|
||||
memento.putString(KEY_FILTER_FIELDS, String.valueOf(fFieldFilterAction.isChecked()));
|
||||
memento.putString(KEY_FILTER_STATIC, String.valueOf(fStaticFilterAction.isChecked()));
|
||||
memento.putString(KEY_FILTER_NON_PUBLIC, String.valueOf(fNonPublicFilterAction.isChecked()));
|
||||
int[] weights= fSplitter.getWeights();
|
||||
memento.putInteger(KEY_SPLITTER_W1, weights[0]);
|
||||
memento.putInteger(KEY_SPLITTER_W2, weights[1]);
|
||||
|
@ -366,7 +409,7 @@ public class THViewPart extends ViewPart {
|
|||
}
|
||||
|
||||
private Control createMethodControl(ViewForm parent) {
|
||||
fMethodLabelProvider= new CUILabelProvider(METHOD_LABEL_OPTIONS_SIMPLE, 0);
|
||||
fMethodLabelProvider= new CUILabelProvider(METHOD_LABEL_OPTIONS_SIMPLE, METHOD_ICON_OPTIONS);
|
||||
fMethodViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
|
||||
fMethodViewer.setContentProvider(new THMethodContentProvider());
|
||||
fMethodViewer.setLabelProvider(fMethodLabelProvider);
|
||||
|
@ -432,6 +475,7 @@ public class THViewPart extends ViewPart {
|
|||
THNode node= selectionToNode(event.getSelection());
|
||||
fModel.onHierarchySelectionChanged(node);
|
||||
fMethodViewer.refresh();
|
||||
updateDescription();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,6 +571,96 @@ public class THViewPart extends ViewPart {
|
|||
fShowSuperTypeHierarchyAction.setToolTipText(Messages.THViewPart_SupertypeHierarchy_tooltip);
|
||||
CPluginImages.setImageDescriptors(fShowSuperTypeHierarchyAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SUPER_TYPE_HIERARCHY);
|
||||
|
||||
fShowInheritedMembersAction= new Action(Messages.THViewPart_ShowInherited_label, IAction.AS_CHECK_BOX) {
|
||||
public void run() {
|
||||
onShowInheritedMembers(isChecked());
|
||||
}
|
||||
};
|
||||
fShowInheritedMembersAction.setToolTipText(Messages.THViewPart_ShowInherited_tooltip);
|
||||
CPluginImages.setImageDescriptors(fShowInheritedMembersAction, CPluginImages.T_LCL, CPluginImages.IMG_LCL_SHOW_INHERITED_MEMBERS);
|
||||
|
||||
fFieldFilter= new ViewerFilter() {
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (element instanceof ICElement) {
|
||||
ICElement node= (ICElement) element;
|
||||
switch (node.getElementType()) {
|
||||
case ICElement.C_ENUMERATOR:
|
||||
case ICElement.C_FIELD:
|
||||
case ICElement.C_TEMPLATE_VARIABLE:
|
||||
case ICElement.C_VARIABLE:
|
||||
case ICElement.C_VARIABLE_DECLARATION:
|
||||
case ICElement.C_VARIABLE_LOCAL:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
fStaticFilter= new ViewerFilter() {
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (element instanceof IDeclaration) {
|
||||
IDeclaration node= (IDeclaration) element;
|
||||
try {
|
||||
return !node.isStatic();
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
fNonPublicFilter= new ViewerFilter() {
|
||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||
if (element instanceof IMember) {
|
||||
IMember node= (IMember) element;
|
||||
try {
|
||||
return ASTAccessVisibility.PUBLIC.equals(node.getVisibility());
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
fFieldFilterAction= new Action(Messages.THViewPart_HideFields_label, IAction.AS_CHECK_BOX) {
|
||||
public void run() {
|
||||
if (isChecked()) {
|
||||
fMethodViewer.addFilter(fFieldFilter);
|
||||
}
|
||||
else {
|
||||
fMethodViewer.removeFilter(fFieldFilter);
|
||||
}
|
||||
}
|
||||
};
|
||||
fFieldFilterAction.setToolTipText(Messages.THViewPart_HideFields_tooltip);
|
||||
CPluginImages.setImageDescriptors(fFieldFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
|
||||
|
||||
fStaticFilterAction= new Action(Messages.THViewPart_HideStatic_label, IAction.AS_CHECK_BOX) {
|
||||
public void run() {
|
||||
if (isChecked()) {
|
||||
fMethodViewer.addFilter(fStaticFilter);
|
||||
}
|
||||
else {
|
||||
fMethodViewer.removeFilter(fStaticFilter);
|
||||
}
|
||||
}
|
||||
};
|
||||
fStaticFilterAction.setToolTipText(Messages.THViewPart_HideStatic_tooltip);
|
||||
CPluginImages.setImageDescriptors(fStaticFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC);
|
||||
|
||||
fNonPublicFilterAction= new Action(Messages.THViewPart_HideNonPublic_label, IAction.AS_CHECK_BOX) {
|
||||
public void run() {
|
||||
if (isChecked()) {
|
||||
fMethodViewer.addFilter(fNonPublicFilter);
|
||||
}
|
||||
else {
|
||||
fMethodViewer.removeFilter(fNonPublicFilter);
|
||||
}
|
||||
}
|
||||
};
|
||||
fNonPublicFilterAction.setToolTipText(Messages.THViewPart_HideNonPublic_tooltip);
|
||||
CPluginImages.setImageDescriptors(fNonPublicFilterAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_PUBLIC);
|
||||
|
||||
fOpenElement= new Action(Messages.THViewPart_Open) {
|
||||
public void run() {
|
||||
onOpenElement(getSite().getSelectionProvider().getSelection());
|
||||
|
@ -595,11 +729,15 @@ public class THViewPart extends ViewPart {
|
|||
submenu.add(fSingleOrientation);
|
||||
|
||||
mm.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, submenu);
|
||||
|
||||
// mm.add(fReferencedByAction);
|
||||
// mm.add(fMakesReferenceToAction);
|
||||
mm.add(new Separator());
|
||||
mm.add(fShowFilesInLabelsAction);
|
||||
|
||||
// method toolbar
|
||||
fMethodToolbarManager.add(fShowInheritedMembersAction);
|
||||
fMethodToolbarManager.add(new Separator());
|
||||
fMethodToolbarManager.add(fFieldFilterAction);
|
||||
fMethodToolbarManager.add(fStaticFilterAction);
|
||||
fMethodToolbarManager.add(fNonPublicFilterAction);
|
||||
}
|
||||
|
||||
protected void onOpenElement(ISelection selection) {
|
||||
|
@ -663,6 +801,19 @@ public class THViewPart extends ViewPart {
|
|||
String scope= workingSet.getLabel();
|
||||
message= MessageFormat.format("{0} - {1}", new Object[] {label, scope}); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
label= ""; //$NON-NLS-1$
|
||||
Image image= null;
|
||||
THNode node= fModel.getSelectionInHierarchy();
|
||||
if (node != null) {
|
||||
elem= node.getRepresentedDeclaration();
|
||||
if (elem != null) {
|
||||
label= CElementLabels.getElementLabel(elem, 0);
|
||||
image= fHierarchyLabelProvider.getImage(elem);
|
||||
}
|
||||
}
|
||||
fMethodLabel.setText(label);
|
||||
fMethodLabel.setImage(image);
|
||||
}
|
||||
}
|
||||
setContentDescription(message);
|
||||
|
@ -689,6 +840,15 @@ public class THViewPart extends ViewPart {
|
|||
}
|
||||
}
|
||||
|
||||
protected void onShowInheritedMembers(boolean show) {
|
||||
if (fModel.isShowInheritedMembers() != show) {
|
||||
fModel.setShowInheritedMembers(show);
|
||||
fMethodLabelProvider.setTextFlags(show ?
|
||||
METHOD_LABEL_OPTIONS_QUALIFIED : METHOD_LABEL_OPTIONS_SIMPLE);
|
||||
fMethodViewer.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateView() {
|
||||
if (!fShowsMessage) {
|
||||
fIgnoreSelectionChanges++;
|
||||
|
|
|
@ -21,18 +21,26 @@ THHistoryListAction_label=Open History...
|
|||
THViewPart_instruction=To display the type hierarchy, select a type or member and select the 'Open Type Hierarchy' menu option.
|
||||
THViewPart_MethodPane_title=Content
|
||||
THViewPart_HorizontalOrientation=Horizontal View Orientation
|
||||
THViewPart_HideNonPublic_tooltip=Hide Non-Public Members
|
||||
THViewPart_VerticalOrientation=Vertical View Orientation
|
||||
THViewPart_SinglePaneOrientation=Hierarchy View Only
|
||||
THViewPart_CompleteTypeHierarchy=Type Hieararchy
|
||||
THViewPart_CompleteTypeHierarchy_tooltip=Show the Type Hierarchy
|
||||
THViewPart_SubtypeHierarchy=Subtype Hieararchy
|
||||
THViewPart_HideFields_label=Hide Fields
|
||||
THViewPart_HideStatic_label=Hide Static Members
|
||||
THViewPart_SubtypeHierarchy_tooltip=Show the Subtype Hierarchy
|
||||
THViewPart_SupertypeHierarchy=Supertype Hieararchy
|
||||
THViewPart_HideFields_tooltip=Hide Fields
|
||||
THViewPart_HideStatic_tooltip=Hide Static Fields and Methods
|
||||
THViewPart_Open=Open
|
||||
THViewPart_Open_tooltip=Open
|
||||
THViewPart_ShowFileNames=Show File Names
|
||||
THViewPart_Cancel_tooltip=Cancel
|
||||
THViewPart_ShowFileNames_tooltip=Show File Names
|
||||
THViewPart_ShowInherited_label=Show Inherited Members
|
||||
THViewPart_HideNonPublic_label=Hide Non-Public Members
|
||||
THViewPart_ShowInherited_tooltip=Show All Inherited Members
|
||||
THViewPart_Refresh=Refresh
|
||||
THViewPart_LayoutMenu=Layout
|
||||
THViewPart_FocusOn=Focus On ''{0}''
|
||||
|
|
|
@ -171,11 +171,13 @@ public class OpenViewActionGroup extends ActionGroup {
|
|||
*/
|
||||
public void fillContextMenu(IMenuManager menu) {
|
||||
super.fillContextMenu(menu);
|
||||
if (useTypeHierarchy() && !fIsTypeHiararchyViewerOwner && fOpenTypeHierarchy.isEnabled()) {
|
||||
menu.appendToGroup(fGroupName, fOpenTypeHierarchy);
|
||||
}
|
||||
if (!fIsCallHiararchyViewerOwner && fOpenCallHierarchy.isEnabled()) {
|
||||
menu.appendToGroup(fGroupName, fOpenCallHierarchy);
|
||||
if (!fEditorIsOwner) {
|
||||
if (useTypeHierarchy() && !fIsTypeHiararchyViewerOwner && fOpenTypeHierarchy.isEnabled()) {
|
||||
menu.appendToGroup(fGroupName, fOpenTypeHierarchy);
|
||||
}
|
||||
if (!fIsCallHiararchyViewerOwner && fOpenCallHierarchy.isEnabled()) {
|
||||
menu.appendToGroup(fGroupName, fOpenCallHierarchy);
|
||||
}
|
||||
}
|
||||
// appendToGroup(menu, fOpenSuperImplementation);
|
||||
IStructuredSelection selection= getStructuredSelection();
|
||||
|
|
Loading…
Add table
Reference in a new issue