Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java449
1 files changed, 215 insertions, 234 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
index 5b6b83948d2..778dc0db1cc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchPage.java
@@ -77,7 +77,7 @@ import org.eclipse.cdt.internal.ui.util.RowLayouter;
*/
public class CSearchPage extends DialogPage implements ISearchPage {
public static final String EXTENSION_ID = CUIPlugin.PLUGIN_ID + ".pdomSearchPage"; //$NON-NLS-1$
-
+
//Dialog store id constants
private final static String PAGE_NAME = "PDOMSearchPage"; //$NON-NLS-1$
private final static String STORE_CASE_SENSITIVE = "caseSensitive"; //$NON-NLS-1$
@@ -85,183 +85,159 @@ public class CSearchPage extends DialogPage implements ISearchPage {
private final static String STORE_SEARCH_FLAGS = "searchFlags"; //$NON-NLS-1$
/** Preference key for external marker enablement */
- public final static String EXTERNALMATCH_ENABLED = "externMatchEnable"; //$NON-NLS-1$
- /** Preference key for external marker visibilty */
- public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
-
- private static final String[] searchForText= {
- CSearchMessages.CSearchPage_searchFor_classStruct,
- CSearchMessages.CSearchPage_searchFor_function,
- CSearchMessages.CSearchPage_searchFor_variable,
- CSearchMessages.CSearchPage_searchFor_union,
- CSearchMessages.CSearchPage_searchFor_method,
- CSearchMessages.CSearchPage_searchFor_field,
- CSearchMessages.CSearchPage_searchFor_enum,
- CSearchMessages.CSearchPage_searchFor_enumr,
- CSearchMessages.CSearchPage_searchFor_namespace,
- CSearchMessages.CSearchPage_searchFor_typedef,
- CSearchMessages.CSearchPage_searchFor_macro,
- CSearchMessages.CSearchPage_searchFor_any
- };
+ public final static String EXTERNALMATCH_ENABLED = "externMatchEnable"; //$NON-NLS-1$
+ /** Preference key for external marker visibilty */
+ public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
+
+ private static final String[] searchForText = { CSearchMessages.CSearchPage_searchFor_classStruct,
+ CSearchMessages.CSearchPage_searchFor_function, CSearchMessages.CSearchPage_searchFor_variable,
+ CSearchMessages.CSearchPage_searchFor_union, CSearchMessages.CSearchPage_searchFor_method,
+ CSearchMessages.CSearchPage_searchFor_field, CSearchMessages.CSearchPage_searchFor_enum,
+ CSearchMessages.CSearchPage_searchFor_enumr, CSearchMessages.CSearchPage_searchFor_namespace,
+ CSearchMessages.CSearchPage_searchFor_typedef, CSearchMessages.CSearchPage_searchFor_macro,
+ CSearchMessages.CSearchPage_searchFor_any };
// These must be in the same order as the Text
- private static final Integer[] searchForData = {
- CSearchPatternQuery.FIND_CLASS_STRUCT,
- CSearchPatternQuery.FIND_FUNCTION,
- CSearchPatternQuery.FIND_VARIABLE,
- CSearchPatternQuery.FIND_UNION,
- CSearchPatternQuery.FIND_METHOD,
- CSearchPatternQuery.FIND_FIELD,
- CSearchPatternQuery.FIND_ENUM,
- CSearchPatternQuery.FIND_ENUMERATOR,
- CSearchPatternQuery.FIND_NAMESPACE,
- CSearchPatternQuery.FIND_TYPEDEF,
- CSearchPatternQuery.FIND_MACRO,
- CSearchPatternQuery.FIND_ALL_TYPES
- };
-
+ private static final Integer[] searchForData = { CSearchPatternQuery.FIND_CLASS_STRUCT,
+ CSearchPatternQuery.FIND_FUNCTION, CSearchPatternQuery.FIND_VARIABLE, CSearchPatternQuery.FIND_UNION,
+ CSearchPatternQuery.FIND_METHOD, CSearchPatternQuery.FIND_FIELD, CSearchPatternQuery.FIND_ENUM,
+ CSearchPatternQuery.FIND_ENUMERATOR, CSearchPatternQuery.FIND_NAMESPACE, CSearchPatternQuery.FIND_TYPEDEF,
+ CSearchPatternQuery.FIND_MACRO, CSearchPatternQuery.FIND_ALL_TYPES };
+
// the index of FIND_ALL_TYPES
private static final int searchAllButtonIndex = searchForData.length - 1;
- private static String[] limitToText = {
- CSearchMessages.CSearchPage_limitTo_declarations,
- CSearchMessages.CSearchPage_limitTo_definitions,
- CSearchMessages.CSearchPage_limitTo_references,
- CSearchMessages.CSearchPage_limitTo_allOccurrences
- };
+ private static String[] limitToText = { CSearchMessages.CSearchPage_limitTo_declarations,
+ CSearchMessages.CSearchPage_limitTo_definitions, CSearchMessages.CSearchPage_limitTo_references,
+ CSearchMessages.CSearchPage_limitTo_allOccurrences };
// Must be in the same order as the text
- private static Integer[] limitToData = {
- CSearchQuery.FIND_DECLARATIONS,
- CSearchQuery.FIND_DEFINITIONS,
- CSearchQuery.FIND_REFERENCES,
- CSearchQuery.FIND_ALL_OCCURRENCES,
- };
-
+ private static Integer[] limitToData = { CSearchQuery.FIND_DECLARATIONS, CSearchQuery.FIND_DEFINITIONS,
+ CSearchQuery.FIND_REFERENCES, CSearchQuery.FIND_ALL_OCCURRENCES, };
+
// The index of FIND_ALL_OCCURANCES
private static final int limitToAllButtonIndex = limitToData.length - 1;
-
+
private Combo patternCombo;
private String[] previousPatterns;
private Button caseSensitiveButton;
-
+
private Button[] searchForButtons;
private Button[] limitToButtons;
-
+
private boolean firstTime = true;
private IStructuredSelection structuredSelection;
private ITextSelection textSelection;
private ISearchPageContainer pageContainer;
-
+
private IStatusLineManager fLineManager;
private static ICProject getProject(String name) {
return CoreModel.getDefault().create(ResourcesPlugin.getWorkspace().getRoot().getProject(name));
}
-
+
private ICElement getElement(Object obj) {
if (obj instanceof IResource) {
return CoreModel.getDefault().create((IResource) obj);
- }
+ }
if (obj instanceof ICElement) {
- ICElement elem= (ICElement) obj;
+ ICElement elem = (ICElement) obj;
if (elem instanceof ISourceReference)
return ((ISourceReference) elem).getTranslationUnit();
if (elem instanceof ITranslationUnit || elem instanceof ICContainer || elem instanceof ICProject)
return elem;
-
+
return elem.getCProject();
}
return null;
}
-
@Override
public boolean performAction() {
- fLineManager.setErrorMessage(null);
-
- boolean isCaseSensitive = caseSensitiveButton.getSelection();
-
- // get the pattern and turn it into a regular expression
- String patternStr = patternCombo.getText();
-
- // Get search flags
- int searchFlags = 0;
- if (searchForButtons[searchAllButtonIndex].getSelection()) {
- searchFlags |= CSearchPatternQuery.FIND_ALL_TYPES;
- } else {
- for (int i = 0; i < searchForButtons.length; ++i) {
- if (searchForButtons[i].getSelection())
- searchFlags |= ((Integer) searchForButtons[i].getData()).intValue();
- }
- }
- for (int i = 0; i < limitToButtons.length; ++i) {
- if (limitToButtons[i].getSelection())
- searchFlags |= ((Integer) limitToButtons[i].getData()).intValue();
- }
-
+ fLineManager.setErrorMessage(null);
+
+ boolean isCaseSensitive = caseSensitiveButton.getSelection();
+
+ // get the pattern and turn it into a regular expression
+ String patternStr = patternCombo.getText();
+
+ // Get search flags
+ int searchFlags = 0;
+ if (searchForButtons[searchAllButtonIndex].getSelection()) {
+ searchFlags |= CSearchPatternQuery.FIND_ALL_TYPES;
+ } else {
+ for (int i = 0; i < searchForButtons.length; ++i) {
+ if (searchForButtons[i].getSelection())
+ searchFlags |= ((Integer) searchForButtons[i].getData()).intValue();
+ }
+ }
+ for (int i = 0; i < limitToButtons.length; ++i) {
+ if (limitToButtons[i].getSelection())
+ searchFlags |= ((Integer) limitToButtons[i].getData()).intValue();
+ }
+
// get the list of elements for the scope
Set<ICElement> elements = new HashSet<ICElement>();
String scopeDescription = ""; //$NON-NLS-1$
switch (getContainer().getSelectedScope()) {
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
final String[] prjNames = getContainer().getSelectedProjectNames();
- scopeDescription= CSearchMessages.ProjectScope;
- int ip= 0;
- for (String prjName: prjNames) {
+ scopeDescription = CSearchMessages.ProjectScope;
+ int ip = 0;
+ for (String prjName : prjNames) {
ICProject project = getProject(prjName);
if (project != null) {
elements.add(project);
- switch(ip++) {
- case 0:
- scopeDescription+= " '" + prjName + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ switch (ip++) {
+ case 0:
+ scopeDescription += " '" + prjName + "'"; //$NON-NLS-1$//$NON-NLS-2$
break;
case 1:
- scopeDescription= scopeDescription + ", '" + prjName + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+ scopeDescription = scopeDescription + ", '" + prjName + "'"; //$NON-NLS-1$ //$NON-NLS-2$
break;
case 2:
- scopeDescription+= ", ..."; //$NON-NLS-1$
+ scopeDescription += ", ..."; //$NON-NLS-1$
break;
default:
break;
- }
+ }
}
}
break;
case ISearchPageContainer.SELECTION_SCOPE:
if (structuredSelection != null) {
- scopeDescription = CSearchMessages.SelectionScope;
- int ie= 0;
+ scopeDescription = CSearchMessages.SelectionScope;
+ int ie = 0;
for (Object sel : structuredSelection.toList()) {
- ICElement elem= getElement(sel);
+ ICElement elem = getElement(sel);
if (elem != null) {
elements.add(elem);
- switch(ie++) {
- case 0:
- scopeDescription= " '" + elem.toString() + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ switch (ie++) {
+ case 0:
+ scopeDescription = " '" + elem.toString() + "'"; //$NON-NLS-1$//$NON-NLS-2$
break;
case 1:
- scopeDescription= scopeDescription + ", '" + elem.toString() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
+ scopeDescription = scopeDescription + ", '" + elem.toString() + "'"; //$NON-NLS-1$ //$NON-NLS-2$
break;
case 2:
- scopeDescription+= ", ..."; //$NON-NLS-1$
+ scopeDescription += ", ..."; //$NON-NLS-1$
break;
default:
break;
- }
+ }
}
}
break;
}
break;
case ISearchPageContainer.WORKSPACE_SCOPE:
- scopeDescription = CSearchMessages.WorkspaceScope;
+ scopeDescription = CSearchMessages.WorkspaceScope;
// Don't add anything
break;
case ISearchPageContainer.WORKING_SET_SCOPE:
- IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
- scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(workingSets));
+ IWorkingSet[] workingSets = getContainer().getSelectedWorkingSets();
+ scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(workingSets));
for (int i = 0; i < workingSets.length; ++i) {
IAdaptable[] wsElements = workingSets[i].getElements();
for (int j = 0; j < wsElements.length; ++j) {
@@ -272,26 +248,25 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
break;
}
-
- ICElement[] scope = elements.isEmpty() ?
- null : elements.toArray(new ICElement[elements.size()]);
-
+
+ ICElement[] scope = elements.isEmpty() ? null : elements.toArray(new ICElement[elements.size()]);
+
try {
- CSearchPatternQuery job = new CSearchPatternQuery(scope, scopeDescription, patternStr,
- isCaseSensitive, searchFlags);
+ CSearchPatternQuery job = new CSearchPatternQuery(scope, scopeDescription, patternStr, isCaseSensitive,
+ searchFlags);
NewSearchUI.activateSearchResultView();
-
+
NewSearchUI.runQueryInBackground(job);
} catch (PatternSyntaxException e) {
- fLineManager.setErrorMessage(CSearchMessages.PDOMSearch_query_pattern_error);
+ fLineManager.setErrorMessage(CSearchMessages.PDOMSearch_query_pattern_error);
return false;
}
-
+
// Save our settings
IDialogSettings settings = getDialogSettings();
settings.put(STORE_CASE_SENSITIVE, isCaseSensitive);
-
+
if (previousPatterns == null) {
previousPatterns = new String[] { patternStr };
} else {
@@ -313,7 +288,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
settings.put(STORE_PREVIOUS_PATTERNS, previousPatterns);
-
+
settings.put(STORE_SEARCH_FLAGS, searchFlags);
return true;
@@ -322,104 +297,99 @@ public class CSearchPage extends DialogPage implements ISearchPage {
@Override
public void createControl(Composite parent) {
initializeDialogUnits(parent);
-
+
GridData gd;
- Composite result = new Composite(parent, SWT.NONE);
+ Composite result = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
layout.horizontalSpacing = 10;
result.setLayout(layout);
result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
+
RowLayouter layouter = new RowLayouter(layout.numColumns);
gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
- gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
-
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL;
+
layouter.setDefaultGridData(gd, 0);
layouter.setDefaultGridData(gd, 1);
layouter.setDefaultSpan();
layouter.perform(createExpression(result));
layouter.perform(createSearchFor(result), createLimitTo(result), -1);
-
+
createNote(result);
-
+
setControl(result);
-
+
fLineManager = getStatusLineManager();
-
+
Dialog.applyDialogFont(result);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(result, ICHelpContextIds.C_SEARCH_PAGE);
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(result, ICHelpContextIds.C_SEARCH_PAGE);
}
private void createNote(Composite result) {
// Create a note that tells the user that this search only processes the active code (not grayed out in editor)
GridData gd;
- String noteTitle= CSearchMessages.CSearchPage_label_note;
- String noteMessage= CSearchMessages.CSearchPage_label_activeCodeRemark;
- Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
+ String noteTitle = CSearchMessages.CSearchPage_label_note;
+ String noteMessage = CSearchMessages.CSearchPage_label_activeCodeRemark;
+ Composite noteControl = createNoteComposite(JFaceResources.getDialogFont(), result, noteTitle, noteMessage);
+ gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ gd.horizontalSpan = 2;
noteControl.setLayoutData(gd);
}
- /**
- * Creates a composite with a highlighted Note entry and a message text.
- * This is designed to take up the full width of the page.<br>
- * This method has been copied from class {@link PreferencePage}
- *
- * @param font the font to use
- * @param composite the parent composite
- * @param title the title of the note
- * @param message the message for the note
- * @return the composite for the note
- */
- protected Composite createNoteComposite(Font font, Composite composite,
- String title, String message) {
- Composite messageComposite = new Composite(composite, SWT.NONE);
- GridLayout messageLayout = new GridLayout();
- messageLayout.numColumns = 2;
- messageLayout.marginWidth = 0;
- messageLayout.marginHeight = 0;
- messageComposite.setLayout(messageLayout);
- messageComposite.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_FILL));
- messageComposite.setFont(font);
-
- final Label noteLabel = new Label(messageComposite, SWT.BOLD);
- noteLabel.setText(title);
- noteLabel.setFont(JFaceResources.getFontRegistry().getBold(
- JFaceResources.DIALOG_FONT));
- noteLabel
- .setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
- Label messageLabel = new Label(messageComposite, SWT.WRAP);
- messageLabel.setText(message);
- messageLabel.setFont(font);
- return messageComposite;
- }
-
-
- private IStatusLineManager getStatusLineManager(){
-
- IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ /**
+ * Creates a composite with a highlighted Note entry and a message text.
+ * This is designed to take up the full width of the page.<br>
+ * This method has been copied from class {@link PreferencePage}
+ *
+ * @param font the font to use
+ * @param composite the parent composite
+ * @param title the title of the note
+ * @param message the message for the note
+ * @return the composite for the note
+ */
+ protected Composite createNoteComposite(Font font, Composite composite, String title, String message) {
+ Composite messageComposite = new Composite(composite, SWT.NONE);
+ GridLayout messageLayout = new GridLayout();
+ messageLayout.numColumns = 2;
+ messageLayout.marginWidth = 0;
+ messageLayout.marginHeight = 0;
+ messageComposite.setLayout(messageLayout);
+ messageComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
+ messageComposite.setFont(font);
+
+ final Label noteLabel = new Label(messageComposite, SWT.BOLD);
+ noteLabel.setText(title);
+ noteLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
+ noteLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
+
+ Label messageLabel = new Label(messageComposite, SWT.WRAP);
+ messageLabel.setText(message);
+ messageLabel.setFont(font);
+ return messageComposite;
+ }
+
+ private IStatusLineManager getStatusLineManager() {
+
+ IWorkbenchWindow wbWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (wbWindow != null) {
- IWorkbenchPage page= wbWindow.getActivePage();
+ IWorkbenchPage page = wbWindow.getActivePage();
if (page != null) {
- IWorkbenchPartSite workbenchSite = page.getActivePart().getSite();
- if (workbenchSite instanceof IViewSite){
- return ((IViewSite) workbenchSite).getActionBars().getStatusLineManager();
- } else if (workbenchSite instanceof IEditorSite){
- return ((IEditorSite) workbenchSite).getActionBars().getStatusLineManager();
- }
+ IWorkbenchPartSite workbenchSite = page.getActivePart().getSite();
+ if (workbenchSite instanceof IViewSite) {
+ return ((IViewSite) workbenchSite).getActionBars().getStatusLineManager();
+ } else if (workbenchSite instanceof IEditorSite) {
+ return ((IEditorSite) workbenchSite).getActionBars().getStatusLineManager();
+ }
}
}
-
+
return null;
}
private Control createExpression(Composite parent) {
- Composite result = new Composite(parent, SWT.NONE);
+ Composite result = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout(2, false);
result.setLayout(layout);
GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
@@ -429,7 +399,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
// Pattern text + info
Label label = new Label(result, SWT.LEFT);
- label.setText(CSearchMessages.CSearchPage_expression_label);
+ label.setText(CSearchMessages.CSearchPage_expression_label);
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 2;
label.setLayoutData(gd);
@@ -440,29 +410,40 @@ public class CSearchPage extends DialogPage implements ISearchPage {
@Override
public void verifyText(VerifyEvent event) {
final String text = patternCombo.getText();
- final char[] newChars= event.text.toCharArray();
- final StringBuilder result= new StringBuilder(newChars.length);
- boolean relax= prefix(text, event.start, result).contains(Keywords.OPERATOR);
+ final char[] newChars = event.text.toCharArray();
+ final StringBuilder result = new StringBuilder(newChars.length);
+ boolean relax = prefix(text, event.start, result).contains(Keywords.OPERATOR);
for (final char c : newChars) {
switch (c) {
- case '_':
+ case '_':
case ':': // scope operator
- case '?': case '*': // wild cards
+ case '?':
+ case '*': // wild cards
case '\\': // escaping wild-cards
result.append(c);
break;
case ' ':
if (prefix(text, event.start, result).endsWith(Keywords.OPERATOR)) {
- relax= true;
+ relax = true;
result.append(c);
}
break;
- case '&': case '|': case '+': case '-':
- case '!': case '=': case '>': case '<':
- case '%': case '^': case '(': case ')':
- case '[': case ']':
+ case '&':
+ case '|':
+ case '+':
+ case '-':
+ case '!':
+ case '=':
+ case '>':
+ case '<':
+ case '%':
+ case '^':
+ case '(':
+ case ')':
+ case '[':
+ case ']':
if (prefix(text, event.start, result).endsWith(Keywords.OPERATOR)) {
- relax= true;
+ relax = true;
}
if (relax)
result.append(c);
@@ -474,49 +455,48 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
break;
}
- event.text= result.toString();
+ event.text = result.toString();
}
}
private String prefix(String text, int len, StringBuilder rest) {
- StringBuilder result= new StringBuilder(len + rest.length());
+ StringBuilder result = new StringBuilder(len + rest.length());
result.append(text, 0, len);
result.append(rest);
return result.toString();
}
});
-
+
patternCombo.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
setPerformActionEnabled();
}
});
-
+
gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalIndent = -gd.horizontalIndent;
patternCombo.setLayoutData(gd);
-
- // Ignore case checkbox
- caseSensitiveButton= new Button(result, SWT.CHECK);
- caseSensitiveButton.setText(CSearchMessages.CSearchPage_expression_caseSensitive);
- gd= new GridData();
+ // Ignore case checkbox
+ caseSensitiveButton = new Button(result, SWT.CHECK);
+ caseSensitiveButton.setText(CSearchMessages.CSearchPage_expression_caseSensitive);
+ gd = new GridData();
caseSensitiveButton.setLayoutData(gd);
caseSensitiveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
-// isCaseSensitive = caseSensitiveButton.getSelection();
+ // isCaseSensitive = caseSensitiveButton.getSelection();
setPerformActionEnabled();
}
});
-
+
return result;
}
private Control createLimitTo(Composite parent) {
Group result = new Group(parent, SWT.NONE);
- result.setText(CSearchMessages.CSearchPage_limitTo_label);
+ result.setText(CSearchMessages.CSearchPage_limitTo_label);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
result.setLayout(layout);
@@ -524,7 +504,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
Listener limitToListener = new Listener() {
@Override
public void handleEvent(Event event) {
- Button me = (Button)event.widget;
+ Button me = (Button) event.widget;
if (me == limitToButtons[limitToAllButtonIndex]) {
if (me.getSelection()) {
for (int i = 0; i < limitToButtons.length; ++i) {
@@ -545,9 +525,9 @@ public class CSearchPage extends DialogPage implements ISearchPage {
setPerformActionEnabled();
}
};
-
+
limitToButtons = new Button[limitToText.length];
- for(int i = 0; i < limitToText.length; i++){
+ for (int i = 0; i < limitToText.length; i++) {
Button button = new Button(result, SWT.CHECK);
button.setText(limitToText[i]);
button.setData(limitToData[i]);
@@ -555,20 +535,20 @@ public class CSearchPage extends DialogPage implements ISearchPage {
limitToButtons[i] = button;
}
- return result;
+ return result;
}
-
+
private Control createSearchFor(Composite parent) {
- Group result= new Group(parent, SWT.NONE);
- result.setText(CSearchMessages.CSearchPage_searchFor_label);
- GridLayout layout= new GridLayout();
- layout.numColumns= 3;
+ Group result = new Group(parent, SWT.NONE);
+ result.setText(CSearchMessages.CSearchPage_searchFor_label);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
result.setLayout(layout);
-
+
SelectionAdapter searchForSelectionAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- Button me = (Button)event.widget;
+ Button me = (Button) event.widget;
if (me == searchForButtons[searchAllButtonIndex]) {
if (me.getSelection()) {
for (int i = 0; i < searchForButtons.length; ++i) {
@@ -590,34 +570,34 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
};
- searchForButtons= new Button[searchForText.length];
- for (int i= 0; i < searchForText.length; i++) {
- Button button= new Button(result, SWT.CHECK);
+ searchForButtons = new Button[searchForText.length];
+ for (int i = 0; i < searchForText.length; i++) {
+ Button button = new Button(result, SWT.CHECK);
button.setText(searchForText[i]);
button.setData(searchForData[i]);
button.addSelectionListener(searchForSelectionAdapter);
- searchForButtons[i]= button;
+ searchForButtons[i] = button;
}
- return result;
+ return result;
}
-
+
@Override
public void setContainer(ISearchPageContainer container) {
pageContainer = container;
}
-
+
private ISearchPageContainer getContainer() {
return pageContainer;
}
-
+
private void setPerformActionEnabled() {
// Need a text string to search
if (this.patternCombo.getText().length() == 0) {
getContainer().setPerformActionEnabled(false);
return;
}
-
+
// Need a type
boolean any = false;
for (int i = 0; i < this.searchForButtons.length; ++i) {
@@ -630,7 +610,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
getContainer().setPerformActionEnabled(false);
return;
}
-
+
// Set limit to
any = false;
@@ -646,7 +626,7 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
getContainer().setPerformActionEnabled(true);
}
-
+
private IDialogSettings getDialogSettings() {
IDialogSettings settings = CUIPlugin.getDefault().getDialogSettings();
IDialogSettings searchSettings = settings.getSection(PAGE_NAME);
@@ -659,10 +639,10 @@ public class CSearchPage extends DialogPage implements ISearchPage {
public void setVisible(boolean visible) {
if (visible) {
if (firstTime) {
- firstTime= false;
-
+ firstTime = false;
+
IDialogSettings settings = getDialogSettings();
-
+
int searchFlags = CSearchPatternQuery.FIND_ALL_TYPES | CSearchQuery.FIND_ALL_OCCURRENCES;
try {
searchFlags = settings.getInt(STORE_SEARCH_FLAGS);
@@ -673,16 +653,16 @@ public class CSearchPage extends DialogPage implements ISearchPage {
previousPatterns = settings.getArray(STORE_PREVIOUS_PATTERNS);
if (previousPatterns != null)
patternCombo.setItems(previousPatterns);
-
+
patternCombo.setVisibleItemCount(15);
// Initialize the selection
ISelection selection = getContainer().getSelection();
if (selection instanceof IStructuredSelection) {
- structuredSelection = (IStructuredSelection)selection;
+ structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
if (obj instanceof ICElement) {
- ICElement element = (ICElement)obj;
+ ICElement element = (ICElement) obj;
patternCombo.setText(element.getElementName());
// Clear the type flags so we can set them correctly for what we have selected
searchFlags = searchFlags & ~CSearchPatternQuery.FIND_ALL_TYPES;
@@ -728,17 +708,18 @@ public class CSearchPage extends DialogPage implements ISearchPage {
}
}
} else if (selection instanceof ITextSelection) {
- textSelection = (ITextSelection)selection;
+ textSelection = (ITextSelection) selection;
patternCombo.setText(textSelection.getText());
// TODO it might be good to do a selection parse to ensure that
// the selection is valid.
}
- if (patternCombo.getText().trim().length() == 0 && previousPatterns != null && previousPatterns.length > 0) {
+ if (patternCombo.getText().trim().length() == 0 && previousPatterns != null
+ && previousPatterns.length > 0) {
patternCombo.setText(previousPatterns[0]);
}
caseSensitiveButton.setSelection(settings.getBoolean(STORE_CASE_SENSITIVE));
-
+
if ((searchFlags & CSearchPatternQuery.FIND_ALL_TYPES) == CSearchPatternQuery.FIND_ALL_TYPES) {
searchForButtons[searchAllButtonIndex].setSelection(true);
for (int i = 0; i < searchForButtons.length; ++i) {
@@ -752,11 +733,11 @@ public class CSearchPage extends DialogPage implements ISearchPage {
for (int i = 0; i < searchForButtons.length; ++i) {
if (i != searchAllButtonIndex) {
searchForButtons[i].setSelection(
- (searchFlags & ((Integer)searchForButtons[i].getData()).intValue()) != 0);
+ (searchFlags & ((Integer) searchForButtons[i].getData()).intValue()) != 0);
}
}
}
-
+
if ((searchFlags & CSearchQuery.FIND_ALL_OCCURRENCES) == CSearchQuery.FIND_ALL_OCCURRENCES) {
limitToButtons[limitToAllButtonIndex].setSelection(true);
for (int i = 0; i < limitToButtons.length; ++i) {
@@ -768,12 +749,12 @@ public class CSearchPage extends DialogPage implements ISearchPage {
} else {
limitToButtons[limitToAllButtonIndex].setSelection(false);
for (int i = 0; i < limitToButtons.length - 1; ++i) {
- limitToButtons[i].setSelection(
- (searchFlags & ((Integer)limitToButtons[i].getData()).intValue()) != 0);
+ limitToButtons[i]
+ .setSelection((searchFlags & ((Integer) limitToButtons[i].getData()).intValue()) != 0);
}
}
}
-
+
patternCombo.setFocus();
setPerformActionEnabled();
}

Back to the top