Patch for Devin Steffler w/ Modifications - Indexer View Search
BIN
core/org.eclipse.cdt.ui.tests/icons/dom_view/refresh_view.gif
Normal file
After Width: | Height: | Size: 182 B |
BIN
core/org.eclipse.cdt.ui.tests/icons/dom_view/reload_view.gif
Normal file
After Width: | Height: | Size: 144 B |
BIN
core/org.eclipse.cdt.ui.tests/icons/indexer_view/alphab_sort.gif
Normal file
After Width: | Height: | Size: 224 B |
After Width: | Height: | Size: 99 B |
Before Width: | Height: | Size: 838 B |
After Width: | Height: | Size: 181 B |
After Width: | Height: | Size: 590 B |
Before Width: | Height: | Size: 836 B |
After Width: | Height: | Size: 73 B |
Before Width: | Height: | Size: 837 B |
After Width: | Height: | Size: 117 B |
After Width: | Height: | Size: 563 B |
Before Width: | Height: | Size: 849 B After Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 838 B |
After Width: | Height: | Size: 111 B |
Before Width: | Height: | Size: 888 B After Width: | Height: | Size: 586 B |
Before Width: | Height: | Size: 896 B |
BIN
core/org.eclipse.cdt.ui.tests/icons/indexer_view/fwd_struct.gif
Normal file
After Width: | Height: | Size: 585 B |
Before Width: | Height: | Size: 906 B |
BIN
core/org.eclipse.cdt.ui.tests/icons/indexer_view/fwd_union.gif
Normal file
After Width: | Height: | Size: 170 B |
Before Width: | Height: | Size: 822 B After Width: | Height: | Size: 856 B |
Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 856 B |
Before Width: | Height: | Size: 822 B After Width: | Height: | Size: 857 B |
Before Width: | Height: | Size: 819 B After Width: | Height: | Size: 847 B |
Before Width: | Height: | Size: 846 B |
After Width: | Height: | Size: 193 B |
Before Width: | Height: | Size: 889 B |
After Width: | Height: | Size: 585 B |
After Width: | Height: | Size: 361 B |
Before Width: | Height: | Size: 871 B |
After Width: | Height: | Size: 585 B |
|
@ -149,20 +149,20 @@ public class DOMAST extends ViewPart {
|
|||
private Action displayNodeSignatureAction;
|
||||
private Action displayExpressionAction;
|
||||
private Action displayInitializerAction;
|
||||
private Action singleClickAction;
|
||||
protected Action singleClickAction;
|
||||
private Action loadActiveEditorAction;
|
||||
private Action refreshAction;
|
||||
private Action expandAllAction;
|
||||
private Action collapseAllAction;
|
||||
private Action clearAction;
|
||||
private Action searchNamesAction;
|
||||
private IFile file = null;
|
||||
protected IFile file = null;
|
||||
private IEditorPart part = null;
|
||||
private ParserLanguage lang = null;
|
||||
protected ParserLanguage lang = null;
|
||||
|
||||
private CustomFiltersActionGroup customFiltersActionGroup;
|
||||
|
||||
private static ViewContentProvider.StartInitializingASTView initializeASTViewJob = null;
|
||||
protected static ViewContentProvider.StartInitializingASTView initializeASTViewJob = null;
|
||||
|
||||
/*
|
||||
* The content provider class is responsible for providing objects to the
|
||||
|
@ -177,7 +177,7 @@ public class DOMAST extends ViewPart {
|
|||
private DOMASTNodeParent invisibleRoot;
|
||||
private DOMASTNodeParent tuTreeParent = null;
|
||||
private IASTTranslationUnit tu = null;
|
||||
private IASTProblem[] astProblems = null;
|
||||
protected IASTProblem[] astProblems = null;
|
||||
|
||||
public ViewContentProvider() {
|
||||
}
|
||||
|
@ -283,16 +283,16 @@ public class DOMAST extends ViewPart {
|
|||
|
||||
}
|
||||
|
||||
private void expandTreeIfNecessary(TreeItem[] tree, Object[] expanded) {
|
||||
private void expandTreeIfNecessary(TreeItem[] tree, Object[] theExpanded) {
|
||||
for( int i=0; i<tree.length; i++) {
|
||||
for( int j=0; j<expanded.length; j++) {
|
||||
if (expanded[j] instanceof DOMASTNodeLeaf &&
|
||||
for( int j=0; j<theExpanded.length; j++) {
|
||||
if (theExpanded[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())) {
|
||||
((DOMASTNodeLeaf)theExpanded[j]).toString().equals(((DOMASTNodeLeaf)tree[i].getData()).toString()) &&
|
||||
((DOMASTNodeLeaf)theExpanded[j]).getOffset() == (((DOMASTNodeLeaf)tree[i].getData()).getOffset())) {
|
||||
tree[i].setExpanded(true);
|
||||
viewer.refresh();
|
||||
expandTreeIfNecessary(tree[i].getItems(), expanded);
|
||||
expandTreeIfNecessary(tree[i].getItems(), theExpanded);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,10 @@ public class DOMAST extends ViewPart {
|
|||
|
||||
private class InitializeView extends Job {
|
||||
|
||||
private static final String RETRIEVING_PREPROCESSOR_PROBLEMS = "Retrieving all preprocessor problems from TU"; //$NON-NLS-1$
|
||||
private static final String COLON_SPACE = ": "; //$NON-NLS-1$
|
||||
private static final String DOM_AST_VIEW_DONE = "[DOM AST View] done "; //$NON-NLS-1$
|
||||
private static final String DOM_AST_VIEW_FINISHED = "[DOM AST View] finished: "; //$NON-NLS-1$
|
||||
private static final String RETRIEVING_PREPROCESSOR_PROBLEMS = "Retrieving all preprocessor problems from TU"; //$NON-NLS-1$
|
||||
private static final String RETRIEVING_PREPROCESSOR_STATEMENTS = "Retrieving all preprocessor statements from TU"; //$NON-NLS-1$
|
||||
private static final String _PREPROCESSOR_PROBLEMS_ = " preprocessor problems"; //$NON-NLS-1$
|
||||
private static final String _PREPROCESSOR_STATEMENTS_ = " preprocessor statements"; //$NON-NLS-1$
|
||||
|
@ -318,7 +321,7 @@ public class DOMAST extends ViewPart {
|
|||
DOMASTNodeParent root = null;
|
||||
ViewContentProvider provider = null;
|
||||
TreeViewer view = null;
|
||||
IFile file = null;
|
||||
IFile aFile = null;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
|
@ -329,7 +332,7 @@ public class DOMAST extends ViewPart {
|
|||
setUser(true);
|
||||
this.provider = provider;
|
||||
this.view = view;
|
||||
this.file = file;
|
||||
this.aFile = file;
|
||||
}
|
||||
|
||||
public DOMASTNodeParent getInvisibleRoot() {
|
||||
|
@ -350,24 +353,24 @@ public class DOMAST extends ViewPart {
|
|||
long start=0;
|
||||
long overallStart=System.currentTimeMillis();
|
||||
|
||||
if (file == null || lang == null || monitor == null)
|
||||
if (aFile == null || lang == null || monitor == null)
|
||||
return Status.CANCEL_STATUS;
|
||||
|
||||
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
|
||||
monitor.beginTask(name, 8);
|
||||
monitor.beginTask(name, 100);
|
||||
start=System.currentTimeMillis();
|
||||
|
||||
IPopulateDOMASTAction action = null;
|
||||
IASTTranslationUnit tu = null;
|
||||
IASTTranslationUnit aTu = null;
|
||||
try {
|
||||
monitor.subTask(PARSING_TRANSLATION_UNIT);
|
||||
start=System.currentTimeMillis();
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
file,
|
||||
aTu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
aFile,
|
||||
CDOM.getInstance().getCodeReaderFactory(
|
||||
CDOM.PARSE_SAVED_RESOURCES));
|
||||
monitor.worked(1);
|
||||
System.out.println("[DOM AST View] done " + PARSING_TRANSLATION_UNIT + ": " + (System.currentTimeMillis()- start) );
|
||||
monitor.worked(30);
|
||||
System.out.println(DOM_AST_VIEW_DONE + PARSING_TRANSLATION_UNIT + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
@ -376,14 +379,14 @@ public class DOMAST extends ViewPart {
|
|||
monitor.subTask(GENERATING_INITIAL_TREE);
|
||||
start=System.currentTimeMillis();
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
action = new CPPPopulateASTViewAction(tu, monitor);
|
||||
tu.accept( (CPPASTVisitor) action);
|
||||
action = new CPPPopulateASTViewAction(aTu, monitor);
|
||||
aTu.accept( (CPPASTVisitor) action);
|
||||
} else {
|
||||
action = new CPopulateASTViewAction(tu, monitor);
|
||||
tu.accept( (CASTVisitor) action);
|
||||
action = new CPopulateASTViewAction(aTu, monitor);
|
||||
aTu.accept( (CASTVisitor) action);
|
||||
}
|
||||
monitor.worked(2);
|
||||
System.out.println("[DOM AST View] done " + GENERATING_INITIAL_TREE + ": " + (System.currentTimeMillis()- start) );
|
||||
monitor.worked(30);
|
||||
System.out.println(DOM_AST_VIEW_DONE + GENERATING_INITIAL_TREE + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
|
||||
// display roots
|
||||
root = new DOMASTNodeParent(null); //$NON-NLS-1$
|
||||
|
@ -391,38 +394,38 @@ public class DOMAST extends ViewPart {
|
|||
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
|
||||
monitor.subTask(RETRIEVING_PREPROCESSOR_STATEMENTS);
|
||||
start=System.currentTimeMillis();
|
||||
IASTPreprocessorStatement[] statements = tu.getAllPreprocessorStatements();
|
||||
monitor.worked(3);
|
||||
System.out.println("[DOM AST View] done " + RETRIEVING_PREPROCESSOR_STATEMENTS + ": " + (System.currentTimeMillis()- start) );
|
||||
IASTPreprocessorStatement[] statements = aTu.getAllPreprocessorStatements();
|
||||
monitor.worked(5);
|
||||
System.out.println(DOM_AST_VIEW_DONE + RETRIEVING_PREPROCESSOR_STATEMENTS + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
|
||||
monitor.subTask(MERGING_ + statements.length + _PREPROCESSOR_STATEMENTS_);
|
||||
start=System.currentTimeMillis();
|
||||
// merge preprocessor statements to the tree
|
||||
action.mergePreprocessorStatements(statements);
|
||||
monitor.worked(4);
|
||||
System.out.println("[DOM AST View] done " + MERGING_ + statements.length + _PREPROCESSOR_STATEMENTS_ + ": " + (System.currentTimeMillis()- start) );
|
||||
monitor.worked(2);
|
||||
System.out.println(DOM_AST_VIEW_DONE + MERGING_ + statements.length + _PREPROCESSOR_STATEMENTS_ + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
|
||||
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
|
||||
monitor.subTask(RETRIEVING_PREPROCESSOR_PROBLEMS);
|
||||
start=System.currentTimeMillis();
|
||||
IASTProblem[] problems = tu.getPreprocessorProblems();
|
||||
monitor.worked(5);
|
||||
System.out.println("[DOM AST View] done " + RETRIEVING_PREPROCESSOR_PROBLEMS + ": " + (System.currentTimeMillis()- start) );
|
||||
IASTProblem[] problems = aTu.getPreprocessorProblems();
|
||||
monitor.worked(2);
|
||||
System.out.println(DOM_AST_VIEW_DONE + RETRIEVING_PREPROCESSOR_PROBLEMS + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
|
||||
monitor.subTask(MERGING_ + problems.length + _PREPROCESSOR_PROBLEMS_);
|
||||
start=System.currentTimeMillis();
|
||||
// merge preprocessor problems to the tree
|
||||
action.mergePreprocessorProblems(problems);
|
||||
monitor.worked(6);
|
||||
System.out.println("[DOM AST View] done " + MERGING_ + problems.length + _PREPROCESSOR_PROBLEMS_ + ": " + (System.currentTimeMillis()- start) );
|
||||
monitor.worked(1);
|
||||
System.out.println(DOM_AST_VIEW_DONE + MERGING_ + problems.length + _PREPROCESSOR_PROBLEMS_ + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
|
||||
if (monitor.isCanceled()) return Status.CANCEL_STATUS;
|
||||
monitor.subTask(GROUPING_AST);
|
||||
start=System.currentTimeMillis();
|
||||
// group #includes
|
||||
action.groupIncludes(statements);
|
||||
monitor.worked(7);
|
||||
System.out.println("[DOM AST View] done " + GROUPING_AST + ": " + (System.currentTimeMillis()- start) );
|
||||
monitor.worked(30);
|
||||
System.out.println(DOM_AST_VIEW_DONE + GROUPING_AST + COLON_SPACE + (System.currentTimeMillis()- start) );
|
||||
|
||||
root.addChild(action.getTree());
|
||||
|
||||
|
@ -436,7 +439,7 @@ public class DOMAST extends ViewPart {
|
|||
|
||||
monitor.done();
|
||||
|
||||
System.out.println("[DOM AST View] finished: " + (System.currentTimeMillis()- overallStart) );
|
||||
System.out.println(DOM_AST_VIEW_FINISHED + (System.currentTimeMillis()- overallStart) );
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
@ -481,7 +484,7 @@ public class DOMAST extends ViewPart {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
private TreeItem expandTreeToTreeObject(TreeItem[] treeItems, DOMASTNodeLeaf treeObj) {
|
||||
|
@ -553,8 +556,10 @@ public class DOMAST extends ViewPart {
|
|||
|
||||
class ViewLabelProvider extends LabelProvider {
|
||||
|
||||
public String getText(Object obj) {
|
||||
if (obj == null) return "";
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
public String getText(Object obj) {
|
||||
if (obj == null) return BLANK_STRING;
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
|
@ -808,7 +813,7 @@ public class DOMAST extends ViewPart {
|
|||
};
|
||||
loadActiveEditorAction.setText(LOAD_ACTIVE_EDITOR);
|
||||
loadActiveEditorAction.setToolTipText(LOAD_ACTIVE_EDITOR);
|
||||
loadActiveEditorAction.setImageDescriptor(DOMASTPluginImages.DESC_DEFAULT);
|
||||
loadActiveEditorAction.setImageDescriptor(DOMASTPluginImages.DESC_RELOAD_VIEW);
|
||||
|
||||
refreshAction = new Action() {
|
||||
public void run() {
|
||||
|
@ -821,7 +826,7 @@ public class DOMAST extends ViewPart {
|
|||
};
|
||||
refreshAction.setText(REFRESH_DOM_AST);
|
||||
refreshAction.setToolTipText(REFRESH_DOM_AST);
|
||||
refreshAction.setImageDescriptor(DOMASTPluginImages.DESC_IASTInitializer);
|
||||
refreshAction.setImageDescriptor(DOMASTPluginImages.DESC_REFRESH_VIEW);
|
||||
|
||||
expandAllAction = new Action() {
|
||||
public void run() {
|
||||
|
@ -938,7 +943,7 @@ public class DOMAST extends ViewPart {
|
|||
singleClickAction = new ASTHighlighterAction(part);
|
||||
}
|
||||
|
||||
private IEditorPart getActiveEditor() {
|
||||
protected IEditorPart getActiveEditor() {
|
||||
IEditorPart editor = null;
|
||||
|
||||
if (getSite().getPage().isEditorAreaVisible() &&
|
||||
|
@ -1122,6 +1127,7 @@ public class DOMAST extends ViewPart {
|
|||
* Passing the focus request to the viewer's control.
|
||||
*/
|
||||
public void setFocus() {
|
||||
if (viewer==null) return;
|
||||
viewer.getControl().setFocus();
|
||||
|
||||
ISelection selection = viewer.getSelection();
|
||||
|
|
|
@ -76,6 +76,8 @@ public class DOMASTPluginImages {
|
|||
public static final String IMG_COLLAPSE_ALL = NAME_PREFIX + "collapseall.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_CLEAR = NAME_PREFIX + "clear.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_SEARCH_NAMES = NAME_PREFIX + "search_ref_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_REFRESH_VIEW = NAME_PREFIX + "refresh_view.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_RELOAD_VIEW = NAME_PREFIX + "reload_view.gif"; //$NON-NLS-1$
|
||||
|
||||
public static final ImageDescriptor DESC_IASTArrayModifier= createManaged(ICON_PREFIX, IMG_IASTArrayModifier);
|
||||
public static final ImageDescriptor DESC_IASTDeclaration= createManaged(ICON_PREFIX, IMG_IASTDeclaration);
|
||||
|
@ -101,6 +103,8 @@ public class DOMASTPluginImages {
|
|||
public static final ImageDescriptor DESC_COLLAPSE_ALL= createManaged(ICON_PREFIX, IMG_COLLAPSE_ALL);
|
||||
public static final ImageDescriptor DESC_CLEAR= createManaged(ICON_PREFIX, IMG_CLEAR);
|
||||
public static final ImageDescriptor DESC_SEARCH_NAMES= createManaged(ICON_PREFIX, IMG_SEARCH_NAMES);
|
||||
public static final ImageDescriptor DESC_REFRESH_VIEW= createManaged(ICON_PREFIX, IMG_REFRESH_VIEW);
|
||||
public static final ImageDescriptor DESC_RELOAD_VIEW= createManaged(ICON_PREFIX, IMG_RELOAD_VIEW);
|
||||
|
||||
private static ImageDescriptor createManaged(String prefix, String name) {
|
||||
return createManaged(imageRegistry, prefix, name);
|
||||
|
|
|
@ -147,9 +147,12 @@ public class IndexerNodeLeaf implements IAdaptable {
|
|||
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);
|
||||
if (stringBeforeName == null) {
|
||||
name = word;
|
||||
return;
|
||||
}
|
||||
|
||||
name = word.substring(word.indexOf(stringBeforeName) + stringBeforeName.length());
|
||||
|
||||
}
|
||||
|
||||
|
@ -291,6 +294,9 @@ public class IndexerNodeLeaf implements IAdaptable {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
if (!parent.isDisplayFullName() && name.indexOf(IIndexConstants.SEPARATOR) > 0)
|
||||
return name.substring(0, name.indexOf(IIndexConstants.SEPARATOR));
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
|
|||
private boolean firstDisplay=true;
|
||||
private IndexerFilterManager filterManager = null;
|
||||
private IndexerView.ViewContentProvider view=null;
|
||||
private boolean sort=true;
|
||||
private boolean displayFullName=true;
|
||||
private boolean navigate=false;
|
||||
|
||||
public IndexerNodeParent(IEntryResult result, File indexerFile, IndexerView.ViewContentProvider view) {
|
||||
super(result, indexerFile);
|
||||
|
@ -52,6 +55,14 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
|
|||
public IndexerNodeLeaf[] getChildren() {
|
||||
// if there is nothing to display return an empty list
|
||||
if (children.length == 0) return EMPTY_INDEXER_NODE_LEAVES;
|
||||
|
||||
// navigate is used to determine if the array should be traversed or not (button pressed or first loading)
|
||||
if (!navigate) {
|
||||
return (IndexerNodeLeaf[])ArrayUtil.removeNulls(IndexerNodeLeaf.class, childrenToDisplay);
|
||||
} else {
|
||||
navigate = false;
|
||||
}
|
||||
|
||||
// obey the bounds of the list!
|
||||
if (!firstDisplay && (!isForward && lastBackwardDisplayed==0 ||
|
||||
isForward && lastForwardDisplayed==children.length-1)) {
|
||||
|
@ -63,6 +74,14 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
|
|||
return (IndexerNodeLeaf[])ArrayUtil.removeNulls(IndexerNodeLeaf.class, childrenToDisplay);
|
||||
}
|
||||
|
||||
if (firstDisplay && children.length > 1) {
|
||||
if (sort) {// sort children based on name
|
||||
quickSort(children, 0, children.length - 1, true);
|
||||
} else {// sort children based on word
|
||||
quickSort(children, 0, children.length - 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
int start=0;
|
||||
if (isForward) {
|
||||
if (lastForwardDisplayed==0) start=0;
|
||||
|
@ -139,6 +158,57 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
|
|||
return (IndexerNodeLeaf[])ArrayUtil.removeNulls(IndexerNodeLeaf.class, childrenToDisplay);
|
||||
}
|
||||
|
||||
private static void quickSort(IndexerNodeLeaf[] list, int left, int right, boolean sortName) {
|
||||
int original_left= left;
|
||||
int original_right= right;
|
||||
String mid=null;
|
||||
if (sortName) {
|
||||
mid= list[(left + right) / 2].getName().toUpperCase();
|
||||
} else {
|
||||
mid= new String(list[(left + right) / 2].getResult().getWord()).toUpperCase();
|
||||
}
|
||||
do {
|
||||
String compareL = null;
|
||||
String compareR = null;
|
||||
if (sortName) {
|
||||
compareL = list[left].getName().toUpperCase();
|
||||
compareR = list[right].getName().toUpperCase();
|
||||
} else {
|
||||
compareL = new String(list[left].getResult().getWord()).toUpperCase();
|
||||
compareR = new String(list[right].getResult().getWord()).toUpperCase();
|
||||
}
|
||||
while (compareL.compareTo(mid) < 0) {
|
||||
left++;
|
||||
if (sortName) {
|
||||
compareL = list[left].getName().toUpperCase();
|
||||
} else {
|
||||
compareL = new String(list[left].getResult().getWord()).toUpperCase();
|
||||
}
|
||||
}
|
||||
while (mid.compareTo(compareR) < 0) {
|
||||
right--;
|
||||
if (sortName) {
|
||||
compareR = list[right].getName().toUpperCase();
|
||||
} else {
|
||||
compareR = new String(list[right].getResult().getWord()).toUpperCase();
|
||||
}
|
||||
}
|
||||
if (left <= right) {
|
||||
IndexerNodeLeaf tmp= list[left];
|
||||
list[left]= list[right];
|
||||
list[right]= tmp;
|
||||
left++;
|
||||
right--;
|
||||
}
|
||||
} while (left <= right);
|
||||
if (original_left < right) {
|
||||
quickSort(list, original_left, right, sortName);
|
||||
}
|
||||
if (left < original_right) {
|
||||
quickSort(list, left, original_right, sortName);
|
||||
}
|
||||
}
|
||||
|
||||
public void setChildren(IndexerNodeLeaf[] children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
@ -160,6 +230,7 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
|
|||
}
|
||||
|
||||
public void reset() {
|
||||
navigate=true;
|
||||
lastBackwardDisplayed = 0;
|
||||
lastForwardDisplayed=0;
|
||||
isForward=true;
|
||||
|
@ -182,4 +253,28 @@ public class IndexerNodeParent extends IndexerNodeLeaf {
|
|||
}
|
||||
return filteredCount;
|
||||
}
|
||||
|
||||
public boolean isSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(boolean sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
public boolean isDisplayFullName() {
|
||||
return displayFullName;
|
||||
}
|
||||
|
||||
public void setDisplayFullName(boolean displayFullName) {
|
||||
this.displayFullName = displayFullName;
|
||||
}
|
||||
|
||||
public boolean isNavigate() {
|
||||
return navigate;
|
||||
}
|
||||
|
||||
public void setNavigate(boolean navigate) {
|
||||
this.navigate = navigate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,244 @@
|
|||
/**********************************************************************
|
||||
* 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.browser.PathUtil;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.search.BasicSearchMatch;
|
||||
import org.eclipse.cdt.core.search.IMatch;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.io.BlocksIndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.cindexstorage.io.IndexInput;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchQuery;
|
||||
import org.eclipse.cdt.internal.ui.search.CSearchResult;
|
||||
import org.eclipse.cdt.internal.ui.search.NewSearchResultCollector;
|
||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.OperationCanceledException;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.search.ui.ISearchQuery;
|
||||
import org.eclipse.search.ui.ISearchResult;
|
||||
|
||||
/**
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class IndexerQuery extends CSearchQuery implements ISearchQuery {
|
||||
private static final int DEFAULT_MATCH_INFO_SIZE = 4;
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
private CSearchResult _result;
|
||||
private IndexerNodeLeaf leaf=null;
|
||||
private String queryLabel = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public IndexerQuery(IndexerNodeLeaf leaf, String queryLabel, String pattern) {
|
||||
super(CTestPlugin.getWorkspace(), pattern, false, null, null, null, queryLabel, null);
|
||||
this.leaf = leaf;
|
||||
this.queryLabel = queryLabel;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IStatus run(IProgressMonitor monitor)
|
||||
throws OperationCanceledException {
|
||||
|
||||
final CSearchResult textResult= (CSearchResult) getSearchResult();
|
||||
|
||||
IProgressMonitor mainSearchPM= new SubProgressMonitor(monitor, 1000);
|
||||
NewSearchResultCollector collector = new NewSearchResultCollector(textResult, mainSearchPM);
|
||||
|
||||
collector.aboutToStart();
|
||||
|
||||
MatchInfo[] matches = generateMatchInfo();
|
||||
for (int i=0; i<matches.length; i++) {
|
||||
try {
|
||||
if ( matches[i] != null ) {
|
||||
Object fileResource = null;
|
||||
IResource tempResource = matches[i].getResource();
|
||||
IPath tempPath = matches[i].getPath();
|
||||
//Determine whether this match is internal (ie. has a resource) or
|
||||
//external (ie. has a path) and create a match based on the result
|
||||
if (tempResource != null)
|
||||
fileResource =tempResource;
|
||||
else
|
||||
fileResource = tempPath;
|
||||
collector.acceptMatch( createMatch(fileResource, matches[i].getStart(),
|
||||
matches[i].getEnd(), matches[i].getName(), matches[i].getPath()) );
|
||||
}
|
||||
} catch (CoreException ce) {}
|
||||
}
|
||||
|
||||
mainSearchPM.done();
|
||||
collector.done();
|
||||
|
||||
return new Status(IStatus.OK, CTestPlugin.getPluginId(), 0, BLANK_STRING, null); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
private MatchInfo[] generateMatchInfo() {
|
||||
IndexInput input = new BlocksIndexInput(leaf.indexFile);
|
||||
IEntryResult entryResult = leaf.getResult();
|
||||
MatchInfo[] matches = new MatchInfo[DEFAULT_MATCH_INFO_SIZE];
|
||||
try {
|
||||
input.open();
|
||||
|
||||
int[] references = entryResult.getFileReferences();
|
||||
int[][]offsets = entryResult.getOffsets();
|
||||
int[][]offsetLengths = entryResult.getOffsetLengths();
|
||||
if (offsets != null){
|
||||
for (int j=0; j<offsets.length; j++){
|
||||
for (int k=0; k<offsets[j].length; k++){
|
||||
MatchInfo match = new MatchInfo();
|
||||
if (references.length > j-1) {
|
||||
IndexedFileEntry file = input.getIndexedFile(references[j]);
|
||||
if (file != null){
|
||||
IPath filePath = new Path(file.getPath());
|
||||
//If we can verify that the file exists within the workspace, we'll use it
|
||||
//to open the appropriate editor - if not we can just set the path and we'll
|
||||
//use the external editor mechanism
|
||||
IFile tempFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
|
||||
if (tempFile != null && tempFile.exists())
|
||||
match.setResource(tempFile);
|
||||
else {
|
||||
match.setPath(PathUtil.getWorkspaceRelativePath(file.getPath()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
int start=0;
|
||||
int end=0;
|
||||
try {
|
||||
start=Integer.valueOf(String.valueOf(offsets[j][k]).substring(1)).intValue();
|
||||
end=start+offsetLengths[j][k];
|
||||
} catch (NumberFormatException nfe) {}
|
||||
|
||||
match.setStart(start) ;
|
||||
match.setEnd(end);
|
||||
match.setName(leaf.getName());
|
||||
|
||||
matches = (MatchInfo[])ArrayUtil.append(MatchInfo.class, matches, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
private class MatchInfo {
|
||||
private IPath path=null;
|
||||
private int start=0;
|
||||
private int end=0;
|
||||
private String name=null;
|
||||
private IResource resource=null;
|
||||
|
||||
public IPath getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(IPath path) {
|
||||
this.path = path;
|
||||
}
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
public void setEnd(int end) {
|
||||
this.end = end;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
public void setStart(int start) {
|
||||
this.start = start;
|
||||
}
|
||||
public IResource getResource() {
|
||||
return resource;
|
||||
}
|
||||
public void setResource(IResource resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
}
|
||||
|
||||
public IMatch createMatch( Object fileResource, int start, int end, String name, IPath referringElement ) {
|
||||
BasicSearchMatch result = new BasicSearchMatch();
|
||||
if( fileResource instanceof IResource )
|
||||
result.resource = (IResource) fileResource;
|
||||
else if( fileResource instanceof IPath )
|
||||
result.path = (IPath) fileResource;
|
||||
|
||||
result.startOffset = start;
|
||||
result.endOffset = end;
|
||||
result.parentName = BLANK_STRING; //$NON-NLS-1$
|
||||
result.referringElement = referringElement;
|
||||
|
||||
result.name = name;
|
||||
|
||||
result.type = ICElement.C_FIELD; // TODO Devin static for now, want something like BasicSearchResultCollector#setElementInfo
|
||||
result.visibility = ICElement.CPP_PUBLIC; // TODO Devin static for now, want something like BasicSearchResultCollector#setElementInfo
|
||||
result.returnType = BLANK_STRING;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.search.ui.ISearchQuery#getLabel()
|
||||
*/
|
||||
public String getLabel() {
|
||||
return queryLabel;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.search.ui.ISearchQuery#canRerun()
|
||||
*/
|
||||
public boolean canRerun() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.search.ui.ISearchQuery#canRunInBackground()
|
||||
*/
|
||||
public boolean canRunInBackground() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.search.ui.ISearchQuery#getSearchResult()
|
||||
*/
|
||||
public ISearchResult getSearchResult() {
|
||||
if (_result == null)
|
||||
_result= new CSearchResult(this);
|
||||
return _result;
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@ 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;
|
||||
|
@ -36,12 +35,14 @@ 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.IStructuredSelection;
|
||||
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.search.ui.NewSearchUI;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
@ -57,6 +58,10 @@ import org.eclipse.ui.views.properties.PropertySheet;
|
|||
* @author dsteffle
|
||||
*/
|
||||
public class IndexerView extends ViewPart {
|
||||
private static final int DEFAULT_INDEXER_SIZE = 1;
|
||||
private static final String SWITCH_FULL_NAMES = "Switch Full Names"; //$NON-NLS-1$
|
||||
private static final String SORT_RESULTS = "Sort Results"; //$NON-NLS-1$
|
||||
private static final String SEARCH_LOCATIONS = "Search Locations"; //$NON-NLS-1$
|
||||
private static final String _TOTAL_IENTRYRESULTS = " total IEntryResults"; //$NON-NLS-1$
|
||||
private static final String _FILTERED_IENTRY_RESULTS_ = " filtered IEntry Results\n"; //$NON-NLS-1$
|
||||
private static final String INDEXER_STATS = "Indexer Stats"; //$NON-NLS-1$
|
||||
|
@ -70,14 +75,17 @@ public class IndexerView extends ViewPart {
|
|||
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 searchLocationAction;
|
||||
protected Action previousPageAction;
|
||||
protected Action nextPageAction;
|
||||
protected Action singleClickAction;
|
||||
protected Action setFiltersAction;
|
||||
protected Action sortAction;
|
||||
protected Action displayFullNameAction;
|
||||
protected Action displayStatsAction;
|
||||
protected IIndexer[] indexers = new IIndexer[CTestPlugin.getWorkspace().getRoot().getProjects().length];
|
||||
protected IIndexer[] indexers = new IIndexer[DEFAULT_INDEXER_SIZE]; // support 1 indexer for now new IIndexer[CTestPlugin.getWorkspace().getRoot().getProjects().length];
|
||||
protected IProject project = null;
|
||||
|
||||
|
||||
protected static ViewContentProvider.StartInitializingIndexerView initializeIndexerViewJob = null;
|
||||
|
||||
public class ViewContentProvider implements IStructuredContentProvider,
|
||||
|
@ -143,7 +151,6 @@ public class IndexerView extends ViewPart {
|
|||
|
||||
invisibleRoot.setIsForward(true); // initial display direction is forward
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +174,8 @@ public class IndexerView extends ViewPart {
|
|||
*/
|
||||
public void run() {
|
||||
if (!updateView) return;
|
||||
|
||||
|
||||
enableButtons(false);
|
||||
view.refresh();
|
||||
|
||||
if (view.getTable().getItems().length > 0) {
|
||||
|
@ -178,6 +186,7 @@ public class IndexerView extends ViewPart {
|
|||
view.getTable().setSelection(selection);
|
||||
}
|
||||
|
||||
enableButtons(true);
|
||||
previousPageAction.setEnabled(displayBackwards);
|
||||
nextPageAction.setEnabled(displayForwards);
|
||||
}
|
||||
|
@ -234,6 +243,7 @@ public class IndexerView extends ViewPart {
|
|||
initializeIndexerViewJob.schedule();
|
||||
}
|
||||
|
||||
invisibleRoot.reset();
|
||||
this.displayForwards=displayForwards;
|
||||
this.displayBackwards=displayBackwards;
|
||||
}
|
||||
|
@ -247,7 +257,7 @@ public class IndexerView extends ViewPart {
|
|||
|
||||
public void dispose() {}
|
||||
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
public void inputChanged(Viewer aViewer, Object oldInput, Object newInput) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
|
@ -381,12 +391,25 @@ public class IndexerView extends ViewPart {
|
|||
contributeToActionBars();
|
||||
}
|
||||
|
||||
protected void enableButtons(boolean value) {
|
||||
setFiltersAction.setEnabled(value);
|
||||
setFiltersAction.setEnabled(value);
|
||||
sortAction.setEnabled(value);
|
||||
displayFullNameAction.setEnabled(value);
|
||||
}
|
||||
|
||||
private void makeActions() {
|
||||
searchLocationAction = new SearchLocationsAction();
|
||||
searchLocationAction.setText(SEARCH_LOCATIONS);
|
||||
searchLocationAction.setToolTipText(SEARCH_LOCATIONS);
|
||||
searchLocationAction.setImageDescriptor(IndexerViewPluginImages.DESC_SEARCH_LOCATION);
|
||||
|
||||
previousPageAction = new Action() {
|
||||
public void run() {
|
||||
if (viewer.getContentProvider() instanceof ViewContentProvider) {
|
||||
IndexerNodeParent root = ((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot();
|
||||
root.setIsForward(false);
|
||||
root.setNavigate(true);
|
||||
}
|
||||
viewer.refresh();
|
||||
|
||||
|
@ -403,6 +426,7 @@ public class IndexerView extends ViewPart {
|
|||
if (viewer.getContentProvider() instanceof ViewContentProvider) {
|
||||
IndexerNodeParent root = ((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot();
|
||||
root.setIsForward(true);
|
||||
root.setNavigate(true);
|
||||
}
|
||||
viewer.refresh();
|
||||
|
||||
|
@ -422,11 +446,9 @@ public class IndexerView extends ViewPart {
|
|||
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());
|
||||
// reset the view but remember the buttons being displayed from the old content provider
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().reset();
|
||||
viewer.refresh();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -434,6 +456,48 @@ public class IndexerView extends ViewPart {
|
|||
setFiltersAction.setToolTipText(SET_FILTERS);
|
||||
setFiltersAction.setImageDescriptor(IndexerViewPluginImages.DESC_FILTER_BUTTON);
|
||||
|
||||
sortAction = new Action() {
|
||||
public void run() {
|
||||
if (viewer.getContentProvider() instanceof ViewContentProvider) {
|
||||
enableButtons(false);
|
||||
if (((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().isSort()) {
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().setSort(false);
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().reset();
|
||||
viewer.refresh();
|
||||
this.setImageDescriptor(IndexerViewPluginImages.DESC_SORT);
|
||||
} else {
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().setSort(true);
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().reset();
|
||||
viewer.refresh();
|
||||
this.setImageDescriptor(IndexerViewPluginImages.DESC_SORTED);
|
||||
}
|
||||
enableButtons(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
sortAction.setText(SORT_RESULTS);
|
||||
sortAction.setToolTipText(SORT_RESULTS);
|
||||
sortAction.setImageDescriptor(IndexerViewPluginImages.DESC_SORTED);
|
||||
|
||||
displayFullNameAction = new Action() {
|
||||
public void run() {
|
||||
if (viewer.getContentProvider() instanceof ViewContentProvider) {
|
||||
if (((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().isDisplayFullName()) {
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().setDisplayFullName(false);
|
||||
viewer.refresh();
|
||||
this.setImageDescriptor(IndexerViewPluginImages.DESC_DISPLAY_FULL_NAME);
|
||||
} else {
|
||||
((ViewContentProvider)viewer.getContentProvider()).getInvisibleRoot().setDisplayFullName(true);
|
||||
viewer.refresh();
|
||||
this.setImageDescriptor(IndexerViewPluginImages.DESC_FULL_NAME_DISPLAYED);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
displayFullNameAction.setText(SWITCH_FULL_NAMES);
|
||||
displayFullNameAction.setToolTipText(SWITCH_FULL_NAMES);
|
||||
displayFullNameAction.setImageDescriptor(IndexerViewPluginImages.DESC_FULL_NAME_DISPLAYED);
|
||||
|
||||
displayStatsAction = new Action() {
|
||||
public void run() {
|
||||
CTestPlugin.getStandardDisplay().asyncExec(new Runnable() {
|
||||
|
@ -454,7 +518,7 @@ public class IndexerView extends ViewPart {
|
|||
|
||||
singleClickAction = new IndexerHighlighterAction();
|
||||
}
|
||||
|
||||
|
||||
private void hookContextMenu() {
|
||||
MenuManager menuMgr = new MenuManager(_INDEXER_MENU_MANAGER);
|
||||
menuMgr.setRemoveAllWhenShown(true);
|
||||
|
@ -473,6 +537,8 @@ public class IndexerView extends ViewPart {
|
|||
}
|
||||
|
||||
void fillContextMenu(IMenuManager manager) {
|
||||
manager.add(searchLocationAction);
|
||||
manager.add(new Separator());
|
||||
// Other plug-ins can contribute there actions here
|
||||
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
||||
}
|
||||
|
@ -502,13 +568,14 @@ public class IndexerView extends ViewPart {
|
|||
fillLocalToolBar(bars.getToolBarManager());
|
||||
}
|
||||
|
||||
private void fillLocalPullDown(IMenuManager manager) {
|
||||
}
|
||||
private void fillLocalPullDown(IMenuManager manager) {}
|
||||
|
||||
private void fillLocalToolBar(IToolBarManager manager) {
|
||||
manager.add(previousPageAction);
|
||||
manager.add(nextPageAction);
|
||||
manager.add(new Separator());
|
||||
manager.add(sortAction);
|
||||
manager.add(displayFullNameAction);
|
||||
manager.add(setFiltersAction);
|
||||
manager.add(new Separator());
|
||||
manager.add(displayStatsAction);
|
||||
|
@ -523,11 +590,14 @@ public class IndexerView extends ViewPart {
|
|||
}
|
||||
|
||||
public void appendIndexer(IIndexer indexer) {
|
||||
indexers = (IIndexer[])ArrayUtil.append(IIndexer.class, indexers, indexer);
|
||||
// indexers = (IIndexer[])ArrayUtil.append(IIndexer.class, indexers, indexer);
|
||||
// only support 1 indexer for now
|
||||
indexers[0] = indexer;
|
||||
}
|
||||
|
||||
public void clearIndexers() {
|
||||
indexers = new IIndexer[CTestPlugin.getWorkspace().getRoot().getProjects().length];
|
||||
// for now only support 1 indexer at a time
|
||||
indexers = new IIndexer[1];
|
||||
}
|
||||
|
||||
public void setContentProvider(ViewContentProvider provider) {
|
||||
|
@ -548,4 +618,22 @@ public class IndexerView extends ViewPart {
|
|||
|
||||
return project.getName();
|
||||
}
|
||||
|
||||
private class SearchLocationsAction extends Action {
|
||||
private static final String LOCATIONS = "Locations"; //$NON-NLS-1$
|
||||
private static final String INDEX = "Index"; //$NON-NLS-1$
|
||||
protected void displayLocations(IndexerNodeLeaf leaf, String queryLabel, String pattern) {
|
||||
IndexerQuery job = new IndexerQuery(leaf, queryLabel, pattern);
|
||||
NewSearchUI.activateSearchResultView();
|
||||
NewSearchUI.runQuery(job);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (viewer.getSelection() instanceof IStructuredSelection &&
|
||||
((IStructuredSelection)viewer.getSelection()).getFirstElement() instanceof IndexerNodeLeaf) {
|
||||
displayLocations((IndexerNodeLeaf)((IStructuredSelection)viewer.getSelection()).getFirstElement(),
|
||||
INDEX, LOCATIONS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,11 @@ public class IndexerViewPluginImages {
|
|||
public static final String IMG_GROUPED_DECL= NAME_PREFIX + "grouped_decl.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_GROUPED_REF= NAME_PREFIX + "grouped_ref.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_GROUPED_TYPE= NAME_PREFIX + "grouped_type.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_SEARCH_LOCATION= NAME_PREFIX + "search_decl_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_SORT= NAME_PREFIX + "alphab_sort.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_SORTED= NAME_PREFIX + "alphab_sorted.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_FULL_NAME_DISPLAYED= NAME_PREFIX + "full_name_displayed.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_DISPLAY_FULL_NAME= NAME_PREFIX + "display_full_name.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);
|
||||
|
@ -129,6 +134,11 @@ public class IndexerViewPluginImages {
|
|||
public static final ImageDescriptor DESC_GROUPED_DECL= createManaged(ICON_PREFIX, IMG_GROUPED_DECL);
|
||||
public static final ImageDescriptor DESC_GROUPED_REF= createManaged(ICON_PREFIX, IMG_GROUPED_REF);
|
||||
public static final ImageDescriptor DESC_GROUPED_TYPE= createManaged(ICON_PREFIX, IMG_GROUPED_TYPE);
|
||||
public static final ImageDescriptor DESC_SEARCH_LOCATION= createManaged(ICON_PREFIX, IMG_SEARCH_LOCATION);
|
||||
public static final ImageDescriptor DESC_SORT= createManaged(ICON_PREFIX, IMG_SORT);
|
||||
public static final ImageDescriptor DESC_SORTED= createManaged(ICON_PREFIX, IMG_SORTED);
|
||||
public static final ImageDescriptor DESC_FULL_NAME_DISPLAYED= createManaged(ICON_PREFIX, IMG_FULL_NAME_DISPLAYED);
|
||||
public static final ImageDescriptor DESC_DISPLAY_FULL_NAME= createManaged(ICON_PREFIX, IMG_DISPLAY_FULL_NAME);
|
||||
|
||||
private static ImageDescriptor createManaged(String prefix, String name) {
|
||||
return createManaged(imageRegistry, prefix, name);
|
||||
|
|