Example usage for org.eclipse.jdt.core.search SearchEngine createWorkspaceScope

List of usage examples for org.eclipse.jdt.core.search SearchEngine createWorkspaceScope

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search SearchEngine createWorkspaceScope.

Prototype

public static IJavaSearchScope createWorkspaceScope() 

Source Link

Document

Returns a Java search scope with the workspace as the only limit.

Usage

From source file:org.springframework.tooling.jdt.ls.commons.java.FluxJdtSearch.java

License:Open Source License

public IJavaSearchScope workspaceScope(boolean includeBinaries) {
    if (includeBinaries) {
        return SearchEngine.createWorkspaceScope();
    } else {/*w w  w  .  j a  v a 2  s.  co m*/
        List<IJavaProject> projects = new ArrayList<>();
        for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
            try {
                if (p.isAccessible() && p.hasNature(JavaCore.NATURE_ID)) {
                    IJavaProject jp = JavaCore.create(p);
                    projects.add(jp);
                }
            } catch (Exception e) {
                logger.log(e);
            }
        }
        int includeMask = IJavaSearchScope.SOURCES;
        return SearchEngine.createJavaSearchScope(projects.toArray(new IJavaElement[projects.size()]),
                includeMask);
    }
}

From source file:org.springsource.ide.eclipse.commons.frameworks.core.async.FluxJdtSearch.java

License:Open Source License

public static IJavaSearchScope workspaceScope(boolean includeBinaries) {
    if (includeBinaries) {
        return SearchEngine.createWorkspaceScope();
    } else {// ww  w .  j a v  a  2 s .  co  m
        List<IJavaProject> projects = new ArrayList<>();
        for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
            try {
                if (p.isAccessible() && p.hasNature(JavaCore.NATURE_ID)) {
                    IJavaProject jp = JavaCore.create(p);
                    projects.add(jp);
                }
            } catch (Exception e) {
                FrameworkCoreActivator.log(e);
            }
        }
        int includeMask = IJavaSearchScope.SOURCES;
        return SearchEngine.createJavaSearchScope(projects.toArray(new IJavaElement[projects.size()]),
                includeMask);
    }
}

From source file:org.switchyard.tools.ui.bpmn2.component.BPMImplementationComposite.java

License:Open Source License

/**
 * @param shell Shell for the window/*  ww  w.j a  va 2s  .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) {
        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 && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$
        if (project == null && _implementation != null) {
            project = PlatformResourceAdapterFactory.getContainingProject(_implementation);
        }
        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.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.common.impl.JavaInterfaceControlAdapter.java

License:Open Source License

@Override
public boolean browse(Shell shell, IJavaElement element) {
    IJavaSearchScope scope;/* w  w  w  . j  a  v a  2s  .  co m*/
    if (element == null) {
        scope = SearchEngine.createWorkspaceScope();
    } else {
        scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { element });
    }
    try {
        SelectionDialog dialog = JavaUI.createTypeDialog(shell, PlatformUI.getWorkbench().getProgressService(),
                scope, IJavaElementSearchConstants.CONSIDER_INTERFACES, false,
                _interface.getInterface() == null ? "*Service" : _interface.getInterface()); //$NON-NLS-1$
        if (dialog.open() == SelectionDialog.OK) {
            Object[] result = dialog.getResult();
            if (result.length > 0 && result[0] instanceof IType) {
                IType type = (IType) result[0];
                _interface.setInterface(type.getFullyQualifiedName());
                return true;
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:org.switchyard.tools.ui.editor.components.bean.BeanImplementationComposite.java

License:Open Source License

private void handleBrowse() {
    IJavaSearchScope scope = null;/*from w ww.  ja v a  2 s.  co  m*/
    if (_project == null) {
        scope = SearchEngine.createWorkspaceScope();
    } else {
        scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { _project });
    }
    try {
        String filter = _beanClassText.getText();
        SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope,
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, filter.isEmpty() ? "* " : filter); //$NON-NLS-1$
        if (dialog.open() == SelectionDialog.OK) {
            Object[] result = dialog.getResult();
            if (result.length > 0 && result[0] instanceof IType) {
                _beanClassText.setText(((IType) result[0]).getFullyQualifiedName());
                handleModify(_beanClassText);
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
}

From source file:org.switchyard.tools.ui.editor.components.bean.BeanImplementationWizardPage.java

License:Open Source License

private void handleBrowse() {
    IJavaSearchScope scope = null;/*  w w w  .j  av  a2 s  . c o  m*/
    if (_project == null) {
        scope = SearchEngine.createWorkspaceScope();
    } else {
        if (_serviceInterface == null) {
            scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { _project });
        } else {
            try {
                scope = SearchEngine.createStrictHierarchyScope(_project, _serviceInterfaceType, true, false,
                        null);
            } catch (JavaModelException e) {
                // fallback to any type
                scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { _project });
            }
        }
    }

    try {
        SelectionDialog dialog = JavaUI.createTypeDialog(getShell(), getContainer(), scope,
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, "*Bean"); //$NON-NLS-1$
        if (dialog.open() == SelectionDialog.OK) {
            Object[] result = dialog.getResult();
            if (result.length > 0 && result[0] instanceof IType) {
                _beanClass = (IType) result[0];
                _beanClassText.setText(((IType) result[0]).getFullyQualifiedName());
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
}

From source file:org.switchyard.tools.ui.editor.components.binding.sca.BindingSCAComposite.java

License:Open Source License

private String handleBrowse(String filter) {
    IJavaSearchScope scope = null;//from   w w w  .j  ava  2  s  .  c  o m
    if (_project == null) {
        scope = SearchEngine.createWorkspaceScope();
    } else {
        scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { _project });
    }
    try {
        SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope,
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, filter.isEmpty() ? "* " : filter); //$NON-NLS-1$
        if (dialog.open() == SelectionDialog.OK) {
            Object[] result = dialog.getResult();
            if (result.length > 0 && result[0] instanceof IType) {
                return ((IType) result[0]).getFullyQualifiedName();
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:org.switchyard.tools.ui.editor.components.camel.cxf.CamelCxfConsumerComposite.java

License:Open Source License

private String handleBrowse(String initialSelection) {
    IJavaSearchScope scope = null;//w ww .j a  v a2s  .  co  m
    IFile modelFile = SwitchyardSCAEditor.getActiveEditor().getModelFile();
    IJavaProject javaProject = null;
    if (modelFile != null) {
        if (modelFile.getProject() != null) { //$NON-NLS-1$
            javaProject = JavaCore.create(modelFile.getProject());
        }
    }
    if (javaProject == null) {
        scope = SearchEngine.createWorkspaceScope();
    } else {
        scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaProject });
    }
    try {
        String filter = initialSelection;
        SelectionDialog dialog = JavaUI.createTypeDialog(Display.getCurrent().getActiveShell(), null, scope,
                IJavaElementSearchConstants.CONSIDER_CLASSES, false, filter.isEmpty() ? "* " : filter); //$NON-NLS-1$
        if (dialog.open() == SelectionDialog.OK) {
            Object[] result = dialog.getResult();
            if (result.length > 0 && result[0] instanceof IType) {
                return ((IType) result[0]).getFullyQualifiedName();
            }
        }
    } catch (JavaModelException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:org.switchyard.tools.ui.editor.components.camel.java.CamelJavaRouteComposite.java

License:Open Source License

/**
 * @param shell Shell for the window//from   www . j a  v a 2s.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) {
        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 && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$
        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.components.resteasy.DelimitedStringList.java

License:Open Source License

/**
 * @param shell Shell for the window/*  ww  w.  j  a  v a 2s .  co 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) {
        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 && !superTypeName.equals("java.lang.Object")) { //$NON-NLS-1$
        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.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];
}