List of usage examples for org.eclipse.jdt.core.search SearchEngine createWorkspaceScope
public static IJavaSearchScope createWorkspaceScope()
From source file:org.switchyard.tools.ui.editor.components.soap.InterceptorTypeInputDialog.java
License:Open Source License
private void handleBrowse() { IJavaSearchScope scope = null;//from www. j a v a2 s . co m IProject project = SwitchyardSCAEditor.getActiveEditor().getModelFile().getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject == null) { scope = SearchEngine.createWorkspaceScope(); } else { scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); } try { SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false); if (dialog.open() == SelectionDialog.OK) { Object[] result = dialog.getResult(); if (result.length > 0 && result[0] instanceof IType) { IType clazz = (IType) result[0]; _classNameText.setText(clazz.getFullyQualifiedName()); _interceptor.setClass(clazz.getFullyQualifiedName()); } getButton(IDialogConstants.OK_ID).setEnabled(validate()); } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:org.switchyard.tools.ui.editor.diagram.binding.AbstractSYBindingComposite.java
License:Open Source License
/** * @param shell Shell for the window/* w w w . j ava 2 s .c o m*/ * @param superTypeName supertype to search for * @param project project to look in * @return IType the type created * @throws JavaModelException exception thrown */ public IType selectType(Shell shell, String superTypeName, IProject project) throws JavaModelException { IJavaSearchScope searchScope = null; if (project != null && superTypeName != null && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$ IJavaProject javaProject = JavaCore.create(project); IType superType = javaProject.findType(superTypeName); if (superType != null) { searchScope = SearchEngine.createHierarchyScope(superType); } } else if (project != null) { IJavaProject javaProject = JavaCore.create(project); searchScope = SearchEngine.createJavaSearchScope(javaProject.getJavaModel().getChildren()); } else { searchScope = SearchEngine.createWorkspaceScope(); } SelectionDialog dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), searchScope, IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false); dialog.setTitle("Select entries"); dialog.setMessage("Matching items"); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } Object[] types = dialog.getResult(); if (types == null || types.length == 0) { return null; } return (IType) types[0]; }
From source file:org.switchyard.tools.ui.editor.diagram.binding.MessageComposerComposite.java
License:Open Source License
/** * @param shell Shell for the window//from w ww .j a va 2s . com * @param superTypeName supertype to search for * @param project project to look in * @return IType the type created * @throws JavaModelException exception thrown */ public IType selectType(Shell shell, String superTypeName, IProject project) throws JavaModelException { IJavaSearchScope searchScope = null; if (project != null && superTypeName != null && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$ IJavaProject javaProject = JavaCore.create(project); IType superType = javaProject.findType(superTypeName); if (superType != null) { searchScope = SearchEngine.createHierarchyScope(superType); } } else if (project != null) { IJavaProject javaProject = JavaCore.create(project); searchScope = SearchEngine.createJavaSearchScope(javaProject.getJavaModel().getChildren()); } else { searchScope = SearchEngine.createWorkspaceScope(); } SelectionDialog dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), searchScope, IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false); dialog.setTitle(Messages.title_selectEntries); dialog.setMessage(Messages.description_matchingItems); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } Object[] types = dialog.getResult(); if (types == null || types.length == 0) { return null; } return (IType) types[0]; }
From source file:org.switchyard.tools.ui.editor.diagram.binding.OperationSelectorComposite.java
License:Open Source License
/** * @param shell Shell for the window//from ww w .j a va 2s . c om * @param superTypeName supertype to search for * @param project project to look in * @return IType the type created * @throws JavaModelException exception thrown */ public IType selectType(Shell shell, String superTypeName, IProject project) throws JavaModelException { IJavaSearchScope searchScope = null; if (project == null) { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) selection; if (selectionToPass.getFirstElement() instanceof IFile) { project = ((IFile) selectionToPass.getFirstElement()).getProject(); } } } if (superTypeName != null) { if (project == null) { project = SwitchyardSCAEditor.getActiveEditor().getModelFile().getProject(); } IJavaProject javaProject = JavaCore.create(project); IType superType = javaProject.findType(superTypeName); if (superType != null) { searchScope = SearchEngine.createStrictHierarchyScope(javaProject, superType, true, false, null); } } else { searchScope = SearchEngine.createWorkspaceScope(); } SelectionDialog dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), searchScope, IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false); dialog.setTitle(Messages.label_selectEntries); dialog.setMessage(Messages.label_matchingItems); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } Object[] types = dialog.getResult(); if (types == null || types.length == 0) { return null; } return (IType) types[0]; }
From source file:org.switchyard.tools.ui.editor.diagram.shared.ClassDialogCellEditor.java
License:Open Source License
@Override protected Object openDialogBox(Control cellEditorWindow) { try {/* w ww .j a v a 2s .c om*/ final Resource resource = getResource(); final String platformPath = resource == null ? null : resource.getURI().toPlatformString(true); final IPath path = platformPath == null ? null : new Path(platformPath); final IProject project = path == null || path.segmentCount() == 0 ? null : ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0)); final IJavaProject javaProject = project == null || !project.exists() || !project.isOpen() ? null : JavaCore.create(project); final IType type = javaProject == null ? null : javaProject.findType(_baseType); final SelectionDialog dialog = JavaUI.createTypeDialog(cellEditorWindow.getShell(), PlatformUI.getWorkbench().getProgressService(), javaProject == null ? SearchEngine.createWorkspaceScope() : SearchEngine.createStrictHierarchyScope(javaProject, type, true, false, null), IJavaElementSearchConstants.CONSIDER_CLASSES, false, "* "); //$NON-NLS-1$ dialog.setTitle(_title); dialog.setMessage(_description); if (dialog.open() == SelectionDialog.OK) { Object[] types = dialog.getResult(); if (types != null && types.length > 0) { final IType selection = (IType) types[0]; return selection.getFullyQualifiedName(); } } } catch (JavaModelException e) { Activator.logStatus(e.getStatus()); } return null; }
From source file:org.switchyard.tools.ui.editor.diagram.shared.JavaInterfaceSelectionComposite.java
License:Open Source License
/** * @param shell Shell for the window//from ww w . j a v a2s. c om * @param superTypeName supertype to search for * @param project project to look in * @return IType the type created * @throws JavaModelException exception thrown */ public IType selectType(Shell shell, String superTypeName, IProject project) throws JavaModelException { IJavaSearchScope searchScope = null; if (project == null) { ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService() .getSelection(); IStructuredSelection selectionToPass = StructuredSelection.EMPTY; if (selection instanceof IStructuredSelection) { selectionToPass = (IStructuredSelection) selection; if (selectionToPass.getFirstElement() instanceof IFile) { project = ((IFile) selectionToPass.getFirstElement()).getProject(); } } } if (project != null && superTypeName != null && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$ IJavaProject javaProject = JavaCore.create(project); IType superType = javaProject.findType(superTypeName); if (superType != null) { searchScope = SearchEngine.createHierarchyScope(superType); } } else if (project != null) { IJavaProject javaProject = JavaCore.create(project); searchScope = SearchEngine.createJavaSearchScope(javaProject.getJavaModel().getChildren()); } else { searchScope = SearchEngine.createWorkspaceScope(); } SelectionDialog dialog = JavaUI.createTypeDialog(shell, new ProgressMonitorDialog(shell), searchScope, IJavaElementSearchConstants.CONSIDER_INTERFACES, false); dialog.setTitle(Messages.title_selectEntries); dialog.setMessage(Messages.description_matchingItems); if (dialog.open() == IDialogConstants.CANCEL_ID) { return null; } Object[] types = dialog.getResult(); if (types == null || types.length == 0) { return null; } return (IType) types[0]; }
From source file:org.switchyard.tools.ui.editor.impl.security.NewSecurityTypeWizardPage.java
License:Open Source License
private void handleBrowse() { IJavaSearchScope scope = null;/* www . j av a 2s.co m*/ IProject project = SwitchyardSCAEditor.getActiveEditor().getModelFile().getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject == null) { scope = SearchEngine.createWorkspaceScope(); } else { try { IType superType = javaProject.findType("javax.security.auth.callback.CallbackHandler"); //$NON-NLS-1$ if (superType != null) { scope = SearchEngine.createStrictHierarchyScope(javaProject, superType, true, false, null); } else { scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); } } catch (JavaModelException e) { e.printStackTrace(); } } try { SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false); if (dialog.open() == SelectionDialog.OK) { Object[] result = dialog.getResult(); if (result.length > 0 && result[0] instanceof IType) { IType clazz = (IType) result[0]; String className = clazz.getFullyQualifiedName(); _callbackHandlerText.setText(className); _callbackHandler = className; } } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:org.switchyard.tools.ui.editor.transform.wizards.JavaTransformComposite.java
License:Open Source License
private void handleBrowse() { IJavaSearchScope scope = null;//w w w .java2 s. c o m IProject project = SwitchyardSCAEditor.getActiveEditor().getModelFile().getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject == null) { scope = SearchEngine.createWorkspaceScope(); } else { scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); } try { SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false); if (dialog.open() == SelectionDialog.OK) { Object[] result = dialog.getResult(); if (result.length > 0 && result[0] instanceof IType) { IType clazz = (IType) result[0]; _classText.setText(clazz.getFullyQualifiedName()); handleModify(_classText); } } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:org.switchyard.tools.ui.editor.validator.wizards.JavaValidatorComposite.java
License:Open Source License
private void handleBrowse(final Text control) { IJavaSearchScope scope = null;/* www . j a v a2 s . c o m*/ IProject project = SwitchyardSCAEditor.getActiveEditor().getModelFile().getProject(); IJavaProject javaProject = JavaCore.create(project); if (javaProject == null) { scope = SearchEngine.createWorkspaceScope(); } else { scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject }); } try { SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope, IJavaElementSearchConstants.CONSIDER_CLASSES, false); if (dialog.open() == SelectionDialog.OK) { Object[] result = dialog.getResult(); if (result.length > 0 && result[0] instanceof IType) { IType clazz = (IType) result[0]; control.setText(clazz.getFullyQualifiedName()); handleModify(control); } } } catch (JavaModelException e) { e.printStackTrace(); } }
From source file:org.talend.designer.runtime.visualization.internal.actions.OpenDeclarationAction.java
License:Open Source License
/** * Searches the source for the given class name. * /*from ww w . j a v a 2 s. c o m*/ * @param name The class name * @return The source * @throws CoreException */ IType doSearchSource(String name) throws CoreException { final List<IType> results = new ArrayList<IType>(); // create requester SearchRequestor requestor = new SearchRequestor() { @Override public void acceptSearchMatch(SearchMatch match) throws CoreException { Object element = match.getElement(); if (element instanceof IType) { results.add((IType) element); } } }; String baseName = name.replace('$', '.'); // create search engine and pattern SearchEngine engine = new SearchEngine(); SearchPattern pattern = SearchPattern.createPattern(baseName, IJavaSearchConstants.TYPE, IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH); // search the source for the given name engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, SearchEngine.createWorkspaceScope(), requestor, null); if (results.size() > 0) { // at most one source should be found return results.get(0); } return null; }