mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Call Hierarchy: Actions to open the call hierarchy, navigation of nodes.
This commit is contained in:
parent
1d508cd878
commit
95b8581183
20 changed files with 529 additions and 301 deletions
|
@ -57,7 +57,7 @@ public class AsyncViewerTest extends TestCase {
|
||||||
super(disp);
|
super(disp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
|
protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
|
||||||
Node n= (Node) parentElement;
|
Node n= (Node) parentElement;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(n.fAsync);
|
Thread.sleep(n.fAsync);
|
||||||
|
@ -67,7 +67,7 @@ public class AsyncViewerTest extends TestCase {
|
||||||
return n.fChildren;
|
return n.fChildren;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] syncronouslyComputeChildren(Object parentElement) {
|
protected Object[] syncronouslyComputeChildren(Object parentElement) {
|
||||||
Node n= (Node) parentElement;
|
Node n= (Node) parentElement;
|
||||||
if (n.fAsync != 0) {
|
if (n.fAsync != 0) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -71,6 +71,7 @@ Require-Bundle: org.eclipse.ui.ide,
|
||||||
org.eclipse.ui.navigator,
|
org.eclipse.ui.navigator,
|
||||||
org.eclipse.core.expressions,
|
org.eclipse.core.expressions,
|
||||||
org.eclipse.ui.navigator.resources,
|
org.eclipse.ui.navigator.resources,
|
||||||
com.ibm.icu
|
com.ibm.icu,
|
||||||
|
org.eclipse.cdt.refactoring
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
Bundle-RequiredExecutionEnvironment: J2SE-1.4
|
||||||
|
|
|
@ -104,6 +104,9 @@ ActionDefinition.finddecl.description= Find Declaration
|
||||||
ActionDefinition.findrefs.name= Find References
|
ActionDefinition.findrefs.name= Find References
|
||||||
ActionDefinition.findrefs.description= Find References
|
ActionDefinition.findrefs.description= Find References
|
||||||
|
|
||||||
|
ActionDefinition.openCallHierarchy.name= Open Call Hierarchy
|
||||||
|
ActionDefinition.openCallHierarchy.description= Open the call hierarchy for the selected element
|
||||||
|
|
||||||
ActionDefinition.addBlockComment.name= Add Block Comment
|
ActionDefinition.addBlockComment.name= Add Block Comment
|
||||||
ActionDefinition.addBlockComment.description= Enclose the selection with a block comment
|
ActionDefinition.addBlockComment.description= Enclose the selection with a block comment
|
||||||
|
|
||||||
|
@ -352,3 +355,6 @@ Dummy.label = dummy
|
||||||
|
|
||||||
# Common Navigator
|
# Common Navigator
|
||||||
navigatorContent.name = CDT Elements
|
navigatorContent.name = CDT Elements
|
||||||
|
|
||||||
|
OpenCallHierarchy.label = Open Call Hierarchy
|
||||||
|
OpenCallHierarchy.tooltip = Open Call Hierarchy
|
|
@ -880,6 +880,11 @@
|
||||||
contextId="org.eclipse.cdt.ui.cEditorScope"
|
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||||
commandId="org.eclipse.cdt.ui.edit.text.c.remove.block.comment"
|
commandId="org.eclipse.cdt.ui.edit.text.c.remove.block.comment"
|
||||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||||
|
<key
|
||||||
|
sequence="M1+M3+H"
|
||||||
|
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||||
|
commandId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
|
||||||
|
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||||
<key
|
<key
|
||||||
sequence="M1+F3"
|
sequence="M1+F3"
|
||||||
contextId="org.eclipse.cdt.ui.cEditorScope"
|
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||||
|
@ -1024,6 +1029,11 @@
|
||||||
description="%ActionDefinition.findrefs.description"
|
description="%ActionDefinition.findrefs.description"
|
||||||
name="%ActionDefinition.findrefs.name"
|
name="%ActionDefinition.findrefs.name"
|
||||||
id="org.eclipse.cdt.ui.search.findrefs"/>
|
id="org.eclipse.cdt.ui.search.findrefs"/>
|
||||||
|
<command
|
||||||
|
categoryId="org.eclipse.ui.category.navigate"
|
||||||
|
description="%ActionDefinition.openCallHierarchy.description"
|
||||||
|
name="%ActionDefinition.openCallHierarchy.name"
|
||||||
|
id="org.eclipse.cdt.ui.edit.open.call.hierarchy"/>
|
||||||
<!--command
|
<!--command
|
||||||
name="%ActionDefinition.openTypeHierarchy.name"
|
name="%ActionDefinition.openTypeHierarchy.name"
|
||||||
description="%ActionDefinition.openTypeHierarchy.description"
|
description="%ActionDefinition.openTypeHierarchy.description"
|
||||||
|
@ -1118,6 +1128,15 @@
|
||||||
menubarPath="navigate/open.ext2"
|
menubarPath="navigate/open.ext2"
|
||||||
tooltip="%OpenTypeAction.tooltip">
|
tooltip="%OpenTypeAction.tooltip">
|
||||||
</action>
|
</action>
|
||||||
|
<action
|
||||||
|
definitionId="org.eclipse.cdt.ui.edit.open.call.hierarchy"
|
||||||
|
id="org.eclipse.cdt.ui.actions.OpenCallHierarchy"
|
||||||
|
label="%OpenCallHierarchy.label"
|
||||||
|
menubarPath="navigate/open.ext"
|
||||||
|
retarget="true"
|
||||||
|
toolbarPath="org.eclipse.search.searchActionSet/Search"
|
||||||
|
tooltip="%OpenCallHierarchy.tooltip">
|
||||||
|
</action>
|
||||||
<!--action
|
<!--action
|
||||||
definitionId="org.eclipse.cdt.ui.edit.text.c.open.type.hierarchy"
|
definitionId="org.eclipse.cdt.ui.edit.text.c.open.type.hierarchy"
|
||||||
label="%OpenTypeHierarchyAction.label"
|
label="%OpenTypeHierarchyAction.label"
|
||||||
|
|
|
@ -6,19 +6,22 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Rational Software - Initial API and implementation
|
* IBM Rational Software - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.corext.util;
|
package org.eclipse.cdt.internal.corext.util;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
|
||||||
|
|
||||||
public class CModelUtil {
|
public class CModelUtil {
|
||||||
/**
|
/**
|
||||||
|
@ -98,4 +101,17 @@ public class CModelUtil {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the translation unit the element belongs to or <code>null</code> if it does not.
|
||||||
|
*/
|
||||||
|
public static ITranslationUnit getTranslationUnit(ICElement elem) {
|
||||||
|
while (elem != null) {
|
||||||
|
if (elem instanceof ITranslationUnit) {
|
||||||
|
return (ITranslationUnit) elem;
|
||||||
|
}
|
||||||
|
elem= elem.getParent();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,11 @@ import java.util.Map;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
import org.eclipse.jface.text.Region;
|
||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IPositionConverter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -34,6 +37,8 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.corext.util.CModelUtil;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries;
|
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries;
|
||||||
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries.IPDOMReference;
|
import org.eclipse.cdt.internal.ui.missingapi.CIndexQueries.IPDOMReference;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider;
|
||||||
|
@ -61,10 +66,11 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
return super.getParent(element);
|
return super.getParent(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] syncronouslyComputeChildren(Object parentElement) {
|
protected Object[] syncronouslyComputeChildren(Object parentElement) {
|
||||||
if (parentElement instanceof ICElement) {
|
if (parentElement instanceof ICElement) {
|
||||||
ICElement element = (ICElement) parentElement;
|
ICElement element = (ICElement) parentElement;
|
||||||
return new Object[] { new CHNode(null, null, element, 0) };
|
ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
|
||||||
|
return new Object[] { new CHNode(null, tu, 0, element) };
|
||||||
}
|
}
|
||||||
if (parentElement instanceof CHNode) {
|
if (parentElement instanceof CHNode) {
|
||||||
CHNode node = (CHNode) parentElement;
|
CHNode node = (CHNode) parentElement;
|
||||||
|
@ -79,7 +85,7 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] asyncronouslyComputeChildren(Object parentElement,
|
protected Object[] asyncronouslyComputeChildren(Object parentElement,
|
||||||
IProgressMonitor monitor) {
|
IProgressMonitor monitor) {
|
||||||
if (parentElement instanceof CHNode) {
|
if (parentElement instanceof CHNode) {
|
||||||
CHNode node = (CHNode) parentElement;
|
CHNode node = (CHNode) parentElement;
|
||||||
|
@ -96,50 +102,41 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
return NO_CHILDREN;
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object[] asyncronouslyComputeReferencedBy(CHNode parent, ICElement elem) {
|
private static IASTName toASTName(ICElement elem) throws CoreException {
|
||||||
try {
|
if (elem instanceof ISourceReference) {
|
||||||
if (elem instanceof ISourceReference) {
|
ISourceReference sf= (ISourceReference) elem;
|
||||||
ISourceReference sf= (ISourceReference) elem;
|
ISourceRange range = sf.getSourceRange();
|
||||||
ISourceRange range = sf.getSourceRange();
|
ITranslationUnit tu = sf.getTranslationUnit();
|
||||||
ITranslationUnit tu = sf.getTranslationUnit();
|
if (tu != null) {
|
||||||
if (tu != null) {
|
ILanguage language = tu.getLanguage();
|
||||||
ILanguage language = tu.getLanguage();
|
IASTTranslationUnit ast = language.getASTTranslationUnit(tu, ILanguage.AST_SKIP_ALL_HEADERS | ILanguage.AST_USE_INDEX);
|
||||||
IASTTranslationUnit ast = language.getASTTranslationUnit(tu, ILanguage.AST_SKIP_ALL_HEADERS | ILanguage.AST_USE_INDEX);
|
IASTName[] names = language.getSelectedNames(ast, range.getIdStartPos(), range.getIdLength());
|
||||||
IASTName[] names = language.getSelectedNames(ast, range.getIdStartPos(), range.getIdLength());
|
if (names.length > 0) {
|
||||||
if (names.length > 0) {
|
return names[names.length-1];
|
||||||
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);
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] asyncronouslyComputeReferencedBy(CHNode parent, ICElement elem) {
|
||||||
|
try {
|
||||||
|
IASTName name = toASTName(elem);
|
||||||
|
if (name != null) {
|
||||||
|
IPDOMReference[] refs= CIndexQueries.getInstance().findReferences(name, NPM);
|
||||||
|
HashMap refsPerElement = sortPerElement(refs);
|
||||||
|
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()) {
|
||||||
|
CHNode node = createRefbyNode(parent, element, references);
|
||||||
|
result.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toArray();
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.getDefault().log(e);
|
CUIPlugin.getDefault().log(e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
@ -147,13 +144,41 @@ public class CHContentProvider extends AsyncTreeContentProvider {
|
||||||
return NO_CHILDREN;
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CHNode createRefbyNode(CHNode parent, ICElement element, List references) {
|
||||||
|
IPDOMReference firstRef= (IPDOMReference) references.get(0);
|
||||||
|
ITranslationUnit tu= CModelUtil.getTranslationUnit(element);
|
||||||
|
CHNode node= new CHNode(parent, tu, firstRef.getTimestamp(), element);
|
||||||
|
for (Iterator iter = references.iterator(); iter.hasNext(); ) {
|
||||||
|
IPDOMReference nextRef = (IPDOMReference) iter.next();
|
||||||
|
node.addReference(new CHReferenceInfo(nextRef.getOffset(), nextRef.getLength()));
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private HashMap sortPerElement(IPDOMReference[] refs) throws CoreException {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return refsPerElement;
|
||||||
|
}
|
||||||
|
|
||||||
private ICElement findCaller(IPDOMReference reference) throws CoreException {
|
private ICElement findCaller(IPDOMReference reference) throws CoreException {
|
||||||
ITranslationUnit tu= reference.getTranslationUnit();
|
ITranslationUnit tu= reference.getTranslationUnit();
|
||||||
return findCaller(tu, reference.getOffset());
|
long timestamp= reference.getTimestamp();
|
||||||
|
IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(tu.getPath(), timestamp);
|
||||||
|
int offset= reference.getOffset();
|
||||||
|
if (pc != null) {
|
||||||
|
offset= pc.historicToActual(new Region(offset, 0)).getOffset();
|
||||||
|
}
|
||||||
|
return findCaller(tu, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICElement findCaller(ICElement element, int offset) throws CModelException {
|
private ICElement findCaller(ICElement element, int offset) throws CModelException {
|
||||||
// mstodo use position tracker
|
|
||||||
if (element == null || (element instanceof IFunctionDeclaration)) {
|
if (element == null || (element instanceof IFunctionDeclaration)) {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,13 +102,6 @@ public class CHLabelProvider extends LabelProvider implements IColorProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (node.getRepresentedTranslationUnit() == null) {
|
|
||||||
// flags |= CElementImageDescriptor.WARNING;
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (flags == 0) {
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
String key= image.toString()+String.valueOf(flags);
|
String key= image.toString()+String.valueOf(flags);
|
||||||
Image result= (Image) fCachedImages.get(key);
|
Image result= (Image) fCachedImages.get(key);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
|
|
@ -15,8 +15,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IMacro;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.IMacro;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||||
public class CHNode {
|
public class CHNode {
|
||||||
private CHNode fParent;
|
private CHNode fParent;
|
||||||
private ICElement fRepresentedDecl;
|
private ICElement fRepresentedDecl;
|
||||||
|
private ITranslationUnit fFileOfReferences;
|
||||||
private List fReferences;
|
private List fReferences;
|
||||||
|
|
||||||
private int fHashCode;
|
private int fHashCode;
|
||||||
|
@ -34,10 +36,11 @@ public class CHNode {
|
||||||
/**
|
/**
|
||||||
* Creates a new node for the include browser
|
* Creates a new node for the include browser
|
||||||
*/
|
*/
|
||||||
public CHNode(CHNode parent, CHReferenceInfo reference, ICElement decl, long timestamp) {
|
public CHNode(CHNode parent, ITranslationUnit fileOfReferences, long timestamp, ICElement decl) {
|
||||||
assert decl != null;
|
assert decl != null;
|
||||||
fParent= parent;
|
fParent= parent;
|
||||||
fReferences= Collections.singletonList(reference);
|
fFileOfReferences= fileOfReferences;
|
||||||
|
fReferences= Collections.EMPTY_LIST;
|
||||||
fRepresentedDecl= decl;
|
fRepresentedDecl= decl;
|
||||||
fIsRecursive= computeIsRecursive(fParent, decl);
|
fIsRecursive= computeIsRecursive(fParent, decl);
|
||||||
fHashCode= computeHashCode();
|
fHashCode= computeHashCode();
|
||||||
|
@ -121,9 +124,18 @@ public class CHNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addReference(CHReferenceInfo info) {
|
public void addReference(CHReferenceInfo info) {
|
||||||
if (fReferences.size() == 1) {
|
switch (fReferences.size()) {
|
||||||
|
case 0:
|
||||||
|
fReferences= Collections.singletonList(info);
|
||||||
|
return;
|
||||||
|
case 1:
|
||||||
fReferences= new ArrayList(fReferences);
|
fReferences= new ArrayList(fReferences);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
fReferences.add(info);
|
fReferences.add(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ITranslationUnit getFileOfReferences() {
|
||||||
|
return fFileOfReferences;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,18 @@ package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
public class CHReferenceInfo {
|
public class CHReferenceInfo {
|
||||||
private int fOffset;
|
private int fOffset;
|
||||||
|
private int fLength;
|
||||||
|
|
||||||
public CHReferenceInfo(int offset) {
|
public CHReferenceInfo(int offset, int length) {
|
||||||
fOffset= offset;
|
fOffset= offset;
|
||||||
|
fLength= length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOffset() {
|
public int getOffset() {
|
||||||
return fOffset;
|
return fOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return fLength;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.callhierarchy;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
|
@ -22,9 +23,11 @@ import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
import org.eclipse.jface.action.MenuManager;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.jface.action.Separator;
|
import org.eclipse.jface.action.Separator;
|
||||||
|
import org.eclipse.jface.text.Region;
|
||||||
import org.eclipse.jface.util.LocalSelectionTransfer;
|
import org.eclipse.jface.util.LocalSelectionTransfer;
|
||||||
import org.eclipse.jface.viewers.IOpenListener;
|
import org.eclipse.jface.viewers.IOpenListener;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.OpenEvent;
|
import org.eclipse.jface.viewers.OpenEvent;
|
||||||
import org.eclipse.jface.viewers.StructuredSelection;
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
@ -46,13 +49,14 @@ import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IMemento;
|
import org.eclipse.ui.IMemento;
|
||||||
import org.eclipse.ui.IViewSite;
|
import org.eclipse.ui.IViewSite;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.IWorkbenchPartSite;
|
import org.eclipse.ui.IWorkbenchPartSite;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.actions.ActionFactory;
|
import org.eclipse.ui.actions.ActionFactory;
|
||||||
import org.eclipse.ui.part.PageBook;
|
import org.eclipse.ui.part.PageBook;
|
||||||
import org.eclipse.ui.part.ShowInContext;
|
|
||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
@ -60,6 +64,7 @@ import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.internal.ui.util.CoreUtility;
|
import org.eclipse.cdt.internal.ui.util.CoreUtility;
|
||||||
import org.eclipse.cdt.internal.ui.util.Messages;
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
|
import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
|
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
|
||||||
|
@ -76,7 +81,9 @@ public class CHViewPart extends ViewPart {
|
||||||
|
|
||||||
private IMemento fMemento;
|
private IMemento fMemento;
|
||||||
private boolean fShowsMessage;
|
private boolean fShowsMessage;
|
||||||
private CHNode fLastNavigationNode;
|
private CHNode fNavigationNode;
|
||||||
|
private int fNavigationDetail;
|
||||||
|
|
||||||
private ArrayList fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE);
|
private ArrayList fHistoryEntries= new ArrayList(MAX_HISTORY_SIZE);
|
||||||
|
|
||||||
// widgets
|
// widgets
|
||||||
|
@ -228,8 +235,10 @@ public class CHViewPart extends ViewPart {
|
||||||
fTreeViewer.setLabelProvider(fLabelProvider);
|
fTreeViewer.setLabelProvider(fLabelProvider);
|
||||||
fTreeViewer.setAutoExpandLevel(2);
|
fTreeViewer.setAutoExpandLevel(2);
|
||||||
fTreeViewer.addOpenListener(new IOpenListener() {
|
fTreeViewer.addOpenListener(new IOpenListener() {
|
||||||
public void open(OpenEvent event) {
|
public void open(OpenEvent event) {
|
||||||
onShowReference(event.getSelection());
|
fNavigationDetail= 0;
|
||||||
|
fNavigationNode= selectionToNode(event.getSelection());
|
||||||
|
onShowReference();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -424,26 +433,39 @@ public class CHViewPart extends ViewPart {
|
||||||
mm.add(fFilterVariablesAction);
|
mm.add(fFilterVariablesAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CHNode getNextNode(boolean forward) {
|
private void setNextNode(boolean forward) {
|
||||||
TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
|
TreeNavigator navigator= new TreeNavigator(fTreeViewer.getTree(), CHNode.class);
|
||||||
TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
|
TreeItem selectedItem= navigator.getSelectedItemOrFirstOnLevel(1, forward);
|
||||||
if (selectedItem == null) {
|
if (selectedItem == null) {
|
||||||
return null;
|
fNavigationNode= null;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedItem.getData().equals(fLastNavigationNode)) {
|
|
||||||
selectedItem= navigator.getNextSibbling(selectedItem, forward);
|
if (selectedItem.getData().equals(fNavigationNode)) {
|
||||||
|
if (forward && fNavigationDetail < fNavigationNode.getReferenceCount()-1) {
|
||||||
|
fNavigationDetail++;
|
||||||
|
}
|
||||||
|
else if (!forward && fNavigationDetail > 0) {
|
||||||
|
fNavigationDetail--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
selectedItem= navigator.getNextSibbling(selectedItem, forward);
|
||||||
|
fNavigationNode= selectedItem == null ? null : (CHNode) selectedItem.getData();
|
||||||
|
if (fNavigationNode != null) {
|
||||||
|
fNavigationDetail= forward ? 0 : fNavigationNode.getReferenceCount()-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectedItem == null ? null : (CHNode) selectedItem.getData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onNextOrPrevious(boolean forward) {
|
protected void onNextOrPrevious(boolean forward) {
|
||||||
CHNode nextItem= getNextNode(forward);
|
setNextNode(forward);
|
||||||
if (nextItem != null) {
|
if (fNavigationNode != null) {
|
||||||
StructuredSelection sel= new StructuredSelection(nextItem);
|
StructuredSelection sel= new StructuredSelection(fNavigationNode);
|
||||||
fTreeViewer.setSelection(sel);
|
fTreeViewer.setSelection(sel);
|
||||||
onShowReference(sel);
|
onShowReference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,76 +599,47 @@ public class CHViewPart extends ViewPart {
|
||||||
m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
|
m.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onShowReference(ISelection selection) {
|
protected void onShowReference() {
|
||||||
// CHNode node= IBConversions.selectionToNode(selection);
|
if (fNavigationNode != null) {
|
||||||
// if (node != null) {
|
ITranslationUnit file= fNavigationNode.getFileOfReferences();
|
||||||
// IWorkbenchPage page= getSite().getPage();
|
if (file != null) {
|
||||||
// IBFile ibf= node.getDirectiveFile();
|
IWorkbenchPage page= getSite().getPage();
|
||||||
// long timestamp= node.getTimestamp();
|
if (fNavigationNode.getReferenceCount() > 0) {
|
||||||
// if (ibf != null) {
|
long timestamp= fNavigationNode.getTimestamp();
|
||||||
// IEditorPart editor= null;
|
if (fNavigationDetail < 0) {
|
||||||
// IPath filebufferKey= null;
|
fNavigationDetail= 0;
|
||||||
// IFile f= ibf.getResource();
|
}
|
||||||
// if (f != null) {
|
else if (fNavigationDetail >= fNavigationNode.getReferenceCount()-1) {
|
||||||
// if (timestamp == 0) {
|
fNavigationDetail= fNavigationNode.getReferenceCount()-1;
|
||||||
// timestamp= f.getLocalTimeStamp();
|
}
|
||||||
// }
|
|
||||||
// fLastNavigationNode= node;
|
CHReferenceInfo ref= fNavigationNode.getReference(fNavigationDetail);
|
||||||
// try {
|
Region region= new Region(ref.getOffset(), ref.getLength());
|
||||||
// editor= IDE.openEditor(page, f, false);
|
EditorOpener.open(page, file, region, timestamp);
|
||||||
// filebufferKey= f.getFullPath();
|
}
|
||||||
// } catch (PartInitException e) {
|
else {
|
||||||
// CUIPlugin.getDefault().log(e);
|
try {
|
||||||
// }
|
EditorOpener.open(page, fNavigationNode.getRepresentedDeclaration());
|
||||||
// }
|
} catch (CModelException e) {
|
||||||
// else {
|
CUIPlugin.getDefault().log(e);
|
||||||
// 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() {
|
private CHNode selectionToNode(ISelection selection) {
|
||||||
return new ShowInContext(null, fTreeViewer.getSelection());
|
if (selection instanceof IStructuredSelection) {
|
||||||
}
|
IStructuredSelection ss= (IStructuredSelection) selection;
|
||||||
|
for (Iterator iter = ss.iterator(); iter.hasNext(); ) {
|
||||||
|
Object cand= iter.next();
|
||||||
|
if (cand instanceof CHNode) {
|
||||||
|
return (CHNode) cand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Control getPageBook() {
|
public Control getPageBook() {
|
||||||
return fPagebook;
|
return fPagebook;
|
||||||
|
|
|
@ -7,16 +7,10 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.cview;
|
package org.eclipse.cdt.internal.ui.cview;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
|
||||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
|
||||||
import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
|
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
|
||||||
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
@ -33,19 +27,27 @@ import org.eclipse.swt.events.KeyEvent;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IMemento;
|
import org.eclipse.ui.IMemento;
|
||||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
|
||||||
import org.eclipse.ui.IWorkingSet;
|
import org.eclipse.ui.IWorkingSet;
|
||||||
import org.eclipse.ui.actions.ActionContext;
|
import org.eclipse.ui.actions.ActionContext;
|
||||||
import org.eclipse.ui.actions.ActionFactory;
|
|
||||||
import org.eclipse.ui.actions.AddBookmarkAction;
|
import org.eclipse.ui.actions.AddBookmarkAction;
|
||||||
import org.eclipse.ui.actions.AddTaskAction;
|
import org.eclipse.ui.actions.AddTaskAction;
|
||||||
import org.eclipse.ui.actions.ExportResourcesAction;
|
import org.eclipse.ui.actions.ExportResourcesAction;
|
||||||
import org.eclipse.ui.actions.ImportResourcesAction;
|
import org.eclipse.ui.actions.ImportResourcesAction;
|
||||||
import org.eclipse.ui.actions.NewWizardMenu;
|
import org.eclipse.ui.actions.NewWizardMenu;
|
||||||
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
|
import org.eclipse.ui.actions.WorkingSetFilterActionGroup;
|
||||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
|
||||||
import org.eclipse.ui.ide.IDEActionFactory;
|
import org.eclipse.ui.ide.IDEActionFactory;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.refactoring.actions.CRefactoringActionGroup;
|
||||||
|
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
||||||
|
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction;
|
||||||
|
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main action group for the cview. This contains a few actions and several
|
* The main action group for the cview. This contains a few actions and several
|
||||||
* subgroups.
|
* subgroups.
|
||||||
|
@ -55,7 +57,6 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
// Actions for Menu context.
|
// Actions for Menu context.
|
||||||
AddBookmarkAction addBookmarkAction;
|
AddBookmarkAction addBookmarkAction;
|
||||||
AddTaskAction addTaskAction;
|
AddTaskAction addTaskAction;
|
||||||
PropertyDialogAction propertyDialogAction;
|
|
||||||
|
|
||||||
ImportResourcesAction importAction;
|
ImportResourcesAction importAction;
|
||||||
ExportResourcesAction exportAction;
|
ExportResourcesAction exportAction;
|
||||||
|
@ -78,6 +79,9 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
|
|
||||||
SelectionSearchGroup selectionSearchGroup;
|
SelectionSearchGroup selectionSearchGroup;
|
||||||
|
|
||||||
|
OpenViewActionGroup openViewActionGroup;
|
||||||
|
CRefactoringActionGroup crefactoringActionGroup;
|
||||||
|
|
||||||
private NewWizardMenu newWizardMenu;
|
private NewWizardMenu newWizardMenu;
|
||||||
|
|
||||||
public MainActionGroup(CView cview) {
|
public MainActionGroup(CView cview) {
|
||||||
|
@ -145,7 +149,6 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
|
|
||||||
addBookmarkAction = new AddBookmarkAction(shell);
|
addBookmarkAction = new AddBookmarkAction(shell);
|
||||||
addTaskAction = new AddTaskAction(shell);
|
addTaskAction = new AddTaskAction(shell);
|
||||||
propertyDialogAction = new PropertyDialogAction(shellProvider, viewer);
|
|
||||||
|
|
||||||
// Importing/exporting.
|
// Importing/exporting.
|
||||||
importAction = new ImportResourcesAction(getCView().getSite().getWorkbenchWindow());
|
importAction = new ImportResourcesAction(getCView().getSite().getWorkbenchWindow());
|
||||||
|
@ -159,6 +162,8 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
// toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
|
// toggleLinkingAction.setHoverImageDescriptor(getImageDescriptor("clcl16/synced.gif"));//$NON-NLS-1$
|
||||||
|
|
||||||
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
|
selectionSearchGroup = new SelectionSearchGroup(getCView().getSite());
|
||||||
|
openViewActionGroup= new OpenViewActionGroup(getCView());
|
||||||
|
crefactoringActionGroup= new CRefactoringActionGroup(getCView());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,34 +185,36 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
//Can be added once support for manually adding external files to index is established
|
//Can be added once support for manually adding external files to index is established
|
||||||
/*menu.add(new Separator());
|
/*menu.add(new Separator());
|
||||||
menu.add(addToIndexAction);*/
|
menu.add(addToIndexAction);*/
|
||||||
menu.add(new Separator(org.eclipse.search.ui.IContextMenuConstants.GROUP_SEARCH));
|
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
|
||||||
addSearchMenu(menu, celements);
|
addSearchMenu(menu, celements);
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
|
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
|
||||||
menu.add(new Separator());
|
menu.add(new Separator());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.add(new Separator());
|
menu.add(new Separator(IContextMenuConstants.GROUP_GOTO));
|
||||||
gotoGroup.fillContextMenu(menu);
|
gotoGroup.fillContextMenu(menu);
|
||||||
menu.add(new Separator());
|
menu.add(new Separator(IContextMenuConstants.GROUP_OPEN));
|
||||||
openFileGroup.fillContextMenu(menu);
|
openFileGroup.fillContextMenu(menu);
|
||||||
menu.add(new Separator());
|
menu.add(new Separator(IContextMenuConstants.GROUP_BUILD));
|
||||||
buildGroup.fillContextMenu(menu);
|
buildGroup.fillContextMenu(menu);
|
||||||
menu.add(new Separator());
|
menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE));
|
||||||
refactorGroup.fillContextMenu(menu);
|
refactorGroup.fillContextMenu(menu);
|
||||||
menu.add(new Separator());
|
menu.add(new Separator("group.private1")); //$NON-NLS-1$
|
||||||
importAction.selectionChanged(resources);
|
importAction.selectionChanged(resources);
|
||||||
menu.add(importAction);
|
menu.add(importAction);
|
||||||
exportAction.selectionChanged(resources);
|
exportAction.selectionChanged(resources);
|
||||||
menu.add(exportAction);
|
menu.add(exportAction);
|
||||||
menu.add(new Separator());
|
menu.add(new Separator("group.private2")); //$NON-NLS-1$
|
||||||
openProjectGroup.fillContextMenu(menu);
|
openProjectGroup.fillContextMenu(menu);
|
||||||
addBookMarkMenu(menu, resources);
|
addBookMarkMenu(menu, resources);
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS));
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS + "-end")); //$NON-NLS-1$
|
menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS + "-end")); //$NON-NLS-1$
|
||||||
addPropertyMenu(menu, resources);
|
menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES));
|
||||||
|
|
||||||
|
openViewActionGroup.fillContextMenu(menu);
|
||||||
|
crefactoringActionGroup.fillContextMenu(menu);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Extends the superclass implementation to set the context in the
|
* Extends the superclass implementation to set the context in the
|
||||||
|
@ -220,6 +227,8 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
openProjectGroup.setContext(context);
|
openProjectGroup.setContext(context);
|
||||||
refactorGroup.setContext(context);
|
refactorGroup.setContext(context);
|
||||||
buildGroup.setContext(context);
|
buildGroup.setContext(context);
|
||||||
|
openViewActionGroup.setContext(context);
|
||||||
|
crefactoringActionGroup.setContext(context);
|
||||||
//sortAndFilterGroup.setContext(context);
|
//sortAndFilterGroup.setContext(context);
|
||||||
//workspaceGroup.setContext(context);
|
//workspaceGroup.setContext(context);
|
||||||
}
|
}
|
||||||
|
@ -242,13 +251,6 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPropertyMenu(IMenuManager menu, IStructuredSelection selection) {
|
|
||||||
propertyDialogAction.selectionChanged(selection);
|
|
||||||
if (propertyDialogAction.isApplicableForSelection()) {
|
|
||||||
menu.add(propertyDialogAction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void addSearchMenu(IMenuManager menu, IStructuredSelection selection) {
|
void addSearchMenu(IMenuManager menu, IStructuredSelection selection) {
|
||||||
IAdaptable element = (IAdaptable) selection.getFirstElement();
|
IAdaptable element = (IAdaptable) selection.getFirstElement();
|
||||||
|
|
||||||
|
@ -279,7 +281,6 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
public void updateActionBars() {
|
public void updateActionBars() {
|
||||||
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
|
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
|
||||||
|
|
||||||
propertyDialogAction.setEnabled(selection.size() == 1);
|
|
||||||
//sortByTypeAction.selectionChanged(selection);
|
//sortByTypeAction.selectionChanged(selection);
|
||||||
//sortByNameAction.selectionChanged(selection);
|
//sortByNameAction.selectionChanged(selection);
|
||||||
addBookmarkAction.selectionChanged(selection);
|
addBookmarkAction.selectionChanged(selection);
|
||||||
|
@ -292,12 +293,14 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
refactorGroup.updateActionBars();
|
refactorGroup.updateActionBars();
|
||||||
workingSetGroup.updateActionBars();
|
workingSetGroup.updateActionBars();
|
||||||
fCustomFiltersActionGroup.updateActionBars();
|
fCustomFiltersActionGroup.updateActionBars();
|
||||||
|
|
||||||
|
openViewActionGroup.updateActionBars();
|
||||||
|
crefactoringActionGroup.updateActionBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillActionBars(IActionBars actionBars) {
|
public void fillActionBars(IActionBars actionBars) {
|
||||||
actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
|
actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), addBookmarkAction);
|
||||||
actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
|
actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), addTaskAction);
|
||||||
actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), propertyDialogAction);
|
|
||||||
|
|
||||||
workingSetGroup.fillActionBars(actionBars);
|
workingSetGroup.fillActionBars(actionBars);
|
||||||
fCustomFiltersActionGroup.fillActionBars(actionBars);
|
fCustomFiltersActionGroup.fillActionBars(actionBars);
|
||||||
|
@ -307,6 +310,9 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
openProjectGroup.fillActionBars(actionBars);
|
openProjectGroup.fillActionBars(actionBars);
|
||||||
buildGroup.fillActionBars(actionBars);
|
buildGroup.fillActionBars(actionBars);
|
||||||
|
|
||||||
|
openViewActionGroup.fillActionBars(actionBars);
|
||||||
|
crefactoringActionGroup.fillActionBars(actionBars);
|
||||||
|
|
||||||
IToolBarManager toolBar = actionBars.getToolBarManager();
|
IToolBarManager toolBar = actionBars.getToolBarManager();
|
||||||
toolBar.add(new Separator());
|
toolBar.add(new Separator());
|
||||||
toolBar.add(collapseAllAction);
|
toolBar.add(collapseAllAction);
|
||||||
|
@ -343,6 +349,8 @@ public class MainActionGroup extends CViewActionGroup {
|
||||||
gotoGroup.dispose();
|
gotoGroup.dispose();
|
||||||
buildGroup.dispose();
|
buildGroup.dispose();
|
||||||
newWizardMenu.dispose();
|
newWizardMenu.dispose();
|
||||||
|
openViewActionGroup.dispose();
|
||||||
|
crefactoringActionGroup.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,30 +14,32 @@ package org.eclipse.cdt.internal.ui.editor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
|
||||||
import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
|
|
||||||
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
|
||||||
import org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter;
|
|
||||||
import org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter;
|
|
||||||
import org.eclipse.cdt.internal.ui.dnd.*;
|
|
||||||
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
|
||||||
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
|
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
|
||||||
import org.eclipse.cdt.ui.actions.*;
|
|
||||||
import org.eclipse.core.runtime.ListenerList;
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
import org.eclipse.jface.action.*;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.viewers.*;
|
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.viewers.AbstractTreeViewer;
|
||||||
|
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||||
|
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.dnd.DND;
|
import org.eclipse.swt.dnd.DND;
|
||||||
import org.eclipse.swt.dnd.Transfer;
|
import org.eclipse.swt.dnd.Transfer;
|
||||||
import org.eclipse.swt.widgets.*;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.*;
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Menu;
|
||||||
|
import org.eclipse.ui.IActionBars;
|
||||||
|
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.actions.ActionContext;
|
import org.eclipse.ui.actions.ActionContext;
|
||||||
import org.eclipse.ui.actions.ActionGroup;
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
import org.eclipse.ui.part.IPageSite;
|
import org.eclipse.ui.part.IPageSite;
|
||||||
|
@ -46,6 +48,31 @@ import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
|
||||||
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
|
||||||
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
|
import org.eclipse.ui.views.navigator.LocalSelectionTransfer;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.refactoring.actions.CRefactoringActionGroup;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
import org.eclipse.cdt.ui.actions.CustomFiltersActionGroup;
|
||||||
|
import org.eclipse.cdt.ui.actions.MemberFilterActionGroup;
|
||||||
|
import org.eclipse.cdt.ui.actions.OpenViewActionGroup;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction;
|
||||||
|
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||||
|
import org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.dnd.DelegatingDropAdapter;
|
||||||
|
import org.eclipse.cdt.internal.ui.dnd.TransferDragSourceListener;
|
||||||
|
import org.eclipse.cdt.internal.ui.dnd.TransferDropTargetListener;
|
||||||
|
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
|
||||||
|
|
||||||
public class CContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener {
|
public class CContentOutlinePage extends Page implements IContentOutlinePage, ISelectionChangedListener {
|
||||||
private CEditor fEditor;
|
private CEditor fEditor;
|
||||||
private ITranslationUnit fInput;
|
private ITranslationUnit fInput;
|
||||||
|
@ -62,6 +89,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
|
|
||||||
private ActionGroup fSelectionSearchGroup;
|
private ActionGroup fSelectionSearchGroup;
|
||||||
private ActionGroup fOpenViewActionGroup;
|
private ActionGroup fOpenViewActionGroup;
|
||||||
|
private ActionGroup fRefactoringActionGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom filter action group.
|
* Custom filter action group.
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
|
@ -203,24 +232,23 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
protected void contextMenuAboutToShow(IMenuManager menu) {
|
protected void contextMenuAboutToShow(IMenuManager menu) {
|
||||||
CUIPlugin.createStandardGroups(menu);
|
CUIPlugin.createStandardGroups(menu);
|
||||||
|
|
||||||
if (OpenViewActionGroup.canActionBeAdded(getSelection())){
|
ISelection selection= getSelection();
|
||||||
fOpenViewActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
|
if (OpenViewActionGroup.canActionBeAdded(selection)){
|
||||||
|
fOpenViewActionGroup.setContext(new ActionContext(selection));
|
||||||
fOpenViewActionGroup.fillContextMenu(menu);
|
fOpenViewActionGroup.fillContextMenu(menu);
|
||||||
fOpenViewActionGroup.setContext(null);
|
fOpenViewActionGroup.setContext(null);
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OpenIncludeAction.canActionBeAdded(getSelection())) {
|
if (OpenIncludeAction.canActionBeAdded(selection)) {
|
||||||
menu.add(fOpenIncludeAction);
|
menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenIncludeAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
if (SelectionSearchGroup.canActionBeAdded(selection)){
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS+"-end"));//$NON-NLS-1$
|
|
||||||
|
|
||||||
if (SelectionSearchGroup.canActionBeAdded(getSelection())){
|
|
||||||
fSelectionSearchGroup.fillContextMenu(menu);
|
fSelectionSearchGroup.fillContextMenu(menu);
|
||||||
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fRefactoringActionGroup.fillContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CContentOutlinerProvider createContentProvider(TreeViewer viewer) {
|
protected CContentOutlinerProvider createContentProvider(TreeViewer viewer) {
|
||||||
|
@ -279,6 +307,7 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
|
|
||||||
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
||||||
fOpenViewActionGroup = new OpenViewActionGroup(this);
|
fOpenViewActionGroup = new OpenViewActionGroup(this);
|
||||||
|
fRefactoringActionGroup= new CRefactoringActionGroup(this);
|
||||||
// Custom filter group
|
// Custom filter group
|
||||||
fCustomFiltersActionGroup= new CustomFiltersActionGroup("org.eclipse.cdt.ui.COutlinePage", getTreeViewer()); //$NON-NLS-1$
|
fCustomFiltersActionGroup= new CustomFiltersActionGroup("org.eclipse.cdt.ui.COutlinePage", getTreeViewer()); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -309,6 +338,11 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
fOpenViewActionGroup= null;
|
fOpenViewActionGroup= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fRefactoringActionGroup != null) {
|
||||||
|
fRefactoringActionGroup.dispose();
|
||||||
|
fRefactoringActionGroup= null;
|
||||||
|
}
|
||||||
|
|
||||||
if (fSelectionSearchGroup != null) {
|
if (fSelectionSearchGroup != null) {
|
||||||
fSelectionSearchGroup.dispose();
|
fSelectionSearchGroup.dispose();
|
||||||
fSelectionSearchGroup= null;
|
fSelectionSearchGroup= null;
|
||||||
|
@ -342,8 +376,9 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
|
|
||||||
fMemberFilterActionGroup= new MemberFilterActionGroup(fTreeViewer, "COutlineViewer"); //$NON-NLS-1$
|
fMemberFilterActionGroup= new MemberFilterActionGroup(fTreeViewer, "COutlineViewer"); //$NON-NLS-1$
|
||||||
fMemberFilterActionGroup.fillActionBars(actionBars);
|
fMemberFilterActionGroup.fillActionBars(actionBars);
|
||||||
|
|
||||||
fCustomFiltersActionGroup.fillActionBars(actionBars);
|
fCustomFiltersActionGroup.fillActionBars(actionBars);
|
||||||
|
fOpenViewActionGroup.fillActionBars(actionBars);
|
||||||
|
fRefactoringActionGroup.fillActionBars(actionBars);
|
||||||
|
|
||||||
IMenuManager menu= actionBars.getMenuManager();
|
IMenuManager menu= actionBars.getMenuManager();
|
||||||
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
|
menu.add(new Separator("EndFilterGroup")); //$NON-NLS-1$
|
||||||
|
@ -375,6 +410,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
||||||
for (int i = 0; i < listeners.length; ++i) {
|
for (int i = 0; i < listeners.length; ++i) {
|
||||||
((ISelectionChangedListener) listeners[i]).selectionChanged(event);
|
((ISelectionChangedListener) listeners[i]).selectionChanged(event);
|
||||||
}
|
}
|
||||||
|
fRefactoringActionGroup.setContext(new ActionContext(selection));
|
||||||
|
fRefactoringActionGroup.updateActionBars();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -124,6 +124,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ISourceRange;
|
import org.eclipse.cdt.core.model.ISourceRange;
|
||||||
import org.eclipse.cdt.core.model.ISourceReference;
|
import org.eclipse.cdt.core.model.ISourceReference;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
|
import org.eclipse.cdt.refactoring.actions.CRefactoringActionGroup;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
import org.eclipse.cdt.ui.IWorkingCopyManager;
|
||||||
import org.eclipse.cdt.ui.PreferenceConstants;
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
@ -502,6 +503,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
||||||
/** Search actions **/
|
/** Search actions **/
|
||||||
private ActionGroup fSelectionSearchGroup;
|
private ActionGroup fSelectionSearchGroup;
|
||||||
private ActionGroup fTextSearchGroup;
|
private ActionGroup fTextSearchGroup;
|
||||||
|
private CRefactoringActionGroup fRefactoringActionGroup;
|
||||||
|
|
||||||
/** Action which shows selected element in CView. */
|
/** Action which shows selected element in CView. */
|
||||||
private ShowInCViewAction fShowInCViewAction;
|
private ShowInCViewAction fShowInCViewAction;
|
||||||
|
|
||||||
|
@ -953,6 +956,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
||||||
fTextSearchGroup = null;
|
fTextSearchGroup = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fRefactoringActionGroup != null) {
|
||||||
|
fRefactoringActionGroup.dispose();
|
||||||
|
fRefactoringActionGroup = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (fEditorSelectionChangedListener != null) {
|
if (fEditorSelectionChangedListener != null) {
|
||||||
fEditorSelectionChangedListener.uninstall(getSelectionProvider());
|
fEditorSelectionChangedListener.uninstall(getSelectionProvider());
|
||||||
fEditorSelectionChangedListener= null;
|
fEditorSelectionChangedListener= null;
|
||||||
|
@ -1091,6 +1099,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
||||||
//Assorted action groupings
|
//Assorted action groupings
|
||||||
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
||||||
fTextSearchGroup= new TextSearchGroup(this);
|
fTextSearchGroup= new TextSearchGroup(this);
|
||||||
|
fRefactoringActionGroup= new CRefactoringActionGroup(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1123,6 +1132,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
||||||
|
|
||||||
fSelectionSearchGroup.fillContextMenu(menu);
|
fSelectionSearchGroup.fillContextMenu(menu);
|
||||||
fTextSearchGroup.fillContextMenu(menu);
|
fTextSearchGroup.fillContextMenu(menu);
|
||||||
|
fRefactoringActionGroup.fillContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
return super.getParent(element);
|
return super.getParent(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] syncronouslyComputeChildren(Object parentElement) {
|
protected Object[] syncronouslyComputeChildren(Object parentElement) {
|
||||||
if (parentElement instanceof ITranslationUnit) {
|
if (parentElement instanceof ITranslationUnit) {
|
||||||
ITranslationUnit tu = (ITranslationUnit) parentElement;
|
ITranslationUnit tu = (ITranslationUnit) parentElement;
|
||||||
return new Object[] { new IBNode(null, new IBFile(tu), null, null, 0, 0) };
|
return new Object[] { new IBNode(null, new IBFile(tu), null, null, 0, 0) };
|
||||||
|
@ -61,7 +61,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] asyncronouslyComputeChildren(Object parentElement,
|
protected Object[] asyncronouslyComputeChildren(Object parentElement,
|
||||||
IProgressMonitor monitor) {
|
IProgressMonitor monitor) {
|
||||||
if (parentElement instanceof IBNode) {
|
if (parentElement instanceof IBNode) {
|
||||||
IBNode node = (IBNode) parentElement;
|
IBNode node = (IBNode) parentElement;
|
||||||
|
|
|
@ -51,8 +51,6 @@ import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.swt.widgets.Text;
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.swt.widgets.TreeItem;
|
import org.eclipse.swt.widgets.TreeItem;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IEditorDescriptor;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.IMemento;
|
import org.eclipse.ui.IMemento;
|
||||||
import org.eclipse.ui.IPageLayout;
|
import org.eclipse.ui.IPageLayout;
|
||||||
import org.eclipse.ui.IViewSite;
|
import org.eclipse.ui.IViewSite;
|
||||||
|
@ -62,7 +60,6 @@ import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.actions.ActionFactory;
|
import org.eclipse.ui.actions.ActionFactory;
|
||||||
import org.eclipse.ui.actions.ContributionItemFactory;
|
import org.eclipse.ui.actions.ContributionItemFactory;
|
||||||
import org.eclipse.ui.actions.OpenFileAction;
|
import org.eclipse.ui.actions.OpenFileAction;
|
||||||
import org.eclipse.ui.ide.IDE;
|
|
||||||
import org.eclipse.ui.part.IShowInSource;
|
import org.eclipse.ui.part.IShowInSource;
|
||||||
import org.eclipse.ui.part.IShowInTarget;
|
import org.eclipse.ui.part.IShowInTarget;
|
||||||
import org.eclipse.ui.part.IShowInTargetList;
|
import org.eclipse.ui.part.IShowInTargetList;
|
||||||
|
@ -70,21 +67,17 @@ import org.eclipse.ui.part.PageBook;
|
||||||
import org.eclipse.ui.part.ResourceTransfer;
|
import org.eclipse.ui.part.ResourceTransfer;
|
||||||
import org.eclipse.ui.part.ShowInContext;
|
import org.eclipse.ui.part.ShowInContext;
|
||||||
import org.eclipse.ui.part.ViewPart;
|
import org.eclipse.ui.part.ViewPart;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.IPositionConverter;
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
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;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.CPluginImages;
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
|
||||||
import org.eclipse.cdt.internal.ui.util.Messages;
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.EditorOpener;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
|
import org.eclipse.cdt.internal.ui.viewsupport.TreeNavigator;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
|
import org.eclipse.cdt.internal.ui.viewsupport.WorkingSetFilterUI;
|
||||||
|
@ -661,55 +654,24 @@ public class IBViewPart extends ViewPart
|
||||||
protected void onShowInclude(ISelection selection) {
|
protected void onShowInclude(ISelection selection) {
|
||||||
IBNode node= IBConversions.selectionToNode(selection);
|
IBNode node= IBConversions.selectionToNode(selection);
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
fLastNavigationNode= node;
|
||||||
|
|
||||||
IWorkbenchPage page= getSite().getPage();
|
IWorkbenchPage page= getSite().getPage();
|
||||||
IBFile ibf= node.getDirectiveFile();
|
IBFile ibf= node.getDirectiveFile();
|
||||||
long timestamp= node.getTimestamp();
|
|
||||||
if (ibf != null) {
|
if (ibf != null) {
|
||||||
IEditorPart editor= null;
|
IRegion region= new Region(node.getDirectiveCharacterOffset(), node.getDirectiveName().length() + 2);
|
||||||
IPath filebufferKey= null;
|
long timestamp= node.getTimestamp();
|
||||||
|
|
||||||
IFile f= ibf.getResource();
|
IFile f= ibf.getResource();
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
if (timestamp == 0) {
|
EditorOpener.open(page, f, region, timestamp);
|
||||||
timestamp= f.getLocalTimeStamp();
|
|
||||||
}
|
|
||||||
fLastNavigationNode= node;
|
|
||||||
try {
|
|
||||||
editor= IDE.openEditor(page, f, false);
|
|
||||||
filebufferKey= f.getFullPath();
|
|
||||||
} catch (PartInitException e) {
|
|
||||||
CUIPlugin.getDefault().log(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IPath location= ibf.getLocation();
|
IPath location= ibf.getLocation();
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
if (timestamp == 0) {
|
EditorOpener.openExternalFile(page, location, region, timestamp);
|
||||||
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;
|
|
||||||
IRegion pos= new Region(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 {
|
else {
|
||||||
ITranslationUnit tu= IBConversions.selectionToTU(selection);
|
ITranslationUnit tu= IBConversions.selectionToTU(selection);
|
||||||
|
|
|
@ -84,6 +84,9 @@ public class CIndexQueries {
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
public int getLength() {
|
||||||
|
return fName.getFileLocation().getNodeLength();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final IPDOMInclude[] EMPTY_INCLUDES = new IPDOMInclude[0];
|
private static final IPDOMInclude[] EMPTY_INCLUDES = new IPDOMInclude[0];
|
||||||
|
@ -118,7 +121,7 @@ public class CIndexQueries {
|
||||||
ICProject cproject= tu.getCProject();
|
ICProject cproject= tu.getCProject();
|
||||||
if (cproject != null) {
|
if (cproject != null) {
|
||||||
projects.remove(cproject);
|
projects.remove(cproject);
|
||||||
projects.addFirst(cproject);
|
projects.addLast(cproject);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Iterator iter = projects.iterator(); iter.hasNext();) {
|
for (Iterator iter = projects.iterator(); iter.hasNext();) {
|
||||||
|
@ -181,38 +184,36 @@ public class CIndexQueries {
|
||||||
return EMPTY_INCLUDES;
|
return EMPTY_INCLUDES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPDOMReference[] findReferences(ITranslationUnit tu, IASTName name, IProgressMonitor pm) throws CoreException, InterruptedException {
|
public IPDOMReference[] findReferences(IASTName name, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
ArrayList result= new ArrayList();
|
ArrayList result= new ArrayList();
|
||||||
LinkedList projects= new LinkedList(Arrays.asList(CoreModel.getDefault().getCModel().getCProjects()));
|
LinkedList projects= new LinkedList(Arrays.asList(CoreModel.getDefault().getCModel().getCProjects()));
|
||||||
ICProject cproject= tu.getCProject();
|
|
||||||
if (cproject != null) {
|
|
||||||
projects.remove(cproject);
|
|
||||||
projects.addFirst(cproject);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// resolve the binding.
|
||||||
name.resolveBinding();
|
name.resolveBinding();
|
||||||
|
|
||||||
for (Iterator iter = projects.iterator(); iter.hasNext();) {
|
for (Iterator iter = projects.iterator(); iter.hasNext();) {
|
||||||
cproject = (ICProject) iter.next();
|
findReferences(name, (ICProject) iter.next(), result);
|
||||||
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()]);
|
return (IPDOMReference[]) result.toArray(new IPDOMReference[result.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void findReferences(IASTName name, ICProject project, Collection result) throws InterruptedException, CoreException {
|
||||||
|
PDOM pdom= (PDOM) CCorePlugin.getPDOMManager().getPDOM(project);
|
||||||
|
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];
|
||||||
|
result.add(new IPDOMReference(project, rname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
pdom.releaseReadLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public abstract class AsyncTreeContentProvider implements ITreeContentProvider {
|
||||||
* @param parentElement the parent element
|
* @param parentElement the parent element
|
||||||
* @return an array of child elements, or <code>null</code>
|
* @return an array of child elements, or <code>null</code>
|
||||||
*/
|
*/
|
||||||
public Object[] syncronouslyComputeChildren(Object parentElement) {
|
protected Object[] syncronouslyComputeChildren(Object parentElement) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public abstract class AsyncTreeContentProvider implements ITreeContentProvider {
|
||||||
* @param monitor the monitor that can be checked for a cancel event.
|
* @param monitor the monitor that can be checked for a cancel event.
|
||||||
* @return an array of child elements.
|
* @return an array of child elements.
|
||||||
*/
|
*/
|
||||||
public Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
|
protected Object[] asyncronouslyComputeChildren(Object parentElement, IProgressMonitor monitor) {
|
||||||
return NO_CHILDREN;
|
return NO_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.viewsupport;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.jface.text.Region;
|
||||||
|
import org.eclipse.ui.IEditorDescriptor;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.ide.IDE;
|
||||||
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.IPositionConverter;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
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.core.resources.FileStorage;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An utility to open editors for references or elements.
|
||||||
|
* @author markus.schorn@windriver.com
|
||||||
|
*/
|
||||||
|
public class EditorOpener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the editor selecting the given region.
|
||||||
|
*/
|
||||||
|
public static void open(IWorkbenchPage page, IFile file, IRegion region, long timestamp) {
|
||||||
|
IEditorPart editor= null;
|
||||||
|
if (timestamp == 0) {
|
||||||
|
timestamp= file.getLocalTimeStamp();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
editor= IDE.openEditor(page, file, false);
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
|
selectRegion(file.getFullPath(), region, timestamp, editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void selectRegion(IPath filebufferKey, IRegion region, long timestamp, IEditorPart editor) {
|
||||||
|
if (editor instanceof ITextEditor) {
|
||||||
|
ITextEditor te= (ITextEditor) editor;
|
||||||
|
IPositionConverter pc= CCorePlugin.getPositionTrackerManager().findPositionConverter(filebufferKey, timestamp);
|
||||||
|
if (pc != null) {
|
||||||
|
region= pc.historicToActual(region);
|
||||||
|
}
|
||||||
|
te.selectAndReveal(region.getOffset(), region.getLength());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the editor for an external location, selecting the given region.
|
||||||
|
*/
|
||||||
|
public static void openExternalFile(IWorkbenchPage page, IPath location, IRegion region, long timestamp) {
|
||||||
|
IEditorPart editor= null;
|
||||||
|
if (timestamp == 0) {
|
||||||
|
timestamp= location.toFile().lastModified();
|
||||||
|
}
|
||||||
|
ExternalEditorInput ei= new ExternalEditorInput(new FileStorage(null, location));
|
||||||
|
try {
|
||||||
|
IEditorDescriptor descriptor = IDE.getEditorDescriptor(location.lastSegment());
|
||||||
|
editor= IDE.openEditor(page, ei, descriptor.getId(), false);
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
|
selectRegion(location, region, timestamp, editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the editor for an ICElement, selecting the id.
|
||||||
|
* @throws CModelException
|
||||||
|
*/
|
||||||
|
public static void open(IWorkbenchPage page, ICElement element) throws CModelException {
|
||||||
|
if (element instanceof ISourceReference) {
|
||||||
|
ISourceReference sr= (ISourceReference) element;
|
||||||
|
ITranslationUnit tu= sr.getTranslationUnit();
|
||||||
|
ISourceRange range= sr.getSourceRange();
|
||||||
|
long timestamp= 0; // last modified of file.
|
||||||
|
if (tu.isWorkingCopy()) {
|
||||||
|
timestamp= -1;
|
||||||
|
}
|
||||||
|
open(page, tu, new Region(range.getIdStartPos(), range.getIdLength()), timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens the editor for an ICElement, selecting the given region.
|
||||||
|
*/
|
||||||
|
public static void open(IWorkbenchPage page, ITranslationUnit tu, Region region, long timestamp) {
|
||||||
|
if (tu != null) {
|
||||||
|
IResource r= tu.getResource();
|
||||||
|
if (r instanceof IFile) {
|
||||||
|
EditorOpener.open(page, (IFile) r, region, timestamp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IPath location= tu.getPath();
|
||||||
|
if (location != null) {
|
||||||
|
EditorOpener.openExternalFile(page, location, region, timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -91,11 +91,22 @@ public class TreeNavigator {
|
||||||
*/
|
*/
|
||||||
public TreeItem getNextSibbling(TreeItem current, boolean forward) {
|
public TreeItem getNextSibbling(TreeItem current, boolean forward) {
|
||||||
TreeItem parentItem= current.getParentItem();
|
TreeItem parentItem= current.getParentItem();
|
||||||
int itemCount = parentItem.getItemCount();
|
if (parentItem == null) {
|
||||||
if (parentItem != null && itemCount > 1) {
|
Tree tree= current.getParent();
|
||||||
int index= parentItem.indexOf(current);
|
int itemCount = tree.getItemCount();
|
||||||
index = (index + (forward ? 1 : itemCount-1)) % itemCount;
|
if (itemCount > 0) {
|
||||||
return parentItem.getItem(index);
|
int index= tree.indexOf(current);
|
||||||
|
index = (index + (forward ? 1 : itemCount-1)) % itemCount;
|
||||||
|
return tree.getItem(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int itemCount = parentItem.getItemCount();
|
||||||
|
if (itemCount > 0) {
|
||||||
|
int index= parentItem.indexOf(current);
|
||||||
|
index = (index + (forward ? 1 : itemCount-1)) % itemCount;
|
||||||
|
return parentItem.getItem(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.ui.IActionBars;
|
import org.eclipse.ui.IActionBars;
|
||||||
import org.eclipse.ui.IViewPart;
|
import org.eclipse.ui.IViewPart;
|
||||||
import org.eclipse.ui.IWorkbenchSite;
|
import org.eclipse.ui.IWorkbenchSite;
|
||||||
|
import org.eclipse.ui.actions.ActionContext;
|
||||||
import org.eclipse.ui.actions.ActionFactory;
|
import org.eclipse.ui.actions.ActionFactory;
|
||||||
import org.eclipse.ui.actions.ActionGroup;
|
import org.eclipse.ui.actions.ActionGroup;
|
||||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
||||||
|
@ -181,6 +182,7 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
// provider.removeSelectionChangedListener(fOpenExternalJavadoc);
|
// provider.removeSelectionChangedListener(fOpenExternalJavadoc);
|
||||||
// provider.removeSelectionChangedListener(fOpenTypeHierarchy);
|
// provider.removeSelectionChangedListener(fOpenTypeHierarchy);
|
||||||
provider.removeSelectionChangedListener(fOpenCallHierarchy);
|
provider.removeSelectionChangedListener(fOpenCallHierarchy);
|
||||||
|
fOpenPropertiesDialog.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,14 +190,17 @@ public class OpenViewActionGroup extends ActionGroup {
|
||||||
// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_SUPER_IMPLEMENTATION, fOpenSuperImplementation);
|
// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_SUPER_IMPLEMENTATION, fOpenSuperImplementation);
|
||||||
// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_EXTERNAL_JAVA_DOC, fOpenExternalJavadoc);
|
// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_EXTERNAL_JAVA_DOC, fOpenExternalJavadoc);
|
||||||
// actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_TYPE_HIERARCHY, fOpenTypeHierarchy);
|
// actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_TYPE_HIERARCHY, fOpenTypeHierarchy);
|
||||||
// actionBars.setGlobalActionHandler(JdtActionConstants.OPEN_CALL_HIERARCHY, fOpenCallHierarchy);
|
actionBars.setGlobalActionHandler(CdtActionConstants.OPEN_CALL_HIERARCHY, fOpenCallHierarchy);
|
||||||
actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
|
actionBars.setGlobalActionHandler(ActionFactory.PROPERTIES.getId(), fOpenPropertiesDialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IStructuredSelection getStructuredSelection() {
|
private IStructuredSelection getStructuredSelection() {
|
||||||
ISelection selection= getContext().getSelection();
|
ActionContext context= getContext();
|
||||||
if (selection instanceof IStructuredSelection)
|
if (context != null) {
|
||||||
return (IStructuredSelection)selection;
|
ISelection selection= getContext().getSelection();
|
||||||
|
if (selection instanceof IStructuredSelection)
|
||||||
|
return (IStructuredSelection)selection;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue