1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Patch for Devin Steffler: Initial IndexViewer patch

This commit is contained in:
Bogdan Gheorghe 2005-03-29 21:40:34 +00:00
parent 568c1dd81e
commit 7a1f792fe6
79 changed files with 2291 additions and 162 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 895 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 868 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 836 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 837 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 960 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

View file

@ -56,6 +56,14 @@
name="DOM AST"
id="org.eclipse.cdt.ui.tests.DOMAST.DOMAST">
</view>
<view
allowMultiple="true"
category="org.eclipse.cdt.ui.views"
class="org.eclipse.cdt.ui.tests.IndexerView.IndexerView"
fastViewWidthRatio="0.35"
icon="icons/used/output_obj.gif"
id="org.eclipse.cdt.ui.tests.IndexerView"
name="Indexer View"/>
</extension>
<extension
point="org.eclipse.ui.perspectiveExtensions">
@ -72,8 +80,17 @@
<extension
point="org.eclipse.ui.popupMenus">
<viewerContribution
targetID="org.eclipse.cdt.ui.CView"
id="org.eclipse.cdt.ui.CView">
targetID="#CEditorContext"
id="org.eclipse.cdt.ui.tests.cEditorContribution">
<action
label="Show IASTNode in DOM View"
class="org.eclipse.cdt.ui.tests.DOMAST.ShowInDOMViewAction"
menubarPath="additions"
id="org.eclipse.cdt.ui.tests.DOMAST.ShowInDOMViewAction1"/>
</viewerContribution>
<viewerContribution
id="org.eclipse.cdt.ui.CView1"
targetID="org.eclipse.cdt.ui.CView">
<action
label="Show in DOM AST"
class="org.eclipse.cdt.ui.tests.DOMAST.OpenDOMViewAction"
@ -93,13 +110,18 @@
</visibility>
</viewerContribution>
<viewerContribution
targetID="#CEditorContext"
id="org.eclipse.cdt.ui.tests.cEditorContribution">
id="org.eclipse.cdt.ui.CView2"
targetID="org.eclipse.cdt.ui.CView">
<action
label="Show IASTNode in DOM View"
class="org.eclipse.cdt.ui.tests.DOMAST.ShowInDOMViewAction"
menubarPath="additions"
id="org.eclipse.cdt.ui.tests.DOMAST.ShowInDOMViewAction1"/>
class="org.eclipse.cdt.ui.tests.IndexerView.OpenIndexerViewAction"
id="org.eclipse.cdt.ui.tests.IndexerView.OpenIndexerViewAction"
label="Show in Indexer View"
menubarPath="additions"/>
<visibility>
<or>
<objectClass name="org.eclipse.cdt.internal.core.model.CProject"/>
</or>
</visibility>
</viewerContribution>
</extension>
<extension
@ -130,5 +152,4 @@
</filter>
</extension>
</plugin>

View file

@ -65,12 +65,12 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
shouldVisitNamespaces = true;
}
TreeParent root = null;
DOMASTNodeParent root = null;
IProgressMonitor monitor = null;
IASTProblem[] astProblems = new IASTProblem[INITIAL_PROBLEM_SIZE];
public CPPPopulateASTViewAction(IASTTranslationUnit tu, IProgressMonitor monitor) {
root = new TreeParent(tu);
root = new DOMASTNodeParent(tu);
this.monitor = monitor;
}
@ -85,17 +85,17 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
nodeLocations[0].getNodeLength() > 0))
return PROCESS_CONTINUE;
TreeParent parent = root.findTreeParentForNode(node);
DOMASTNodeParent parent = root.findTreeParentForNode(node);
if (parent == null)
parent = root;
TreeParent tree = new TreeParent(node);
DOMASTNodeParent tree = new DOMASTNodeParent(node);
parent.addChild(tree);
// set filter flags
if (node instanceof IASTProblemHolder || node instanceof IASTProblem) {
tree.setFiltersFlag(TreeObject.FLAG_PROBLEM);
tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PROBLEM);
if (node instanceof IASTProblemHolder)
astProblems = (IASTProblem[])ArrayUtil.append(IASTProblem.class, astProblems, ((IASTProblemHolder)node).getProblem());
@ -103,9 +103,9 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
astProblems = (IASTProblem[])ArrayUtil.append(IASTProblem.class, astProblems, node);
}
if (node instanceof IASTPreprocessorStatement)
tree.setFiltersFlag(TreeObject.FLAG_PREPROCESSOR);
tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PREPROCESSOR);
if (node instanceof IASTPreprocessorIncludeStatement)
tree.setFiltersFlag(TreeObject.FLAG_INCLUDE_STATEMENTS);
tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_INCLUDE_STATEMENTS);
return PROCESS_CONTINUE;
}
@ -248,7 +248,7 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
}
}
public TreeParent getTree() {
public DOMASTNodeParent getTree() {
return root;
}
@ -269,7 +269,7 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
}
// get the tree model elements corresponding to the includes
TreeParent[] treeIncludes = new TreeParent[index];
DOMASTNodeParent[] treeIncludes = new DOMASTNodeParent[index];
for (int i=0; i<treeIncludes.length; i++) {
if (monitor != null && monitor.isCanceled()) return;
treeIncludes[i] = root.findTreeObject(includes[i], false);
@ -277,7 +277,7 @@ public class CPPPopulateASTViewAction extends CPPASTVisitor implements IPopulate
// loop through the includes and make sure that all of the nodes
// that are children of the TU are in the proper include (based on offset)
TreeObject child = null;
DOMASTNodeLeaf child = null;
outerLoop: for (int i=treeIncludes.length-1; i>=0; i--) {
if (treeIncludes[i] == null) continue;

View file

@ -58,12 +58,12 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
shouldVisitEnumerators = true;
}
TreeParent root = null;
DOMASTNodeParent root = null;
IProgressMonitor monitor = null;
IASTProblem[] astProblems = new IASTProblem[INITIAL_PROBLEM_SIZE];
public CPopulateASTViewAction(IASTTranslationUnit tu, IProgressMonitor monitor) {
root = new TreeParent(tu);
root = new DOMASTNodeParent(tu);
this.monitor = monitor;
}
@ -77,17 +77,17 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
nodeLocations[0].getNodeLength() > 0))
return PROCESS_CONTINUE;
TreeParent parent = root.findTreeParentForNode(node);
DOMASTNodeParent parent = root.findTreeParentForNode(node);
if (parent == null)
parent = root;
TreeParent tree = new TreeParent(node);
DOMASTNodeParent tree = new DOMASTNodeParent(node);
parent.addChild(tree);
// set filter flags
if (node instanceof IASTProblemHolder || node instanceof IASTProblem) {
tree.setFiltersFlag(TreeObject.FLAG_PROBLEM);
tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PROBLEM);
if (node instanceof IASTProblemHolder)
astProblems = (IASTProblem[])ArrayUtil.append(IASTProblem.class, astProblems, ((IASTProblemHolder)node).getProblem());
@ -95,9 +95,9 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
astProblems = (IASTProblem[])ArrayUtil.append(IASTProblem.class, astProblems, node);
}
if (node instanceof IASTPreprocessorStatement)
tree.setFiltersFlag(TreeObject.FLAG_PREPROCESSOR);
tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_PREPROCESSOR);
if (node instanceof IASTPreprocessorIncludeStatement)
tree.setFiltersFlag(TreeObject.FLAG_INCLUDE_STATEMENTS);
tree.setFiltersFlag(DOMASTNodeLeaf.FLAG_INCLUDE_STATEMENTS);
@ -221,7 +221,7 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
}
}
public TreeParent getTree() {
public DOMASTNodeParent getTree() {
return root;
}
@ -242,7 +242,7 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
}
// get the tree model elements corresponding to the includes
TreeParent[] treeIncludes = new TreeParent[index];
DOMASTNodeParent[] treeIncludes = new DOMASTNodeParent[index];
for (int i=0; i<treeIncludes.length; i++) {
if (monitor != null && monitor.isCanceled()) return;
treeIncludes[i] = root.findTreeObject(includes[i], false);
@ -250,7 +250,7 @@ public class CPopulateASTViewAction extends CASTVisitor implements IPopulateDOMA
// loop through the includes and make sure that all of the nodes
// that are children of the TU are in the proper include (based on offset)
TreeObject child = null;
DOMASTNodeLeaf child = null;
outerLoop: for (int i=treeIncludes.length-1; i>=0; i--) {
if (treeIncludes[i] == null) continue;

View file

@ -110,6 +110,7 @@ import org.eclipse.ui.views.properties.PropertySheet;
*/
public class DOMAST extends ViewPart {
public static final String VIEW_ID = "org.eclipse.cdt.ui.tests.DOMAST.DOMAST"; //$NON-NLS-1$
private static final String PROPERTIES_VIEW = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$
private static final String ASTUTIL_MENU_LABEL = "ASTUtil#"; //$NON-NLS-1$
private static final String DISPLAY_TYPE = "getNodeType(IASTNode)"; //$NON-NLS-1$
@ -168,8 +169,8 @@ public class DOMAST extends ViewPart {
public class ViewContentProvider implements IStructuredContentProvider,
ITreeContentProvider {
private static final String POPULATING_AST_VIEW = "Populating AST View"; //$NON-NLS-1$
private TreeParent invisibleRoot;
private TreeParent tuTreeParent = null;
private DOMASTNodeParent invisibleRoot;
private DOMASTNodeParent tuTreeParent = null;
private IASTTranslationUnit tu = null;
private IASTProblem[] astProblems = null;
@ -186,11 +187,11 @@ public class DOMAST extends ViewPart {
}
public TreeParent getTUTreeParent() {
public DOMASTNodeParent getTUTreeParent() {
if (tuTreeParent == null && invisibleRoot != null) {
for(int i=0; i<invisibleRoot.getChildren().length; i++) {
if (invisibleRoot.getChildren()[i] instanceof TreeParent && invisibleRoot.getChildren()[i].getNode() instanceof IASTTranslationUnit){
tuTreeParent = (TreeParent)invisibleRoot.getChildren()[i];
if (invisibleRoot.getChildren()[i] instanceof DOMASTNodeParent && invisibleRoot.getChildren()[i].getNode() instanceof IASTTranslationUnit){
tuTreeParent = (DOMASTNodeParent)invisibleRoot.getChildren()[i];
return tuTreeParent;
}
}
@ -202,7 +203,7 @@ public class DOMAST extends ViewPart {
public IASTTranslationUnit getTU() {
if (tu == null && invisibleRoot != null) {
for(int i=0; i<invisibleRoot.getChildren().length; i++) {
if (invisibleRoot.getChildren()[i] instanceof TreeParent && invisibleRoot.getChildren()[i].getNode() instanceof IASTTranslationUnit){
if (invisibleRoot.getChildren()[i] instanceof DOMASTNodeParent && invisibleRoot.getChildren()[i].getNode() instanceof IASTTranslationUnit){
tu = (IASTTranslationUnit)invisibleRoot.getChildren()[i].getNode();
}
}
@ -224,22 +225,22 @@ public class DOMAST extends ViewPart {
}
public Object getParent(Object child) {
if (child instanceof TreeObject) {
return ((TreeObject) child).getParent();
if (child instanceof DOMASTNodeLeaf) {
return ((DOMASTNodeLeaf) child).getParent();
}
return null;
}
public Object[] getChildren(Object parent) {
if (parent instanceof TreeParent) {
return ((TreeParent) parent).getChildren();
if (parent instanceof DOMASTNodeParent) {
return ((DOMASTNodeParent) parent).getChildren();
}
return new Object[0];
}
public boolean hasChildren(Object parent) {
if (parent instanceof TreeParent)
return ((TreeParent) parent).hasChildren();
if (parent instanceof DOMASTNodeParent)
return ((DOMASTNodeParent) parent).hasChildren();
return false;
}
@ -280,10 +281,10 @@ public class DOMAST extends ViewPart {
private void expandTreeIfNecessary(TreeItem[] tree, Object[] expanded) {
for( int i=0; i<tree.length; i++) {
for( int j=0; j<expanded.length; j++) {
if (expanded[j] instanceof TreeObject &&
tree[i].getData() instanceof TreeObject &&
((TreeObject)expanded[j]).toString().equals(((TreeObject)tree[i].getData()).toString()) &&
((TreeObject)expanded[j]).getOffset() == (((TreeObject)tree[i].getData()).getOffset())) {
if (expanded[j] instanceof DOMASTNodeLeaf &&
tree[i].getData() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)expanded[j]).toString().equals(((DOMASTNodeLeaf)tree[i].getData()).toString()) &&
((DOMASTNodeLeaf)expanded[j]).getOffset() == (((DOMASTNodeLeaf)tree[i].getData()).getOffset())) {
tree[i].setExpanded(true);
viewer.refresh();
expandTreeIfNecessary(tree[i].getItems(), expanded);
@ -309,7 +310,7 @@ public class DOMAST extends ViewPart {
private static final String GENERATING_INITIAL_TREE = "Generating initial AST Tree for the View"; //$NON-NLS-1$
private static final String PARSING_TRANSLATION_UNIT = "Parsing Translation Unit"; //$NON-NLS-1$
String name = null;
TreeParent root = null;
DOMASTNodeParent root = null;
ViewContentProvider provider = null;
TreeViewer view = null;
IFile file = null;
@ -326,7 +327,7 @@ public class DOMAST extends ViewPart {
this.file = file;
}
public TreeParent getInvisibleRoot() {
public DOMASTNodeParent getInvisibleRoot() {
return root;
}
@ -380,7 +381,7 @@ public class DOMAST extends ViewPart {
System.out.println("[DOM AST View] done " + GENERATING_INITIAL_TREE + ": " + (System.currentTimeMillis()- start) );
// display roots
root = new TreeParent(null); //$NON-NLS-1$
root = new DOMASTNodeParent(null); //$NON-NLS-1$
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
monitor.subTask(RETRIEVING_PREPROCESSOR_STATEMENTS);
@ -442,10 +443,10 @@ public class DOMAST extends ViewPart {
}
private void initialize() {
invisibleRoot = new TreeParent(); // blank the AST View, when the job above is complete it will update the AST View with the proper tree
invisibleRoot = new DOMASTNodeParent(); // blank the AST View, when the job above is complete it will update the AST View with the proper tree
}
protected void setInvisibleRoot(TreeParent root) {
protected void setInvisibleRoot(DOMASTNodeParent root) {
invisibleRoot = root;
}
@ -478,13 +479,13 @@ public class DOMAST extends ViewPart {
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
private TreeItem expandTreeToTreeObject(TreeItem[] treeItems, TreeObject treeObj) {
private TreeItem expandTreeToTreeObject(TreeItem[] treeItems, DOMASTNodeLeaf treeObj) {
for (int i=0; i<treeItems.length; i++) {
if (treeItems[i].getData() == treeObj) {
return treeItems[i];
}
TreeParent parent = treeObj.getParent();
DOMASTNodeParent parent = treeObj.getParent();
if (parent == null) return null;
@ -504,7 +505,7 @@ public class DOMAST extends ViewPart {
return null; // nothing found
}
private TreeItem expandTreeToTreeObject(TreeObject treeObj) {
private TreeItem expandTreeToTreeObject(DOMASTNodeLeaf treeObj) {
return expandTreeToTreeObject(viewer.getTree().getItems(), treeObj);
}
@ -521,14 +522,14 @@ public class DOMAST extends ViewPart {
* @return
*/
public boolean findAndSelect(IASTNode node, boolean useOffset) {
// get the TreeObject from the AST View's model corresponding to the IASTNode
TreeObject treeNode = null;
// get the DOMASTNodeLeaf from the AST View's model corresponding to the IASTNode
DOMASTNodeLeaf treeNode = null;
TreeItem treeItem = null;
treeNode = getTUTreeParent().findTreeObject(node, useOffset);
if (treeNode != null && treeNode.getParent() != null) {
// found a matching TreeObject, so expand the tree to that object
// found a matching DOMASTNodeLeaf, so expand the tree to that object
treeItem = expandTreeToTreeObject(treeNode);
}
@ -556,8 +557,8 @@ public class DOMAST extends ViewPart {
String imageKey = DOMASTPluginImages.IMG_DEFAULT;
IASTNode node = null;
if (obj instanceof TreeObject) {
node = ((TreeObject) obj).getNode();
if (obj instanceof DOMASTNodeLeaf) {
node = ((DOMASTNodeLeaf) obj).getNode();
}
if (node instanceof IASTArrayModifier) {
@ -693,8 +694,8 @@ public class DOMAST extends ViewPart {
IASTNode selectedNode = null;
if (viewer.getSelection() instanceof StructuredSelection
&& ((StructuredSelection) viewer.getSelection())
.getFirstElement() instanceof TreeObject) {
selectedNode = ((TreeObject) ((StructuredSelection) viewer
.getFirstElement() instanceof DOMASTNodeLeaf) {
selectedNode = ((DOMASTNodeLeaf) ((StructuredSelection) viewer
.getSelection()).getFirstElement()).getNode();
}
@ -881,9 +882,9 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof TreeObject &&
((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode() != null) {
showMessage("ASTUtil#getNodeType(IASTNode): \"" + ASTTypeUtil.getNodeType(((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode() != null) {
showMessage("ASTUtil#getNodeType(IASTNode): \"" + ASTTypeUtil.getNodeType(((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
} };
displayNodeTypeAction.setText(DISPLAY_TYPE);
@ -894,9 +895,9 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof TreeObject &&
((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode() != null) {
showMessage("ASTSignatureUtil#getNodeSignature(IASTNode): \"" + ASTSignatureUtil.getNodeSignature(((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode() != null) {
showMessage("ASTSignatureUtil#getNodeSignature(IASTNode): \"" + ASTSignatureUtil.getNodeSignature(((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
} };
displayNodeSignatureAction.setText(DISPLAY_SIGNATURE);
@ -907,9 +908,9 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof TreeObject &&
((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTExpression) {
showMessage("ASTSignatureUtil#getExpressionString(IASTExpression): \"" + ASTSignatureUtil.getExpressionString((IASTExpression)((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTExpression) {
showMessage("ASTSignatureUtil#getExpressionString(IASTExpression): \"" + ASTSignatureUtil.getExpressionString((IASTExpression)((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
} };
displayExpressionAction.setText(DISPLAY_EXPRESSION);
@ -920,9 +921,9 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof TreeObject &&
((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTInitializer) {
showMessage("ASTSignatureUtil#getInitializerString(IASTInitializer): \"" + ASTSignatureUtil.getInitializerString((IASTInitializer)((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTInitializer) {
showMessage("ASTSignatureUtil#getInitializerString(IASTInitializer): \"" + ASTSignatureUtil.getInitializerString((IASTInitializer)((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode()) + "\""); //$NON-NLS-1$ //$NON-NLS-2$
}
} };
displayInitializerAction.setText(DISPLAY_INITIALIZER);
@ -974,10 +975,10 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (aPart instanceof CEditor && obj instanceof TreeObject) {
String filename = ((TreeObject) obj).getFilename();
if (aPart instanceof CEditor && obj instanceof DOMASTNodeLeaf) {
String filename = ((DOMASTNodeLeaf) obj).getFilename();
if (filename.equals(TreeObject.BLANK_STRING))
if (filename.equals(DOMASTNodeLeaf.BLANK_STRING))
return;
IResource r = ParserUtil.getResourceForFilename(filename);
@ -1000,10 +1001,10 @@ public class DOMAST extends ViewPart {
return;
}
}
((CEditor) aPart).selectAndReveal(((TreeObject) obj).getOffset(),
((TreeObject) obj).getLength());
((CEditor) aPart).selectAndReveal(((DOMASTNodeLeaf) obj).getOffset(),
((DOMASTNodeLeaf) obj).getLength());
aPart.getSite().getPage().activate(aPart.getSite().getPage().findView(OpenDOMViewAction.VIEW_ID));
aPart.getSite().getPage().activate(aPart.getSite().getPage().findView(VIEW_ID));
}
}
}
@ -1013,19 +1014,19 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof TreeObject &&
((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTName) {
IASTName name = (IASTName)((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode();
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTName) {
IASTName name = (IASTName)((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode();
StringBuffer pattern = new StringBuffer(STRING_QUOTE);
if (name.toString() != null)
pattern.append(name.toString());
pattern.append(STRING_QUOTE);
if (lang == ParserLanguage.CPP) {
IASTName[] names = ((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getDeclarations(name.resolveBinding());
IASTName[] names = ((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getDeclarations(name.resolveBinding());
displayNames(names, OPEN_DECLARATIONS, pattern.toString());
} else {
IASTName[] names = ((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getDeclarations(name.resolveBinding());
IASTName[] names = ((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getDeclarations(name.resolveBinding());
displayNames(names, OPEN_DECLARATIONS, pattern.toString());
}
}
@ -1037,19 +1038,19 @@ public class DOMAST extends ViewPart {
public void run() {
ISelection selection = viewer.getSelection();
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof TreeObject &&
((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTName) {
IASTName name = (IASTName)((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode();
((IStructuredSelection)selection).getFirstElement() instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode() instanceof IASTName) {
IASTName name = (IASTName)((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode();
StringBuffer pattern = new StringBuffer(STRING_QUOTE);
if (name.toString() != null)
pattern.append(name.toString());
pattern.append(STRING_QUOTE);
if (lang == ParserLanguage.CPP) {
IASTName[] names = ((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getReferences(name.resolveBinding());
IASTName[] names = ((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getReferences(name.resolveBinding());
displayNames(names, OPEN_REFERENCES, pattern.toString());
} else {
IASTName[] names = ((TreeObject)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getReferences(name.resolveBinding());
IASTName[] names = ((DOMASTNodeLeaf)((IStructuredSelection)selection).getFirstElement()).getNode().getTranslationUnit().getReferences(name.resolveBinding());
displayNames(names, OPEN_REFERENCES, pattern.toString());
}
}
@ -1187,7 +1188,7 @@ public class DOMAST extends ViewPart {
if (editor instanceof CEditor) {
try {
tempView = site.getPage().showView(OpenDOMViewAction.VIEW_ID);
tempView = site.getPage().showView(VIEW_ID);
} catch (PartInitException pie) {}
if (tempView != null) {

View file

@ -54,7 +54,7 @@ import org.eclipse.ui.views.properties.TextPropertyDescriptor;
/**
* @author dsteffle
*/
public class TreeObject implements IAdaptable {
public class DOMASTNodeLeaf implements IAdaptable {
private static final String VARIABLE_SIZED_ = "* "; //$NON-NLS-1$
private static final String VOLATILE_ = "volatile "; //$NON-NLS-1$
private static final String STATIC_ = "static "; //$NON-NLS-1$
@ -73,25 +73,25 @@ public class TreeObject implements IAdaptable {
private static final String LIST_SEPARATOR = ", "; //$NON-NLS-1$
private static final String PERIOD = "."; //$NON-NLS-1$
private IASTNode node = null;
private TreeParent parent;
private DOMASTNodeParent parent;
// used for applying filters to the tree, since it is lazily populated
// all parents of the desired tree object to display need to have a flag as well
private int filterFlag = 0;
public static final int FLAG_PROBLEM = 0x1;
public static final int FLAG_PREPROCESSOR = 0x2;
public static final int FLAG_INCLUDE_STATEMENTS = 0x2;
public static final int FLAG_PROBLEM = 1<<0;
public static final int FLAG_PREPROCESSOR = 1<<1;
public static final int FLAG_INCLUDE_STATEMENTS = 1<<2;
public TreeObject(IASTNode node) {
public DOMASTNodeLeaf(IASTNode node) {
this.node = node;
}
public IASTNode getNode() {
return node;
}
public void setParent(TreeParent parent) {
public void setParent(DOMASTNodeParent parent) {
this.parent = parent;
}
public TreeParent getParent() {
public DOMASTNodeParent getParent() {
return parent;
}

View file

@ -23,30 +23,30 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
/**
* @author dsteffle
*/
public class TreeParent extends TreeObject {
private static final TreeObject[] EMPTY_CHILDREN_ARRAY = new TreeObject[0];
public class DOMASTNodeParent extends DOMASTNodeLeaf {
private static final DOMASTNodeLeaf[] EMPTY_CHILDREN_ARRAY = new DOMASTNodeLeaf[0];
private static final int DEFAULT_NODE_CHAIN_SIZE = 4;
private static final int DEFAULT_CHILDREN_SIZE = 4;
int index=0;
private TreeObject[] children;
private DOMASTNodeLeaf[] children;
boolean cleanupedElements = false;
public int getStartSearch() {
return index;
}
public TreeParent() {
public DOMASTNodeParent() {
super(null);
children = EMPTY_CHILDREN_ARRAY;
}
public TreeParent(IASTNode node) {
public DOMASTNodeParent(IASTNode node) {
super(node);
children = new TreeObject[DEFAULT_CHILDREN_SIZE];
children = new DOMASTNodeLeaf[DEFAULT_CHILDREN_SIZE];
}
public void addChild(TreeObject child) {
public void addChild(DOMASTNodeLeaf child) {
if (index==children.length) {
children = (TreeObject[])ArrayUtil.append(TreeObject.class, children, child);
children = (DOMASTNodeLeaf[])ArrayUtil.append(DOMASTNodeLeaf.class, children, child);
index++;
} else {
children[index++] = child;
@ -54,7 +54,7 @@ public class TreeParent extends TreeObject {
child.setParent(this);
}
public void removeChild(TreeObject child) {
public void removeChild(DOMASTNodeLeaf child) {
for(int i=0; i<children.length; i++) {
if (children[i] == child) {
children[i] = null;
@ -64,7 +64,7 @@ public class TreeParent extends TreeObject {
child.setParent(null);
}
public TreeObject[] getChildren(boolean cleanupElements) {
public DOMASTNodeLeaf[] getChildren(boolean cleanupElements) {
if (cleanupElements) {
return getChildren();
} else {
@ -72,19 +72,19 @@ public class TreeParent extends TreeObject {
}
}
public TreeObject [] getChildren() {
public DOMASTNodeLeaf [] getChildren() {
// remove null children from the array (if not already done so)
if (!cleanupedElements) {
// remove null elements
children = (TreeObject[])ArrayUtil.removeNulls(TreeObject.class, children);
children = (DOMASTNodeLeaf[])ArrayUtil.removeNulls(DOMASTNodeLeaf.class, children);
// sort the elements
Arrays.sort(children, new Comparator() {
public int compare(Object a, Object b) {
if(a instanceof TreeObject && b instanceof TreeObject &&
((TreeObject)a).getNode() instanceof ASTNode &&
((TreeObject)b).getNode() instanceof ASTNode) {
return ((ASTNode)((TreeObject)a).getNode()).getOffset() - ((ASTNode)((TreeObject)b).getNode()).getOffset();
if(a instanceof DOMASTNodeLeaf && b instanceof DOMASTNodeLeaf &&
((DOMASTNodeLeaf)a).getNode() instanceof ASTNode &&
((DOMASTNodeLeaf)b).getNode() instanceof ASTNode) {
return ((ASTNode)((DOMASTNodeLeaf)a).getNode()).getOffset() - ((ASTNode)((DOMASTNodeLeaf)b).getNode()).getOffset();
}
return 0;
@ -93,8 +93,8 @@ public class TreeParent extends TreeObject {
// need to also clean up the children's children, to make sure all nulls are removed (prevent expansion sign when there isn't one)
for(int i=0; i<children.length; i++) {
if (children[i] instanceof TreeParent) {
((TreeParent)children[i]).setChildren((TreeObject[])ArrayUtil.removeNulls(TreeObject.class, ((TreeParent)children[i]).getChildren()));
if (children[i] instanceof DOMASTNodeParent) {
((DOMASTNodeParent)children[i]).setChildren((DOMASTNodeLeaf[])ArrayUtil.removeNulls(DOMASTNodeLeaf.class, ((DOMASTNodeParent)children[i]).getChildren()));
}
}
@ -108,12 +108,12 @@ public class TreeParent extends TreeObject {
}
/**
* Returns the TreeParent whose IASTNode is the parent of the IASTNode.
* Returns the DOMASTNodeParent whose IASTNode is the parent of the IASTNode.
*
* @param node
* @return
*/
public TreeParent findTreeParentForNode(IASTNode node) {
public DOMASTNodeParent findTreeParentForNode(IASTNode node) {
if (node == null || node.getParent() == null) return null;
IASTNode parentToFind = node.getParent();
@ -123,7 +123,7 @@ public class TreeParent extends TreeObject {
return this;
}
// build the chain of nodes... and use it to search the tree for the TreeParent that owns the node's parent
// build the chain of nodes... and use it to search the tree for the DOMASTNodeParent that owns the node's parent
IASTNode[] nodeChain = new IASTNode[DEFAULT_NODE_CHAIN_SIZE];
IASTNode topNode = node.getParent();
ArrayUtil.append(IASTNode.class, nodeChain, node);
@ -134,22 +134,22 @@ public class TreeParent extends TreeObject {
}
// loop through the chain of nodes and use it to only search the necessary children required to find the node
TreeObject[] childrenToSearch = children;
DOMASTNodeLeaf[] childrenToSearch = children;
int j=getStartSearch();
outerLoop: for(int i=nodeChain.length-1; i>=0; i--) {
if (nodeChain[i] != null) {
parentToFind = nodeChain[i];
for(; j>=0; j--) { // use the TreeParent's index to start searching at the end of it's children (performance optimization)
if (j<childrenToSearch.length && childrenToSearch[j] instanceof TreeParent) {
for(; j>=0; j--) { // use the DOMASTNodeParent's index to start searching at the end of it's children (performance optimization)
if (j<childrenToSearch.length && childrenToSearch[j] instanceof DOMASTNodeParent) {
if ( childrenToSearch[j].getNode() == node.getParent() ) {
return (TreeParent)childrenToSearch[j];
return (DOMASTNodeParent)childrenToSearch[j];
}
if (childrenToSearch[j].getNode() == parentToFind) {
int pos = j;
j = ((TreeParent)childrenToSearch[pos]).getStartSearch();
childrenToSearch = ((TreeParent)childrenToSearch[pos]).getChildren(false);
j = ((DOMASTNodeParent)childrenToSearch[pos]).getStartSearch();
childrenToSearch = ((DOMASTNodeParent)childrenToSearch[pos]).getChildren(false);
continue outerLoop;
}
}
@ -159,7 +159,7 @@ public class TreeParent extends TreeObject {
// try finding the best parent possible
IASTNode parent = node.getParent();
TreeParent tree = null;
DOMASTNodeParent tree = null;
while (parent != null && tree == null) {
tree = findTreeParentForNode(parent);
if (tree != null) return tree;
@ -171,13 +171,13 @@ public class TreeParent extends TreeObject {
}
/**
* Returns the TreeParent that corresponds to the IASTNode. This is the TreeParent
* Returns the DOMASTNodeParent that corresponds to the IASTNode. This is the DOMASTNodeParent
* that represents the IASTNode in the DOM AST View.
*
* @param node
* @return
*/
public TreeParent findTreeObject(IASTNode node, boolean useOffset) {
public DOMASTNodeParent findTreeObject(IASTNode node, boolean useOffset) {
if (node == null) return null;
IASTNode nodeToFind = node;
@ -187,7 +187,7 @@ public class TreeParent extends TreeObject {
return this;
}
// build the chain of nodes... and use it to search the tree for the TreeParent that contains the node
// build the chain of nodes... and use it to search the tree for the DOMASTNodeParent that contains the node
IASTNode[] nodeChain = new IASTNode[DEFAULT_NODE_CHAIN_SIZE];
IASTNode topNode = node;
nodeChain = (IASTNode[])ArrayUtil.append(IASTNode.class, nodeChain, topNode);
@ -197,26 +197,26 @@ public class TreeParent extends TreeObject {
}
// loop through the chain of nodes and use it to only search the necessary children required to find the node
TreeObject[] childrenToSearch = children;
DOMASTNodeLeaf[] childrenToSearch = children;
outerLoop: for(int i=nodeChain.length-1; i>=0; i--) {
if (nodeChain[i] != null) {
nodeToFind = nodeChain[i];
for(int j=0; j<childrenToSearch.length; j++) {
if (childrenToSearch[j] instanceof TreeParent) {
if (childrenToSearch[j] instanceof DOMASTNodeParent) {
if ( equalNodes(childrenToSearch[j].getNode(), node, useOffset) ) {
return (TreeParent)childrenToSearch[j];
return (DOMASTNodeParent)childrenToSearch[j];
}
if ( equalNodes(childrenToSearch[j].getNode(), nodeToFind, useOffset) ) {
childrenToSearch = ((TreeParent)childrenToSearch[j]).getChildren(false);
childrenToSearch = ((DOMASTNodeParent)childrenToSearch[j]).getChildren(false);
continue outerLoop;
}
// since the nodeChain doesn't include #includes, if an #include is encountered then search it's children
if (childrenToSearch[j].getNode() instanceof IASTPreprocessorIncludeStatement) {
TreeParent foundParentInInclude = ((TreeParent)childrenToSearch[j]).findTreeObject(node, useOffset);
DOMASTNodeParent foundParentInInclude = ((DOMASTNodeParent)childrenToSearch[j]).findTreeObject(node, useOffset);
if(foundParentInInclude != null) {
return foundParentInInclude;
}
@ -261,7 +261,7 @@ public class TreeParent extends TreeObject {
return false;
}
public void setChildren(TreeObject[] children) {
public void setChildren(DOMASTNodeLeaf[] children) {
this.children = children;
}

View file

@ -50,7 +50,7 @@ public class DOMASTPluginImages {
public static final String PLUGIN_ID = "org.eclipse.cdt.testplugin.CTestPlugin"; //$NON-NLS-1$
private static final String NAME_PREFIX= PLUGIN_ID + '.';
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
public static final String ICON_PREFIX= "used/"; //$NON-NLS-1$
public static final String ICON_PREFIX= "dom_view/"; //$NON-NLS-1$
public static final String IMG_IASTArrayModifier= NAME_PREFIX + "showasarray_co.gif"; //$NON-NLS-1$
public static final String IMG_IASTDeclaration= NAME_PREFIX + "cdeclaration_obj.gif"; //$NON-NLS-1$

View file

@ -36,10 +36,10 @@ import org.eclipse.swt.widgets.TreeItem;
public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTargetExtension3 {
IASTTranslationUnit tu = null;
TreeParent tuTreeParent = null;
DOMASTNodeParent tuTreeParent = null;
ParserLanguage lang = null;
TreeViewer viewer = null;
TreeObject startingNode = null;
DOMASTNodeLeaf startingNode = null;
IASTName[] matchingNames = null;
boolean wasForward = true;
int index = 0;
@ -306,13 +306,13 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
return null;
}
private TreeItem expandTreeToTreeObject(TreeItem[] treeItems, TreeObject treeObj) {
private TreeItem expandTreeToTreeObject(TreeItem[] treeItems, DOMASTNodeLeaf treeObj) {
for (int i=0; i<treeItems.length; i++) {
if (treeItems[i].getData() == treeObj) {
return treeItems[i];
}
TreeParent parent = treeObj.getParent();
DOMASTNodeParent parent = treeObj.getParent();
if (parent == null) return null;
@ -332,7 +332,7 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
return null; // nothing found
}
private TreeItem expandTreeToTreeObject(TreeObject treeObj) {
private TreeItem expandTreeToTreeObject(DOMASTNodeLeaf treeObj) {
return expandTreeToTreeObject(viewer.getTree().getItems(), treeObj);
}
@ -351,14 +351,14 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
IStructuredSelection selection = (IStructuredSelection)viewer.getSelection();
if (selection.isEmpty()) {
if (viewer.getTree().getItems()[0].getData() instanceof TreeObject);
startingNode = (TreeObject)viewer.getTree().getItems()[0].getData();
if (viewer.getTree().getItems()[0].getData() instanceof DOMASTNodeLeaf);
startingNode = (DOMASTNodeLeaf)viewer.getTree().getItems()[0].getData();
return new Point(0, 0);
}
startingNode = (TreeObject)selection.getFirstElement();
return new Point(((ASTNode)((TreeObject)selection.getFirstElement()).getNode()).getOffset(), 0);
startingNode = (DOMASTNodeLeaf)selection.getFirstElement();
return new Point(((ASTNode)((DOMASTNodeLeaf)selection.getFirstElement()).getNode()).getOffset(), 0);
}
/* (non-Javadoc)
@ -398,13 +398,13 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
IASTName foundName = null;
foundName = findNextMatchingName( findString, searchForward, caseSensitive, wholeWord, regExSearch );
// get the TreeObject from the AST View's model corresponding to that name
TreeObject treeNode = null;
// get the DOMASTNodeLeaf from the AST View's model corresponding to that name
DOMASTNodeLeaf treeNode = null;
TreeItem treeItem = null;
treeNode = tuTreeParent.findTreeObject(foundName, true);
if (treeNode != null && treeNode.getParent() != null) {
// found a matching TreeObject, so expand the tree to that object
// found a matching DOMASTNodeLeaf, so expand the tree to that object
treeItem = expandTreeToTreeObject(treeNode);
}
@ -416,7 +416,7 @@ public class FindIASTNameTarget implements IFindReplaceTarget, IFindReplaceTarge
treeNode = tuTreeParent.findTreeObject(foundName, true);
if (treeNode != null && treeNode.getParent() != null) {
// found a matching TreeObject, so expand the tree to that object
// found a matching DOMASTNodeLeaf, so expand the tree to that object
treeItem = expandTreeToTreeObject(treeNode);
}
}

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTProblem;
* @author dsteffle
*/
public interface IPopulateDOMASTAction {
public TreeParent getTree();
public DOMASTNodeParent getTree();
public void mergePreprocessorStatements(IASTPreprocessorStatement[] statements);
public void mergePreprocessorProblems(IASTProblem[] problems);
public void groupIncludes(IASTPreprocessorStatement[] statements);

View file

@ -24,10 +24,10 @@ public class IncludeStatementFilter extends ViewerFilter {
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof TreeObject) {
int flag = ((TreeObject)element).getFiltersFlag() & TreeObject.FLAG_INCLUDE_STATEMENTS;
if (element instanceof DOMASTNodeLeaf) {
int flag = ((DOMASTNodeLeaf)element).getFiltersFlag() & DOMASTNodeLeaf.FLAG_INCLUDE_STATEMENTS;
if (flag > 0) {
IASTNode node = ((TreeObject)element).getNode();
IASTNode node = ((DOMASTNodeLeaf)element).getNode();
if (node instanceof IASTPreprocessorIncludeStatement)
return false;

View file

@ -35,7 +35,6 @@ import org.eclipse.ui.PartInitException;
*/
public class OpenDOMViewAction implements IViewActionDelegate, IEditorActionDelegate, IObjectActionDelegate {
public static final String VIEW_ID = "org.eclipse.cdt.ui.tests.DOMAST.DOMAST"; //$NON-NLS-1$
IViewPart viewPart = null;
ISelection selection = null;
IFile file = null;
@ -76,7 +75,7 @@ public class OpenDOMViewAction implements IViewActionDelegate, IEditorActionDele
IViewPart tempView = null;
try {
tempView = viewPart.getSite().getPage().showView(VIEW_ID);
tempView = viewPart.getSite().getPage().showView(DOMAST.VIEW_ID);
} catch (PartInitException pie) {}
if (tempView != null) {

View file

@ -23,10 +23,10 @@ public class PreprocessorFilter extends ViewerFilter {
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof TreeObject) {
int flag = ((TreeObject)element).getFiltersFlag() & TreeObject.FLAG_PREPROCESSOR;
if (element instanceof DOMASTNodeLeaf) {
int flag = ((DOMASTNodeLeaf)element).getFiltersFlag() & DOMASTNodeLeaf.FLAG_PREPROCESSOR;
if (flag > 0) {
if (((TreeObject)element).getNode() instanceof IASTPreprocessorStatement)
if (((DOMASTNodeLeaf)element).getNode() instanceof IASTPreprocessorStatement)
return false;
return true;

View file

@ -25,10 +25,10 @@ public class ProblemHolderFilter extends ViewerFilter {
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof TreeObject) {
int flag = ((TreeObject)element).getFiltersFlag() & TreeObject.FLAG_PROBLEM;
if (element instanceof DOMASTNodeLeaf) {
int flag = ((DOMASTNodeLeaf)element).getFiltersFlag() & DOMASTNodeLeaf.FLAG_PROBLEM;
if (flag > 0) {
IASTNode node = ((TreeObject)element).getNode();
IASTNode node = ((DOMASTNodeLeaf)element).getNode();
if (node instanceof IASTProblem ||
node instanceof IASTProblemHolder)
return false;

View file

@ -84,7 +84,7 @@ public class ShowInDOMViewAction extends ActionDelegate implements
if (file == null) return false;
try {
view = editor.getSite().getPage().showView(OpenDOMViewAction.VIEW_ID);
view = editor.getSite().getPage().showView(DOMAST.VIEW_ID);
} catch (PartInitException pie) {}
if (view instanceof DOMAST) {

View file

@ -0,0 +1,846 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.browser.typeinfo.TypeInfoMessages;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* @author dsteffle
*/
public class FilterIndexerViewDialog extends Dialog {
private static final String BLANK_STRING = ""; //$NON-NLS-1$
private static final String PAGE_SIZE_ = "Page Size:"; //$NON-NLS-1$
private static final String TYPESELECTIONDIALOG_FILTERLABEL = "TypeSelectionDialog.filterLabel"; //$NON-NLS-1$
private static final String FILTER_INDEXER_RESULTS = "Filter Indexer Results"; //$NON-NLS-1$
private static final String SETTINGS = "Settings"; //$NON-NLS-1$
private static final String PAGE_SIZE = "PAGE_SIZE"; //$NON-NLS-1$
private String fFilter = BLANK_STRING; //$NON-NLS-1$
Text filterText = null;
private String pageSize = BLANK_STRING; //$NON-NLS-1$
Text pageSizeText = null;
protected Collection fFilterMatcher = new HashSet();
private String message = "Filter Indexer Results (. = any character, .* = any string):"; //$NON-NLS-1$
public static final int ENTRY_REF = 1;
public static final String ENTRY_REF_STRING = String.valueOf(IIndexConstants.REF);
public static final int ENTRY_TYPE_REF = 2;
public static final String ENTRY_TYPE_REF_STRING = String.valueOf(IIndexConstants.TYPE_REF);
public static final String ENTRY_TYPE_DECL_STRING = String.valueOf(IIndexConstants.TYPE_DECL);
public static final int ENTRY_FUNCTION_REF = 4;
public static final String ENTRY_FUNCTION_REF_STRING = String.valueOf(IIndexConstants.FUNCTION_REF);
public static final int ENTRY_FUNCTION_DECL = 5;
public static final String ENTRY_FUNCTION_DECL_STRING = String.valueOf(IIndexConstants.FUNCTION_DECL);
public static final int ENTRY_CONSTRUCTOR_REF = 6;
public static final String ENTRY_CONSTRUCTOR_REF_STRING = String.valueOf(IIndexConstants.CONSTRUCTOR_REF);
public static final int ENTRY_CONSTRUCTOR_DECL = 7;
public static final String ENTRY_CONSTRUCTOR_DECL_STRING = String.valueOf(IIndexConstants.CONSTRUCTOR_DECL);
public static final int ENTRY_NAMESPACE_REF = 8;
public static final String ENTRY_NAMESPACE_REF_STRING = String.valueOf(IIndexConstants.NAMESPACE_REF);
public static final int ENTRY_NAMESPACE_DECL = 9;
public static final String ENTRY_NAMESPACE_DECL_STRING = String.valueOf(IIndexConstants.NAMESPACE_DECL);
public static final int ENTRY_FIELD_REF = 10;
public static final String ENTRY_FIELD_REF_STRING = String.valueOf(IIndexConstants.FIELD_REF);
public static final int ENTRY_FIELD_DECL = 11;
public static final String ENTRY_FIELD_DECL_STRING = String.valueOf(IIndexConstants.FIELD_DECL);
public static final int ENTRY_ENUMTOR_REF = 12;
public static final String ENTRY_ENUMTOR_REF_STRING = String.valueOf(IIndexConstants.ENUMTOR_REF);
public static final int ENTRY_ENUMTOR_DECL = 13;
public static final String ENTRY_ENUMTOR_DECL_STRING = String.valueOf(IIndexConstants.ENUMTOR_DECL);
public static final int ENTRY_METHOD_REF = 14;
public static final String ENTRY_METHOD_REF_STRING = String.valueOf(IIndexConstants.METHOD_REF);
public static final int ENTRY_METHOD_DECL = 15;
public static final String ENTRY_METHOD_DECL_STRING = String.valueOf(IIndexConstants.METHOD_DECL);
public static final int ENTRY_MACRO_DECL = 16;
public static final String ENTRY_MACRO_DECL_STRING = String.valueOf(IIndexConstants.MACRO_DECL);
public static final int ENTRY_INCLUDE_REF = 17;
public static final String ENTRY_INCLUDE_REF_STRING = String.valueOf(IIndexConstants.INCLUDE_REF);
public static final int ENTRY_SUPER_REF = 18;
public static final String ENTRY_SUPER_REF_STRING = String.valueOf(IIndexConstants.SUPER_REF);
public static final int ENTRY_TYPE_DECL_T = 19;
public static final String ENTRY_TYPE_DECL_T_STRING = String.valueOf(IIndexConstants.TYPEDEF_DECL);
public static final int ENTRY_TYPE_DECL_C = 20;
public static final String ENTRY_TYPE_DECL_C_STRING = String.valueOf(IIndexConstants.CLASS_DECL);
public static final int ENTRY_TYPE_DECL_V = 21;
public static final String ENTRY_TYPE_DECL_V_STRING = String.valueOf(IIndexConstants.VAR_DECL);
public static final int ENTRY_TYPE_DECL_S = 22;
public static final String ENTRY_TYPE_DECL_S_STRING = String.valueOf(IIndexConstants.STRUCT_DECL);
public static final int ENTRY_TYPE_DECL_E = 23;
public static final String ENTRY_TYPE_DECL_E_STRING = String.valueOf(IIndexConstants.ENUM_DECL);
public static final int ENTRY_TYPE_DECL_U = 24;
public static final String ENTRY_TYPE_DECL_U_STRING = String.valueOf(IIndexConstants.UNION_DECL);
public static final int ENTRY_TYPE_DECL_D = 25;
public static final String ENTRY_TYPE_DECL_D_STRING = String.valueOf(IIndexConstants.TYPE_DECL) + String.valueOf(IIndexConstants.DERIVED_SUFFIX) + String.valueOf(IIndexConstants.SEPARATOR);
public static final int ENTRY_TYPE_DECL_F = 26;
public static final String ENTRY_TYPE_DECL_F_STRING = String.valueOf(IIndexConstants.TYPE_DECL) + String.valueOf(IIndexConstants.FRIEND_SUFFIX) + String.valueOf(IIndexConstants.SEPARATOR);
public static final int ENTRY_TYPE_DECL_G = 27;
public static final String ENTRY_TYPE_DECL_G_STRING = String.valueOf(IIndexConstants.TYPE_DECL) + String.valueOf(IIndexConstants.FWD_CLASS_SUFFIX) + String.valueOf(IIndexConstants.SEPARATOR);
public static final int ENTRY_TYPE_DECL_H = 28;
public static final String ENTRY_TYPE_DECL_H_STRING = String.valueOf(IIndexConstants.TYPE_DECL) + String.valueOf(IIndexConstants.FWD_STRUCT_SUFFIX) + String.valueOf(IIndexConstants.SEPARATOR);
public static final int ENTRY_TYPE_DECL_I = 29;
public static final String ENTRY_TYPE_DECL_I_STRING = String.valueOf(IIndexConstants.TYPE_DECL) + String.valueOf(IIndexConstants.FWD_UNION_SUFFIX) + String.valueOf(IIndexConstants.SEPARATOR);
private String fDialogSection;
private static final String DIALOG_SETTINGS = FilterIndexerViewDialog.class.getName();
private static final String SETTINGS_X_POS = "x"; //$NON-NLS-1$
private static final String SETTINGS_Y_POS = "y"; //$NON-NLS-1$
private static final String SETTINGS_WIDTH = "width"; //$NON-NLS-1$
private static final String SETTINGS_HEIGHT = "height"; //$NON-NLS-1$
private Point fLocation;
private Point fSize;
IndexerNodeParent root = null;
private String projName = null;
private static final int[] fAllTypes = { ENTRY_REF, ENTRY_TYPE_REF,
ENTRY_FUNCTION_REF, ENTRY_FUNCTION_DECL, // ENTRY_TYPE_DECL,
ENTRY_CONSTRUCTOR_REF, ENTRY_CONSTRUCTOR_DECL, ENTRY_NAMESPACE_REF,
ENTRY_NAMESPACE_DECL, ENTRY_FIELD_REF, ENTRY_FIELD_DECL,
ENTRY_ENUMTOR_REF, ENTRY_ENUMTOR_DECL, ENTRY_METHOD_REF,
ENTRY_METHOD_DECL, ENTRY_MACRO_DECL, ENTRY_INCLUDE_REF,
ENTRY_SUPER_REF, ENTRY_TYPE_DECL_T, ENTRY_TYPE_DECL_C,
ENTRY_TYPE_DECL_V, ENTRY_TYPE_DECL_S, ENTRY_TYPE_DECL_E,
ENTRY_TYPE_DECL_U, ENTRY_TYPE_DECL_D, ENTRY_TYPE_DECL_F,
ENTRY_TYPE_DECL_G, ENTRY_TYPE_DECL_H, ENTRY_TYPE_DECL_I };
private Set fKnownTypes = new HashSet(fAllTypes.length);
protected FilterIndexerViewDialog(Shell parentShell, IndexerNodeParent root, String projName) {
super(parentShell);
this.root = root;
this.projName = projName;
setVisibleTypes(fAllTypes);
setDialogSettings(DIALOG_SETTINGS);
}
/**
* Sets section name to use when storing the dialog settings.
*
* @param section Name of section.
*/
public void setDialogSettings(String section) {
fDialogSection = section + SETTINGS + projName;
}
public boolean close() {
return super.close();
}
/*
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(FILTER_INDEXER_RESULTS);
}
/*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
protected Control createDialogArea(Composite parent) {
readSettings(getDialogSettings());
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
applyDialogFont(composite);
createMessageArea(composite);
createFilterText(composite);
createTypeFilterArea(composite);
createPageSizeArea(composite);
return composite;
}
/**
* Creates a label if name was not <code>null</code>.
*
* @param parent
* the parent composite.
* @param name
* the name of the label.
* @return returns a label if a name was given, <code>null</code>
* otherwise.
*/
protected Label createLabel(Composite parent, String name) {
if (name == null)
return null;
Label label = new Label(parent, SWT.NONE);
label.setText(name);
label.setFont(parent.getFont());
return label;
}
/**
* Sets which CElement types are visible in the dialog.
*
* @param types
* Array of CElement types.
*/
public void setVisibleTypes(int[] types) {
fKnownTypes.clear();
for (int i = 0; i < types.length; ++i) {
fKnownTypes.add(new Integer(types[i]));
}
}
/**
* Creates a type filter checkbox.
*/
private void createTypeCheckbox(Composite parent, Integer typeObject) {
String name;
int type = typeObject.intValue();
switch (type) {
case ENTRY_REF:
name = ENTRY_REF_STRING;
break;
case ENTRY_TYPE_REF:
name = ENTRY_TYPE_REF_STRING;
break;
// case ENTRY_TYPE_DECL:
// name = ENTRY_TYPE_DECL_STRING;
// break;
case ENTRY_FUNCTION_REF:
name = ENTRY_FUNCTION_REF_STRING;
break;
case ENTRY_FUNCTION_DECL:
name = ENTRY_FUNCTION_DECL_STRING;
break;
case ENTRY_CONSTRUCTOR_REF:
name = ENTRY_CONSTRUCTOR_REF_STRING;
break;
case ENTRY_CONSTRUCTOR_DECL:
name = ENTRY_CONSTRUCTOR_DECL_STRING;
break;
case ENTRY_NAMESPACE_REF:
name = ENTRY_NAMESPACE_REF_STRING;
break;
case ENTRY_NAMESPACE_DECL:
name = ENTRY_NAMESPACE_DECL_STRING;
break;
case ENTRY_FIELD_REF:
name = ENTRY_FIELD_REF_STRING;
break;
case ENTRY_FIELD_DECL:
name = ENTRY_FIELD_DECL_STRING;
break;
case ENTRY_ENUMTOR_REF:
name = ENTRY_ENUMTOR_REF_STRING;
break;
case ENTRY_ENUMTOR_DECL:
name = ENTRY_ENUMTOR_DECL_STRING;
break;
case ENTRY_METHOD_REF:
name = ENTRY_METHOD_REF_STRING;
break;
case ENTRY_METHOD_DECL:
name = ENTRY_METHOD_DECL_STRING;
break;
case ENTRY_MACRO_DECL:
name = ENTRY_MACRO_DECL_STRING;
break;
case ENTRY_INCLUDE_REF:
name = ENTRY_INCLUDE_REF_STRING;
break;
case ENTRY_SUPER_REF:
name = ENTRY_SUPER_REF_STRING;
break;
case ENTRY_TYPE_DECL_T:
name = ENTRY_TYPE_DECL_T_STRING;
break;
case ENTRY_TYPE_DECL_C:
name = ENTRY_TYPE_DECL_C_STRING;
break;
case ENTRY_TYPE_DECL_V:
name = ENTRY_TYPE_DECL_V_STRING;
break;
case ENTRY_TYPE_DECL_S:
name = ENTRY_TYPE_DECL_S_STRING;
break;
case ENTRY_TYPE_DECL_E:
name = ENTRY_TYPE_DECL_E_STRING;
break;
case ENTRY_TYPE_DECL_U:
name = ENTRY_TYPE_DECL_U_STRING;
break;
case ENTRY_TYPE_DECL_D:
name = ENTRY_TYPE_DECL_D_STRING;
break;
case ENTRY_TYPE_DECL_F:
name = ENTRY_TYPE_DECL_F_STRING;
break;
case ENTRY_TYPE_DECL_G:
name = ENTRY_TYPE_DECL_G_STRING;
break;
case ENTRY_TYPE_DECL_H:
name = ENTRY_TYPE_DECL_H_STRING;
break;
case ENTRY_TYPE_DECL_I:
name = ENTRY_TYPE_DECL_I_STRING;
break;
default:
return;
}
Image icon = getTypeIcon(type);
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
composite.setLayout(layout);
final Integer fTypeObject = typeObject;
Button checkbox = new Button(composite, SWT.CHECK);
checkbox.setFont(composite.getFont());
checkbox.setImage(icon);
checkbox.setSelection(fFilterMatcher.contains(fTypeObject));
checkbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (e.widget instanceof Button) {
Button aCheckbox = (Button) e.widget;
if (aCheckbox.getSelection())
fFilterMatcher.add(fTypeObject);
else
fFilterMatcher.remove(fTypeObject);
}
}
});
Label label = new Label(composite, SWT.LEFT);
label.setFont(composite.getFont());
label.setText(name);
}
private Image getTypeIcon(int type)
{
switch (type)
{
case ENTRY_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_REF);
case ENTRY_TYPE_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_TYPE_REF);
// case ENTRY_TYPE_DECL:
// return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_TYPE_DECL);
case ENTRY_FUNCTION_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FUNCTION_REF);
case ENTRY_FUNCTION_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FUNCTION_DECL);
case ENTRY_CONSTRUCTOR_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_CONSTRUCTOR_REF);
case ENTRY_CONSTRUCTOR_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_CONSTRUCTOR_DECL);
case ENTRY_NAMESPACE_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_NAMESPACE_REF);
case ENTRY_NAMESPACE_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_NAMESPACE_DECL);
case ENTRY_FIELD_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FIELD_REF);
case ENTRY_FIELD_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FIELD_DECL);
case ENTRY_ENUMTOR_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_ENUMTOR_REF);
case ENTRY_ENUMTOR_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_ENUMTOR_DECL);
case ENTRY_METHOD_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_METHOD_REF);
case ENTRY_METHOD_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_METHOD_DECL);
case ENTRY_MACRO_DECL:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_MACRO_DECL);
case ENTRY_INCLUDE_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_INCLUDE_REF);
case ENTRY_SUPER_REF:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_SUPER_REF);
case ENTRY_TYPE_DECL_T:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_TYPEDEF);
case ENTRY_TYPE_DECL_C:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_CLASS);
case ENTRY_TYPE_DECL_V:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_VARIABLE);
case ENTRY_TYPE_DECL_S:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_STRUCT);
case ENTRY_TYPE_DECL_E:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_ENUM);
case ENTRY_TYPE_DECL_U:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_UNION);
case ENTRY_TYPE_DECL_D:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_DERIVED);
case ENTRY_TYPE_DECL_F:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FRIEND);
case ENTRY_TYPE_DECL_G:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FWD_CLASS);
case ENTRY_TYPE_DECL_H:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FWD_STRUCT);
case ENTRY_TYPE_DECL_I:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_FWD_UNION);
default:
return IndexerViewPluginImages.get(IndexerViewPluginImages.IMG_WARNING);
}
}
/**
* Creates an area to filter types.
*
* @param parent
* area to create controls in
*/
private void createTypeFilterArea(Composite parent) {
createLabel(parent, TypeInfoMessages
.getString(TYPESELECTIONDIALOG_FILTERLABEL));
Composite upperRow = new Composite(parent, SWT.NONE);
GridLayout upperLayout = new GridLayout(3, true);
upperLayout.verticalSpacing = 2;
upperLayout.marginHeight = 0;
upperLayout.marginWidth = 0;
upperRow.setLayout(upperLayout);
// the for loop is here to guarantee we always
// create the checkboxes in the same order
for (int i = 0; i < fAllTypes.length; ++i) {
Integer typeObject = new Integer(fAllTypes[i]);
if (fKnownTypes.contains(typeObject))
createTypeCheckbox(upperRow, typeObject);
}
Composite lowerRow = new Composite(parent, SWT.NONE);
GridLayout lowerLayout = new GridLayout(1, true);
lowerLayout.verticalSpacing = 2;
lowerLayout.marginHeight = 0;
upperLayout.marginWidth = 0;
lowerRow.setLayout(lowerLayout);
Composite composite = new Composite(lowerRow, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
composite.setLayout(layout);
}
/**
* Creates an area to filter types.
*
* @param parent
* area to create controls in
*/
private void createPageSizeArea(Composite parent) {
createLabel(parent, PAGE_SIZE_);
pageSizeText = new Text(parent, SWT.BORDER);
GridData data = new GridData();
data.grabExcessVerticalSpace = false;
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
pageSizeText.setLayoutData(data);
pageSizeText.setFont(parent.getFont());
pageSizeText.setText((pageSize == null ? BLANK_STRING : pageSize));
}
/**
* Creates the message text widget and sets layout data.
*
* @param composite
* the parent composite of the message area.
*/
protected Label createMessageArea(Composite composite) {
Label label = new Label(composite, SWT.NONE);
if (message != null) {
label.setText(message);
}
label.setFont(composite.getFont());
GridData data = new GridData();
data.grabExcessVerticalSpace = false;
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
label.setLayoutData(data);
return label;
}
protected Text createFilterText(Composite parent) {
filterText = new Text(parent, SWT.BORDER);
GridData data = new GridData();
data.grabExcessVerticalSpace = false;
data.grabExcessHorizontalSpace = true;
data.horizontalAlignment = GridData.FILL;
data.verticalAlignment = GridData.BEGINNING;
filterText.setLayoutData(data);
filterText.setFont(parent.getFont());
filterText.setText((fFilter == null ? BLANK_STRING : fFilter));
return filterText;
}
/*
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
apply();
}
super.buttonPressed(buttonId);
}
public IDialogSettings getDialogSettings() {
IDialogSettings allSettings = CUIPlugin.getDefault().getDialogSettings();
IDialogSettings section = allSettings.getSection(fDialogSection);
if (section == null) {
section = allSettings.addNewSection(fDialogSection);
writeDefaultSettings(section);
}
return section;
}
/**
* Stores current configuration in the dialog store.
*/
protected void writeSettings(IDialogSettings section) {
Point location = getShell().getLocation();
section.put(SETTINGS_X_POS, location.x);
section.put(SETTINGS_Y_POS, location.y);
Point size = getShell().getSize();
section.put(SETTINGS_WIDTH, size.x);
section.put(SETTINGS_HEIGHT, size.y);
section.put(ENTRY_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_REF)));
section.put(ENTRY_TYPE_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_REF)));
// section.put(ENTRY_TYPE_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL)));
section.put(ENTRY_FUNCTION_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_FUNCTION_REF)));
section.put(ENTRY_FUNCTION_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_FUNCTION_DECL)));
section.put(ENTRY_CONSTRUCTOR_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_CONSTRUCTOR_REF)));
section.put(ENTRY_CONSTRUCTOR_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_CONSTRUCTOR_DECL)));
section.put(ENTRY_NAMESPACE_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_NAMESPACE_REF)));
section.put(ENTRY_NAMESPACE_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_NAMESPACE_DECL)));
section.put(ENTRY_FIELD_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_FIELD_REF)));
section.put(ENTRY_FIELD_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_FIELD_DECL)));
section.put(ENTRY_ENUMTOR_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_ENUMTOR_REF)));
section.put(ENTRY_ENUMTOR_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_ENUMTOR_DECL)));
section.put(ENTRY_METHOD_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_METHOD_REF)));
section.put(ENTRY_METHOD_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_METHOD_DECL)));
section.put(ENTRY_MACRO_DECL_STRING, fFilterMatcher.contains(new Integer(ENTRY_MACRO_DECL)));
section.put(ENTRY_INCLUDE_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_INCLUDE_REF)));
section.put(ENTRY_SUPER_REF_STRING, fFilterMatcher.contains(new Integer(ENTRY_SUPER_REF)));
section.put(ENTRY_TYPE_DECL_T_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_T)));
section.put(ENTRY_TYPE_DECL_C_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_C)));
section.put(ENTRY_TYPE_DECL_V_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_V)));
section.put(ENTRY_TYPE_DECL_S_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_S)));
section.put(ENTRY_TYPE_DECL_E_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_E)));
section.put(ENTRY_TYPE_DECL_U_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_U)));
section.put(ENTRY_TYPE_DECL_D_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_D)));
section.put(ENTRY_TYPE_DECL_F_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_F)));
section.put(ENTRY_TYPE_DECL_G_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_G)));
section.put(ENTRY_TYPE_DECL_H_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_H)));
section.put(ENTRY_TYPE_DECL_I_STRING, fFilterMatcher.contains(new Integer(ENTRY_TYPE_DECL_I)));
section.put(PAGE_SIZE, pageSize);
}
/**
* Stores default dialog settings.
*/
protected void writeDefaultSettings(IDialogSettings section) {
section.put(ENTRY_REF_STRING, true);
section.put(ENTRY_TYPE_REF_STRING, true);
// section.put(ENTRY_TYPE_DECL_STRING, true);
section.put(ENTRY_FUNCTION_REF_STRING, true);
section.put(ENTRY_FUNCTION_DECL_STRING, true);
section.put(ENTRY_CONSTRUCTOR_REF_STRING, true);
section.put(ENTRY_CONSTRUCTOR_DECL_STRING, true);
section.put(ENTRY_NAMESPACE_REF_STRING, true);
section.put(ENTRY_NAMESPACE_DECL_STRING, true);
section.put(ENTRY_FIELD_REF_STRING, true);
section.put(ENTRY_FIELD_DECL_STRING, true);
section.put(ENTRY_ENUMTOR_REF_STRING, true);
section.put(ENTRY_ENUMTOR_DECL_STRING, true);
section.put(ENTRY_METHOD_REF_STRING, true);
section.put(ENTRY_METHOD_DECL_STRING, true);
section.put(ENTRY_MACRO_DECL_STRING, true);
section.put(ENTRY_INCLUDE_REF_STRING, true);
section.put(ENTRY_SUPER_REF_STRING, true);
section.put(ENTRY_TYPE_DECL_T_STRING, true);
section.put(ENTRY_TYPE_DECL_C_STRING, true);
section.put(ENTRY_TYPE_DECL_V_STRING, true);
section.put(ENTRY_TYPE_DECL_S_STRING, true);
section.put(ENTRY_TYPE_DECL_E_STRING, true);
section.put(ENTRY_TYPE_DECL_U_STRING, true);
section.put(ENTRY_TYPE_DECL_D_STRING, true);
section.put(ENTRY_TYPE_DECL_F_STRING, true);
section.put(ENTRY_TYPE_DECL_G_STRING, true);
section.put(ENTRY_TYPE_DECL_H_STRING, true);
section.put(ENTRY_TYPE_DECL_I_STRING, true);
section.put(PAGE_SIZE, IndexerNodeParent.PAGE_SIZE);
}
protected Point getInitialLocation(Point initialSize) {
Point result = super.getInitialLocation(initialSize);
if (fLocation != null) {
result.x = fLocation.x;
result.y = fLocation.y;
Rectangle display = getShell().getDisplay().getClientArea();
int xe = result.x + initialSize.x;
if (xe > display.width) {
result.x -= xe - display.width;
}
int ye = result.y + initialSize.y;
if (ye > display.height) {
result.y -= ye - display.height;
}
}
return result;
}
protected Point getInitialSize() {
Point result = super.getInitialSize();
if (fSize != null) {
result.x = Math.max(result.x, fSize.x);
result.y = Math.max(result.y, fSize.y);
Rectangle display = getShell().getDisplay().getClientArea();
result.x = Math.min(result.x, display.width);
result.y = Math.min(result.y, display.height);
}
return result;
}
/**
* Initializes itself from the dialog settings with the same state
* as at the previous invocation.
*/
public void readSettings(IDialogSettings section) {
try {
int x = section.getInt(SETTINGS_X_POS);
int y = section.getInt(SETTINGS_Y_POS);
fLocation = new Point(x, y);
int width = section.getInt(SETTINGS_WIDTH);
int height = section.getInt(SETTINGS_HEIGHT);
fSize = new Point(width, height);
pageSize = String.valueOf(section.getInt(PAGE_SIZE));
} catch (NumberFormatException e) {
fLocation = null;
fSize = null;
}
if (section.getBoolean(ENTRY_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
// if (section.getBoolean(ENTRY_TYPE_DECL_STRING)) {
// Integer typeObject = new Integer(ENTRY_TYPE_DECL);
// if (fKnownTypes.contains(typeObject))
// fFilterMatcher.add(typeObject);
// }
if (section.getBoolean(ENTRY_FUNCTION_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_FUNCTION_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_FUNCTION_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_FUNCTION_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_CONSTRUCTOR_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_CONSTRUCTOR_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_CONSTRUCTOR_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_CONSTRUCTOR_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_NAMESPACE_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_NAMESPACE_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_NAMESPACE_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_NAMESPACE_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_FIELD_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_FIELD_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_FIELD_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_FIELD_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_ENUMTOR_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_ENUMTOR_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_ENUMTOR_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_ENUMTOR_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_METHOD_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_METHOD_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_METHOD_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_METHOD_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_MACRO_DECL_STRING)) {
Integer typeObject = new Integer(ENTRY_MACRO_DECL);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_INCLUDE_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_INCLUDE_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_SUPER_REF_STRING)) {
Integer typeObject = new Integer(ENTRY_SUPER_REF);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_T_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_T);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_C_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_C);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_V_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_V);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_S_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_S);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_E_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_E);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_U_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_U);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_D_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_D);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_F_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_F);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_G_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_G);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_H_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_H);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
if (section.getBoolean(ENTRY_TYPE_DECL_I_STRING)) {
Integer typeObject = new Integer(ENTRY_TYPE_DECL_I);
if (fKnownTypes.contains(typeObject))
fFilterMatcher.add(typeObject);
}
}
public IndexerFilterManager createFilterManager() {
return new IndexerFilterManager(fFilterMatcher, fFilter);
}
private void apply() {
fFilter = filterText.getText();
pageSize = pageSizeText.getText();
writeSettings(getDialogSettings());
root.setFilterManager(fFilterMatcher, fFilter);
int size=IndexerNodeParent.PAGE_SIZE;
try {
size = Integer.valueOf(pageSize).intValue();
if (size<=0) size=IndexerNodeParent.PAGE_SIZE;
} catch (NumberFormatException e) {}
root.setPageSize(size);
root.reset();
}
public String getPageSize() {
return pageSize;
}
}

View file

@ -0,0 +1,51 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.util.Collection;
/**
* @author dsteffle
*/
public class IndexerFilterManager {
private static final String BLANK_STRING = ""; //$NON-NLS-1$
private static final String COMMA_SEPARATOR = ","; //$NON-NLS-1$
Collection filters = null;
String nameFilter = null;
public IndexerFilterManager(Collection filters, String nameFilter) {
this.filters = filters;
this.nameFilter = nameFilter;
}
public boolean isFiltered(IndexerNodeLeaf leaf) {
String[] nameFilters = nameFilter.split(COMMA_SEPARATOR);
for(int i=0; i<nameFilters.length; i++) {
if (nameFilters != null) nameFilters[i] = nameFilters[i].trim();
}
if (!filters.contains(new Integer(leaf.getFiltersType()))) return false;
if (leaf.getName() != null && nameFilters != null && nameFilters.length > 0) {
boolean matchesPattern=false;
for(int l=0; l<nameFilters.length; l++) {
if (nameFilters[l].equals(BLANK_STRING) || leaf.getName().matches(nameFilters[l])) {
matchesPattern=true;
break;
}
}
if (!matchesPattern)
return false;
}
return true;
}
}

View file

@ -0,0 +1,278 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.File;
import java.io.IOException;
import org.eclipse.cdt.core.browser.PathUtil;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.impl.BlocksIndexInput;
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;
/**
* @author dsteffle
*/
public class IndexerNodeLeaf implements IAdaptable {
private static final char EMPTY_SPACE = ' ';
private int filtersType=0;
IEntryResult result = null;
String name = null;
File indexFile = null;
char type = EMPTY_SPACE;
private IndexerNodeParent parent = null;
public IndexerNodeLeaf(IEntryResult result, File indexFile) {
this.result = result;
this.indexFile = indexFile;
setNameAndFiltersFlag();
}
private void setNameAndFiltersFlag() {
if (result == null) return;
String word = String.valueOf(result.getWord());
String stringBeforeName = null;
// set the filtersFlag
if (word.startsWith(FilterIndexerViewDialog.ENTRY_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_REF;
// } else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_STRING)) {
// stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_STRING;
// filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FUNCTION_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_FUNCTION_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_FUNCTION_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FUNCTION_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_FUNCTION_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_FUNCTION_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_NAMESPACE_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_NAMESPACE_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_NAMESPACE_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_NAMESPACE_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_NAMESPACE_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_NAMESPACE_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FIELD_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_FIELD_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_FIELD_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FIELD_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_FIELD_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_FIELD_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_ENUMTOR_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_ENUMTOR_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_ENUMTOR_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_ENUMTOR_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_ENUMTOR_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_ENUMTOR_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_METHOD_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_METHOD_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_METHOD_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_METHOD_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_METHOD_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_METHOD_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_MACRO_DECL_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_MACRO_DECL_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_MACRO_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_INCLUDE_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_INCLUDE_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_INCLUDE_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_SUPER_REF_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_SUPER_REF_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_SUPER_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_T_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_T_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_T;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_C_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_C_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_C;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_V_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_V_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_V;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_S_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_S_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_S;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_E_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_E_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_E;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_U_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_U_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_U;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_D_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_D_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_D;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_F_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_F_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_F;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_G_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_G_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_G;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_H_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_H_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_H;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_I_STRING)) {
stringBeforeName = FilterIndexerViewDialog.ENTRY_TYPE_DECL_I_STRING;
filtersType = FilterIndexerViewDialog.ENTRY_TYPE_DECL_I;
}
// set the name
if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_REF_STRING)) { // if the name is after an additional field then reset stringBeforeName
int start = word.indexOf(stringBeforeName) + stringBeforeName.length();
stringBeforeName = stringBeforeName + word.substring(start, start + 2);
}
int end = word.length();
if (word.indexOf(IIndexConstants.SEPARATOR, word.indexOf(stringBeforeName) + stringBeforeName.length() ) > 0) end = word.indexOf(IIndexConstants.SEPARATOR, word.indexOf(stringBeforeName) + stringBeforeName.length() );
name = word.substring(word.indexOf(stringBeforeName) + stringBeforeName.length(), end);
}
public IndexerNodeParent getParent() {
return parent;
}
public void setParent(IndexerNodeParent parent) {
this.parent = parent;
}
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class)
return new IndexerPropertySource(result);
return null;
}
private class IndexerPropertySource implements IPropertySource {
private static final String IENTRYRESULT = "IEntryResult"; //$NON-NLS-1$
private static final String IENTRYRESULT_GETWORD__ = "IEntryResult#getWord()"; //$NON-NLS-1$
private static final String REFERENCES = "References"; //$NON-NLS-1$
private static final String REFERENCE_NUMBER_ = "reference# "; //$NON-NLS-1$
private static final int DEFAULT_DESCRIPTOR_SIZE = 4;
IEntryResult entryResult = null;
public IndexerPropertySource(IEntryResult result) {
this.entryResult = result;
}
public Object getEditableValue() {
return null;
}
public IPropertyDescriptor[] getPropertyDescriptors() {
IPropertyDescriptor[] descriptors = new IPropertyDescriptor[DEFAULT_DESCRIPTOR_SIZE];
TextPropertyDescriptor text = null;
IndexInput input = new BlocksIndexInput(indexFile);
try {
input.open();
// get the reference descriptors
int[] references = entryResult.getFileReferences();
if (references != null) {
for (int j = 0; j < references.length; ++j) {
IndexedFile file = input.getIndexedFile(references[j]);
if (file != null && file.getPath() != null) {
String id = REFERENCE_NUMBER_ + String.valueOf(j);
text = new TextPropertyDescriptor(new TextDescriptorId(id, PathUtil.getWorkspaceRelativePath(file.getPath()).toOSString()), id);
text.setCategory(REFERENCES);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
}
}
}
// add a word descriptor
text = new TextPropertyDescriptor(new TextDescriptorId(IENTRYRESULT_GETWORD__, String.valueOf(entryResult.getWord())), IENTRYRESULT_GETWORD__);
text.setCategory(IENTRYRESULT);
descriptors = (IPropertyDescriptor[])ArrayUtil.append(IPropertyDescriptor.class, descriptors, text);
} catch (IOException e) {
}
return (IPropertyDescriptor[])ArrayUtil.trim(IPropertyDescriptor.class, descriptors);
}
private class TextDescriptorId {
String id = null;
String file = null;
public TextDescriptorId(String id, String file) {
this.id=id;
this.file=file;
}
public String getFile() {
return file;
}
}
public Object getPropertyValue(Object id) {
if (id instanceof TextDescriptorId) {
return ((TextDescriptorId)id).getFile();
}
return null;
}
public boolean isPropertySet(Object id) {
return false;
}
public void resetPropertyValue(Object id) { }
public void setPropertyValue(Object id, Object value) { }
}
public IEntryResult getResult() {
return result;
}
public void setResult(IEntryResult result) {
this.result = result;
}
public String toString() {
return name;
}
public int getFiltersType() {
return filtersType;
}
public char getType() {
return type;
}
public String getName() {
return name;
}
}

View file

@ -0,0 +1,177 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.File;
import java.util.Collection;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
/**
* @author dsteffle
*/
public class IndexerNodeParent extends IndexerNodeLeaf {
public static final int PAGE_SIZE = 40;
private int pageSize=PAGE_SIZE;
private static final IndexerNodeLeaf[] EMPTY_INDEXER_NODE_LEAVES = new IndexerNodeLeaf[0];
private IndexerNodeLeaf[] children = EMPTY_INDEXER_NODE_LEAVES;
private IndexerNodeLeaf[] childrenToDisplay = new IndexerNodeLeaf[PAGE_SIZE];
private int lastBackwardDisplayed = 0;
private int lastForwardDisplayed=0;
private boolean isForward=true;
private boolean firstDisplay=true;
private IndexerFilterManager filterManager = null;
private IndexerView.ViewContentProvider view=null;
public IndexerNodeParent(IEntryResult result, File indexerFile, IndexerView.ViewContentProvider view) {
super(result, indexerFile);
// create an IndexerFilterManager using the FilterIndexerViewDialog (since all of the work is done there anyways)
FilterIndexerViewDialog dialog = new FilterIndexerViewDialog(CTestPlugin.getStandardDisplay().getActiveShell(), this, view.getProjectName());
dialog.readSettings(dialog.getDialogSettings());
filterManager = dialog.createFilterManager();
try {
pageSize = Integer.valueOf(dialog.getPageSize()).intValue();
} catch (NumberFormatException e) {}
this.view = view;
}
public IndexerNodeLeaf[] getChildren() {
// if there is nothing to display return an empty list
if (children.length == 0) return EMPTY_INDEXER_NODE_LEAVES;
// obey the bounds of the list!
if (!firstDisplay && (!isForward && lastBackwardDisplayed==0 ||
isForward && lastForwardDisplayed==children.length-1)) {
if (isForward)
view.setDisplayForwards(false);
else
view.setDisplayBackwards(false);
return (IndexerNodeLeaf[])ArrayUtil.removeNulls(IndexerNodeLeaf.class, childrenToDisplay);
}
int start=0;
if (isForward) {
if (lastForwardDisplayed==0) start=0;
else start=lastForwardDisplayed+1;
} else {
if (lastBackwardDisplayed==0) start=0;
else start=lastBackwardDisplayed-1;
}
boolean shouldDisplay=true;
int numAdded=0;
int i=start, j=(isForward?0:pageSize-1);
IndexerNodeLeaf[] temp = new IndexerNodeLeaf[pageSize];
boolean tempIsUseful=false;
while(numAdded<pageSize && i<children.length && i >=0) {
// only add the child to the children to display if it matches the current filters set on the view
shouldDisplay = filterManager.isFiltered(children[i]);
if (shouldDisplay) {
tempIsUseful=true;
temp[j] = children[i];
numAdded++;
if (isForward) lastForwardDisplayed=i;
else if (j==pageSize-1) lastForwardDisplayed=i;
if (j==0) lastBackwardDisplayed=i;
// move the index to the next entry in the array to store the next valid child to display
if (isForward) {
if (j+1<temp.length) j++;
} else {
if (j-1>=0) j--;
}
}
shouldDisplay=true; // reset this value
// move the index to the next child to analyze
if (isForward) {
i++;
} else {
i--;
}
}
// if there is useful content on the next page, return it, otherwise just return what is being displayed
if (tempIsUseful) {
childrenToDisplay = new IndexerNodeLeaf[pageSize]; // blank the old array being displayed
// copy the temp array into the actual array
for(int k=0, l=0; k<temp.length; k++) {
if (temp[k] != null) {
childrenToDisplay[k] = temp[k];
l++;
}
}
if (isForward) {
if (firstDisplay)
view.setDisplayForwards(true);
else
view.setDisplayBackwards(true);
} else {
view.setDisplayForwards(true);
}
} else {
if (isForward)
view.setDisplayForwards(false);
else
view.setDisplayBackwards(false);
}
firstDisplay=false;
return (IndexerNodeLeaf[])ArrayUtil.removeNulls(IndexerNodeLeaf.class, childrenToDisplay);
}
public void setChildren(IndexerNodeLeaf[] children) {
this.children = children;
}
public boolean hasChildren() {
return (children!=null && children.length > 0);
}
public int getFullLength() {
return children.length;
}
public void setIsForward(boolean direction) {
isForward = direction;
}
public void setFilterManager(Collection filters, String filterName) {
this.filterManager = new IndexerFilterManager(filters, filterName);
}
public void reset() {
lastBackwardDisplayed = 0;
lastForwardDisplayed=0;
isForward=true;
firstDisplay=true;
childrenToDisplay = EMPTY_INDEXER_NODE_LEAVES;
}
public void setPageSize(int size) {
pageSize = size;
}
public void setView(IndexerView.ViewContentProvider view) {
this.view = view;
}
}

View file

@ -0,0 +1,525 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.io.IOException;
import org.eclipse.cdt.core.index.ICDTIndexer;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.internal.core.index.IEntryResult;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IIndexer;
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.action.Action;
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.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.ViewPart;
import org.eclipse.ui.views.properties.PropertySheet;
/**
* @author dsteffle
*/
public class IndexerView extends ViewPart {
private static final String INDEXER_VIEW___ = "Indexer View - "; //$NON-NLS-1$
private static final String _INDEXER_MENU_MANAGER = "#Indexer_Menu_Manager"; //$NON-NLS-1$
private static final String SET_FILTERS = "Set Filters"; //$NON-NLS-1$
private static final String NEXT_PAGE = "Next Page"; //$NON-NLS-1$
private static final String PREVIOUS_PAGE = "Previous Page"; //$NON-NLS-1$
public static final String VIEW_ID = "org.eclipse.cdt.ui.tests.IndexerView"; //$NON-NLS-1$
private static final String PROPERTIES_VIEW = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$
protected static final String BLANK_STRING = ""; //$NON-NLS-1$
static TableViewer viewer;
protected Action previousPageAction;
protected Action nextPageAction;
protected Action singleClickAction;
protected Action setFiltersAction;
protected IIndexer[] indexers = new IIndexer[CTestPlugin.getWorkspace().getRoot().getProjects().length];
protected IProject project = null;
protected static ViewContentProvider.StartInitializingIndexerView initializeIndexerViewJob = null;
public class ViewContentProvider implements IStructuredContentProvider,
ITreeContentProvider {
private static final String POPULATING_INDEXER_VIEW = "populating indexer view"; //$NON-NLS-1$
protected IndexerNodeParent invisibleRoot;
protected boolean displayForwards=false;
protected boolean displayBackwards=false;
private class InitializeView extends Job {
private static final String ALL_NAME_SEARCH = "*"; //$NON-NLS-1$
private static final String INDEXER_VIEW = "Indexer View"; //$NON-NLS-1$
TableViewer theViewer = null;
public InitializeView(String name, TableViewer viewer) {
super(name);
this.theViewer = viewer;
}
protected IStatus run(IProgressMonitor monitor) {
for(int i=0; i<indexers.length; i++) {
if (indexers[i] instanceof ICDTIndexer) {
if (project == null) {
CTestPlugin.getStandardDisplay().asyncExec(new Runnable() {
public void run() {
MessageDialog.openInformation(theViewer.getControl().getShell(), INDEXER_VIEW,
"SourceIndexer points to a null project."); //$NON-NLS-1$ //$NON-NLS-2$
}
});
return Status.CANCEL_STATUS;
}
IIndex index = ((ICDTIndexer)indexers[i]).getIndex(project.getFullPath(), true, true);
if (index==null) return Status.CANCEL_STATUS;
try {
char[] prefix = BLANK_STRING.toCharArray();
char optionalType = (char)0;
char[] name = ALL_NAME_SEARCH.toCharArray();
char [][] containingTypes = new char[0][];
int matchMode = ICSearchConstants.PATTERN_MATCH;
boolean isCaseSensitive = false;
char[] queryString = AbstractIndexer.bestPrefix( prefix, optionalType, name, containingTypes, matchMode, isCaseSensitive);
IEntryResult[] results = index.queryEntries(queryString);
if (results == null) return Status.CANCEL_STATUS;
int size = results.length;
IndexerNodeLeaf[] children = new IndexerNodeLeaf[size];
for(int j=0; j<size; j++) {
children[j] = new IndexerNodeLeaf(results[j], index.getIndexFile());
children[j].setParent(invisibleRoot);
}
invisibleRoot.setChildren(children);
invisibleRoot.setIsForward(true); // initial display direction is forward
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return Status.OK_STATUS;
}
}
public class InitializeRunnable implements Runnable {
TableViewer view = null;
boolean updateView = true;
public InitializeRunnable(TableViewer view, boolean updateView) {
this.view = view;
this.updateView = updateView;
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
if (!updateView) return;
view.refresh();
if (view.getTable().getItems().length > 0) {
TableItem[] selection = new TableItem[1];
selection[0] = view.getTable().getItems()[0];
// select the first item to prevent it from being selected accidentally (and possibly switching editors accidentally)
view.getTable().setSelection(selection);
}
previousPageAction.setEnabled(displayBackwards);
nextPageAction.setEnabled(displayForwards);
}
}
private class StartInitializingIndexerView extends Job {
private static final String INITIALIZE_INDEXER_VIEW = "initialize Indexer View"; //$NON-NLS-1$
InitializeView job = null;
boolean updateView=true;
public StartInitializingIndexerView(InitializeView job, boolean updateView) {
super(INITIALIZE_INDEXER_VIEW);
this.job = job;
this.updateView = updateView;
}
protected IStatus run(IProgressMonitor monitor) {
job.schedule();
try {
job.join();
} catch (InterruptedException ie) {
return Status.CANCEL_STATUS;
}
CTestPlugin.getStandardDisplay().asyncExec(new InitializeRunnable(viewer, updateView)); // update the view from the Display thread
updateView=true;
return job.getResult();
}
}
public ViewContentProvider() {
this(null, false, false);
}
public void setDisplayForwards(boolean displayForwards) {
this.displayForwards = displayForwards;
}
public void setDisplayBackwards(boolean displayBackwards) {
this.displayBackwards = displayBackwards;
}
public ViewContentProvider(IndexerNodeParent parent, boolean displayForwards, boolean displayBackwards) {
if (parent == null) {
invisibleRoot = new IndexerNodeParent(null, null, this);
initializeIndexerViewJob = new StartInitializingIndexerView(new InitializeView(POPULATING_INDEXER_VIEW, viewer), true);
initializeIndexerViewJob.schedule();
} else {
invisibleRoot = parent;
initializeIndexerViewJob = new StartInitializingIndexerView(new InitializeView(POPULATING_INDEXER_VIEW, viewer), false);
initializeIndexerViewJob.schedule();
}
this.displayForwards=displayForwards;
this.displayBackwards=displayBackwards;
}
public Object[] getElements(Object inputElement) {
if (inputElement.equals(getViewSite())) {
return getChildren(invisibleRoot);
}
return getChildren(inputElement);
}
public void dispose() {}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// TODO Auto-generated method stub
}
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IndexerNodeParent) {
return ((IndexerNodeParent) parentElement).getChildren();
}
return new Object[0];
}
public Object getParent(Object element) {
if (element instanceof IndexerNodeLeaf) {
return ((IndexerNodeLeaf) element).getParent();
}
return null;
}
public boolean hasChildren(Object element) {
if (element instanceof IndexerNodeParent)
return ((IndexerNodeParent) element).hasChildren();
return false;
}
public IndexerNodeParent getInvisibleRoot() {
return invisibleRoot;
}
public boolean isDisplayForwards() {
return displayForwards;
}
public boolean isDisplayBackwards() {
return displayBackwards;
}
public String getProjectName() {
if (project == null) return BLANK_STRING;
return project.getName();
}
}
class ViewLabelProvider extends LabelProvider {
public String getText(Object obj) {
if (obj == null) return BLANK_STRING;
return obj.toString();
}
public Image getImage(Object obj) {
String imageKey = IndexerViewPluginImages.IMG_WARNING;
if (obj instanceof IndexerNodeLeaf) {
String word = String.valueOf(((IndexerNodeLeaf)obj).getResult().getWord());
if (word.startsWith(FilterIndexerViewDialog.ENTRY_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FUNCTION_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FUNCTION_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FUNCTION_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FUNCTION_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_CONSTRUCTOR_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_CONSTRUCTOR_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_CONSTRUCTOR_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_NAMESPACE_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_NAMESPACE_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_NAMESPACE_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_NAMESPACE_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FIELD_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FIELD_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_FIELD_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FIELD_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_ENUMTOR_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_ENUMTOR_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_ENUMTOR_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_ENUMTOR_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_METHOD_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_METHOD_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_METHOD_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_METHOD_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_MACRO_DECL_STRING)) {
imageKey = IndexerViewPluginImages.IMG_MACRO_DECL;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_INCLUDE_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_INCLUDE_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_SUPER_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_SUPER_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_T_STRING)) {
imageKey = IndexerViewPluginImages.IMG_TYPEDEF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_C_STRING)) {
imageKey = IndexerViewPluginImages.IMG_CLASS;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_V_STRING)) {
imageKey = IndexerViewPluginImages.IMG_VARIABLE;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_S_STRING)) {
imageKey = IndexerViewPluginImages.IMG_STRUCT;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_E_STRING)) {
imageKey = IndexerViewPluginImages.IMG_ENUM;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_U_STRING)) {
imageKey = IndexerViewPluginImages.IMG_UNION;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_REF_STRING)) {
imageKey = IndexerViewPluginImages.IMG_TYPE_REF;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_D_STRING)) {
imageKey = IndexerViewPluginImages.IMG_DERIVED;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_F_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FRIEND;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_G_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FWD_CLASS;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_H_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FWD_STRUCT;
} else if (word.startsWith(FilterIndexerViewDialog.ENTRY_TYPE_DECL_I_STRING)) {
imageKey = IndexerViewPluginImages.IMG_FWD_UNION;
}
}
return IndexerViewPluginImages.get(imageKey);
}
}
public void createPartControl(Composite parent) {
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setInput(getViewSite());
makeActions();
hookContextMenu();
hookSingleClickAction();
contributeToActionBars();
}
private void makeActions() {
previousPageAction = new Action() {
public void run() {
if (viewer.getContentProvider() instanceof ViewContentProvider) {
IndexerNodeParent root = ((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot();
root.setIsForward(false);
}
viewer.refresh();
setEnabled(((ViewContentProvider)viewer.getContentProvider()).isDisplayBackwards());
nextPageAction.setEnabled(((ViewContentProvider)viewer.getContentProvider()).isDisplayForwards());
}
};
previousPageAction.setText(PREVIOUS_PAGE);
previousPageAction.setToolTipText(PREVIOUS_PAGE);
previousPageAction.setImageDescriptor(IndexerViewPluginImages.DESC_BACK);
nextPageAction = new Action() {
public void run() {
if (viewer.getContentProvider() instanceof ViewContentProvider) {
IndexerNodeParent root = ((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot();
root.setIsForward(true);
}
viewer.refresh();
previousPageAction.setEnabled(((ViewContentProvider)viewer.getContentProvider()).isDisplayBackwards());
setEnabled(((ViewContentProvider)viewer.getContentProvider()).isDisplayForwards());
}
};
nextPageAction.setText(NEXT_PAGE);
nextPageAction.setToolTipText(NEXT_PAGE);
nextPageAction.setImageDescriptor(IndexerViewPluginImages.DESC_NEXT);
setFiltersAction = new Action() {
public void run() {
if (!(viewer.getContentProvider() instanceof ViewContentProvider)) return;
FilterIndexerViewDialog dialog = new FilterIndexerViewDialog(getSite().getShell(), ((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot(), project.getName());
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
viewer.setContentProvider(new ViewContentProvider(((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot(), true, true));
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().setView((ViewContentProvider)viewer.getContentProvider()); // update the root's content provider
previousPageAction.setEnabled(((ViewContentProvider)viewer.getContentProvider()).isDisplayBackwards());
nextPageAction.setEnabled(((ViewContentProvider)viewer.getContentProvider()).isDisplayForwards());
}
}
};
setFiltersAction.setText(SET_FILTERS);
setFiltersAction.setToolTipText(SET_FILTERS);
setFiltersAction.setImageDescriptor(IndexerViewPluginImages.DESC_FILTER_BUTTON);
singleClickAction = new IndexerHighlighterAction();
}
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager(_INDEXER_MENU_MANAGER);
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener() {
private void hideMenuItems(IMenuManager manager) {
}
public void menuAboutToShow(IMenuManager manager) {
IndexerView.this.fillContextMenu(manager);
hideMenuItems(manager);
}
});
Menu menu = menuMgr.createContextMenu(viewer.getControl());
viewer.getControl().setMenu(menu);
getSite().registerContextMenu(menuMgr, viewer);
}
void fillContextMenu(IMenuManager manager) {
// Other plug-ins can contribute there actions here
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
private class IndexerHighlighterAction extends Action {
public void run() {
ISelection selection = viewer.getSelection();
IViewPart part = getSite().getPage().findView(PROPERTIES_VIEW);
if (part instanceof PropertySheet) {
((PropertySheet)part).selectionChanged(getSite().getPart(), selection); // TODO Devin need to instead get the part that this action belongs to...
}
}
}
private void hookSingleClickAction() {
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
singleClickAction.run();
}
});
}
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
}
private void fillLocalPullDown(IMenuManager manager) {
}
private void fillLocalToolBar(IToolBarManager manager) {
manager.add(previousPageAction);
manager.add(nextPageAction);
manager.add(new Separator());
manager.add(setFiltersAction);
manager.add(new Separator());
}
public void setFocus() {
IViewPart part = getSite().getPage().findView(PROPERTIES_VIEW);
if (part instanceof PropertySheet) {
((PropertySheet)part).selectionChanged(getSite().getPart(), viewer.getSelection());
}
}
public void appendIndexer(IIndexer indexer) {
indexers = (IIndexer[])ArrayUtil.append(IIndexer.class, indexers, indexer);
}
public void clearIndexers() {
indexers = new IIndexer[CTestPlugin.getWorkspace().getRoot().getProjects().length];
}
public void setContentProvider(ViewContentProvider provider) {
viewer.setContentProvider(provider);
}
public void setProject(IProject project) {
this.setPartName(INDEXER_VIEW___ + project.getName());
this.project=project;
}
public static ViewerFilter[] getViewerFilters() {
return viewer.getFilters();
}
public String getProjectName() {
if (project == null) return BLANK_STRING;
return project.getName();
}
}

View file

@ -0,0 +1,149 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import java.net.MalformedURLException;
import java.net.URL;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
/**
* @author dsteffle
*/
public class IndexerViewPluginImages {
private static ImageRegistry imageRegistry = new ImageRegistry(CUIPlugin.getStandardDisplay());
/**
* Returns the standard display to be used. The method first checks, if
* the thread calling this method has an associated display. If so, this
* display is returned. Otherwise the method returns the default display.
*/
public static Display getStandardDisplay() {
Display display= Display.getCurrent();
if (display == null) {
display= Display.getDefault();
}
return display;
}
// Subdirectory (under the package containing this class) where 16 color images are
private static URL fgIconBaseURL;
static {
try {
fgIconBaseURL= new URL(CTestPlugin.getDefault().getBundle().getEntry("/"), "icons/" ); //$NON-NLS-1$ //$NON-NLS-2$
} catch (MalformedURLException e) {}
}
public static final String PLUGIN_ID = "org.eclipse.cdt.testplugin.CTestPlugin"; //$NON-NLS-1$
private static final String NAME_PREFIX= PLUGIN_ID + '.';
private static final int NAME_PREFIX_LENGTH= NAME_PREFIX.length();
public static final String ICON_PREFIX= "indexer_view/"; //$NON-NLS-1$
public static final String IMG_REF= NAME_PREFIX + "ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_TYPE_REF= NAME_PREFIX + "typedecl_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_TYPE_DECL= NAME_PREFIX + "typedecl_obj.gif"; //$NON-NLS-1$
public static final String IMG_FUNCTION_REF= NAME_PREFIX + "function_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_FUNCTION_DECL= NAME_PREFIX + "function_obj.gif"; //$NON-NLS-1$
public static final String IMG_CONSTRUCTOR_REF= NAME_PREFIX + "constructor_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_CONSTRUCTOR_DECL= NAME_PREFIX + "constructor_obj.gif"; //$NON-NLS-1$
public static final String IMG_NAMESPACE_REF= NAME_PREFIX + "namespace_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_NAMESPACE_DECL= NAME_PREFIX + "namespace_obj.gif"; //$NON-NLS-1$
public static final String IMG_FIELD_REF= NAME_PREFIX + "field_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_FIELD_DECL= NAME_PREFIX + "field_obj.gif"; //$NON-NLS-1$
public static final String IMG_ENUMTOR_REF= NAME_PREFIX + "enumerator_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_ENUMTOR_DECL= NAME_PREFIX + "enumerator_obj.gif"; //$NON-NLS-1$
public static final String IMG_METHOD_REF= NAME_PREFIX + "method_public_ref_obj.gif"; //$NON-NLS-1$
public static final String IMG_METHOD_DECL= NAME_PREFIX + "method_public_obj.gif"; //$NON-NLS-1$
public static final String IMG_MACRO_DECL= NAME_PREFIX + "macroDecl_obj.gif"; //$NON-NLS-1$
public static final String IMG_INCLUDE_REF= NAME_PREFIX + "include_obj.gif"; //$NON-NLS-1$
public static final String IMG_SUPER_REF= NAME_PREFIX + "super_co.gif"; //$NON-NLS-1$
public static final String IMG_VARIABLE= NAME_PREFIX + "variable_obj.gif"; //$NON-NLS-1$
public static final String IMG_CLASS= NAME_PREFIX + "class_obj.gif"; //$NON-NLS-1$
public static final String IMG_ENUM= NAME_PREFIX + "enum_obj.gif"; //$NON-NLS-1$
public static final String IMG_BACK= NAME_PREFIX + "ngback.gif"; //$NON-NLS-1$
public static final String IMG_NEXT= NAME_PREFIX + "ngnext.gif"; //$NON-NLS-1$
public static final String IMG_STRUCT= NAME_PREFIX + "struct_obj.gif"; //$NON-NLS-1$
public static final String IMG_TYPEDEF= NAME_PREFIX + "typedef_obj.gif"; //$NON-NLS-1$
public static final String IMG_UNION= NAME_PREFIX + "union_obj.gif"; //$NON-NLS-1$
public static final String IMG_DERIVED= NAME_PREFIX + "derived.gif"; //$NON-NLS-1$
public static final String IMG_FRIEND= NAME_PREFIX + "friend.gif"; //$NON-NLS-1$
public static final String IMG_FWD_CLASS= NAME_PREFIX + "fwd_class.gif"; //$NON-NLS-1$
public static final String IMG_FWD_STRUCT= NAME_PREFIX + "fwd_struct.gif"; //$NON-NLS-1$
public static final String IMG_FWD_UNION= NAME_PREFIX + "fwd_union.gif"; //$NON-NLS-1$
public static final String IMG_WARNING= NAME_PREFIX + "warning_icon.gif"; //$NON-NLS-1$
public static final String IMG_FILTER_BUTTON= NAME_PREFIX + "filterbutton.gif"; //$NON-NLS-1$
public static final ImageDescriptor DESC_REF= createManaged(ICON_PREFIX, IMG_REF);
public static final ImageDescriptor DESC_TYPE_REF= createManaged(ICON_PREFIX, IMG_TYPE_REF);
public static final ImageDescriptor DESC_TYPE_DECL= createManaged(ICON_PREFIX, IMG_TYPE_DECL);
public static final ImageDescriptor DESC_FUNCTION_REF= createManaged(ICON_PREFIX, IMG_FUNCTION_REF);
public static final ImageDescriptor DESC_FUNCTION_DECL= createManaged(ICON_PREFIX, IMG_FUNCTION_DECL);
public static final ImageDescriptor DESC_CONSTRUCTOR_REF= createManaged(ICON_PREFIX, IMG_CONSTRUCTOR_REF);
public static final ImageDescriptor DESC_CONSTRUCTOR_DECL= createManaged(ICON_PREFIX, IMG_CONSTRUCTOR_DECL);
public static final ImageDescriptor DESC_NAMESPACE_REF= createManaged(ICON_PREFIX, IMG_NAMESPACE_REF);
public static final ImageDescriptor DESC_NAMESPACE_DECL= createManaged(ICON_PREFIX, IMG_NAMESPACE_DECL);
public static final ImageDescriptor DESC_FIELD_REF= createManaged(ICON_PREFIX, IMG_FIELD_REF);
public static final ImageDescriptor DESC_FIELD_DECL= createManaged(ICON_PREFIX, IMG_FIELD_DECL);
public static final ImageDescriptor DESC_ENUMTOR_REF= createManaged(ICON_PREFIX, IMG_ENUMTOR_REF);
public static final ImageDescriptor DESC_ENUMTOR_DECL= createManaged(ICON_PREFIX, IMG_ENUMTOR_DECL);
public static final ImageDescriptor DESC_METHOD_REF= createManaged(ICON_PREFIX, IMG_METHOD_REF);
public static final ImageDescriptor DESC_METHOD_DECL= createManaged(ICON_PREFIX, IMG_METHOD_DECL);
public static final ImageDescriptor DESC_MACRO_DECL= createManaged(ICON_PREFIX, IMG_MACRO_DECL);
public static final ImageDescriptor DESC_INCLUDE_REF= createManaged(ICON_PREFIX, IMG_INCLUDE_REF);
public static final ImageDescriptor DESC_SUPER_REF= createManaged(ICON_PREFIX, IMG_SUPER_REF);
public static final ImageDescriptor DESC_VARIABLE= createManaged(ICON_PREFIX, IMG_VARIABLE);
public static final ImageDescriptor DESC_CLASS= createManaged(ICON_PREFIX, IMG_CLASS);
public static final ImageDescriptor DESC_ENUM= createManaged(ICON_PREFIX, IMG_ENUM);
public static final ImageDescriptor DESC_BACK= createManaged(ICON_PREFIX, IMG_BACK);
public static final ImageDescriptor DESC_NEXT= createManaged(ICON_PREFIX, IMG_NEXT);
public static final ImageDescriptor DESC_STRUCT= createManaged(ICON_PREFIX, IMG_STRUCT);
public static final ImageDescriptor DESC_TYPEDEF= createManaged(ICON_PREFIX, IMG_TYPEDEF);
public static final ImageDescriptor DESC_UNION= createManaged(ICON_PREFIX, IMG_UNION);
public static final ImageDescriptor DESC_DERIVED= createManaged(ICON_PREFIX, IMG_DERIVED);
public static final ImageDescriptor DESC_FRIEND= createManaged(ICON_PREFIX, IMG_FRIEND);
public static final ImageDescriptor DESC_FWD_CLASS= createManaged(ICON_PREFIX, IMG_FWD_CLASS);
public static final ImageDescriptor DESC_FWD_STRUCT= createManaged(ICON_PREFIX, IMG_FWD_STRUCT);
public static final ImageDescriptor DESC_FWD_UNION= createManaged(ICON_PREFIX, IMG_FWD_UNION);
public static final ImageDescriptor DESC_WARNING= createManaged(ICON_PREFIX, IMG_WARNING);
public static final ImageDescriptor DESC_FILTER_BUTTON= createManaged(ICON_PREFIX, IMG_FILTER_BUTTON);
private static ImageDescriptor createManaged(String prefix, String name) {
return createManaged(imageRegistry, prefix, name);
}
private static ImageDescriptor createManaged(ImageRegistry registry, String prefix, String name) {
ImageDescriptor result= ImageDescriptor.createFromURL(makeIconFileURL(prefix, name.substring(NAME_PREFIX_LENGTH)));
registry.put(name, result);
return result;
}
private static URL makeIconFileURL(String prefix, String name) {
StringBuffer buffer= new StringBuffer(prefix);
buffer.append(name);
try {
return new URL(fgIconBaseURL, buffer.toString());
} catch (MalformedURLException e) {
CUIPlugin.getDefault().log(e);
return null;
}
}
public static Image get(String key) {
return imageRegistry.get(key);
}
}

View file

@ -0,0 +1,82 @@
/**********************************************************************
* Copyright (c) 2005 IBM Canada and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v0.5
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v05.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
**********************************************************************/
package org.eclipse.cdt.ui.tests.IndexerView;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.index.IIndexer;
import org.eclipse.cdt.internal.core.model.CProject;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IEditorActionDelegate;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PartInitException;
/**
* @author dsteffle
*/
public class OpenIndexerViewAction implements IViewActionDelegate,
IEditorActionDelegate, IObjectActionDelegate {
IViewPart viewPart = null;
IProject proj = null;
public static int numViewsOpen=0;
public void init(IViewPart view) {
this.viewPart = view;
}
public void run(IAction action) {
IViewPart tempView = null;
try {
// TODO Devin add support for multiple views
// tempView = viewPart.getSite().getPage().showView(IndexerView.VIEW_ID, proj.getName(), IWorkbenchPage.VIEW_ACTIVATE);
tempView = viewPart.getSite().getPage().showView(IndexerView.VIEW_ID);
if (tempView instanceof IndexerView)
((IndexerView)tempView).setProject(proj);
OpenIndexerViewAction.numViewsOpen++;
} catch (PartInitException pie) {}
if (tempView != null) {
if (tempView instanceof IndexerView) {
((IndexerView)tempView).clearIndexers();
IIndexer indexer = CCorePlugin.getDefault().getCoreModel().getIndexManager().getIndexerForProject(proj);
((IndexerView)tempView).appendIndexer(indexer);
((IndexerView)tempView).setContentProvider(((IndexerView)tempView).new ViewContentProvider());
}
}
viewPart.getSite().getPage().activate(tempView);
}
public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof IStructuredSelection &&
((IStructuredSelection)selection).getFirstElement() instanceof CProject) {
proj = ((CProject)((IStructuredSelection)selection).getFirstElement()).getProject();
}
}
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
// TODO Auto-generated method stub
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
// TODO Auto-generated method stub
}
}