org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator Java Examples
The following examples show how to use
org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator.
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: ClientBundleResourceSelectionDialog.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private ClientBundleResourceSelectionDialog(Shell shell, IJavaProject javaProject, boolean multiSelection) { super(shell, new JavaElementLabelProvider( JavaElementLabelProvider.SHOW_DEFAULT), new StandardJavaElementContentProvider()); setValidator(new TypedElementSelectionValidator(new Class[] {IFile.class}, multiSelection)); setComparator(new JavaElementComparator()); setTitle("Resource Selection"); String message = MessageFormat.format("Choose {0} to bundle:", (multiSelection ? "one or more resources" : "a resource")); setMessage(message); addFilter(new ViewerFilter(javaProject)); }
Example #2
Source File: BuildPathDialogAccess.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Shows the UI to configure a JAR or ZIP archive located in the workspace. * The dialog returns the configured classpath entry path or <code>null</code> if the dialog has * been canceled. The dialog does not apply any changes. * * @param shell The parent shell for the dialog. * @param initialEntry The path of the initial archive entry * @param usedEntries An array of paths that are already on the classpath and therefore should not be * selected again. * @return Returns the configured JAR path or <code>null</code> if the dialog has * been canceled by the user. */ public static IPath configureJAREntry(Shell shell, IPath initialEntry, IPath[] usedEntries) { if (initialEntry == null || usedEntries == null) { throw new IllegalArgumentException(); } Class<?>[] acceptedClasses= new Class[] { IFile.class }; TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); ArrayList<IResource> usedJars= new ArrayList<IResource>(usedEntries.length); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); for (int i= 0; i < usedEntries.length; i++) { IPath curr= usedEntries[i]; if (!curr.equals(initialEntry)) { IResource resource= root.findMember(usedEntries[i]); if (resource instanceof IFile) { usedJars.add(resource); } } } IResource existing= root.findMember(initialEntry); FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setValidator(validator); dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_title); dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_edit_description); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.addFilter(new ArchiveFileFilter(usedJars, true, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setInitialSelection(existing); if (dialog.open() == Window.OK) { IResource element= (IResource) dialog.getFirstResult(); return element.getFullPath(); } return null; }
Example #3
Source File: BuildPathDialogAccess.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Shows the UI to select new JAR or ZIP archive entries located in the workspace. * The dialog returns the selected entries or <code>null</code> if the dialog has * been canceled. The dialog does not apply any changes. * * @param shell The parent shell for the dialog. * @param initialSelection The path of the element (container or archive) to initially select or <code>null</code> to not select an entry. * @param usedEntries An array of paths that are already on the classpath and therefore should not be * selected again. * @return Returns the new JAR paths or <code>null</code> if the dialog has * been canceled by the user. */ public static IPath[] chooseJAREntries(Shell shell, IPath initialSelection, IPath[] usedEntries) { if (usedEntries == null) { throw new IllegalArgumentException(); } Class<?>[] acceptedClasses= new Class[] { IFile.class }; TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); ArrayList<IResource> usedJars= new ArrayList<IResource>(usedEntries.length); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); for (int i= 0; i < usedEntries.length; i++) { IResource resource= root.findMember(usedEntries[i]); if (resource instanceof IFile) { usedJars.add(resource); } } IResource focus= initialSelection != null ? root.findMember(initialSelection) : null; FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setHelpAvailable(false); dialog.setValidator(validator); dialog.setTitle(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_title); dialog.setMessage(NewWizardMessages.BuildPathDialogAccess_JARArchiveDialog_new_description); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.addFilter(new ArchiveFileFilter(usedJars, true, true)); dialog.setInput(root); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setInitialSelection(focus); if (dialog.open() == Window.OK) { Object[] elements= dialog.getResult(); IPath[] res= new IPath[elements.length]; for (int i= 0; i < res.length; i++) { IResource elem= (IResource)elements[i]; res[i]= elem.getFullPath(); } return res; } return null; }
Example #4
Source File: JavadocConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String chooseWorkspaceArchive() { String initSelection= fArchiveField.getText(); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); Class<?>[] acceptedClasses= new Class[] { IFile.class }; TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); IResource initSel= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (initSelection.length() > 0) { initSel= root.findMember(new Path(initSelection)); } FilteredElementTreeSelectionDialog dialog= new FilteredElementTreeSelectionDialog(fShell, lp, cp); dialog.setInitialFilter(ArchiveFileFilter.JARZIP_FILTER_STRING); dialog.setAllowMultiple(false); dialog.setValidator(validator); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setTitle(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_title); dialog.setMessage(PreferencesMessages.JavadocConfigurationBlock_workspace_archive_selection_dialog_description); dialog.setInput(root); dialog.setInitialSelection(initSel); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { IResource res= (IResource) dialog.getFirstResult(); return res.getFullPath().makeRelative().toString(); } return null; }
Example #5
Source File: NativeLibrariesConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private String chooseInternal() { String initSelection= fPathField.getText(); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class }; TypedElementSelectionValidator validator= new TypedElementSelectionValidator(acceptedClasses, true); ViewerFilter filter= new TypedViewerFilter(acceptedClasses); IResource initSel= null; IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); if (initSelection.length() > 0) { initSel= root.findMember(new Path(initSelection)); } if (initSel == null) { initSel= root.findMember(fEntry.getPath()); } ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(fShell, lp, cp); dialog.setAllowMultiple(false); dialog.setValidator(validator); dialog.addFilter(filter); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setTitle(NewWizardMessages.NativeLibrariesDialog_intfiledialog_title); dialog.setMessage(NewWizardMessages.NativeLibrariesDialog_intfiledialog_message); dialog.setInput(root); dialog.setInitialSelection(initSel); dialog.setHelpAvailable(false); if (dialog.open() == Window.OK) { IResource res= (IResource) dialog.getFirstResult(); return res.getFullPath().makeRelative().toString(); } return null; }
Example #6
Source File: BuildPathsBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IContainer chooseContainer() { Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class }; ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); IProject[] allProjects= fWorkspaceRoot.getProjects(); ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length); IProject currProject= fCurrJProject.getProject(); for (int i= 0; i < allProjects.length; i++) { if (!allProjects[i].equals(currProject)) { rejectedElements.add(allProjects[i]); } } ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray()); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); IResource initSelection= null; if (fOutputLocationPath != null) { initSelection= fWorkspaceRoot.findMember(fOutputLocationPath); } FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp); dialog.setTitle(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_title); dialog.setValidator(validator); dialog.setMessage(NewWizardMessages.BuildPathsBlock_ChooseOutputFolderDialog_description); dialog.addFilter(filter); dialog.setInput(fWorkspaceRoot); dialog.setInitialSelection(initSelection); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); if (dialog.open() == Window.OK) { return (IContainer)dialog.getFirstResult(); } return null; }
Example #7
Source File: AddSourceFolderWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IFolder chooseFolder(String title, String message, IPath initialPath) { Class<?>[] acceptedClasses= new Class[] { IFolder.class }; ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); ViewerFilter filter= new TypedViewerFilter(acceptedClasses, null); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); IProject currProject= fNewElement.getJavaProject().getProject(); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp) { @Override protected Control createDialogArea(Composite parent) { Control result= super.createDialogArea(parent); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IJavaHelpContextIds.BP_CHOOSE_EXISTING_FOLDER_TO_MAKE_SOURCE_FOLDER); return result; } }; dialog.setValidator(validator); dialog.setTitle(title); dialog.setMessage(message); dialog.addFilter(filter); dialog.setInput(currProject); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); IResource res= currProject.findMember(initialPath); if (res != null) { dialog.setInitialSelection(res); } if (dialog.open() == Window.OK) { return (IFolder) dialog.getFirstResult(); } return null; }
Example #8
Source File: OutputLocationDialog.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private IContainer chooseOutputLocation() { IWorkspaceRoot root= fCurrProject.getWorkspace().getRoot(); final Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class }; IProject[] allProjects= root.getProjects(); ArrayList<IProject> rejectedElements= new ArrayList<IProject>(allProjects.length); for (int i= 0; i < allProjects.length; i++) { if (!allProjects[i].equals(fCurrProject)) { rejectedElements.add(allProjects[i]); } } ViewerFilter filter= new TypedViewerFilter(acceptedClasses, rejectedElements.toArray()); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); IResource initSelection= null; if (fOutputLocation != null) { initSelection= root.findMember(fOutputLocation); } FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp); dialog.setTitle(NewWizardMessages.OutputLocationDialog_ChooseOutputFolder_title); dialog.setValidator(new ISelectionStatusValidator() { ISelectionStatusValidator validator= new TypedElementSelectionValidator(acceptedClasses, false); public IStatus validate(Object[] selection) { IStatus typedStatus= validator.validate(selection); if (!typedStatus.isOK()) return typedStatus; if (selection[0] instanceof IFolder) { IFolder folder= (IFolder) selection[0]; try { IStatus result= ClasspathModifier.checkSetOutputLocationPrecondition(fEntryToEdit, folder.getFullPath(), fAllowInvalidClasspath, fCPJavaProject); if (result.getSeverity() == IStatus.ERROR) return result; } catch (CoreException e) { JavaPlugin.log(e); } return new StatusInfo(); } else { return new StatusInfo(IStatus.ERROR, ""); //$NON-NLS-1$ } } }); dialog.setMessage(NewWizardMessages.OutputLocationDialog_ChooseOutputFolder_description); dialog.addFilter(filter); dialog.setInput(root); dialog.setInitialSelection(initSelection); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); if (dialog.open() == Window.OK) { return (IContainer)dialog.getFirstResult(); } return null; }