|
From: Markus B. <mba...@us...> - 2005-10-24 22:57:54
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7433/src/org/rubypeople/rdt/internal/ui/search Modified Files: RubySearchPage.java RubySearchQuery.java Log Message: updated search for Method Index: RubySearchQuery.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchQuery.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RubySearchQuery.java 24 Oct 2005 11:08:11 -0000 1.2 --- RubySearchQuery.java 24 Oct 2005 22:57:42 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- import org.rubypeople.rdt.internal.core.symbols.ISymbolTypes; import org.rubypeople.rdt.internal.core.symbols.SearchResult; + import org.rubypeople.rdt.internal.ui.RubyUIMessages; public class RubySearchQuery implements ISearchQuery, ISymbolTypes { *************** *** 33,40 **** private SearchScope fScope; private RubySearchResult fResult; ! public RubySearchQuery(SearchScope scope, String searchString) { fScope = scope; fSearchString = searchString; } --- 34,43 ---- private SearchScope fScope; private RubySearchResult fResult; + private int fSymbolType ; ! public RubySearchQuery(SearchScope scope, String searchString, int symbolType) { fScope = scope; fSearchString = searchString; + fSymbolType = symbolType ; } *************** *** 49,54 **** public String getLabel() { ! // TODO Auto-generated method stub ! return "RubySearchJob"; } --- 52,56 ---- public String getLabel() { ! return toString() ; } *************** *** 63,67 **** public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { ! Set entries = RubyCore.getPlugin().getSymbolIndex().find(fSearchString, CLASS_SYMBOL ); for (Iterator iter = entries.iterator(); iter.hasNext();) { --- 65,69 ---- public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { ! Set entries = RubyCore.getPlugin().getSymbolIndex().find(fSearchString, fSymbolType ); for (Iterator iter = entries.iterator(); iter.hasNext();) { *************** *** 71,80 **** fResult.addMatch(new Match(searchResult, Match.UNIT_CHARACTER, startOffset, length)); } ! MultiStatus status = new MultiStatus(NewSearchUI.PLUGIN_ID, IStatus.OK, "Alright", null); return status; } public String toString() { ! return "reg exp. query for " + fSearchString; } --- 73,94 ---- fResult.addMatch(new Match(searchResult, Match.UNIT_CHARACTER, startOffset, length)); } ! MultiStatus status = new MultiStatus(NewSearchUI.PLUGIN_ID, IStatus.OK, "Alright", null); //$NON-NLS-1$ return status; } public String toString() { ! String args[] = new String[2] ; ! switch (fSymbolType) { ! case METHOD_SYMBOL: ! args[0] = RubyUIMessages.getString("RubySearch.SearchForMethodSymbol") ; //$NON-NLS-1$ ! break; ! case CLASS_SYMBOL: ! args[0] = RubyUIMessages.getString("RubySearch.SearchForClassSymbol") ; //$NON-NLS-1$ ! break; ! default: ! break; ! } ! args[1] = fSearchString ; ! return RubyUIMessages.getFormattedString("RubySearch.ResultLabel", args) ; //$NON-NLS-1$ } Index: RubySearchPage.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RubySearchPage.java 23 Oct 2005 20:13:31 -0000 1.2 --- RubySearchPage.java 24 Oct 2005 22:57:42 -0000 1.3 *************** *** 42,53 **** import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.rubypeople.rdt.core.IRubyElement; ! public class RubySearchPage extends DialogPage implements ISearchPage { // Shouldn't SearchPatternData be a public class in org.eclipse.search ? --- 42,57 ---- import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; + import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; + import org.eclipse.swt.widgets.Listener; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.rubypeople.rdt.core.IRubyElement; + import org.rubypeople.rdt.internal.core.symbols.ISymbolTypes; + import org.rubypeople.rdt.internal.ui.RubyUIMessages; ! public class RubySearchPage extends DialogPage implements ISearchPage, ISymbolTypes { // Shouldn't SearchPatternData be a public class in org.eclipse.search ? *************** *** 58,70 **** private String pattern; private boolean isCaseSensitive; ! private IRubyElement rubyElement; private int scope; private IWorkingSet[] workingSets; ! public SearchPatternData(int searchFor, int limitTo, boolean isCaseSensitive, String pattern, IRubyElement element) { ! this(searchFor, limitTo, pattern, isCaseSensitive, element, ISearchPageContainer.WORKSPACE_SCOPE, null); } ! public SearchPatternData(int searchFor, int limitTo, String pattern, boolean isCaseSensitive, IRubyElement element, int scope, IWorkingSet[] workingSets) { this.searchFor = searchFor; this.limitTo = limitTo; --- 62,74 ---- private String pattern; private boolean isCaseSensitive; ! private int scope; private IWorkingSet[] workingSets; ! public SearchPatternData(int searchFor, int limitTo, boolean isCaseSensitive, String pattern) { ! this(searchFor, limitTo, pattern, isCaseSensitive, ISearchPageContainer.WORKSPACE_SCOPE, null); } ! public SearchPatternData(int searchFor, int limitTo, String pattern, boolean isCaseSensitive, int scope, IWorkingSet[] workingSets) { this.searchFor = searchFor; this.limitTo = limitTo; *************** *** 74,82 **** this.workingSets = workingSets; - setRubyElement(element); - } - - public void setRubyElement(IRubyElement element) { - this.rubyElement = element; } --- 78,81 ---- *************** *** 85,92 **** } - public IRubyElement getRubyElement() { - return rubyElement; - } - public int getLimitTo() { return limitTo; --- 84,87 ---- *************** *** 158,162 **** // TODO IRubyElement elem = null; // settings.get("rubyElement") ; ! return new SearchPatternData(searchFor, limitTo, pattern, isCaseSensitive, elem, scope, workingSets); } catch (NumberFormatException e) { return null; --- 153,157 ---- // TODO IRubyElement elem = null; // settings.get("rubyElement") ; ! return new SearchPatternData(searchFor, limitTo, pattern, isCaseSensitive, scope, workingSets); } catch (NumberFormatException e) { return null; *************** *** 177,181 **** private SearchPatternData fInitialData; - private IRubyElement fRubyElement; private boolean fFirstTime = true; private IDialogSettings fDialogSettings; --- 172,175 ---- *************** *** 186,201 **** private Button fCaseSensitive; - private Button[] fSearchFor; - // TODO: externalize strings - private String[] fSearchForText = { "class", "method" - /* - * SearchMessages.SearchPage_searchFor_type, - * SearchMessages.SearchPage_searchFor_method, - * SearchMessages.SearchPage_searchFor_module, - * SearchMessages.SearchPage_searchFor_field - */}; - private Button[] fLimitTo; ! private String[] fLimitToText = { "declarations" /* * SearchMessages.SearchPage_limitTo_declarations, --- 180,185 ---- private Button fCaseSensitive; private Button[] fLimitTo; ! private String[] fLimitToText = { "declarations" //$NON-NLS-1$ /* * SearchMessages.SearchPage_limitTo_declarations, *************** *** 208,211 **** --- 192,196 ---- private static final int INDEX_REFERENCES = 2; private static final int INDEX_ALL = 3; + private SearchForManager searchForManager = new SearchForManager(); /** *************** *** 246,256 **** NewSearchUI.activateSearchResultView(); ! return new RubySearchQuery(scope, patternData.getPattern()); } private int getLimitTo() { ! //for (int i = 0; i < fLimitTo.length; i++) { ! // if (fLimitTo[i].getSelection()) return i; ! //} return -1; } --- 231,241 ---- NewSearchUI.activateSearchResultView(); ! return new RubySearchQuery(scope, patternData.getPattern(), patternData.getSearchFor()); } private int getLimitTo() { ! // for (int i = 0; i < fLimitTo.length; i++) { ! // if (fLimitTo[i].getSelection()) return i; ! // } return -1; } *************** *** 285,296 **** } - private int getSearchFor() { - for (int i = 0; i < fSearchFor.length; i++) { - if (fSearchFor[i].getSelection()) return i; - } - Assert.isTrue(false, "shouldNeverHappen"); //$NON-NLS-1$ - return -1; - } - private String getPattern() { return fPattern.getText(); --- 270,273 ---- *************** *** 315,319 **** fPreviousSearchPatterns.remove(match); } ! match = new SearchPatternData(getSearchFor(), getLimitTo(), pattern, fCaseSensitive.getSelection(), fRubyElement, getContainer().getSelectedScope(), getContainer().getSelectedWorkingSets()); fPreviousSearchPatterns.add(0, match); // insert on top --- 292,296 ---- fPreviousSearchPatterns.remove(match); } ! match = new SearchPatternData(searchForManager.getSelectedSymbolType(), getLimitTo(), pattern, fCaseSensitive.getSelection(), getContainer().getSelectedScope(), getContainer().getSelectedWorkingSets()); fPreviousSearchPatterns.add(0, match); // insert on top *************** *** 366,370 **** separator.setLayoutData(data); ! Control searchFor = createSearchFor(result); searchFor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1)); --- 343,347 ---- separator.setLayoutData(data); ! Control searchFor = searchForManager.createSearchFor(result); searchFor.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 1, 1)); *************** *** 374,395 **** // createParticipants(result); - SelectionAdapter javaElementInitializer = new SelectionAdapter() { - - public void widgetSelected(SelectionEvent event) { - if (getSearchFor() == fInitialData.getSearchFor()) - fRubyElement = fInitialData.getRubyElement(); - else - fRubyElement = null; - setLimitTo(getSearchFor(), getLimitTo()); - doPatternModified(); - } - }; - - // fSearchFor[TYPE].addSelectionListener(javaElementInitializer); - // fSearchFor[METHOD].addSelectionListener(javaElementInitializer); - // fSearchFor[FIELD].addSelectionListener(javaElementInitializer); - // fSearchFor[CONSTRUCTOR].addSelectionListener(javaElementInitializer); - // fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer); - setControl(result); --- 351,354 ---- *************** *** 429,433 **** Label label = new Label(result, SWT.LEFT); // TODO ! label.setText("Expression"); // label.setText(SearchMessages.SearchPage_expression_label); label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1)); --- 388,392 ---- Label label = new Label(result, SWT.LEFT); // TODO ! label.setText("Expression"); //$NON-NLS-1$ // label.setText(SearchMessages.SearchPage_expression_label); label.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false, 2, 1)); *************** *** 457,461 **** fCaseSensitive = new Button(result, SWT.CHECK); // TODO ! fCaseSensitive.setText("CaseSensitive"); fCaseSensitive.addSelectionListener(new SelectionAdapter() { --- 416,420 ---- fCaseSensitive = new Button(result, SWT.CHECK); // TODO ! fCaseSensitive.setText("CaseSensitive"); //$NON-NLS-1$ fCaseSensitive.addSelectionListener(new SelectionAdapter() { *************** *** 471,475 **** private boolean isValidSearchPattern() { if (getPattern().length() == 0) { return false; } - if (fRubyElement != null) { return true; } // TODO return true; --- 430,433 ---- *************** *** 500,533 **** } - private void setSearchFor(int searchFor) { - for (int i = 0; i < fSearchFor.length; i++) { - fSearchFor[i].setSelection(searchFor == i); - } - } - - private Control createSearchFor(Composite parent) { - Group result = new Group(parent, SWT.NONE); - // TODO - result.setText("searchfor"); - result.setLayout(new GridLayout(2, true)); - - fSearchFor = new Button[fSearchForText.length]; - for (int i = 0; i < fSearchForText.length; i++) { - Button button = new Button(result, SWT.RADIO); - button.setText(fSearchForText[i]); - - button.setSelection(i == 0); - button.setLayoutData(new GridData()); - fSearchFor[i] = button; - } - - // Fill with dummy radio buttons - Label filler = new Label(result, SWT.NONE); - filler.setVisible(false); - filler.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1)); - - return result; - } - private Control createLimitTo(Composite parent) { Group result = new Group(parent, SWT.NONE); --- 458,461 ---- *************** *** 564,566 **** --- 492,531 ---- } + class SearchForManager { + + private Button[] fSearchFor; + + private Button createButton(Group parent, String text, int symbolType) { + + Button button = new Button(parent, SWT.RADIO); + button.setText(text); + button.setData(new Integer(symbolType)); + button.setLayoutData(new GridData()); + return button; + } + + private Control createSearchFor(Composite parent) { + Group result = new Group(parent, SWT.NONE); + result.setText(RubyUIMessages.getString("RubySearchPage.SearchForGroupLabel")); //$NON-NLS-1$ + result.setLayout(new GridLayout(2, true)); + + fSearchFor = new Button[2]; + fSearchFor[0] = createButton(result, RubyUIMessages.getString("RubySearch.SearchForClassSymbol"), CLASS_SYMBOL); //$NON-NLS-1$ + fSearchFor[0].setSelection(true); + fSearchFor[1] = createButton(result, RubyUIMessages.getString("RubySearch.SearchForMethodSymbol"), METHOD_SYMBOL); //$NON-NLS-1$ + + return result; + } + + + public int getSelectedSymbolType() { + for (int i = 0; i < fSearchFor.length; i++) { + if (fSearchFor[i].getSelection()) { return ((Integer) fSearchFor[i].getData()).intValue(); } + } + Assert.isTrue(false, "Error in RubySearchPage: There should always be a selected symbol type to search for"); //$NON-NLS-1$ + return CLASS_SYMBOL; + } + + + } } |