org.eclipse.ui.model.WorkbenchContentProvider Java Examples
The following examples show how to use
org.eclipse.ui.model.WorkbenchContentProvider.
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: HiveTab.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void chooseWorkspace () { final ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog ( getShell (), new WorkbenchLabelProvider (), new WorkbenchContentProvider () ); dialog.setTitle ( "Select driver exporter configuration file" ); dialog.setMessage ( "Choose a driver exporter file for the configuration" ); dialog.setInput ( ResourcesPlugin.getWorkspace ().getRoot () ); dialog.setComparator ( new ResourceComparator ( ResourceComparator.NAME ) ); dialog.setAllowMultiple ( true ); dialog.setDialogBoundsSettings ( getDialogBoundsSettings ( HiveTab.WORKSPACE_SELECTION_DIALOG ), Dialog.DIALOG_PERSISTSIZE ); if ( dialog.open () == IDialogConstants.OK_ID ) { final IResource resource = (IResource)dialog.getFirstResult (); if ( resource != null ) { final String arg = resource.getFullPath ().toString (); final String fileLoc = VariablesPlugin.getDefault ().getStringVariableManager ().generateVariableExpression ( "workspace_loc", arg ); //$NON-NLS-1$ this.fileText.setText ( fileLoc ); makeDirty (); } } }
Example #2
Source File: WorkspaceTools.java From depan with Apache License 2.0 | 6 votes |
/** * Open a dialog box asking the user to select an existing project under the * current workspace. * * @param parentShell * @param title */ public static IResource selectFile(Shell parentShell, String title) { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( parentShell, new WorkbenchLabelProvider(), new WorkbenchContentProvider() ); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setTitle(title); dialog.setAllowMultiple(false); if(dialog.open() == ElementTreeSelectionDialog.OK) { return (IResource) dialog.getFirstResult(); } return null; }
Example #3
Source File: ResourceTreeSelectionDialog.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Constructs an instance of <code>ResourceTreeSelectionDialog</code>. * * @param parent the parent shell for the dialog * @param title dialog title * @param message dialog message * @param rootResource resource that serves as the root of the tree. This * resource's descendants are visible in the tree, but the root * itself is not. * @param initialResource the initially-selected resource * @param visibleResourceTypes a set of {@link IResource} types that are * visible in the tree (e.g. * <code>IResource.FILE | IResource.FOLDER</code>) * @param acceptedResourceTypes a set of {@link IResource} types that can be * selected * @param multiSelection whether or not to allow selection of multiple * resources */ public ResourceTreeSelectionDialog(Shell parent, String title, String message, IContainer rootResource, IResource initialResource, int visibleResourceTypes, int acceptedResourceTypes, boolean multiSelection) { super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); setTitle(title); setMessage(message); setHelpAvailable(false); setInput(rootResource); if (initialResource != null) { setInitialSelection(initialResource); } setComparator(new ResourceComparator(ResourceComparator.NAME)); setValidator(new ResourceFilter(acceptedResourceTypes, multiSelection)); addFilter(new ResourceFilter(visibleResourceTypes)); }
Example #4
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 #5
Source File: BuildPathDialogAccess.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static IPath[] internalChooseFolderEntry(Shell shell, IPath initialSelection, IPath[] usedEntries, String title, String message) { Class<?>[] acceptedClasses= new Class[] { IProject.class, IFolder.class }; ArrayList<IResource> usedContainers= 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 IContainer) { usedContainers.add(resource); } } IResource focus= initialSelection != null ? root.findMember(initialSelection) : null; Object[] used= usedContainers.toArray(); MultipleFolderSelectionDialog dialog= new MultipleFolderSelectionDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setExisting(used); dialog.setTitle(title); dialog.setMessage(message); dialog.setHelpAvailable(false); dialog.addFilter(new TypedViewerFilter(acceptedClasses, used)); dialog.setInput(root); dialog.setInitialFocus(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 #6
Source File: NewSourceFolderWizardPage.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= fCurrJProject.getProject(); ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), lp, cp); 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 #7
Source File: SourceAttachmentBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IPath chooseInternal() { String initSelection= fWorkspaceFileNameField.getText(); ViewerFilter filter= new ArchiveFileFilter((List<IResource>) null, false, false); ILabelProvider lp= new WorkbenchLabelProvider(); ITreeContentProvider cp= new WorkbenchContentProvider(); IResource initSel= null; if (initSelection.length() > 0) { initSel= fWorkspaceRoot.findMember(new Path(initSelection)); } if (initSel == null) { initSel= fWorkspaceRoot.findMember(fEntry.getPath()); } FolderSelectionDialog dialog= new FolderSelectionDialog(getShell(), lp, cp); dialog.setAllowMultiple(false); dialog.addFilter(filter); dialog.setTitle(NewWizardMessages.SourceAttachmentBlock_intjardialog_title); dialog.setMessage(NewWizardMessages.SourceAttachmentBlock_intjardialog_message); dialog.setInput(fWorkspaceRoot); dialog.setInitialSelection(initSel); if (dialog.open() == Window.OK) { IResource res= (IResource) dialog.getFirstResult(); return res.getFullPath(); } return null; }
Example #8
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 #9
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 #10
Source File: WizardExportResourcesPage2.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Returns a content provider for <code>IResource</code>s that returns only children of the given resource type. */ private ITreeContentProvider getResourceProvider(final int resourceType) { return new WorkbenchContentProvider() { public Object[] getChildren(Object o) { if (o instanceof IContainer) { IResource[] members = null; try { members = ((IContainer) o).members(); } catch (CoreException e) { // just return an empty set of children return new Object[0]; } // filter out the desired resource types ArrayList results = new ArrayList(); for (int i = 0; i < members.length; i++) { if (members[i].getName().equals(".config") || members[i].getName().equals(".project") ||members[i].getName().equalsIgnoreCase(".temp") ) { defaultExportItems.add(members[i]); continue; } // And the test bits with the resource types to see if they are what we want if ((members[i].getType() & resourceType) > 0) { results.add(members[i]); } } return results.toArray(); } // input element case if (o instanceof ArrayList) { return ((ArrayList) o).toArray(); } return new Object[0]; } }; }
Example #11
Source File: WizardExportResourcesPage2.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Returns a content provider for <code>IResource</code>s that returns only children of the given resource type. */ private ITreeContentProvider getResourceProvider(final int resourceType) { return new WorkbenchContentProvider() { public Object[] getChildren(Object o) { if (o instanceof IContainer) { IResource[] members = null; try { members = ((IContainer) o).members(); } catch (CoreException e) { // just return an empty set of children return new Object[0]; } // filter out the desired resource types ArrayList results = new ArrayList(); for (int i = 0; i < members.length; i++) { if (members[i].getName().equals(".config") || members[i].getName().equals(".project") ||members[i].getName().equalsIgnoreCase(".temp") ) { defaultExportItems.add(members[i]); continue; } // And the test bits with the resource types to see if they are what we want if ((members[i].getType() & resourceType) > 0) { results.add(members[i]); } } return results.toArray(); } // input element case if (o instanceof ArrayList) { return ((ArrayList) o).toArray(); } return new Object[0]; } }; }
Example #12
Source File: BaseResourceSelectionComposite.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Traverses the upper levels of tree element to: * * <ul> * <li>Check them if all resources are checked * <li>Gray them if some resources are checked * <li>Ungray or uncheck them if no resources are checked. * </ul> * * @param resource */ protected void setParentsCheckedORGrayed(IResource resource) { IContainer parentResource = resource.getParent(); if (parentResource != resource.getWorkspace().getRoot()) { int checkedChildren = 0; int grayedChildren = 0; Object[] childs = ((WorkbenchContentProvider) checkboxTreeViewer.getContentProvider()) .getChildren(parentResource); for (int i = 0; i < childs.length; i++) { if (this.checkboxTreeViewer.getChecked(childs[i])) { checkedChildren++; } if (this.checkboxTreeViewer.getGrayed(childs[i])) { grayedChildren++; } } checkedChildren = checkedChildren - grayedChildren; if (childs.length == checkedChildren) { checkboxTreeViewer.setGrayed(parentResource, false); checkboxTreeViewer.setChecked(parentResource, true); } else if ((grayedChildren > 0) || (checkedChildren > 0)) { checkboxTreeViewer.setChecked(parentResource, true); checkboxTreeViewer.setGrayed(parentResource, true); } else { checkboxTreeViewer.setGrayChecked(parentResource, false); } setParentsCheckedORGrayed(parentResource); } return; }
Example #13
Source File: BaseResourceSelectionComposite.java From saros with GNU General Public License v2.0 | 5 votes |
@Override protected void configureViewer(CheckboxTreeViewer viewer) { viewer.setContentProvider(new WorkbenchContentProvider()); viewer.setLabelProvider(new WorkbenchLabelProvider()); viewer.setUseHashlookup(true); viewer.setSorter(new WorkbenchItemsSorter()); }
Example #14
Source File: BaseResourceSelectionComposite.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Returns the displayed Project {@link IResource}s. * * @return */ public List<IResource> getResources() { WorkbenchContentProvider contentProvider = (WorkbenchContentProvider) getViewer().getContentProvider(); Object[] objects = contentProvider.getElements(getViewer().getInput()); return ArrayUtils.getAdaptableObjects(objects, IResource.class, Platform.getAdapterManager()); }
Example #15
Source File: BaseResourceSelectionComposite.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Returns the displayed {@link IProject}s. * * @return */ public int getProjectsCount() { WorkbenchContentProvider contentProvider = (WorkbenchContentProvider) getViewer().getContentProvider(); Object[] objects = contentProvider.getElements(getViewer().getInput()); return ArrayUtils.getAdaptableObjects(objects, IProject.class, Platform.getAdapterManager()) .size(); }
Example #16
Source File: ControlUtils.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public static String openProgramPathDialog(IProject project, Button button) throws OperationCancellation { ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog( button.getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); dialog.setTitle(LangUIMessages.ProgramPathDialog_title); dialog.setMessage(LangUIMessages.ProgramPathDialog_message); dialog.setInput(project); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); if(dialog.open() == IDialogConstants.OK_ID) { IResource resource = (IResource) dialog.getFirstResult(); return resource.getProjectRelativePath().toPortableString(); } throw new OperationCancellation(); }
Example #17
Source File: PearFileResourceExportPage.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Creates the tree viewer. * * @param parent the parent composite * @return TreeViewer that shows uses Workbench Content- and LabelProvider */ protected ContainerCheckedTreeViewer createTreeViewer(Composite parent) { final ContainerCheckedTreeViewer treeViewer = new ContainerCheckedTreeViewer(parent); final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); gridData.heightHint = 150; treeViewer.getTree().setLayoutData(gridData); treeViewer.setContentProvider(new WorkbenchContentProvider()); treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()); treeViewer.setSorter(new WorkbenchViewerSorter()); return treeViewer; }
Example #18
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 #19
Source File: WorkspaceElementSelectionDialog.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * @param parent * Parent shell * @param createButton * Show create button and dialog */ public WorkspaceElementSelectionDialog(Shell parent, boolean createButton) { super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); this.setHelpAvailable(false); this.hasCreateButton = createButton; }
Example #20
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 #21
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 #22
Source File: SvnFoldersExistWarningPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void createControl(Composite parent) { Composite composite = createComposite(parent, 1); createWrappingLabel(composite, Policy.bind("SVNFoldersExistWarningPage.description"), 0 /* indent */, 1 /* columns */); //$NON-NLS-1$ table = createTable(composite, 1); table.setContentProvider(new WorkbenchContentProvider()); table.setLabelProvider(new SvnFoldersLabelProvider()); Arrays.sort(svnFolders, new Comparator() { public int compare(Object obj1, Object obj2) { IFolder folder1 = (IFolder)obj1; IFolder folder2 = (IFolder)obj2; return folder1.getFullPath().toOSString().compareTo(folder2.getFullPath().toOSString()); } }); AdaptableList input = new AdaptableList(svnFolders); table.setInput(input); continueButton = new Button(composite, SWT.CHECK); continueButton.setText(Policy.bind("SVNFoldersExistWarningPage.continue")); continueButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { setPageComplete(continueButton.getSelection()); } }); setPageComplete(false); setControl(composite); }
Example #23
Source File: SVNWizardPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns a content provider for <code>IResource</code>s that returns * only children of the given resource type. */ protected ITreeContentProvider getResourceProvider(final int resourceType) { return new WorkbenchContentProvider() { public Object[] getChildren(Object o) { if (o instanceof IContainer) { IResource[] members = null; try { members = ((IContainer)o).members(); } catch (CoreException e) { //just return an empty set of children return new Object[0]; } //filter out the desired resource types ArrayList results = new ArrayList(); for (int i = 0; i < members.length; i++) { //And the test bits with the resource types to see if they are what we want if ((members[i].getType() & resourceType) > 0) { results.add(members[i]); } } return results.toArray(); } else { return super.getChildren(o); } } }; }
Example #24
Source File: AddToVersionControlDialog.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private void addUnaddedResourcesArea(Composite composite) { // add a description label createWrappingLabel(composite, Policy.bind("ReleaseCommentDialog.unaddedResources")); //$NON-NLS-1$ // add the selectable checkbox list listViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = SELECTION_HEIGHT_HINT; data.widthHint = WIDTH_HINT; listViewer.getTable().setLayoutData(data); // set the contents of the list listViewer.setLabelProvider(new WorkbenchLabelProvider() { protected String decorateText(String input, Object element) { if (element instanceof IResource) return ((IResource)element).getFullPath().toString(); else return input; } }); listViewer.setContentProvider(new WorkbenchContentProvider()); listViewer.setInput(new AdaptableResourceList(unaddedResources)); if (resourcesToAdd == null) { listViewer.setAllChecked(true); } else { listViewer.setCheckedElements(resourcesToAdd); } listViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { resourcesToAdd = listViewer.getCheckedElements(); } }); addSelectionButtons(composite); }
Example #25
Source File: ProjectResourceControl.java From depan with Apache License 2.0 | 5 votes |
protected DrillDownComposite setupContainerControl(Composite parent) { DrillDownComposite result = new DrillDownComposite(parent, SWT.BORDER); containerViewer = new TreeViewer(result, SWT.NONE); result.setChildTree(containerViewer); containerViewer.setContentProvider(new WorkbenchContentProvider()); containerViewer.setLabelProvider(new WorkbenchLabelProvider()); containerViewer.setComparator(new ViewerComparator()); containerViewer.setUseHashlookup(true); containerViewer.setInput(prepareInput()); return result; }
Example #26
Source File: ImportTraceWizardPage.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override protected ITreeContentProvider getFileProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object object) { if (object instanceof TraceFileSystemElement) { TraceFileSystemElement element = (TraceFileSystemElement) object; return element.getFiles().getChildren(element); } return new Object[0]; } }; }
Example #27
Source File: WorkspaceResourceSelectionDialog.java From typescript.java with MIT License | 5 votes |
public WorkspaceResourceSelectionDialog(Shell parent, Mode mode) { super(parent, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); this.mode = mode; setValidator(new ISelectionStatusValidator() { public IStatus validate(Object[] selection) { if (selection.length > 0 && checkMode(selection[0])) { return new Status(IStatus.OK, TypeScriptUIPlugin.PLUGIN_ID, IStatus.OK, EMPTY_STRING, null); } return new Status(IStatus.ERROR, TypeScriptUIPlugin.PLUGIN_ID, IStatus.ERROR, EMPTY_STRING, null); } }); setInput(ResourcesPlugin.getWorkspace().getRoot()); }
Example #28
Source File: DialogUtils.java From typescript.java with MIT License | 5 votes |
public static ElementTreeSelectionDialog createFolderDialog(String initialFolder, final IProject project, final boolean showAllProjects, final boolean showFolder, Shell shell) { ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); FolderSelectionDialog dialog = new FolderSelectionDialog(shell, lp, cp); // dialog.setTitle(TypeScriptUIMessages.TernModuleOptionsPanel_selectPathDialogTitle); IContainer folder = StringUtils.isEmpty(initialFolder) ? project : (project != null ? project.getFolder(initialFolder) : ResourcesPlugin.getWorkspace().getRoot().getFolder(new Path(initialFolder))); if (folder != null && folder.exists()) { dialog.setInitialSelection(folder); } dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); ViewerFilter filter = new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof IProject) { if (showAllProjects) return true; IProject p = (IProject) element; return (p.equals(project)); } else if (element instanceof IContainer) { IContainer container = (IContainer) element; if (showFolder && container.getType() == IResource.FOLDER) { return true; } return false; } return false; } }; dialog.addFilter(filter); return dialog; }
Example #29
Source File: M2DocFileSelectionDialog.java From M2Doc with Eclipse Public License 1.0 | 5 votes |
@Override protected Control createCustomArea(Composite parent) { final Composite container = new Composite(parent, parent.getStyle()); container.setLayout(new GridLayout(1, false)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); fileText = createFilePathComposite(container, defaultFileName); final TreeViewer containerTreeViewer = new TreeViewer(container, SWT.BORDER); Tree tree = containerTreeViewer.getTree(); final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gdTable.minimumWidth = TABLE_MINIMUM_WIDTH; gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT; tree.setLayoutData(gdTable); containerTreeViewer.setContentProvider(new WorkbenchContentProvider() { @Override public Object[] getChildren(Object element) { final List<Object> res = new ArrayList<>(); for (Object obj : super.getChildren(element)) { if (obj instanceof IContainer || (obj instanceof IFile && fileExtension.equals(((IFile) obj).getFileExtension()))) { res.add(obj); } } return res.toArray(); } }); containerTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); containerTreeViewer.addSelectionChangedListener(new ContainerSelectionChangedListener()); containerTreeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot()); if (defaultFileName != null && !defaultFileName.isEmpty()) { final IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(defaultFileName)); containerTreeViewer.setSelection(new StructuredSelection(file)); } return container; }
Example #30
Source File: CustomElementSelectionDialog.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected Control createDialogArea(Composite parent) { CustomElementSelectionForm form = new CustomElementSelectionForm(parent, SWT.FILL); form.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); TreeViewer v = form.getTreeViewer(); for (ViewerFilter filter : filters) { v.addFilter(filter); } this.treeViewer = v; WorkbenchContentProvider contentProvider = new WorkbenchContentProvider(); ILabelProvider labelProvider = new WorkbenchLabelProvider(); this.treeViewer.setContentProvider(contentProvider); this.treeViewer.setLabelProvider(labelProvider); this.treeViewer.setComparator(new ViewerComparator()); this.treeViewer.setAutoExpandLevel(this.getAutoExpandLevel()); form.setElementLabel(this.elementLabel); this.elementNameInput = form.getElementInput(); form.getElementInput().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals(SuffixText.TEXT_PROPERTY) || evt.getPropertyName().equals(SuffixText.SUFFIX_PROPERTY)) { validateElementInput(); elementInputChanged(); } } }); return form; }