@Override public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { ViewerFilter filter= new ArchiveFilter(getSelectedJars(director)); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(shell, lp, cp); dialog.setValidator(validator); dialog.setTitle(SourceLookupUIMessages.ArchiveSourceContainerBrowser_3); dialog.setMessage(SourceLookupUIMessages.ArchiveSourceContainerBrowser_4); dialog.addFilter(filter); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); if (dialog.open() == Window.OK) { Object[] result = dialog.getResult(); ISourceContainer[] containers = new ISourceContainer[result.length]; for (int i = 0; i < containers.length; i++) { containers[i] = new ArchiveSourceContainer((IFile)result[i], true); } return containers; } return new ISourceContainer[0]; } }
@Override public void widgetSelected(SelectionEvent e) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setSorter(new ResourceSorter(ResourceSorter.NAME)); if (dialog.open() == IDialogConstants.OK_ID) { IResource resource = (IResource) dialog.getFirstResult(); String arg = resource.getFullPath().toString(); String fileLoc = VariablesPlugin.getDefault().getStringVariableManager() .generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ fFileText.setText(fileLoc); } } });
private void handleSchemaLocation() { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setTitle(PDEUIMessages.BaseExtensionPointMainPage_schemaLocation_title); dialog.setMessage(PDEUIMessages.BaseExtensionPointMainPage_schemaLocation_desc); dialog.setDoubleClickSelects(false); dialog.setAllowMultiple(false); dialog.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IFile) return false; return true; } }); dialog.setInput(PDEPlugin.getWorkspace().getRoot()); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setInitialSelection(fContainer); dialog.create(); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IHelpContextIds.CONTAINER_SELECTION); if (dialog.open() == Window.OK) { Object[] elements = dialog.getResult(); if (elements.length > 0) { IResource elem = (IResource) elements[0]; String newPath = getWorkspaceRelativePath(elem.getLocation().toString()); fSchemaLocationText.setText(newPath + "/"); //$NON-NLS-1$ } } }
/** * Validate the receiver and update the ok status. * */ protected void updateOKStatus() { if (!fIsEmpty) { if (fValidator != null) { fCurrStatus = fValidator.validate(getResult()); updateStatus(fCurrStatus); } else { fCurrStatus = new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK, "", //$NON-NLS-1$ null); } } else { fCurrStatus = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.ERROR, fEmptyListMessage, null); } updateStatus(fCurrStatus); }
public void widgetSelected(SelectionEvent e) ElementTreeSelectionDialog dlg = new ElementTreeSelectionDialog(getShell(), new LabelProvider() dlg.setTitle(TITLE); dlg.setMessage(MESSAGE); dlg.setInput(NULLABLE); if (dlg.open() == Window.OK) addToTextColumn(Arrays.asList(dlg.getResult()));
/** * Creates and returns a dialog to choose an existing workspace file. */ protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) { int labelFlags= JavaElementLabelProvider.SHOW_BASICS | JavaElementLabelProvider.SHOW_OVERLAY_ICONS | JavaElementLabelProvider.SHOW_SMALL_ICONS; ITreeContentProvider contentProvider= new StandardJavaElementContentProvider(); ILabelProvider labelProvider= new JavaElementLabelProvider(labelFlags); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), labelProvider, contentProvider); dialog.setAllowMultiple(false); dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { StatusInfo res= new StatusInfo(); // only single selection if (selection.length == 1 && (selection[0] instanceof IFile)) res.setOK(); else res.setError(""); //$NON-NLS-1$ return res; } }); dialog.addFilter(new EmptyInnerPackageFilter()); dialog.addFilter(new LibraryFilter()); dialog.setTitle(title); dialog.setMessage(message); dialog.setStatusLineAboveButtons(true); dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot())); return dialog; }
private void chooseWorkspaceFile() { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setValidator(new FileValidator()); dialog.setAllowMultiple(true); dialog.setTitle(PDEUIMessages.LibraryPluginJarsPage_SelectionDialog_title); dialog.setMessage(PDEUIMessages.LibraryPluginJarsPage_SelectionDialog_message); dialog.addFilter(new FileExtensionFilter("jar")); //$NON-NLS-1$ dialog.setInput(PDEPlugin.getWorkspace().getRoot()); dialog.create(); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IHelpContextIds.JAR_SELECTION); if (dialog.open() == Window.OK) { Object[] files = dialog.getResult(); for (Object file : files) { IFile newJarFile = (IFile) file; removeJar(newJarFile.getName()); fJarPaths.add(newJarFile); fTableViewer.add(newJarFile); } updatePageStatus(); } }
@Override public void widgetSelected(SelectionEvent e) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setTitle(LaunchConfigurationsMessages.CommonTab_13); dialog.setMessage(LaunchConfigurationsMessages.CommonTab_14); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setDialogBoundsSettings(getDialogBoundsSettings(WORKSPACE_SELECTION_DIALOG), Dialog.DIALOG_PERSISTSIZE); if (dialog.open() == IDialogConstants.OK_ID) { IResource resource = (IResource) dialog.getFirstResult(); if(resource != null) { String arg = resource.getFullPath().toString(); String fileLoc = VariablesPlugin.getDefault().getStringVariableManager().generateVariableExpression("workspace_loc", arg); //$NON-NLS-1$ fFileText.setText(fileLoc); } } } });
new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider()); dialog.setTitle(title); dialog.setMessage(message); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setInitialSelection(path); dialog.setAllowMultiple(false); dialog.open(); Object[] results = dialog.getResult();
public void widgetSelected(SelectionEvent e) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setTitle("Select input folder"); dialog.setMessage("Select input folder"); dialog.setInput(getProject().getProject()); dialog.setInitialSelection(getWorkspaceRoot().findMember(inputFolderText.getText())); if (dialog.open() == IDialogConstants.OK_ID) { IResource resource = (IResource) dialog.getFirstResult(); if (resource != null) { String fileLoc = resource.getFullPath().toString(); inputFolderText.setText(fileLoc); } } } });
ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getContainer().getShell(), new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), cp); dialog.setDoubleClickSelects(false); dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot())); dialog.addFilter(new EmptyInnerPackageFilter()); dialog.addFilter(new LibraryFilter()); dialog.addFilter(new SealPackagesFilter(packages)); dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { StatusInfo res= new StatusInfo();
dialog.setValidator(new LibrarySelectionValidator(acceptedClasses, true)); dialog.setTitle(PDEUIMessages.BuildEditor_ClasspathSection_jarsTitle); dialog.setMessage(PDEUIMessages.ClasspathSection_jarsMessage); IPluginLibrary[] libraries = getModel().getPluginBase().getLibraries(); IProject project = ((IModel) getPage().getModel()).getUnderlyingResource().getProject(); dialog.addFilter(new LibraryFilter(set)); dialog.setInput(project); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.create(); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IHelpContextIds.ADD_LIBRARY); if (dialog.open() == Window.OK) { Object[] elements = dialog.getResult(); String[] bundlePaths = new String[elements.length]; String[] buildPaths = new String[elements.length];
private void initializeDialogSettings(ElementTreeSelectionDialog dialog) { Class<?>[] acceptedClasses = new Class[] {IFile.class}; dialog.setValidator(new ElementSelectionValidator(acceptedClasses, true)); dialog.setTitle(PDEUIMessages.BuildEditor_ClasspathSection_jarsTitle); dialog.setMessage(PDEUIMessages.BuildEditor_ClasspathSection_jarsDesc); dialog.addFilter(new JARFileFilter()); dialog.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IProject) { try { return ((IProject) element).hasNature(PDE.PLUGIN_NATURE); } catch (CoreException e) { } return false; } else if (element instanceof IResource) { IBuildModel model = getBuildModel(); IBuildEntry entry = model.getBuild().getEntry(IBuildPropertiesConstants.PROPERTY_JAR_EXTRA_CLASSPATH); if (entry != null) return !entry.contains(getRelativePathTokenName((IResource) element)); } return true; } }); dialog.setInput(PDEPlugin.getWorkspace().getRoot()); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setInitialSelection(getBuildModel().getUnderlyingResource().getProject()); }
protected void handleManifestFileBrowseButtonPressed() { ElementTreeSelectionDialog dialog= createWorkspaceFileSelectionDialog(JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_title, JarPackagerMessages.JarManifestWizardPage_manifestSelectionDialog_message); if (fJarPackage.isManifestAccessible()) dialog.setInitialSelections(new IResource[] {fJarPackage.getManifestFile()}); if (dialog.open() == Window.OK) { Object[] resources= dialog.getResult(); if (resources.length != 1) setErrorMessage(JarPackagerMessages.JarManifestWizardPage_error_onlyOneManifestMustBeSelected); else { setErrorMessage(""); //$NON-NLS-1$ fJarPackage.setManifestLocation(((IResource)resources[0]).getFullPath()); fManifestFileText.setText(fJarPackage.getManifestLocation().toString()); } } }
@Override public void run() { ElementTreeSelectionDialog treeViewer = new ElementTreeSelectionDialog( getIntroPart().getIntroSite().getShell(), new IntroModelLabelProvider(), new IntroModelContentProvider()); treeViewer.setInput(getModel()); treeViewer.open(); } };
private void handleNew() { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getSection().getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); initializeDialogSettings(dialog); if (dialog.open() == Window.OK) { Object[] elements = dialog.getResult(); for (Object element : elements) { IResource elem = (IResource) element; String tokenName = getRelativePathTokenName(elem); if (tokenName == null) continue; addClasspathToken(tokenName); } } }
@Override public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { FolderSourceContainerDialog dialog = new FolderSourceContainerDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); if (dialog.open() == Window.OK) { Object[] selection= ((ElementTreeSelectionDialog)dialog).getResult(); ArrayList<ISourceContainer> containers = new ArrayList<>(); for (int i= 0; i < selection.length; i++) { if(selection[i] instanceof IFolder) { containers.add(new FolderSourceContainer((IFolder)selection[i], dialog.isSearchSubfolders())); } } return containers.toArray(new ISourceContainer[containers.size()]); } return new ISourceContainer[0]; }
new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null)); ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( shell, provider, new WorkbenchContentProvider()); dialog.setComparator(new JavaElementComparator()); dialog.setAllowMultiple(false); dialog.setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { StatusInfo res = new StatusInfo(); dialog.addFilter(vf); dialog.setTitle(title); dialog.setMessage(message); dialog.setStatusLineAboveButtons(true); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); return dialog;
public static String selectTemplateFile(Shell shell) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new WorkbenchLabelProvider(), Utils.getResourceContentProvider("xml")); dialog.setTitle("Select TestNG suite template file"); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); String result = null; dialog.open(); Object[] results = dialog.getResult(); if ((results != null) && (results.length > 0) && (results[0] instanceof IFile)) { IFile file = (IFile) results[0]; IProject prj = file.getProject(); IPath relativePath = file.getProjectRelativePath(); String wsRelativePath = prj.getName() + "/" + relativePath; result = "${workspace_loc:" + wsRelativePath + "}"; } return result; }