List of usage examples for org.eclipse.jdt.core.search SearchEngine createWorkspaceScope
public static IJavaSearchScope createWorkspaceScope()
From source file:org.tigris.subversion.subclipse.test.TestProject.java
License:Open Source License
public static void waitForIndexer() throws JavaModelException { ITypeNameRequestor requestor = new ITypeNameRequestor() { public void acceptClass(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {//from ww w . jav a 2 s .co m } public void acceptInterface(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { } }; int matchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE; new SearchEngine().searchAllTypeNames(null, null, matchRule, IJavaSearchConstants.CLASS, SearchEngine.createWorkspaceScope(), requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null); }
From source file:org.universaal.tools.configurationEditor.dialogs.ValidatorDialog.java
License:Apache License
@Override protected Control createDialogArea(Composite parent) { Composite area = (Composite) super.createDialogArea(parent); container = new Composite(area, SWT.NONE); container.setLayoutData(new GridData(GridData.FILL_BOTH)); GridLayout layout = new GridLayout(3, false); container.setLayout(layout);// w w w .j a v a 2 s .c o m // The text fields will grow with the size of the dialog GridData gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; // gridData.horizontalSpan = 2; Label label1 = new Label(container, SWT.NONE); label1.setText("Class:"); classText = new Text(container, SWT.BORDER); classText.setLayoutData(gridData); Button selectClassButton = new Button(container, SWT.PUSH); selectClassButton.setText("Select class"); selectClassButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { SelectionDialog dialog; try { dialog = JavaUI.createTypeDialog(getShell(), new ProgressMonitorDialog(getShell()), SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_CLASSES, false); dialog.setTitle("Validator class"); dialog.setMessage("Select validator a class"); dialog.open(); Object[] types = dialog.getResult(); if (types != null && types.length != 0) { IType selectedClass = (IType) types[0]; classText.setText(selectedClass.getFullyQualifiedName('.')); } } catch (JavaModelException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); gridData = new GridData(); // gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; selectClassButton.setLayoutData(gridData); Label attrLabel = new Label(container, SWT.NONE); attrLabel.setText("Attributes:"); gridData = new GridData(); gridData.verticalAlignment = SWT.TOP; attrLabel.setLayoutData(gridData); attributeList = new List(container, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL); gridData = new GridData(); gridData.grabExcessHorizontalSpace = true; gridData.horizontalAlignment = GridData.FILL; attributeList.setLayoutData(gridData); Button addAttributeButton = new Button(container, SWT.PUSH); addAttributeButton.setText("Add attribute"); addAttributeButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { AttributeDialog ad = new AttributeDialog(getShell()); ad.create(); ad.open(); if (ad.getReturnCode() == Window.OK) { attributeList.add(ad.getAttribute()); } } @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } }); gridData = new GridData(); gridData.verticalAlignment = SWT.TOP; addAttributeButton.setLayoutData(gridData); return area; }
From source file:qwickie.util.DocumentHelper.java
License:Apache License
/** * marks all occurrences of the given string */// w w w . j a v a2 s. c om public static void markOccurrence(final ITextEditor textEditor, final String string) { if (string == null) { return; } SearchPattern pattern = SearchPattern.createPattern(string, IJavaSearchConstants.FIELD, IJavaSearchConstants.ALL_OCCURRENCES, SearchPattern.R_EXACT_MATCH); SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(final SearchMatch match) { IAnnotationModel model = textEditor.getDocumentProvider() .getAnnotationModel(textEditor.getEditorInput()); Annotation annotation = new Annotation("org.eclipse.jdt.ui.occurrences", false, "wicket id constant"); model.addAnnotation(annotation, new Position(match.getOffset(), match.getLength())); } }; SearchEngine searchEngine = new SearchEngine(); try { searchEngine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, SearchEngine.createWorkspaceScope(), requestor, new NullProgressMonitor()); } catch (CoreException e) { } }