Initial version of call-hierarchy, not yet fully working.
|
@ -13,6 +13,7 @@ Export-Package: org.eclipse.cdt.internal.corext,
|
||||||
org.eclipse.cdt.internal.ui.actions,
|
org.eclipse.cdt.internal.ui.actions,
|
||||||
org.eclipse.cdt.internal.ui.browser.opentype,
|
org.eclipse.cdt.internal.ui.browser.opentype,
|
||||||
org.eclipse.cdt.internal.ui.buildconsole,
|
org.eclipse.cdt.internal.ui.buildconsole,
|
||||||
|
org.eclipse.cdt.internal.ui.callhierarchy;x-internal:=true,
|
||||||
org.eclipse.cdt.internal.ui.codemanipulation,
|
org.eclipse.cdt.internal.ui.codemanipulation,
|
||||||
org.eclipse.cdt.internal.ui.compare,
|
org.eclipse.cdt.internal.ui.compare,
|
||||||
org.eclipse.cdt.internal.ui.cview,
|
org.eclipse.cdt.internal.ui.cview,
|
||||||
|
|
Before Width: | Height: | Size: 554 B After Width: | Height: | Size: 350 B |
BIN
core/org.eclipse.cdt.ui/icons/dlcl16/filterDefines.gif
Normal file
After Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 327 B After Width: | Height: | Size: 211 B |
BIN
core/org.eclipse.cdt.ui/icons/elcl16/filterDefines.gif
Normal file
After Width: | Height: | Size: 910 B |
BIN
core/org.eclipse.cdt.ui/icons/view16/call_hierarchy.gif
Normal file
After Width: | Height: | Size: 209 B |
|
@ -344,6 +344,7 @@ RebuildIndex.name=Rebuild Index
|
||||||
indexerPage.name = Indexer Page
|
indexerPage.name = Indexer Page
|
||||||
proposalFilter.name = Code Completion Proposal Filter
|
proposalFilter.name = Code Completion Proposal Filter
|
||||||
includeBrowser.name = Include Browser
|
includeBrowser.name = Include Browser
|
||||||
|
callHierarchy.name = Call Hierarchy
|
||||||
cSearchPage.name = CSearchPage
|
cSearchPage.name = CSearchPage
|
||||||
|
|
||||||
# dummy label (not displayed)
|
# dummy label (not displayed)
|
||||||
|
|
|
@ -255,6 +255,12 @@
|
||||||
icon="icons/view16/includeBrowser.gif"
|
icon="icons/view16/includeBrowser.gif"
|
||||||
id="org.eclipse.cdt.ui.includeBrowser"
|
id="org.eclipse.cdt.ui.includeBrowser"
|
||||||
name="%includeBrowser.name"/>
|
name="%includeBrowser.name"/>
|
||||||
|
<view
|
||||||
|
category="org.eclipse.cdt.ui.views"
|
||||||
|
class="org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart"
|
||||||
|
icon="icons/view16/call_hierarchy.gif"
|
||||||
|
id="org.eclipse.cdt.ui.callHierarchy"
|
||||||
|
name="%callHierarchy.name"/>
|
||||||
<!--category
|
<!--category
|
||||||
name="%CBrowsing.viewCategoryName"
|
name="%CBrowsing.viewCategoryName"
|
||||||
id="org.eclipse.cdt.ui.c.browsing">
|
id="org.eclipse.cdt.ui.c.browsing">
|
||||||
|
|
|
@ -193,14 +193,15 @@ public class CPluginImages {
|
||||||
public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif"; //$NON-NLS-1$
|
public static final String IMG_TOOL_GOTO_NEXT_ERROR= NAME_PREFIX + "next_error_nav.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif"; //$NON-NLS-1$
|
public static final String IMG_EDIT_PROPERTIES= NAME_PREFIX + "prop_edt.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String IMG_ACTION_SHOW_FIELDS= NAME_PREFIX + "fields_co.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_HIDE_FIELDS= NAME_PREFIX + "fields_co.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_SHOW_PUBLIC= NAME_PREFIX + "public_co.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_ACTION_SHOW_STATIC= NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_HIDE_STATIC= NAME_PREFIX + "static_co.gif"; //$NON-NLS-1$
|
||||||
|
|
||||||
public static final String IMG_ACTION_SHOW_REF_BY = NAME_PREFIX + "ch_callers.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_SHOW_REF_BY = NAME_PREFIX + "ch_callers.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_ACTION_SHOW_RELATES_TO = NAME_PREFIX + "ch_callees.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_SHOW_RELATES_TO = NAME_PREFIX + "ch_callees.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_ACTION_HIDE_INACTIVE = NAME_PREFIX + "filterInactive.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_HIDE_INACTIVE = NAME_PREFIX + "filterInactive.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_ACTION_HIDE_SYSTEM = NAME_PREFIX + "filterSystem.gif"; //$NON-NLS-1$
|
public static final String IMG_ACTION_HIDE_SYSTEM = NAME_PREFIX + "filterSystem.gif"; //$NON-NLS-1$
|
||||||
|
public static final String IMG_ACTION_HIDE_MACROS = NAME_PREFIX + "filterDefines.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_SHOW_NEXT= NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
|
public static final String IMG_SHOW_NEXT= NAME_PREFIX + "search_next.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_SHOW_PREV= NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
|
public static final String IMG_SHOW_PREV= NAME_PREFIX + "search_prev.gif"; //$NON-NLS-1$
|
||||||
public static final String IMG_REFRESH= NAME_PREFIX + "refresh_nav.gif"; //$NON-NLS-1$
|
public static final String IMG_REFRESH= NAME_PREFIX + "refresh_nav.gif"; //$NON-NLS-1$
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries;
|
||||||
|
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries.IPDOMReference;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the content provider for the call hierarchy.
|
||||||
|
*/
|
||||||
|
public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
|
|
||||||
|
private static final IProgressMonitor NPM = new NullProgressMonitor();
|
||||||
|
private boolean fComputeReferencedBy = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs the content provider.
|
||||||
|
*/
|
||||||
|
public CHContentProvider(Display disp) {
|
||||||
|
super(disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getParent(Object element) {
|
||||||
|
if (element instanceof CHNode) {
|
||||||
|
CHNode node = (CHNode) element;
|
||||||
|
return node.getParent();
|
||||||
|
}
|
||||||
|
return super.getParent(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] syncronouslyComputeChildren(Object parentElement) {
|
||||||
|
if (parentElement instanceof ICElement) {
|
||||||
|
ICElement element = (ICElement) parentElement;
|
||||||
|
return new Object[] { new CHNode(null, null, element, 0) };
|
||||||
|
}
|
||||||
|
if (parentElement instanceof CHNode) {
|
||||||
|
CHNode node = (CHNode) parentElement;
|
||||||
|
if (node.isRecursive() || node.getRepresentedDeclaration() == null) {
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
if (!fComputeReferencedBy && (node.isVariable() || node.isMacro())) {
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// allow for async computation
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] asyncronouslyComputeChildren(Object parentElement,
|
||||||
|
IProgressMonitor monitor) {
|
||||||
|
if (parentElement instanceof CHNode) {
|
||||||
|
CHNode node = (CHNode) parentElement;
|
||||||
|
ICElement elem= node.getRepresentedDeclaration();
|
||||||
|
if (elem != null) {
|
||||||
|
if (fComputeReferencedBy) {
|
||||||
|
return asyncronouslyComputeReferencedBy(node, elem);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return asyncronouslyComputeRefersTo(node, elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] asyncronouslyComputeReferencedBy(CHNode parent, ICElement elem) {
|
||||||
|
try {
|
||||||
|
if (elem instanceof ISourceReference) {
|
||||||
|
ISourceReference sf= (ISourceReference) elem;
|
||||||
|
ISourceRange range = sf.getSourceRange();
|
||||||
|
ITranslationUnit tu = sf.getTranslationUnit();
|
||||||
|
if (tu != null) {
|
||||||
|
ILanguage language = tu.getLanguage();
|
||||||
|
IASTTranslationUnit ast = language.getASTTranslationUnit(tu, ILanguage.AST_SKIP_ALL_HEADERS | ILanguage.AST_USE_INDEX);
|
||||||
|
IASTName[] names = language.getSelectedNames(ast, range.getIdStartPos(), range.getIdLength());
|
||||||
|
if (names.length > 0) {
|
||||||
|
IASTName name= names[names.length-1];
|
||||||
|
IPDOMReference[] refs= CIndexQueries.getInstance().findReferences(tu, name, NPM);
|
||||||
|
HashMap refsPerElement= new HashMap();
|
||||||
|
for (int i = 0; i < refs.length; i++) {
|
||||||
|
IPDOMReference reference = refs[i];
|
||||||
|
ICElement caller= findCaller(reference);
|
||||||
|
if (caller != null) {
|
||||||
|
addToMap(caller, reference, refsPerElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ArrayList result= new ArrayList();
|
||||||
|
for (Iterator iter= refsPerElement.entrySet().iterator(); iter.hasNext(); ) {
|
||||||
|
Map.Entry entry= (Map.Entry) iter.next();
|
||||||
|
ICElement element= (ICElement) entry.getKey();
|
||||||
|
List references= (List) entry.getValue();
|
||||||
|
if (!references.isEmpty()) {
|
||||||
|
IPDOMReference firstRef= (IPDOMReference) references.get(0);
|
||||||
|
CHNode node= new CHNode(parent, new CHReferenceInfo(firstRef.getOffset()),
|
||||||
|
element, firstRef.getTimestamp());
|
||||||
|
Iterator iterator = references.iterator();
|
||||||
|
for (iterator.next(); iterator.hasNext(); ) {
|
||||||
|
IPDOMReference nextRef = (IPDOMReference) iterator.next();
|
||||||
|
node.addReference(new CHReferenceInfo(nextRef.getOffset()));
|
||||||
|
}
|
||||||
|
result.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
}
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement findCaller(IPDOMReference reference) throws CoreException {
|
||||||
|
ITranslationUnit tu= reference.getTranslationUnit();
|
||||||
|
return findCaller(tu, reference.getOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement findCaller(ICElement element, int offset) throws CModelException {
|
||||||
|
// mstodo use position tracker
|
||||||
|
if (element == null || (element instanceof IFunctionDeclaration)) {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
if (element instanceof IParent) {
|
||||||
|
ICElement[] children= ((IParent) element).getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
ICElement child = children[i];
|
||||||
|
if (child instanceof ISourceReference) {
|
||||||
|
ISourceRange sr= ((ISourceReference) child).getSourceRange();
|
||||||
|
int startPos= sr.getStartPos();
|
||||||
|
if (startPos <= offset && offset < startPos + sr.getLength()) {
|
||||||
|
return findCaller(child, offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addToMap(ICElement caller, IPDOMReference reference, Map map) {
|
||||||
|
List list= (List) map.get(caller);
|
||||||
|
if (list == null) {
|
||||||
|
list= new ArrayList();
|
||||||
|
map.put(caller, list);
|
||||||
|
}
|
||||||
|
list.add(reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] asyncronouslyComputeRefersTo(CHNode parent, ICElement elem) {
|
||||||
|
// mstodo Auto-generated method stub
|
||||||
|
return NO_CHILDREN;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setComputeReferencedBy(boolean value) {
|
||||||
|
fComputeReferencedBy = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getComputeReferencedBy() {
|
||||||
|
return fComputeReferencedBy;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.jface.util.LocalSelectionTransfer;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.swt.dnd.DND;
|
||||||
|
import org.eclipse.swt.dnd.DropTargetEvent;
|
||||||
|
import org.eclipse.swt.dnd.DropTargetListener;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
public class CHDropTargetListener implements DropTargetListener {
|
||||||
|
|
||||||
|
private CHViewPart fCallHierarchy;
|
||||||
|
private ICElement fInput;
|
||||||
|
private boolean fEnabled= true;
|
||||||
|
|
||||||
|
public CHDropTargetListener(CHViewPart view) {
|
||||||
|
fCallHierarchy= view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean val) {
|
||||||
|
fEnabled= val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dragEnter(DropTargetEvent event) {
|
||||||
|
fInput= null;
|
||||||
|
checkOperation(event);
|
||||||
|
if (event.detail != DND.DROP_NONE) {
|
||||||
|
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.currentDataType)) {
|
||||||
|
fInput= checkLocalSelection();
|
||||||
|
if (fInput == null) {
|
||||||
|
event.detail= DND.DROP_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ICElement checkLocalSelection() {
|
||||||
|
ISelection sel= LocalSelectionTransfer.getTransfer().getSelection();
|
||||||
|
if (sel instanceof IStructuredSelection) {
|
||||||
|
for (Iterator iter = ((IStructuredSelection)sel).iterator(); iter.hasNext();) {
|
||||||
|
Object element = iter.next();
|
||||||
|
if (element instanceof ICElement) {
|
||||||
|
return (ICElement) element;
|
||||||
|
}
|
||||||
|
if (element instanceof IAdaptable) {
|
||||||
|
ICElement adapter= (ICElement) ((IAdaptable) element).getAdapter(ICElement.class);
|
||||||
|
if (adapter != null) {
|
||||||
|
return adapter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dragLeave(DropTargetEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dragOperationChanged(DropTargetEvent event) {
|
||||||
|
checkOperation(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dragOver(DropTargetEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drop(DropTargetEvent event) {
|
||||||
|
if (fInput == null) {
|
||||||
|
Display.getCurrent().beep();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fCallHierarchy.setInput(fInput);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dropAccept(DropTargetEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkOperation(DropTargetEvent event) {
|
||||||
|
if (fEnabled && (event.operations & DND.DROP_COPY) != 0) {
|
||||||
|
event.detail= DND.DROP_COPY;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.detail= DND.DROP_NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.CElementLabels;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action used for the include browser forward / backward buttons
|
||||||
|
*/
|
||||||
|
public class CHHistoryAction extends Action {
|
||||||
|
|
||||||
|
private CHViewPart fViewPart;
|
||||||
|
private ICElement fElement;
|
||||||
|
|
||||||
|
public CHHistoryAction(CHViewPart viewPart, ICElement element) {
|
||||||
|
super("", AS_RADIO_BUTTON); //$NON-NLS-1$
|
||||||
|
fViewPart= viewPart;
|
||||||
|
fElement= element;
|
||||||
|
|
||||||
|
String elementName= CElementLabels.getElementLabel(element, CElementLabels.ALL_POST_QUALIFIED);
|
||||||
|
setText(elementName);
|
||||||
|
setImageDescriptor(getImageDescriptor(element));
|
||||||
|
}
|
||||||
|
|
||||||
|
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.setInput(fElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.ActionContributionItem;
|
||||||
|
import org.eclipse.jface.action.IMenuCreator;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class CHHistoryDropDownAction extends Action implements IMenuCreator {
|
||||||
|
|
||||||
|
public static class ClearHistoryAction extends Action {
|
||||||
|
|
||||||
|
private CHViewPart fView;
|
||||||
|
|
||||||
|
public ClearHistoryAction(CHViewPart view) {
|
||||||
|
super(CHMessages.CHHistoryDropDownAction_ClearHistory_label);
|
||||||
|
fView= view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
fView.setHistoryEntries(new ICElement[0]);
|
||||||
|
fView.setInput(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final int RESULTS_IN_DROP_DOWN= 10;
|
||||||
|
|
||||||
|
private CHViewPart fHierarchyView;
|
||||||
|
private Menu fMenu;
|
||||||
|
|
||||||
|
public CHHistoryDropDownAction(CHViewPart view) {
|
||||||
|
fHierarchyView= view;
|
||||||
|
fMenu= null;
|
||||||
|
setToolTipText(CHMessages.CHHistoryDropDownAction_ShowHistoryList_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, "history_list.gif"); //$NON-NLS-1$
|
||||||
|
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();
|
||||||
|
addEntries(fMenu, elements);
|
||||||
|
new MenuItem(fMenu, SWT.SEPARATOR);
|
||||||
|
addActionToMenu(fMenu, new CHHistoryListAction(fHierarchyView));
|
||||||
|
addActionToMenu(fMenu, new ClearHistoryAction(fHierarchyView));
|
||||||
|
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++) {
|
||||||
|
CHHistoryAction action= new CHHistoryAction(fHierarchyView, elements[i]);
|
||||||
|
action.setChecked(elements[i].equals(fHierarchyView.getInput()));
|
||||||
|
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 CHHistoryListAction(fHierarchyView)).run();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,183 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.dialogs.StatusDialog;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.jface.window.Window;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
public class CHHistoryListAction extends Action {
|
||||||
|
|
||||||
|
private class HistoryListDialog extends StatusDialog {
|
||||||
|
|
||||||
|
private ListDialogField fHistoryList;
|
||||||
|
private IStatus fHistoryStatus;
|
||||||
|
private ICElement fResult;
|
||||||
|
|
||||||
|
private HistoryListDialog(Shell shell, ICElement[] historyEntries) {
|
||||||
|
super(shell);
|
||||||
|
setHelpAvailable(false);
|
||||||
|
setTitle(CHMessages.CHHistoryListAction_HistoryDialog_title);
|
||||||
|
String[] buttonLabels= new String[] {
|
||||||
|
CHMessages.CHHistoryListAction_Remove_label,
|
||||||
|
};
|
||||||
|
|
||||||
|
IListAdapter adapter= new IListAdapter() {
|
||||||
|
public void customButtonPressed(ListDialogField field, int index) {
|
||||||
|
doCustomButtonPressed();
|
||||||
|
}
|
||||||
|
public void selectionChanged(ListDialogField field) {
|
||||||
|
doSelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doubleClicked(ListDialogField field) {
|
||||||
|
doDoubleClicked();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LabelProvider labelProvider= new CUILabelProvider(CElementLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS);
|
||||||
|
|
||||||
|
fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
|
||||||
|
fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label);
|
||||||
|
fHistoryList.setElements(Arrays.asList(historyEntries));
|
||||||
|
|
||||||
|
ISelection sel;
|
||||||
|
if (historyEntries.length > 0) {
|
||||||
|
sel= new StructuredSelection(historyEntries[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.setFont(parent.getFont());
|
||||||
|
|
||||||
|
inner.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
|
LayoutUtil.doDefaultLayout(inner, new DialogField[] { fHistoryList }, true, 0, 0);
|
||||||
|
LayoutUtil.setHeightHint(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);
|
||||||
|
// PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, ...);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.jface.window.Window#create()
|
||||||
|
*/
|
||||||
|
public void create() {
|
||||||
|
setShellStyle(getShellStyle() | SWT.RESIZE);
|
||||||
|
super.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private CHViewPart fView;
|
||||||
|
|
||||||
|
public CHHistoryListAction(CHViewPart view) {
|
||||||
|
fView= view;
|
||||||
|
setText(CHMessages.CHHistoryListAction_OpenHistory_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IAction#run()
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
ICElement[] historyEntries= fView.getHistoryEntries();
|
||||||
|
HistoryListDialog dialog= new HistoryListDialog(fView.getSite().getShell(), historyEntries);
|
||||||
|
if (dialog.open() == Window.OK) {
|
||||||
|
fView.setHistoryEntries(dialog.getRemaining());
|
||||||
|
fView.setInput(dialog.getResult());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.viewers.IColorProvider;
|
||||||
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
|
import org.eclipse.swt.graphics.Color;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.ui.CElementImageDescriptor;
|
||||||
|
import org.eclipse.cdt.ui.CElementLabelProvider;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.ImageImageDescriptor;
|
||||||
|
|
||||||
|
public class CHLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
|
private CElementLabelProvider fCLabelProvider= new CElementLabelProvider(CElementLabelProvider.SHOW_PARAMETERS);
|
||||||
|
// private Color fColorInactive;
|
||||||
|
private CHContentProvider fContentProvider;
|
||||||
|
private HashMap fCachedImages= new HashMap();
|
||||||
|
private boolean fShowFiles;
|
||||||
|
|
||||||
|
public CHLabelProvider(Display display, CHContentProvider cp) {
|
||||||
|
// fColorInactive= display.getSystemColor(SWT.COLOR_DARK_GRAY);
|
||||||
|
fContentProvider= cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image getImage(Object element) {
|
||||||
|
if (element instanceof CHNode) {
|
||||||
|
CHNode node= (CHNode) element;
|
||||||
|
ICElement decl= node.getRepresentedDeclaration();
|
||||||
|
if (decl != null) {
|
||||||
|
Image image= fCLabelProvider.getImage(decl);
|
||||||
|
return decorateImage(image, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getImage(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getText(Object element) {
|
||||||
|
if (element instanceof CHNode) {
|
||||||
|
CHNode node= (CHNode) element;
|
||||||
|
ICElement decl= node.getRepresentedDeclaration();
|
||||||
|
if (decl != null) {
|
||||||
|
String text= fCLabelProvider.getText(decl);
|
||||||
|
if (fShowFiles) {
|
||||||
|
// mstodo append filenames
|
||||||
|
// ICElement tu= null;
|
||||||
|
// while (tu == null && decl != null) {
|
||||||
|
// if (decl instanceof ITranslationUnit) {
|
||||||
|
// tu= decl;
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// decl= decl.getParent();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (tu != null) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.getText(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
fCLabelProvider.dispose();
|
||||||
|
for (Iterator iter = fCachedImages.values().iterator(); iter.hasNext();) {
|
||||||
|
Image image = (Image) iter.next();
|
||||||
|
image.dispose();
|
||||||
|
}
|
||||||
|
fCachedImages.clear();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image decorateImage(Image image, CHNode node) {
|
||||||
|
int flags= 0;
|
||||||
|
if (node.isRecursive()) {
|
||||||
|
flags |= CElementImageDescriptor.RECURSIVE_RELATION;
|
||||||
|
}
|
||||||
|
else if (fContentProvider.hasChildren(node)) {
|
||||||
|
if (fContentProvider.getComputeReferencedBy()) {
|
||||||
|
flags |= CElementImageDescriptor.REFERENCED_BY;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
flags |= CElementImageDescriptor.RELATES_TO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (node.getRepresentedTranslationUnit() == null) {
|
||||||
|
// flags |= CElementImageDescriptor.WARNING;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (flags == 0) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
String key= image.toString()+String.valueOf(flags);
|
||||||
|
Image result= (Image) fCachedImages.get(key);
|
||||||
|
if (result == null) {
|
||||||
|
ImageDescriptor desc= new CElementImageDescriptor(
|
||||||
|
new ImageImageDescriptor(image), flags, new Point(20,16));
|
||||||
|
result= desc.createImage();
|
||||||
|
fCachedImages.put(key, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getBackground(Object element) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getForeground(Object element) {
|
||||||
|
// if (element instanceof CHNode) {
|
||||||
|
// CHNode node= (CHNode) element;
|
||||||
|
// if (!node.isActiveCode()) {
|
||||||
|
// return fColorInactive;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowFiles(boolean show) {
|
||||||
|
fShowFiles= show;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
public class CHMessages extends NLS {
|
||||||
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.callhierarchy.CHMessages"; //$NON-NLS-1$
|
||||||
|
public static String CHHistoryListAction_HistoryDialog_title;
|
||||||
|
public static String CHHistoryListAction_HistoryList_label;
|
||||||
|
public static String CHHistoryListAction_OpenHistory_label;
|
||||||
|
public static String CHHistoryListAction_Remove_label;
|
||||||
|
public static String CHViewPart_emptyPageMessage;
|
||||||
|
public static String CHViewPart_FilterVariables_label;
|
||||||
|
public static String CHViewPart_FilterVariables_tooltip;
|
||||||
|
public static String CHViewPart_HideMacros_label;
|
||||||
|
public static String CHViewPart_HideMacros_tooltip;
|
||||||
|
public static String CHViewPart_NextReference_label;
|
||||||
|
public static String CHViewPart_NextReference_tooltip;
|
||||||
|
public static String CHViewPart_OpenReference_label;
|
||||||
|
public static String CHViewPart_PreviousReference_label;
|
||||||
|
public static String CHViewPart_PreviousReference_tooltip;
|
||||||
|
public static String CHViewPart_Refresh_label;
|
||||||
|
public static String CHViewPart_Refresh_tooltip;
|
||||||
|
public static String CHViewPart_ShowCallees_label;
|
||||||
|
public static String CHViewPart_ShowCallees_tooltip;
|
||||||
|
public static String CHViewPart_ShowCallers_label;
|
||||||
|
public static String CHViewPart_ShowCallers_tooltip;
|
||||||
|
public static String CHViewPart_ShowFiles_label;
|
||||||
|
public static String CHViewPart_ShowFiles_tooltip;
|
||||||
|
public static String CHViewPart_Title_callees;
|
||||||
|
public static String CHViewPart_Title_callers;
|
||||||
|
public static String CHViewPart_WorkspaceScope;
|
||||||
|
public static String CHHistoryDropDownAction_ClearHistory_label;
|
||||||
|
public static String CHHistoryDropDownAction_ShowHistoryList_tooltip;
|
||||||
|
public static String OpenCallHierarchyAction_label;
|
||||||
|
public static String OpenCallHierarchyAction_tooltip;
|
||||||
|
static {
|
||||||
|
// initialize resource bundle
|
||||||
|
NLS.initializeMessages(BUNDLE_NAME, CHMessages.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CHMessages() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
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
|
||||||
|
CHViewPart_ShowCallees_label=Show Callees
|
||||||
|
CHViewPart_ShowCallees_tooltip=Show Callees
|
||||||
|
CHViewPart_FilterVariables_label=Filter Variables
|
||||||
|
CHViewPart_FilterVariables_tooltip=Hide Variables, Constents and Enumerators
|
||||||
|
CHViewPart_HideMacros_label=Hide Macros
|
||||||
|
CHViewPart_HideMacros_tooltip=Hides Macros
|
||||||
|
CHViewPart_ShowFiles_label=Show Files
|
||||||
|
CHViewPart_ShowFiles_tooltip=Show Files
|
||||||
|
CHViewPart_NextReference_label=Next Reference
|
||||||
|
CHViewPart_NextReference_tooltip=Show Next Reference
|
||||||
|
CHHistoryListAction_Remove_label=Remove
|
||||||
|
CHViewPart_PreviousReference_label=Previous Reference
|
||||||
|
CHViewPart_PreviousReference_tooltip=Show Previous Reference
|
||||||
|
CHViewPart_Refresh_label=Refresh
|
||||||
|
CHViewPart_Refresh_tooltip=Refresh View Content
|
||||||
|
CHViewPart_WorkspaceScope=workspace
|
||||||
|
CHViewPart_Title_callers=Callers of {0} - in {1}
|
||||||
|
CHViewPart_Title_callees=Calls made by {0} - in {1}
|
||||||
|
CHViewPart_OpenReference_label=Open Reference
|
||||||
|
CHHistoryDropDownAction_ClearHistory_label=Clear History
|
||||||
|
CHHistoryListAction_HistoryDialog_title=Call Hierarchy History
|
||||||
|
CHHistoryListAction_HistoryList_label=Select the input for the Call Hierarchy:
|
||||||
|
CHHistoryListAction_OpenHistory_label=Open History...
|
||||||
|
CHHistoryDropDownAction_ShowHistoryList_tooltip=Show History List
|
||||||
|
OpenCallHierarchyAction_label=Open Call H&ierarchy (work in progress)
|
||||||
|
OpenCallHierarchyAction_tooltip=Open Call Hierarchy (work in progress)
|
|
@ -0,0 +1,129 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.IMacro;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a node in the include browser
|
||||||
|
*/
|
||||||
|
public class CHNode {
|
||||||
|
private CHNode fParent;
|
||||||
|
private ICElement fRepresentedDecl;
|
||||||
|
private List fReferences;
|
||||||
|
|
||||||
|
private int fHashCode;
|
||||||
|
private boolean fIsRecursive;
|
||||||
|
private long fTimestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new node for the include browser
|
||||||
|
*/
|
||||||
|
public CHNode(CHNode parent, CHReferenceInfo reference, ICElement decl, long timestamp) {
|
||||||
|
assert decl != null;
|
||||||
|
fParent= parent;
|
||||||
|
fReferences= Collections.singletonList(reference);
|
||||||
|
fRepresentedDecl= decl;
|
||||||
|
fIsRecursive= computeIsRecursive(fParent, decl);
|
||||||
|
fHashCode= computeHashCode();
|
||||||
|
fTimestamp= timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int computeHashCode() {
|
||||||
|
int hashCode= 0;
|
||||||
|
if (fParent != null) {
|
||||||
|
hashCode= fParent.hashCode() * 31;
|
||||||
|
}
|
||||||
|
hashCode+= fRepresentedDecl.hashCode();
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return fHashCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof CHNode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CHNode rhs = (CHNode) o;
|
||||||
|
if (fHashCode != rhs.fHashCode) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fRepresentedDecl.equals(rhs.fRepresentedDecl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean computeIsRecursive(CHNode parent, ICElement decl) {
|
||||||
|
if (parent == null || decl == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (decl.equals(parent.getRepresentedDeclaration())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return computeIsRecursive(parent.fParent, decl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the parent node or <code>null</code> for the root node.
|
||||||
|
*/
|
||||||
|
public CHNode getParent() {
|
||||||
|
return fParent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isRecursive() {
|
||||||
|
return fIsRecursive;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getReferenceCount() {
|
||||||
|
return fReferences.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CHReferenceInfo getReference(int idx) {
|
||||||
|
return (CHReferenceInfo) fReferences.get(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICElement getRepresentedDeclaration() {
|
||||||
|
return fRepresentedDecl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTimestamp() {
|
||||||
|
return fTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMacro() {
|
||||||
|
return fRepresentedDecl instanceof IMacro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVariable() {
|
||||||
|
return fRepresentedDecl instanceof IVariableDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFirstReferenceOffset() {
|
||||||
|
return fReferences.isEmpty() ? -1 : getReference(0).getOffset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addReference(CHReferenceInfo info) {
|
||||||
|
if (fReferences.size() == 1) {
|
||||||
|
fReferences= new ArrayList(fReferences);
|
||||||
|
}
|
||||||
|
fReferences.add(info);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
public class CHReferenceInfo {
|
||||||
|
private int fOffset;
|
||||||
|
|
||||||
|
public CHReferenceInfo(int offset) {
|
||||||
|
fOffset= offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return fOffset;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,671 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.action.IMenuListener;
|
||||||
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
|
import org.eclipse.jface.action.MenuManager;
|
||||||
|
import org.eclipse.jface.action.Separator;
|
||||||
|
import org.eclipse.jface.util.LocalSelectionTransfer;
|
||||||
|
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.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerComparator;
|
||||||
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
|
import org.eclipse.search.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.dnd.DND;
|
||||||
|
import org.eclipse.swt.dnd.DropTarget;
|
||||||
|
import org.eclipse.swt.dnd.Transfer;
|
||||||
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
|
import org.eclipse.ui.IActionBars;
|
||||||
|
import org.eclipse.ui.IMemento;
|
||||||
|
import org.eclipse.ui.IViewSite;
|
||||||
|
import org.eclipse.ui.IWorkbenchPartSite;
|
||||||
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.actions.ActionFactory;
|
||||||
|
import org.eclipse.ui.part.PageBook;
|
||||||
|
import org.eclipse.ui.part.ShowInContext;
|
||||||
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.CoreUtility;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The view part for the include browser.
|
||||||
|
*/
|
||||||
|
public class CHViewPart extends ViewPart {
|
||||||
|
private static final int MAX_HISTORY_SIZE = 10;
|
||||||
|
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_FILTER_VARIABLES = "variableFilter"; //$NON-NLS-1$
|
||||||
|
private static final String KEY_FILTER_MACROS = "macroFilter"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private IMemento fMemento;
|
||||||
|
private boolean fShowsMessage;
|
||||||
|
private CHNode fLastNavigationNode;
|
||||||
|
private ArrayList fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE);
|
||||||
|
|
||||||
|
// widgets
|
||||||
|
private PageBook fPagebook;
|
||||||
|
private Composite fViewerPage;
|
||||||
|
private Composite fInfoPage;
|
||||||
|
private Text fInfoText;
|
||||||
|
|
||||||
|
// treeviewer
|
||||||
|
private CHContentProvider fContentProvider;
|
||||||
|
private CHLabelProvider fLabelProvider;
|
||||||
|
private ExtendedTreeViewer fTreeViewer;
|
||||||
|
|
||||||
|
// filters, sorter
|
||||||
|
private CHWorkingSetFilter fWorkingSetFilter;
|
||||||
|
private ViewerFilter fVariableFilter;
|
||||||
|
private ViewerFilter fMacroFilter;
|
||||||
|
private ViewerComparator fSorterAlphaNumeric;
|
||||||
|
private ViewerComparator fSorterReferencePosition;
|
||||||
|
|
||||||
|
// actions
|
||||||
|
private Action fReferencedByAction;
|
||||||
|
private Action fMakesReferenceToAction;
|
||||||
|
private Action fFilterVariablesAction;
|
||||||
|
private Action fFilterMacrosAction;
|
||||||
|
private Action fShowFilesInLabelsAction;
|
||||||
|
private Action fNextAction;
|
||||||
|
private Action fPreviousAction;
|
||||||
|
private Action fRefreshAction;
|
||||||
|
private Action fHistoryAction;
|
||||||
|
|
||||||
|
|
||||||
|
public void setFocus() {
|
||||||
|
fPagebook.setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String msg) {
|
||||||
|
fInfoText.setText(msg);
|
||||||
|
fPagebook.showPage(fInfoPage);
|
||||||
|
fShowsMessage= true;
|
||||||
|
updateDescription();
|
||||||
|
updateActionEnablement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInput(ICElement input) {
|
||||||
|
if (input == null) {
|
||||||
|
setMessage(CHMessages.CHViewPart_emptyPageMessage);
|
||||||
|
fTreeViewer.setInput(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fShowsMessage= false;
|
||||||
|
// boolean isHeader= false;
|
||||||
|
// String contentType= input.getContentTypeId();
|
||||||
|
// if (contentType.equals(CCorePlugin.CONTENT_TYPE_CXXHEADER) ||
|
||||||
|
// contentType.equals(CCorePlugin.CONTENT_TYPE_CHEADER)) {
|
||||||
|
// isHeader= true;
|
||||||
|
// }
|
||||||
|
fTreeViewer.setInput(null);
|
||||||
|
// if (!isHeader) {
|
||||||
|
// fContentProvider.setComputeIncludedBy(isHeader);
|
||||||
|
// fIncludedByAction.setChecked(isHeader);
|
||||||
|
// fIncludesToAction.setChecked(!isHeader);
|
||||||
|
// updateSorter();
|
||||||
|
// }
|
||||||
|
fTreeViewer.setInput(input);
|
||||||
|
fPagebook.showPage(fViewerPage);
|
||||||
|
updateDescription();
|
||||||
|
updateHistory(input);
|
||||||
|
updateActionEnablement();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createPartControl(Composite parent) {
|
||||||
|
fPagebook = new PageBook(parent, SWT.NULL);
|
||||||
|
fPagebook.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
createInfoPage();
|
||||||
|
createViewerPage();
|
||||||
|
|
||||||
|
initDragAndDrop();
|
||||||
|
createActions();
|
||||||
|
createContextMenu();
|
||||||
|
|
||||||
|
getSite().setSelectionProvider(fTreeViewer);
|
||||||
|
setMessage(CHMessages.CHViewPart_emptyPageMessage);
|
||||||
|
|
||||||
|
initializeActionStates();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeActionStates() {
|
||||||
|
boolean referencedBy= true;
|
||||||
|
boolean filterVariables= false;
|
||||||
|
boolean filterMacros= false;
|
||||||
|
|
||||||
|
if (fMemento != null) {
|
||||||
|
filterVariables= TRUE.equals(fMemento.getString(KEY_FILTER_VARIABLES));
|
||||||
|
filterMacros= TRUE.equals(fMemento.getString(KEY_FILTER_MACROS));
|
||||||
|
}
|
||||||
|
|
||||||
|
fReferencedByAction.setChecked(referencedBy);
|
||||||
|
fMakesReferenceToAction.setChecked(!referencedBy);
|
||||||
|
fContentProvider.setComputeReferencedBy(referencedBy);
|
||||||
|
|
||||||
|
fFilterMacrosAction.setChecked(filterMacros);
|
||||||
|
fFilterMacrosAction.run();
|
||||||
|
fFilterVariablesAction.setChecked(filterVariables);
|
||||||
|
fFilterVariablesAction.run();
|
||||||
|
updateSorter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(IViewSite site, IMemento memento) throws PartInitException {
|
||||||
|
fMemento= memento;
|
||||||
|
super.init(site, memento);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void saveState(IMemento memento) {
|
||||||
|
if (fWorkingSetFilter != null) {
|
||||||
|
fWorkingSetFilter.getUI().saveState(memento, KEY_WORKING_SET_FILTER);
|
||||||
|
}
|
||||||
|
memento.putString(KEY_FILTER_MACROS, String.valueOf(fFilterMacrosAction.isChecked()));
|
||||||
|
memento.putString(KEY_FILTER_VARIABLES, String.valueOf(fFilterVariablesAction.isChecked()));
|
||||||
|
super.saveState(memento);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createContextMenu() {
|
||||||
|
MenuManager manager = new MenuManager();
|
||||||
|
manager.setRemoveAllWhenShown(true);
|
||||||
|
manager.addMenuListener(new IMenuListener() {
|
||||||
|
public void menuAboutToShow(IMenuManager m) {
|
||||||
|
onContextMenuAboutToShow(m);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Menu menu = manager.createContextMenu(fTreeViewer.getControl());
|
||||||
|
fTreeViewer.getControl().setMenu(menu);
|
||||||
|
IWorkbenchPartSite site = getSite();
|
||||||
|
site.registerContextMenu(CUIPlugin.ID_CALL_HIERARCHY, manager, fTreeViewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createViewerPage() {
|
||||||
|
Display display= getSite().getShell().getDisplay();
|
||||||
|
fViewerPage = new Composite(fPagebook, SWT.NULL);
|
||||||
|
fViewerPage.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
fViewerPage.setSize(100, 100);
|
||||||
|
fViewerPage.setLayout(new FillLayout());
|
||||||
|
|
||||||
|
fContentProvider= new CHContentProvider(display);
|
||||||
|
fLabelProvider= new CHLabelProvider(display, fContentProvider);
|
||||||
|
fTreeViewer= new ExtendedTreeViewer(fViewerPage);
|
||||||
|
fTreeViewer.setContentProvider(fContentProvider);
|
||||||
|
fTreeViewer.setLabelProvider(fLabelProvider);
|
||||||
|
fTreeViewer.setAutoExpandLevel(2);
|
||||||
|
fTreeViewer.addOpenListener(new IOpenListener() {
|
||||||
|
public void open(OpenEvent event) {
|
||||||
|
onShowReference(event.getSelection());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createInfoPage() {
|
||||||
|
fInfoPage = new Composite(fPagebook, SWT.NULL);
|
||||||
|
fInfoPage.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
fInfoPage.setSize(100, 100);
|
||||||
|
fInfoPage.setLayout(new FillLayout());
|
||||||
|
|
||||||
|
fInfoText= new Text(fInfoPage, SWT.WRAP | SWT.READ_ONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initDragAndDrop() {
|
||||||
|
CHDropTargetListener dropListener= new CHDropTargetListener(this);
|
||||||
|
Transfer[] localSelectionTransfer= new Transfer[] {
|
||||||
|
LocalSelectionTransfer.getTransfer()
|
||||||
|
};
|
||||||
|
DropTarget dropTarget = new DropTarget(fPagebook, DND.DROP_COPY);
|
||||||
|
dropTarget.setTransfer(localSelectionTransfer);
|
||||||
|
dropTarget.addDropListener(dropListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createActions() {
|
||||||
|
WorkingSetFilterUI wsFilterUI= new WorkingSetFilterUI(this, fMemento, KEY_WORKING_SET_FILTER) {
|
||||||
|
protected void onWorkingSetChange() {
|
||||||
|
updateWorkingSetFilter(this);
|
||||||
|
}
|
||||||
|
protected void onWorkingSetNameChange() {
|
||||||
|
updateDescription();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fReferencedByAction=
|
||||||
|
new Action(CHMessages.CHViewPart_ShowCallers_label, IAction.AS_RADIO_BUTTON) {
|
||||||
|
public void run() {
|
||||||
|
if (isChecked()) {
|
||||||
|
onSetShowReferencedBy(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fReferencedByAction.setToolTipText(CHMessages.CHViewPart_ShowCallers_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fReferencedByAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_REF_BY);
|
||||||
|
|
||||||
|
fMakesReferenceToAction=
|
||||||
|
new Action(CHMessages.CHViewPart_ShowCallees_label, IAction.AS_RADIO_BUTTON) {
|
||||||
|
public void run() {
|
||||||
|
if (isChecked()) {
|
||||||
|
onSetShowReferencedBy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fMakesReferenceToAction.setToolTipText(CHMessages.CHViewPart_ShowCallees_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fMakesReferenceToAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_RELATES_TO);
|
||||||
|
|
||||||
|
fVariableFilter= new ViewerFilter() {
|
||||||
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
|
if (element instanceof CHNode) {
|
||||||
|
CHNode node= (CHNode) element;
|
||||||
|
return !node.isVariable();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fFilterVariablesAction= new Action(CHMessages.CHViewPart_FilterVariables_label, IAction.AS_CHECK_BOX) {
|
||||||
|
public void run() {
|
||||||
|
if (isChecked()) {
|
||||||
|
fTreeViewer.addFilter(fVariableFilter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fTreeViewer.removeFilter(fVariableFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fFilterVariablesAction.setToolTipText(CHMessages.CHViewPart_FilterVariables_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fFilterVariablesAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
|
||||||
|
|
||||||
|
fMacroFilter= new ViewerFilter() {
|
||||||
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
|
if (element instanceof CHNode) {
|
||||||
|
CHNode node= (CHNode) element;
|
||||||
|
return !node.isMacro();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fFilterMacrosAction= new Action(CHMessages.CHViewPart_HideMacros_label, IAction.AS_CHECK_BOX) {
|
||||||
|
public void run() {
|
||||||
|
if (isChecked()) {
|
||||||
|
fTreeViewer.addFilter(fMacroFilter);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fTreeViewer.removeFilter(fMacroFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fFilterMacrosAction.setToolTipText(CHMessages.CHViewPart_HideMacros_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fFilterMacrosAction, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_MACROS);
|
||||||
|
|
||||||
|
fSorterAlphaNumeric= new ViewerComparator();
|
||||||
|
fSorterReferencePosition= new ViewerComparator() {
|
||||||
|
public int category(Object element) {
|
||||||
|
if (element instanceof CHNode) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
public int compare(Viewer viewer, Object e1, Object e2) {
|
||||||
|
if (!(e1 instanceof CHNode)) {
|
||||||
|
if (!(e2 instanceof CHNode)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (!(e2 instanceof CHNode)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
CHNode n1= (CHNode) e1;
|
||||||
|
CHNode n2= (CHNode) e2;
|
||||||
|
int offset1= n1.getFirstReferenceOffset();
|
||||||
|
int offset2= n2.getFirstReferenceOffset();
|
||||||
|
return CoreUtility.compare(offset1, offset2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fShowFilesInLabelsAction= new Action(CHMessages.CHViewPart_ShowFiles_label, IAction.AS_CHECK_BOX) {
|
||||||
|
public void run() {
|
||||||
|
onShowFilesInLabels(isChecked());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fShowFilesInLabelsAction.setToolTipText(CHMessages.CHViewPart_ShowFiles_tooltip);
|
||||||
|
fNextAction = new Action(CHMessages.CHViewPart_NextReference_label) {
|
||||||
|
public void run() {
|
||||||
|
onNextOrPrevious(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fNextAction.setToolTipText(CHMessages.CHViewPart_NextReference_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fNextAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_NEXT);
|
||||||
|
|
||||||
|
fPreviousAction = new Action(CHMessages.CHViewPart_PreviousReference_label) {
|
||||||
|
public void run() {
|
||||||
|
onNextOrPrevious(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fPreviousAction.setToolTipText(CHMessages.CHViewPart_PreviousReference_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fPreviousAction, CPluginImages.T_LCL, CPluginImages.IMG_SHOW_PREV);
|
||||||
|
|
||||||
|
fRefreshAction = new Action(CHMessages.CHViewPart_Refresh_label) {
|
||||||
|
public void run() {
|
||||||
|
onRefresh();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fRefreshAction.setToolTipText(CHMessages.CHViewPart_Refresh_tooltip);
|
||||||
|
CPluginImages.setImageDescriptors(fRefreshAction, CPluginImages.T_LCL, CPluginImages.IMG_REFRESH);
|
||||||
|
|
||||||
|
fHistoryAction = new CHHistoryDropDownAction(this);
|
||||||
|
|
||||||
|
// setup action bar
|
||||||
|
// global action hooks
|
||||||
|
IActionBars actionBars = getViewSite().getActionBars();
|
||||||
|
actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAction);
|
||||||
|
actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAction);
|
||||||
|
actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fRefreshAction);
|
||||||
|
actionBars.updateActionBars();
|
||||||
|
|
||||||
|
// local toolbar
|
||||||
|
IToolBarManager tm = actionBars.getToolBarManager();
|
||||||
|
tm.add(fNextAction);
|
||||||
|
tm.add(fPreviousAction);
|
||||||
|
tm.add(new Separator());
|
||||||
|
tm.add(fFilterMacrosAction);
|
||||||
|
tm.add(fFilterVariablesAction);
|
||||||
|
tm.add(new Separator());
|
||||||
|
tm.add(fReferencedByAction);
|
||||||
|
tm.add(fMakesReferenceToAction);
|
||||||
|
tm.add(fHistoryAction);
|
||||||
|
tm.add(fRefreshAction);
|
||||||
|
|
||||||
|
// local menu
|
||||||
|
IMenuManager mm = actionBars.getMenuManager();
|
||||||
|
|
||||||
|
// tm.add(fNext);
|
||||||
|
// tm.add(fPrevious);
|
||||||
|
// tm.add(new Separator());
|
||||||
|
wsFilterUI.fillActionBars(actionBars);
|
||||||
|
mm.add(fReferencedByAction);
|
||||||
|
mm.add(fMakesReferenceToAction);
|
||||||
|
mm.add(new Separator());
|
||||||
|
mm.add(fShowFilesInLabelsAction);
|
||||||
|
mm.add(new Separator());
|
||||||
|
mm.add(fFilterMacrosAction);
|
||||||
|
mm.add(fFilterVariablesAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private CHNode getNextNode(boolean forward) {
|
||||||
|
TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
|
||||||
|
TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedItem.getData().equals(fLastNavigationNode)) {
|
||||||
|
selectedItem= navigator.getNextSibbling(selectedItem, forward);
|
||||||
|
}
|
||||||
|
|
||||||
|
return selectedItem == null ? null : (CHNode) selectedItem.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onNextOrPrevious(boolean forward) {
|
||||||
|
CHNode nextItem= getNextNode(forward);
|
||||||
|
if (nextItem != null) {
|
||||||
|
StructuredSelection sel= new StructuredSelection(nextItem);
|
||||||
|
fTreeViewer.setSelection(sel);
|
||||||
|
onShowReference(sel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onRefresh() {
|
||||||
|
fContentProvider.recompute();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onShowFilesInLabels(boolean show) {
|
||||||
|
fLabelProvider.setShowFiles(show);
|
||||||
|
fTreeViewer.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateHistory(ICElement input) {
|
||||||
|
if (input != null) {
|
||||||
|
fHistoryEntries.remove(input);
|
||||||
|
fHistoryEntries.add(0, input);
|
||||||
|
if (fHistoryEntries.size() > MAX_HISTORY_SIZE) {
|
||||||
|
fHistoryEntries.remove(MAX_HISTORY_SIZE-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSorter() {
|
||||||
|
if (fReferencedByAction.isChecked()) {
|
||||||
|
fTreeViewer.setComparator(fSorterAlphaNumeric);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fTreeViewer.setComparator(fSorterReferencePosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDescription() {
|
||||||
|
String message= ""; //$NON-NLS-1$
|
||||||
|
if (!fShowsMessage) {
|
||||||
|
ITranslationUnit tu= getInput();
|
||||||
|
if (tu != null) {
|
||||||
|
IPath path= tu.getPath();
|
||||||
|
if (path != null) {
|
||||||
|
String format, file, scope;
|
||||||
|
|
||||||
|
file= path.lastSegment() + "(" + path.removeLastSegments(1) + ")"; //$NON-NLS-1$//$NON-NLS-2$
|
||||||
|
if (fWorkingSetFilter == null) {
|
||||||
|
scope= CHMessages.CHViewPart_WorkspaceScope;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
scope= fWorkingSetFilter.getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fReferencedByAction.isChecked()) {
|
||||||
|
format= CHMessages.CHViewPart_Title_callers;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
format= CHMessages.CHViewPart_Title_callees;
|
||||||
|
}
|
||||||
|
message= Messages.format(format, file, scope);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message= "The Call Hierarchy is work in progress! - " + message; //$NON-NLS-1$
|
||||||
|
setContentDescription(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateActionEnablement() {
|
||||||
|
fHistoryAction.setEnabled(!fHistoryEntries.isEmpty());
|
||||||
|
fNextAction.setEnabled(!fShowsMessage);
|
||||||
|
fPreviousAction.setEnabled(!fShowsMessage);
|
||||||
|
fRefreshAction.setEnabled(!fShowsMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWorkingSetFilter(WorkingSetFilterUI filterUI) {
|
||||||
|
if (filterUI.getWorkingSet() == null) {
|
||||||
|
if (fWorkingSetFilter != null) {
|
||||||
|
fTreeViewer.removeFilter(fWorkingSetFilter);
|
||||||
|
fWorkingSetFilter= null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (fWorkingSetFilter != null) {
|
||||||
|
fTreeViewer.refresh();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fWorkingSetFilter= new CHWorkingSetFilter(filterUI);
|
||||||
|
fTreeViewer.addFilter(fWorkingSetFilter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onSetShowReferencedBy(boolean showReferencedBy) {
|
||||||
|
if (showReferencedBy != fContentProvider.getComputeReferencedBy()) {
|
||||||
|
Object input= fTreeViewer.getInput();
|
||||||
|
fTreeViewer.setInput(null);
|
||||||
|
fContentProvider.setComputeReferencedBy(showReferencedBy);
|
||||||
|
updateSorter();
|
||||||
|
fTreeViewer.setInput(input);
|
||||||
|
updateDescription();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onContextMenuAboutToShow(IMenuManager m) {
|
||||||
|
// final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
|
||||||
|
// final CHNode node= IBConversions.selectionToNode(selection);
|
||||||
|
//
|
||||||
|
// if (node != null) {
|
||||||
|
// // open reference
|
||||||
|
// if (node.getParent() != null && node.getDirectiveFile() != null) {
|
||||||
|
// m.add(new Action(CHMessages.CHViewPart_OpenReference_label) {
|
||||||
|
// public void run() {
|
||||||
|
// onShowReference(selection);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// support for opening the function/method
|
||||||
|
// final ITranslationUnit tu= node.getRepresentedTranslationUnit();
|
||||||
|
// if (tu != null) {
|
||||||
|
// // open
|
||||||
|
// OpenFileAction ofa= new OpenFileAction(page);
|
||||||
|
// ofa.selectionChanged(selection);
|
||||||
|
// m.add(ofa);
|
||||||
|
//
|
||||||
|
// // open with
|
||||||
|
// // keep the menu shorter, no open with support
|
||||||
|
//// final IResource r= tu.getResource();
|
||||||
|
//// if (r != null) {
|
||||||
|
//// IMenuManager submenu= new MenuManager(IBMessages.IBViewPart_OpenWithMenu_label);
|
||||||
|
//// submenu.add(new OpenWithMenu(page, r));
|
||||||
|
//// m.add(submenu);
|
||||||
|
//// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onShowReference(ISelection selection) {
|
||||||
|
// CHNode node= IBConversions.selectionToNode(selection);
|
||||||
|
// if (node != null) {
|
||||||
|
// IWorkbenchPage page= getSite().getPage();
|
||||||
|
// IBFile ibf= node.getDirectiveFile();
|
||||||
|
// long timestamp= node.getTimestamp();
|
||||||
|
// if (ibf != null) {
|
||||||
|
// IEditorPart editor= null;
|
||||||
|
// IPath filebufferKey= null;
|
||||||
|
// IFile f= ibf.getResource();
|
||||||
|
// if (f != null) {
|
||||||
|
// if (timestamp == 0) {
|
||||||
|
// timestamp= f.getLocalTimeStamp();
|
||||||
|
// }
|
||||||
|
// fLastNavigationNode= node;
|
||||||
|
// try {
|
||||||
|
// editor= IDE.openEditor(page, f, false);
|
||||||
|
// filebufferKey= f.getFullPath();
|
||||||
|
// } catch (PartInitException e) {
|
||||||
|
// CUIPlugin.getDefault().log(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// IPath location= ibf.getLocation();
|
||||||
|
// if (location != null) {
|
||||||
|
// if (timestamp == 0) {
|
||||||
|
// timestamp= location.toFile().lastModified();
|
||||||
|
// }
|
||||||
|
// fLastNavigationNode= node;
|
||||||
|
// ExternalEditorInput ei= new ExternalEditorInput(new FileStorage(null, location));
|
||||||
|
// try {
|
||||||
|
// IEditorDescriptor descriptor = IDE.getEditorDescriptor(location.lastSegment());
|
||||||
|
// editor= IDE.openEditor(page, ei, descriptor.getId(), false);
|
||||||
|
// filebufferKey= location;
|
||||||
|
// } catch (PartInitException e) {
|
||||||
|
// CUIPlugin.getDefault().log(e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if (editor instanceof ITextEditor) {
|
||||||
|
// ITextEditor te= (ITextEditor) editor;
|
||||||
|
// Position pos= new Position(node.getDirectiveCharacterOffset(),
|
||||||
|
// node.getDirectiveName().length() + 2);
|
||||||
|
// if (filebufferKey != null) {
|
||||||
|
// IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(filebufferKey, timestamp);
|
||||||
|
// if (pc != null) {
|
||||||
|
// pos= pc.historicToActual(pos);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// te.selectAndReveal(pos.getOffset(), pos.getLength());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// ITranslationUnit tu= IBConversions.selectionToTU(selection);
|
||||||
|
// if (tu != null) {
|
||||||
|
// IResource r= tu.getResource();
|
||||||
|
// if (r != null) {
|
||||||
|
// OpenFileAction ofa= new OpenFileAction(page);
|
||||||
|
// ofa.selectionChanged((IStructuredSelection) selection);
|
||||||
|
// ofa.run();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShowInContext getShowInContext() {
|
||||||
|
return new ShowInContext(null, fTreeViewer.getSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Control getPageBook() {
|
||||||
|
return fPagebook;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICElement[] getHistoryEntries() {
|
||||||
|
return (ICElement[]) fHistoryEntries.toArray(new ICElement[fHistoryEntries.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHistoryEntries(ICElement[] remaining) {
|
||||||
|
fHistoryEntries.clear();
|
||||||
|
fHistoryEntries.addAll(Arrays.asList(remaining));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ITranslationUnit getInput() {
|
||||||
|
Object input= fTreeViewer.getInput();
|
||||||
|
if (input instanceof ITranslationUnit) {
|
||||||
|
return (ITranslationUnit) input;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
|
import org.eclipse.ui.IWorkingSet;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
|
||||||
|
|
||||||
|
public class CHWorkingSetFilter extends ViewerFilter {
|
||||||
|
|
||||||
|
private WorkingSetFilterUI fWorkingSetFilter;
|
||||||
|
|
||||||
|
public CHWorkingSetFilter(WorkingSetFilterUI wsFilter) {
|
||||||
|
fWorkingSetFilter= wsFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
|
if (parentElement instanceof CHNode && element instanceof CHNode) {
|
||||||
|
CHNode node= (CHNode) element;
|
||||||
|
ICElement decl= node.getRepresentedDeclaration();
|
||||||
|
if (decl != null) {
|
||||||
|
return fWorkingSetFilter.isPartOfWorkingSet(decl);
|
||||||
|
}
|
||||||
|
// mstodo in case of an ambigous callees, check the children instead.
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorkingSetFilterUI getUI() {
|
||||||
|
return fWorkingSetFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
IWorkingSet ws= fWorkingSetFilter.getWorkingSet();
|
||||||
|
if (ws != null) {
|
||||||
|
return ws.getLabel();
|
||||||
|
}
|
||||||
|
return CHMessages.CHViewPart_WorkspaceScope;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
|
|
||||||
|
public class CallHierarchyUI {
|
||||||
|
|
||||||
|
public static CHViewPart open(ICElement input, IWorkbenchWindow window) {
|
||||||
|
if (input != null) {
|
||||||
|
return openInViewPart(window, input);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static CHViewPart openInViewPart(IWorkbenchWindow window, ICElement input) {
|
||||||
|
IWorkbenchPage page= window.getActivePage();
|
||||||
|
try {
|
||||||
|
CHViewPart result= (CHViewPart)page.showView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||||
|
result.setInput(input);
|
||||||
|
return result;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
ExceptionHandler.handle(e, window.getShell(), CHMessages.OpenCallHierarchyAction_label, null);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2006 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 - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||||
|
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||||
|
import org.eclipse.cdt.ui.actions.SelectionDispatchAction;
|
||||||
|
|
||||||
|
|
||||||
|
public class OpenCallHierarchyAction extends SelectionDispatchAction {
|
||||||
|
|
||||||
|
public OpenCallHierarchyAction(IWorkbenchSite site) {
|
||||||
|
super(site);
|
||||||
|
setText(CHMessages.OpenCallHierarchyAction_label);
|
||||||
|
setToolTipText(CHMessages.OpenCallHierarchyAction_tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(ITextSelection sel) {
|
||||||
|
// mstodo run open call tree on editor.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(IStructuredSelection selection) {
|
||||||
|
if (!selection.isEmpty()) {
|
||||||
|
Object selectedObject= selection.getFirstElement();
|
||||||
|
ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
|
||||||
|
if (elem != null) {
|
||||||
|
CallHierarchyUI.open(elem, getSite().getWorkbenchWindow());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(ITextSelection sel) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectionChanged(IStructuredSelection selection) {
|
||||||
|
if (selection.isEmpty()) {
|
||||||
|
setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object selectedObject= selection.getFirstElement();
|
||||||
|
ICElement elem= (ICElement) getAdapter(selectedObject, ICElement.class);
|
||||||
|
if (elem != null) {
|
||||||
|
setEnabled(isValidElement(elem));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidElement(ICElement elem) {
|
||||||
|
return elem instanceof IFunctionDeclaration ||
|
||||||
|
elem instanceof IVariableDeclaration;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getAdapter(Object object, Class desiredClass) {
|
||||||
|
if (desiredClass.isInstance(object)) {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
if (object instanceof IAdaptable) {
|
||||||
|
IAdaptable adaptable= (IAdaptable) object;
|
||||||
|
return adaptable.getAdapter(desiredClass);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -132,6 +132,12 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
*/
|
*/
|
||||||
public static final String OPEN_OUTLINE= "org.eclipse.cdt.ui.edit.open.outline"; //$NON-NLS-1$
|
public static final String OPEN_OUTLINE= "org.eclipse.cdt.ui.edit.open.outline"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action definition ID for opening the call hierarchy.
|
||||||
|
* (value <code>"org.eclipse.cdt.ui.edit.open.call.hierarchy"</code>).
|
||||||
|
*/
|
||||||
|
public static final String OPEN_CALL_HIERARCHY= "org.eclipse.cdt.ui.edit.open.call.hierarchy"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action definition ID for go to next c member.
|
* Action definition ID for go to next c member.
|
||||||
* (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.memeber"</code>)
|
* (value <code>"org.eclipse.cdt.ui.edit.text.c.goto.next.memeber"</code>)
|
||||||
|
|
|
@ -25,6 +25,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -63,7 +66,26 @@ public class CIndexQueries {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class IPDOMReference {
|
||||||
|
private IASTName fName;
|
||||||
|
private ICProject fProject;
|
||||||
|
|
||||||
|
public IPDOMReference(ICProject cproject, IASTName name) {
|
||||||
|
fProject= cproject;
|
||||||
|
fName= name;
|
||||||
|
}
|
||||||
|
public ITranslationUnit getTranslationUnit() throws CoreException {
|
||||||
|
return toTranslationUnit(fProject, fName);
|
||||||
|
}
|
||||||
|
public int getOffset() {
|
||||||
|
return fName.getFileLocation().getNodeOffset();
|
||||||
|
}
|
||||||
|
public long getTimestamp() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final IPDOMInclude[] EMPTY_INCLUDES = new IPDOMInclude[0];
|
private static final IPDOMInclude[] EMPTY_INCLUDES = new IPDOMInclude[0];
|
||||||
private static final CIndexQueries sInstance= new CIndexQueries();
|
private static final CIndexQueries sInstance= new CIndexQueries();
|
||||||
|
|
||||||
|
@ -73,7 +95,15 @@ public class CIndexQueries {
|
||||||
|
|
||||||
public static ITranslationUnit toTranslationUnit(ICProject cproject, PDOMFile includedBy) throws CoreException {
|
public static ITranslationUnit toTranslationUnit(ICProject cproject, PDOMFile includedBy) throws CoreException {
|
||||||
String name= includedBy.getFileName().getString();
|
String name= includedBy.getFileName().getString();
|
||||||
IPath path= Path.fromOSString(name);
|
return toTranslationUnit(cproject, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ITranslationUnit toTranslationUnit(ICProject cproject, IASTName name) throws CoreException {
|
||||||
|
return toTranslationUnit(cproject, name.getFileLocation().getFileName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ITranslationUnit toTranslationUnit(ICProject cproject, String pathStr) throws CModelException {
|
||||||
|
IPath path= Path.fromOSString(pathStr);
|
||||||
ICElement e= cproject.findElement(path);
|
ICElement e= cproject.findElement(path);
|
||||||
if (e instanceof ITranslationUnit) {
|
if (e instanceof ITranslationUnit) {
|
||||||
return (ITranslationUnit) e;
|
return (ITranslationUnit) e;
|
||||||
|
@ -150,4 +180,39 @@ public class CIndexQueries {
|
||||||
}
|
}
|
||||||
return EMPTY_INCLUDES;
|
return EMPTY_INCLUDES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IPDOMReference[] findReferences(ITranslationUnit tu, IASTName name, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
|
ArrayList result= new ArrayList();
|
||||||
|
LinkedList projects= new LinkedList(Arrays.asList(CoreModel.getDefault().getCModel().getCProjects()));
|
||||||
|
ICProject cproject= tu.getCProject();
|
||||||
|
if (cproject != null) {
|
||||||
|
projects.remove(cproject);
|
||||||
|
projects.addFirst(cproject);
|
||||||
|
}
|
||||||
|
|
||||||
|
name.resolveBinding();
|
||||||
|
for (Iterator iter = projects.iterator(); iter.hasNext();) {
|
||||||
|
cproject = (ICProject) iter.next();
|
||||||
|
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(cproject);
|
||||||
|
if (pdom != null) {
|
||||||
|
pdom.acquireReadLock();
|
||||||
|
try {
|
||||||
|
IBinding binding= pdom.resolveBinding(name);
|
||||||
|
if (binding != null) {
|
||||||
|
IASTName[] names= pdom.getReferences(binding);
|
||||||
|
for (int i = 0; i < names.length; i++) {
|
||||||
|
IASTName rname = names[i];
|
||||||
|
if (tu != null) {
|
||||||
|
result.add(new IPDOMReference(cproject, rname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
pdom.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (IPDOMReference[]) result.toArray(new IPDOMReference[result.size()]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,22 @@ public class WorkingSetFilter {
|
||||||
}
|
}
|
||||||
return check == ACCEPT;
|
return check == ACCEPT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
|
||||||
|
if (fResourceFilter == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (resourceOrExternalPath == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Object check= fResourceFilter.get(resourceOrExternalPath);
|
||||||
|
if (check == null) {
|
||||||
|
check= checkWorkingSet(resourceOrExternalPath);
|
||||||
|
fResourceFilter.put(resourceOrExternalPath, check);
|
||||||
|
}
|
||||||
|
return check == ACCEPT;
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized Object checkWorkingSet(IPath path) {
|
private synchronized Object checkWorkingSet(IPath path) {
|
||||||
if (path.segmentCount() == 0) {
|
if (path.segmentCount() == 0) {
|
||||||
return REJECT;
|
return REJECT;
|
||||||
|
|
|
@ -14,12 +14,19 @@ package org.eclipse.cdt.internal.ui.viewsupport;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.ui.*;
|
import org.eclipse.ui.IActionBars;
|
||||||
|
import org.eclipse.ui.IMemento;
|
||||||
|
import org.eclipse.ui.IViewPart;
|
||||||
|
import org.eclipse.ui.IWorkingSet;
|
||||||
|
import org.eclipse.ui.IWorkingSetManager;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
|
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps {@link WorkingSetFilterActionGroup} and handles the property changed
|
* Wraps {@link WorkingSetFilterActionGroup} and handles the property changed
|
||||||
* events
|
* events
|
||||||
|
@ -143,6 +150,13 @@ public abstract class WorkingSetFilterUI {
|
||||||
return fWorkingSetFilter.isPartOfWorkingSet(element);
|
return fWorkingSetFilter.isPartOfWorkingSet(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPartOfWorkingSet(IPath resourceOrExternalPath) {
|
||||||
|
if (fWorkingSetFilter == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return fWorkingSetFilter.isPartOfWorkingSet(resourceOrExternalPath);
|
||||||
|
}
|
||||||
|
|
||||||
public IWorkingSet getWorkingSet() {
|
public IWorkingSet getWorkingSet() {
|
||||||
return fWorkingSet;
|
return fWorkingSet;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.actions;
|
package org.eclipse.cdt.ui.actions;
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ public class MemberFilterActionGroup extends ActionGroup {
|
||||||
MemberFilterAction hideFields= new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields);
|
MemberFilterAction hideFields= new MemberFilterAction(this, title, FILTER_FIELDS, helpContext, doHideFields);
|
||||||
hideFields.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_fields.description")); //$NON-NLS-1$
|
hideFields.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_fields.description")); //$NON-NLS-1$
|
||||||
hideFields.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_fields.tooltip")); //$NON-NLS-1$
|
hideFields.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_fields.tooltip")); //$NON-NLS-1$
|
||||||
CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_FIELDS);
|
CPluginImages.setImageDescriptors(hideFields, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_FIELDS);
|
||||||
|
|
||||||
// static
|
// static
|
||||||
title= ActionMessages.getString("MemberFilterActionGroup.hide_static.label"); //$NON-NLS-1$
|
title= ActionMessages.getString("MemberFilterActionGroup.hide_static.label"); //$NON-NLS-1$
|
||||||
|
@ -114,7 +115,7 @@ public class MemberFilterActionGroup extends ActionGroup {
|
||||||
MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic);
|
MemberFilterAction hideStatic= new MemberFilterAction(this, title, FILTER_STATIC, helpContext, doHideStatic);
|
||||||
hideStatic.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_static.description")); //$NON-NLS-1$
|
hideStatic.setDescription(ActionMessages.getString("MemberFilterActionGroup.hide_static.description")); //$NON-NLS-1$
|
||||||
hideStatic.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_static.tooltip")); //$NON-NLS-1$
|
hideStatic.setToolTipText(ActionMessages.getString("MemberFilterActionGroup.hide_static.tooltip")); //$NON-NLS-1$
|
||||||
CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_SHOW_STATIC);
|
CPluginImages.setImageDescriptors(hideStatic, CPluginImages.T_LCL, CPluginImages.IMG_ACTION_HIDE_STATIC);
|
||||||
|
|
||||||
// non-public
|
// non-public
|
||||||
title= ActionMessages.getString("MemberFilterActionGroup.hide_nonpublic.label"); //$NON-NLS-1$
|
title= ActionMessages.getString("MemberFilterActionGroup.hide_nonpublic.label"); //$NON-NLS-1$
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2005 IBM Corporation and others.
|
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.ui.actions;
|
package org.eclipse.cdt.ui.actions;
|
||||||
|
|
||||||
|
@ -28,10 +29,13 @@ import org.eclipse.ui.part.Page;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart;
|
||||||
|
import org.eclipse.cdt.internal.ui.callhierarchy.OpenCallHierarchyAction;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.ICEditorActionDefinitionIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action group that adds actions to open a new JDT view part or an external
|
* Action group that adds actions to open a new CDT view part or an external
|
||||||
* viewer to a context menu and the global menu bar.
|
* viewer to a context menu and the global menu bar.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -44,14 +48,15 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
|
|
||||||
private boolean fEditorIsOwner;
|
private boolean fEditorIsOwner;
|
||||||
// private boolean fIsTypeHiararchyViewerOwner;
|
// private boolean fIsTypeHiararchyViewerOwner;
|
||||||
// private boolean fIsCallHiararchyViewerOwner;
|
private boolean fIsCallHiararchyViewerOwner;
|
||||||
private IWorkbenchSite fSite;
|
private IWorkbenchSite fSite;
|
||||||
|
private String fGroupName= IContextMenuConstants.GROUP_OPEN;
|
||||||
|
|
||||||
// private OpenSuperImplementationAction fOpenSuperImplementation;
|
// private OpenSuperImplementationAction fOpenSuperImplementation;
|
||||||
// private OpenExternalJavadocAction fOpenExternalJavadoc;
|
// private OpenExternalJavadocAction fOpenExternalJavadoc;
|
||||||
// private OpenTypeHierarchyAction fOpenTypeHierarchy;
|
// private OpenTypeHierarchyAction fOpenTypeHierarchy;
|
||||||
// private OpenCallHierarchyAction fOpenCallHierarchy;
|
|
||||||
private PropertyDialogAction fOpenPropertiesDialog;
|
private PropertyDialogAction fOpenPropertiesDialog;
|
||||||
|
private OpenCallHierarchyAction fOpenCallHierarchy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new <code>OpenActionGroup</code>. The group requires
|
* Creates a new <code>OpenActionGroup</code>. The group requires
|
||||||
|
@ -74,7 +79,7 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
public OpenViewActionGroup(IViewPart part) {
|
public OpenViewActionGroup(IViewPart part) {
|
||||||
createSiteActions(part.getSite());
|
createSiteActions(part.getSite());
|
||||||
// fIsTypeHiararchyViewerOwner= part instanceof TypeHierarchyViewPart;
|
// fIsTypeHiararchyViewerOwner= part instanceof TypeHierarchyViewPart;
|
||||||
// fIsCallHiararchyViewerOwner= part instanceof ICallHierarchyViewPart;
|
fIsCallHiararchyViewerOwner= part instanceof CHViewPart;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,9 +100,8 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
// fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
|
// fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
|
||||||
// part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$
|
// part.setAction("OpenTypeHierarchy", fOpenTypeHierarchy); //$NON-NLS-1$
|
||||||
|
|
||||||
// fOpenCallHierarchy= new OpenCallHierarchyAction(part);
|
fOpenCallHierarchy= new OpenCallHierarchyAction(part.getSite());
|
||||||
// fOpenCallHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
|
fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
|
||||||
// part.setAction("OpenCallHierarchy", fOpenCallHierarchy); //$NON-NLS-1$
|
|
||||||
|
|
||||||
initialize(part.getEditorSite());
|
initialize(part.getEditorSite());
|
||||||
}
|
}
|
||||||
|
@ -112,8 +116,8 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
// fOpenTypeHierarchy= new OpenTypeHierarchyAction(site);
|
// fOpenTypeHierarchy= new OpenTypeHierarchyAction(site);
|
||||||
// fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
|
// fOpenTypeHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
|
||||||
|
|
||||||
// fOpenCallHierarchy= new OpenCallHierarchyAction(site);
|
fOpenCallHierarchy= new OpenCallHierarchyAction(site);
|
||||||
// fOpenCallHierarchy.setActionDefinitionId(IJavaEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
|
fOpenCallHierarchy.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CALL_HIERARCHY);
|
||||||
|
|
||||||
fOpenPropertiesDialog= new PropertyDialogAction(site, site.getSelectionProvider());
|
fOpenPropertiesDialog= new PropertyDialogAction(site, site.getSelectionProvider());
|
||||||
fOpenPropertiesDialog.setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
|
fOpenPropertiesDialog.setActionDefinitionId("org.eclipse.ui.file.properties"); //$NON-NLS-1$
|
||||||
|
@ -128,7 +132,7 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
// fOpenSuperImplementation.update(selection);
|
// fOpenSuperImplementation.update(selection);
|
||||||
// fOpenExternalJavadoc.update(selection);
|
// fOpenExternalJavadoc.update(selection);
|
||||||
// fOpenTypeHierarchy.update(selection);
|
// fOpenTypeHierarchy.update(selection);
|
||||||
// fOpenCallHierarchy.update(selection);
|
fOpenCallHierarchy.update(selection);
|
||||||
if (!fEditorIsOwner) {
|
if (!fEditorIsOwner) {
|
||||||
if (selection instanceof IStructuredSelection) {
|
if (selection instanceof IStructuredSelection) {
|
||||||
IStructuredSelection ss= (IStructuredSelection)selection;
|
IStructuredSelection ss= (IStructuredSelection)selection;
|
||||||
|
@ -139,7 +143,7 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
// provider.addSelectionChangedListener(fOpenSuperImplementation);
|
// provider.addSelectionChangedListener(fOpenSuperImplementation);
|
||||||
// provider.addSelectionChangedListener(fOpenExternalJavadoc);
|
// provider.addSelectionChangedListener(fOpenExternalJavadoc);
|
||||||
// provider.addSelectionChangedListener(fOpenTypeHierarchy);
|
// provider.addSelectionChangedListener(fOpenTypeHierarchy);
|
||||||
// provider.addSelectionChangedListener(fOpenCallHierarchy);
|
provider.addSelectionChangedListener(fOpenCallHierarchy);
|
||||||
// no need to register the open properties dialog action since it registers itself
|
// no need to register the open properties dialog action since it registers itself
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,8 +163,9 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
super.fillContextMenu(menu);
|
super.fillContextMenu(menu);
|
||||||
// if (!fIsTypeHiararchyViewerOwner)
|
// if (!fIsTypeHiararchyViewerOwner)
|
||||||
// appendToGroup(menu, fOpenTypeHierarchy);
|
// appendToGroup(menu, fOpenTypeHierarchy);
|
||||||
// if (!fIsCallHiararchyViewerOwner)
|
if (!fIsCallHiararchyViewerOwner) {
|
||||||
// appendToGroup(menu, fOpenCallHierarchy);
|
menu.appendToGroup(fGroupName, fOpenCallHierarchy);
|
||||||
|
}
|
||||||
// appendToGroup(menu, fOpenSuperImplementation);
|
// appendToGroup(menu, fOpenSuperImplementation);
|
||||||
IStructuredSelection selection= getStructuredSelection();
|
IStructuredSelection selection= getStructuredSelection();
|
||||||
if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection))
|
if (fOpenPropertiesDialog != null && fOpenPropertiesDialog.isEnabled() && selection != null &&fOpenPropertiesDialog.isApplicableForSelection(selection))
|
||||||
|
@ -171,11 +176,11 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
* @see ActionGroup#dispose()
|
* @see ActionGroup#dispose()
|
||||||
*/
|
*/
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
// ISelectionProvider provider= fSite.getSelectionProvider();
|
ISelectionProvider provider= fSite.getSelectionProvider();
|
||||||
// provider.removeSelectionChangedListener(fOpenSuperImplementation);
|
// provider.removeSelectionChangedListener(fOpenSuperImplementation);
|
||||||
// provider.removeSelectionChangedListener(fOpenExternalJavadoc);
|
// provider.removeSelectionChangedListener(fOpenExternalJavadoc);
|
||||||
// provider.removeSelectionChangedListener(fOpenTypeHierarchy);
|
// provider.removeSelectionChangedListener(fOpenTypeHierarchy);
|
||||||
// provider.removeSelectionChangedListener(fOpenCallHierarchy);
|
provider.removeSelectionChangedListener(fOpenCallHierarchy);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,4 +218,9 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setAppendToGroup(String groupName) {
|
||||||
|
fGroupName= groupName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|