Java Code Examples for org.eclipse.jdt.core.search.IJavaSearchConstants#CLASS
The following examples show how to use
org.eclipse.jdt.core.search.IJavaSearchConstants#CLASS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelBasedSearchableEnvironment.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static int convertSearchFilterToModelFilter(int searchFilter) { switch (searchFilter) { case IJavaSearchConstants.CLASS: return NameLookup.ACCEPT_CLASSES; case IJavaSearchConstants.INTERFACE: return NameLookup.ACCEPT_INTERFACES; case IJavaSearchConstants.ENUM: return NameLookup.ACCEPT_ENUMS; case IJavaSearchConstants.ANNOTATION_TYPE: return NameLookup.ACCEPT_ANNOTATIONS; case IJavaSearchConstants.CLASS_AND_ENUM: return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_ENUMS; case IJavaSearchConstants.CLASS_AND_INTERFACE: return NameLookup.ACCEPT_CLASSES | NameLookup.ACCEPT_INTERFACES; default: return NameLookup.ACCEPT_ALL; } }
Example 2
Source File: IntroduceIndirectionInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IType chooseIntermediaryType() { IJavaProject proj= getIntroduceIndirectionRefactoring().getProject(); if (proj == null) return null; IJavaElement[] elements= new IJavaElement[] { proj }; IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); int elementKinds= JavaModelUtil.is18OrHigher(proj) ? IJavaSearchConstants.CLASS_AND_INTERFACE : IJavaSearchConstants.CLASS; FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false, getWizard().getContainer(), scope, elementKinds); dialog.setTitle(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class); dialog.setMessage(RefactoringMessages.IntroduceIndirectionInputPage_dialog_choose_declaring_class_long); if (dialog.open() == Window.OK) { return (IType) dialog.getFirstResult(); } return null; }
Example 3
Source File: NLSAccessorConfigurationDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
protected void browseForAccessorClass() { IProgressService service= PlatformUI.getWorkbench().getProgressService(); IPackageFragmentRoot root= fAccessorPackage.getSelectedFragmentRoot(); IJavaSearchScope scope= root != null ? SearchEngine.createJavaSearchScope(new IJavaElement[] { root }) : SearchEngine.createWorkspaceScope(); FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog (getShell(), false, service, scope, IJavaSearchConstants.CLASS); dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Accessor_Selection); dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_accessor_file); dialog.setInitialPattern("*Messages"); //$NON-NLS-1$ if (dialog.open() == Window.OK) { IType selectedType= (IType) dialog.getFirstResult(); if (selectedType != null) { fAccessorClassName.setText(selectedType.getElementName()); fAccessorPackage.setSelected(selectedType.getPackageFragment()); } } }
Example 4
Source File: IntroduceFactoryInputPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private IType chooseFactoryClass() { IJavaProject proj= getUseFactoryRefactoring().getProject(); if (proj == null) return null; IJavaElement[] elements= new IJavaElement[] { proj }; IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog( getShell(), false, getWizard().getContainer(), scope, IJavaSearchConstants.CLASS); dialog.setTitle(RefactoringMessages.IntroduceFactoryInputPage_chooseFactoryClass_title); dialog.setMessage(RefactoringMessages.IntroduceFactoryInputPage_chooseFactoryClass_message); if (dialog.open() == Window.OK) { return (IType) dialog.getFirstResult(); } return null; }
Example 5
Source File: JavaContext.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private int getSearchForConstant(int typeKinds) { final int CLASSES= SimilarElementsRequestor.CLASSES; final int INTERFACES= SimilarElementsRequestor.INTERFACES; final int ENUMS= SimilarElementsRequestor.ENUMS; final int ANNOTATIONS= SimilarElementsRequestor.ANNOTATIONS; switch (typeKinds & (CLASSES | INTERFACES | ENUMS | ANNOTATIONS)) { case CLASSES: return IJavaSearchConstants.CLASS; case INTERFACES: return IJavaSearchConstants.INTERFACE; case ENUMS: return IJavaSearchConstants.ENUM; case ANNOTATIONS: return IJavaSearchConstants.ANNOTATION_TYPE; case CLASSES | INTERFACES: return IJavaSearchConstants.CLASS_AND_INTERFACE; case CLASSES | ENUMS: return IJavaSearchConstants.CLASS_AND_ENUM; default: return IJavaSearchConstants.TYPE; } }
Example 6
Source File: TypeInfoFilter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private boolean matchesModifiers(TypeNameMatch type) { if (fElementKind == IJavaSearchConstants.TYPE) return true; int modifiers= type.getModifiers() & TYPE_MODIFIERS; switch (fElementKind) { case IJavaSearchConstants.CLASS: return modifiers == 0; case IJavaSearchConstants.ANNOTATION_TYPE: return Flags.isAnnotation(modifiers); case IJavaSearchConstants.INTERFACE: return modifiers == Flags.AccInterface; case IJavaSearchConstants.ENUM: return Flags.isEnum(modifiers); case IJavaSearchConstants.CLASS_AND_INTERFACE: return modifiers == 0 || modifiers == Flags.AccInterface; case IJavaSearchConstants.CLASS_AND_ENUM: return modifiers == 0 || Flags.isEnum(modifiers); case IJavaSearchConstants.INTERFACE_AND_ANNOTATION: return Flags.isInterface(modifiers); } return false; }
Example 7
Source File: AddImportsOperation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private int getSearchForConstant(int typeKinds) { final int CLASSES= SimilarElementsRequestor.CLASSES; final int INTERFACES= SimilarElementsRequestor.INTERFACES; final int ENUMS= SimilarElementsRequestor.ENUMS; final int ANNOTATIONS= SimilarElementsRequestor.ANNOTATIONS; switch (typeKinds & (CLASSES | INTERFACES | ENUMS | ANNOTATIONS)) { case CLASSES: return IJavaSearchConstants.CLASS; case INTERFACES: return IJavaSearchConstants.INTERFACE; case ENUMS: return IJavaSearchConstants.ENUM; case ANNOTATIONS: return IJavaSearchConstants.ANNOTATION_TYPE; case CLASSES | INTERFACES: return IJavaSearchConstants.CLASS_AND_INTERFACE; case CLASSES | ENUMS: return IJavaSearchConstants.CLASS_AND_ENUM; default: return IJavaSearchConstants.TYPE; } }
Example 8
Source File: NewTypeWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Opens a selection dialog that allows to select a super class. * * @return returns the selected type or <code>null</code> if the dialog has been canceled. * The caller typically sets the result to the super class input field. * <p> * Clients can override this method if they want to offer a different dialog. * </p> * * @since 3.2 */ protected IType chooseSuperClass() { IJavaProject project= getJavaProject(); if (project == null) { return null; } IJavaElement[] elements= new IJavaElement[] { project }; IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false, getWizard().getContainer(), scope, IJavaSearchConstants.CLASS); dialog.setTitle(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_title); dialog.setMessage(NewWizardMessages.NewTypeWizardPage_SuperClassDialog_message); dialog.setInitialPattern(getSuperClass()); if (dialog.open() == Window.OK) { return (IType) dialog.getFirstResult(); } return null; }
Example 9
Source File: TemplateCustomPropertiesPage.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
/** * Opens the class selection dialog. * * @param tokenViewer * the token {@link Viewer} * @param servicesTable * the service {@link Viewer} * @param customProperties * the {@link TemplateCustomProperties} */ private void openClassSelectionDialog(Viewer tokenViewer, Viewer servicesTable, final TemplateCustomProperties customProperties) { final IJavaSearchScope scope = SearchEngine.createWorkspaceScope(); final FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog( Display.getCurrent().getActiveShell(), true, PlatformUI.getWorkbench().getProgressService(), scope, IJavaSearchConstants.CLASS); if (dialog.open() == Dialog.OK && dialog.getResult() != null && dialog.getResult().length != 0) { for (Object object : dialog.getResult()) { IPath parentPath = ((IType) object).getParent().getPath(); if (parentPath.getFileExtension().equals("jar")) { int indexOfUnderscore = parentPath.lastSegment().indexOf('_'); if (indexOfUnderscore > -1) { final String pluginName = parentPath.lastSegment().substring(0, indexOfUnderscore); customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), pluginName); } else { customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), ""); } } else { final String bundleName = getBundleName((IType) object); if (bundleName != null) { customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), bundleName); } else { customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), ((IType) object).getJavaProject().getProject().getName()); } } } tokenViewer.refresh(); servicesTable.refresh(); templateVariablesProperties.validatePage(customProperties); } }
Example 10
Source File: ChangeExceptionsControl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IType chooseException() { IJavaElement[] elements= new IJavaElement[] { fProject.getJavaProject() }; final IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements); FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false, PlatformUI.getWorkbench().getProgressService(), scope, IJavaSearchConstants.CLASS); dialog.setTitle(RefactoringMessages.ChangeExceptionsControl_choose_title); dialog.setMessage(RefactoringMessages.ChangeExceptionsControl_choose_message); dialog.setInitialPattern("*Exception*"); //$NON-NLS-1$ dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { if (selection.length == 0) return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$ try { return checkException((IType)selection[0]); } catch (JavaModelException e) { JavaPlugin.log(e); return StatusInfo.OK_STATUS; } } }); if (dialog.open() == Window.OK) { return (IType) dialog.getFirstResult(); } return null; }
Example 11
Source File: TypeMatchFilters.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.0 */ @Override public int getSearchFor() { return IJavaSearchConstants.CLASS; }
Example 12
Source File: JavaUI.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 3 votes |
/** * Creates a selection dialog that lists all types in the given scope. * The caller is responsible for opening the dialog with <code>Window.open</code>, * and subsequently extracting the selected type(s) (of type * <code>IType</code>) via <code>SelectionDialog.getResult</code>. * * @param parent the parent shell of the dialog to be created * @param context the runnable context used to show progress when the dialog * is being populated * @param scope the scope that limits which types are included * @param style flags defining the style of the dialog; the only valid values are * {@link IJavaElementSearchConstants#CONSIDER_CLASSES}, * {@link IJavaElementSearchConstants#CONSIDER_INTERFACES}, * {@link IJavaElementSearchConstants#CONSIDER_ANNOTATION_TYPES}, * {@link IJavaElementSearchConstants#CONSIDER_ENUMS}, * {@link IJavaElementSearchConstants#CONSIDER_ALL_TYPES}, * {@link IJavaElementSearchConstants#CONSIDER_CLASSES_AND_INTERFACES}, * {@link IJavaElementSearchConstants#CONSIDER_CLASSES_AND_ENUMS}, and * {@link IJavaElementSearchConstants#CONSIDER_INTERFACES_AND_ANNOTATIONS}. Please note that * the bitwise OR combination of the elementary constants is not supported. * @param multipleSelection <code>true</code> if multiple selection is allowed * @param filter the initial pattern to filter the set of types. For example "Abstract" shows * all types starting with "abstract". The meta character '?' representing any character and * '*' representing any string are supported. Clients can pass an empty string if no filtering * is required. * @param extension a user interface extension to the type selection dialog or <code>null</code> * if no extension is desired * * @return a new selection dialog * * @exception JavaModelException if the selection dialog could not be opened * * @since 3.2 */ public static SelectionDialog createTypeDialog(Shell parent, IRunnableContext context, IJavaSearchScope scope, int style, boolean multipleSelection, String filter, TypeSelectionExtension extension) throws JavaModelException { int elementKinds= 0; if (style == IJavaElementSearchConstants.CONSIDER_ALL_TYPES) { elementKinds= IJavaSearchConstants.TYPE; } else if (style == IJavaElementSearchConstants.CONSIDER_INTERFACES) { elementKinds= IJavaSearchConstants.INTERFACE; } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES) { elementKinds= IJavaSearchConstants.CLASS; } else if (style == IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES) { elementKinds= IJavaSearchConstants.ANNOTATION_TYPE; } else if (style == IJavaElementSearchConstants.CONSIDER_ENUMS) { elementKinds= IJavaSearchConstants.ENUM; } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES) { elementKinds= IJavaSearchConstants.CLASS_AND_INTERFACE; } else if (style == IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS) { elementKinds= IJavaSearchConstants.CLASS_AND_ENUM; } else if (style == DEPRECATED_CONSIDER_TYPES) { elementKinds= IJavaSearchConstants.CLASS_AND_INTERFACE; } else if (style == IJavaElementSearchConstants.CONSIDER_INTERFACES_AND_ANNOTATIONS) { elementKinds= IJavaSearchConstants.INTERFACE_AND_ANNOTATION; } else { throw new IllegalArgumentException("Invalid style constant."); //$NON-NLS-1$ } FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(parent, multipleSelection, context, scope, elementKinds, extension); dialog.setMessage(JavaUIMessages.JavaUI_defaultDialogMessage); dialog.setInitialPattern(filter); return dialog; }
Example 13
Source File: SuperSkillSelectionDialog.java From sarl with Apache License 2.0 | 3 votes |
/** * Creates new instance. * * @param parent shell to parent the dialog on. * @param context context used to execute long-running operations associated with this dialog. * @param project the java project which will be considered when searching for interfaces. * @param wizardPage the wizard page. * @param extension the wizard type selection extension. * @param multi indicates if multiple elements could be selected. */ public SuperSkillSelectionDialog(Shell parent, IRunnableContext context, IJavaProject project, NewSarlSkillWizardPage wizardPage, SarlSpecificTypeSelectionExtension extension, boolean multi) { super(parent, context, wizardPage, createSearchScope(project, Skill.class, true), IJavaSearchConstants.CLASS, extension, multi); }
Example 14
Source File: SuperEventSelectionDialog.java From sarl with Apache License 2.0 | 3 votes |
/** * Creates new instance. * * @param parent shell to parent the dialog on. * @param context context used to execute long-running operations associated with this dialog. * @param project the java project which will be considered when searching for interfaces. * @param wizardPage the wizard page. * @param extension the wizard type selection extension. * @param multi indicates if multiple elements could be selected. */ public SuperEventSelectionDialog(Shell parent, IRunnableContext context, IJavaProject project, NewSarlEventWizardPage wizardPage, SarlSpecificTypeSelectionExtension extension, boolean multi) { super(parent, context, wizardPage, createSearchScope(project, Event.class, true), IJavaSearchConstants.CLASS, extension, multi); }
Example 15
Source File: SuperAgentSelectionDialog.java From sarl with Apache License 2.0 | 3 votes |
/** * Creates new instance. * * @param parent shell to parent the dialog on. * @param context context used to execute long-running operations associated with this dialog. * @param project the java project which will be considered when searching for interfaces. * @param wizardPage the wizard page. * @param extension the wizard type selection extension. * @param multi indicates if multiple elements could be selected. */ protected SuperAgentSelectionDialog(Shell parent, IRunnableContext context, IJavaProject project, NewSarlAgentWizardPage wizardPage, SarlSpecificTypeSelectionExtension extension, boolean multi) { super(parent, context, wizardPage, createSearchScope(project, Agent.class, true), IJavaSearchConstants.CLASS, extension, multi); }
Example 16
Source File: SuperBehaviorSelectionDialog.java From sarl with Apache License 2.0 | 3 votes |
/** * Creates new instance. * * @param parent shell to parent the dialog on. * @param context context used to execute long-running operations associated with this dialog. * @param project the java project which will be considered when searching for interfaces. * @param wizardPage the wizard page. * @param extension the wizard type selection extension. * @param multi indicates if multiple elements could be selected. */ public SuperBehaviorSelectionDialog(Shell parent, IRunnableContext context, IJavaProject project, NewSarlBehaviorWizardPage wizardPage, SarlSpecificTypeSelectionExtension extension, boolean multi) { super(parent, context, wizardPage, createSearchScope(project, Behavior.class, true), IJavaSearchConstants.CLASS, extension, multi); }