org.eclipse.ui.model.WorkbenchLabelProvider Java Examples

The following examples show how to use org.eclipse.ui.model.WorkbenchLabelProvider. 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: WizardExportResourcesPage2.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the checkbox tree and list for selecting resources.
 * @param parent
 *            the parent control
 */
protected final void createResourcesGroup(Composite parent) {

	// create the input element, which has the root resource
	// as its only child
	List input = new ArrayList();
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	for (int i = 0; i < projects.length; i++) {
		if (projects[i].isOpen()) {
			input.add(projects[i]);
		}
	}

	this.resourceGroup = new ResourceTreeAndListGroup(parent, input, getResourceProvider(IResource.FOLDER
			| IResource.PROJECT), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
			getResourceProvider(IResource.FILE), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
			SWT.NONE, DialogUtil.inRegularFontMode(parent));

	ICheckStateListener listener = new ICheckStateListener() {
		public void checkStateChanged(CheckStateChangedEvent event) {
			updateWidgetEnablements();
		}
	};

	this.resourceGroup.addCheckStateListener(listener);
}
 
Example #2
Source File: ProjectListSelectionDialog.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param parent
 */
public ProjectListSelectionDialog(Shell parent) {
	super(parent, WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
	setTitle(Messages.ProjectSelectionDialog_Title);
	setMessage(Messages.ProjectSelectionDialog_Message);
	final List<Object> list = new ArrayList<Object>();
	try {
		ResourcesPlugin.getWorkspace().getRoot().accept(new IResourceProxyVisitor() {
			public boolean visit(IResourceProxy proxy) throws CoreException {
				if (proxy.getType() == IResource.ROOT) {
					return true;
				}
				if (proxy.isAccessible()) {
					list.add(proxy.requestResource());
				}
				return false;
			}
		}, 0);
	} catch (CoreException e) {
		IdeLog.logError(UIPlugin.getDefault(), e);
	}
	setElements(list.toArray());
}
 
Example #3
Source File: SVNWizardPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected TreeViewer createResourceSelectionTree(Composite composite, int types, int span) {
	TreeViewer tree = new TreeViewer(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
	tree.setUseHashlookup(true);
	tree.setContentProvider(getResourceProvider(types));
	tree.setLabelProvider(
		new DecoratingLabelProvider(
			new WorkbenchLabelProvider(), 
			SVNUIPlugin.getPlugin().getWorkbench().getDecoratorManager().getLabelDecorator()));
	tree.setSorter(new ResourceSorter(ResourceSorter.NAME));
	
	GridData data = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL);
	data.heightHint = LIST_HEIGHT_HINT;
	data.horizontalSpan = span;
	tree.getControl().setLayoutData(data);
	return tree;
}
 
Example #4
Source File: ResourceTreeSelectionDialog.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 #5
Source File: WorkspaceTools.java    From depan with Apache License 2.0 6 votes vote down vote up
/**
 * 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 #6
Source File: CheckNodeTreeView.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
  int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER
      | SWT.H_SCROLL | SWT.V_SCROLL;
  CheckboxTreeViewer result = new CheckboxTreeViewer(parent, style);
  result.setLabelProvider(new WorkbenchLabelProvider());
  result.setContentProvider(new BaseWorkbenchContentProvider());
  result.setComparator(new NodeWrapperTreeSorter());

  result.addCheckStateListener(new ICheckStateListener() {
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {
      if (recursiveTreeSelect) {
        tree.setSubtreeChecked(event.getElement(), event.getChecked());
      }
    }
  });

  tree = result;
  return result;
}
 
Example #7
Source File: ImportTraceWizardPage.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Create the import source selection widget. (Copied from
 * WizardResourceImportPage but instead always uses the internal
 * ResourceTreeAndListGroup to keep compatibility with Kepler)
 */
@Override
protected void createFileSelectionGroup(Composite parent) {

    // Just create with a dummy root.
    fSelectionGroup = new ResourceTreeAndListGroup(parent,
            new FileSystemElement("Dummy", null, true), //$NON-NLS-1$
            getFolderProvider(), new WorkbenchLabelProvider(),
            getFileProvider(), new WorkbenchLabelProvider(), SWT.NONE,
            DialogUtil.inRegularFontMode(parent));

    ICheckStateListener listener = event -> updateWidgetEnablements();

    WorkbenchViewerComparator comparator = new WorkbenchViewerComparator();
    fSelectionGroup.setTreeComparator(comparator);
    fSelectionGroup.setListComparator(comparator);
    fSelectionGroup.addCheckStateListener(listener);

}
 
Example #8
Source File: WizardExportResourcesPage2.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the checkbox tree and list for selecting resources.
 * @param parent
 *            the parent control
 */
protected final void createResourcesGroup(Composite parent) {

	// create the input element, which has the root resource
	// as its only child
	List input = new ArrayList();
	IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	for (int i = 0; i < projects.length; i++) {
		if (projects[i].isOpen()) {
			input.add(projects[i]);
		}
	}

	this.resourceGroup = new ResourceTreeAndListGroup(parent, input, getResourceProvider(IResource.FOLDER
			| IResource.PROJECT), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
			getResourceProvider(IResource.FILE), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
			SWT.NONE, DialogUtil.inRegularFontMode(parent));

	ICheckStateListener listener = new ICheckStateListener() {
		public void checkStateChanged(CheckStateChangedEvent event) {
			updateWidgetEnablements();
		}
	};

	this.resourceGroup.addCheckStateListener(listener);
}
 
Example #9
Source File: AbstractLauncherTab.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
protected IProject chooseXdsProject() {
    ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    dialog.setTitle(Messages.LauncherTabMain_ProjectSelection); 
    dialog.setMessage(Messages.LauncherTabMain_SelectXdsProject+':');

    dialog.setElements(ProjectUtils.getXdsProjects().toArray());

    IProject currentProject = getCurrentXdsProject();
    if (currentProject != null) {
        dialog.setInitialSelections(new Object[] { currentProject });
    }
    if (dialog.open() == Window.OK) {			
        return (IProject) dialog.getFirstResult();
    }		
    return null;		
}
 
Example #10
Source File: PackageFilterEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public int openEditor(Shell parent) {

  this.mDialog = new CheckedTreeSelectionDialog(parent,
          WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(),
          new SourceFolderContentProvider());

  // initialize the dialog with the filter data
  initCheckedTreeSelectionDialog();

  // open the dialog
  int retCode = this.mDialog.open();

  // actualize the filter data
  if (Window.OK == retCode) {
    this.mFilterData = this.getFilterDataFromDialog();

    if (!mDialog.isRecursivelyExcludeSubTree()) {
      mFilterData.add(PackageFilter.RECURSE_OFF_MARKER);
    }
  }

  return retCode;
}
 
Example #11
Source File: HiveTab.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
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 #12
Source File: ProjectField.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected IProject chooseProject() throws OperationCancellation {
	Shell shell = button.getShell();
	ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new WorkbenchLabelProvider());
	dialog.setTitle(LangUIMessages.projectField_chooseProject_title);
	dialog.setMessage(LangUIMessages.projectField_chooseProject_message);

	try {
		final IProject[] projects = getDialogChooseElements(); 
		dialog.setElements(projects);
	} catch (CoreException ce) {
		EclipseCore.logStatus(ce);
	}
	
	final IProject project = getProject();
	if (project != null && project.isOpen()) {
		dialog.setInitialSelections(new Object[] { project });
	}
	
	if (dialog.open() == Window.OK) {
		return (IProject) dialog.getFirstResult();
	}
	throw new OperationCancellation();
}
 
Example #13
Source File: N4JSProjectExplorerLabelProvider.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Sole constructor.
 */
public N4JSProjectExplorerLabelProvider() {
	decorator = new N4JSProjectExplorerProblemsDecorator();
	workbenchLabelProvider = new WorkbenchLabelProvider();
	delegate = new DecoratingLabelProvider(workbenchLabelProvider, decorator);
	workingSetLabelProviderListener = new ILabelProviderListener() {

		@Override
		public void labelProviderChanged(final LabelProviderChangedEvent event) {
			final LabelProviderChangedEvent wrapperEvent = createWorkingSetWrapperEvent(event);
			if (null != wrapperEvent) {
				UIUtils.getDisplay().asyncExec(() -> fireLabelProviderChanged(wrapperEvent));
			}
		}

	};
	delegate.addListener(workingSetLabelProviderListener);
}
 
Example #14
Source File: SourceAttachmentBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #15
Source File: BuildPathDialogAccess.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 #16
Source File: BuildPathDialogAccess.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 #17
Source File: BuildPathDialogAccess.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #18
Source File: ConfigureProjectFromBluePrintAction.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void run(IAction action) {

  IProject[] projects = CheckstyleUIPlugin.getWorkspace().getRoot().getProjects();
  List<IProject> filteredProjects = new ArrayList<>();
  for (int i = 0; i < projects.length; i++) {
    filteredProjects.add(projects[i]);
  }

  filteredProjects.removeAll(mSelectedProjects);

  ListDialog dialog = new ListDialog(mPart.getSite().getShell());
  dialog.setInput(filteredProjects);
  dialog.setContentProvider(new ArrayContentProvider());
  dialog.setLabelProvider(new WorkbenchLabelProvider());
  dialog.setMessage(Messages.ConfigureProjectFromBluePrintAction_msgSelectBlueprintProject);
  dialog.setTitle(Messages.ConfigureProjectFromBluePrintAction_titleSelectBlueprintProject);
  if (Window.OK == dialog.open()) {

    Object[] result = dialog.getResult();

    if (result.length > 0) {

      BulkConfigureJob job = new BulkConfigureJob((IProject) result[0], mSelectedProjects);
      job.schedule();
    }

  }
}
 
Example #19
Source File: JavadocConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #20
Source File: NativeLibrariesConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #21
Source File: ControlUtils.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
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 #22
Source File: NewSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #23
Source File: FileLabelProvider.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public FileLabelProvider(AbstractTextSearchViewPage page, int orderFlag) {
    fLabelProvider = new WorkbenchLabelProvider();
    fOrder = orderFlag;
    fPage = page;

    fLineMatchImage = ImageCache.asImage(SharedUiPlugin.getImageCache().get(UIConstants.LINE_MATCH));
    fMatchComparator = new Comparator<FileMatch>() {
        @Override
        public int compare(FileMatch o1, FileMatch o2) {
            return o1.getOriginalOffset() - o2.getOriginalOffset();
        }
    };
}
 
Example #24
Source File: BuildPathsBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #25
Source File: AddSourceFolderWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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 #26
Source File: PearFileResourceExportPage.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #27
Source File: WorkspaceDialog.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite = (Composite) super.createDialogArea(parent);

	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	composite.setLayout(layout);
	final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
	composite.setLayoutData(data);

	getShell().setText(Messages.getString("dialog.WorkspaceDialog.shell"));

	wsTreeViewer = new TreeViewer(composite, SWT.BORDER);
	final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	gd.widthHint = 550;
	gd.heightHint = 250;
	wsTreeViewer.getTree().setLayoutData(gd);

	wsTreeViewer.setContentProvider(new LocationPageContentProvider());
	wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
	wsTreeViewer.setInput(ResourcesPlugin.getWorkspace());

	final Composite group = new Composite(composite, SWT.NONE);
	layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	group.setLayout(layout);
	group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	final Label label = new Label(group, SWT.NONE);
	label.setLayoutData(new GridData());
	label.setText(Messages.getString("dialog.WorkspaceDialog.label"));

	wsFilenameText = new Text(group, SWT.BORDER);
	wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

	setupListeners();

	return parent;
}
 
Example #28
Source File: CordovaPluginSelectionPage.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private void createProjectGroup(Composite container) {
	Group grpProject = new Group(container, SWT.NONE);
	grpProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	grpProject.setText("Project");
	grpProject.setLayout(new GridLayout(3, false));
	Label lblProject = new Label(grpProject, SWT.NONE);
	lblProject.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
	lblProject.setText("Project:");
	
	textProject = new Text(grpProject, SWT.BORDER);
	textProject.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
	textProject.addListener(SWT.Modify, new Listener() {
		
		@Override
		public void handleEvent(Event event) {
			boolean isValidProject = isValidProject(textProject.getText());
			setPageComplete(validatePage());
			if(isValidProject && getPluginSourceType() == PLUGIN_SOURCE_REGISTRY){
				updateProjectOnViewer();
			}
		}
	});
	
	
	Button btnProjectBrowse = new Button(grpProject, SWT.NONE);
	btnProjectBrowse.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			ElementListSelectionDialog es = new ElementListSelectionDialog(getShell(), WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
			es.setElements(HybridCore.getHybridProjects().toArray());
			es.setTitle("Project Selection");
			es.setMessage("Select a project to run");
			if (es.open() == Window.OK) {			
				HybridProject project = (HybridProject) es.getFirstResult();
				textProject.setText(project.getProject().getName());
			}		
		}
	});
	btnProjectBrowse.setText("Browse...");
}
 
Example #29
Source File: BaseResourceSelectionComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(CheckboxTreeViewer viewer) {
  viewer.setContentProvider(new WorkbenchContentProvider());
  viewer.setLabelProvider(new WorkbenchLabelProvider());
  viewer.setUseHashlookup(true);
  viewer.setSorter(new WorkbenchItemsSorter());
}
 
Example #30
Source File: WorkspaceDialog.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
	Composite composite = (Composite) super.createDialogArea(parent);

	GridLayout layout = new GridLayout();
	layout.numColumns = 1;
	composite.setLayout(layout);
	final GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
	composite.setLayoutData(data);

	getShell().setText(Messages.getString("dialog.WorkspaceDialog.shell"));

	wsTreeViewer = new TreeViewer(composite, SWT.BORDER);
	final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
	gd.widthHint = 550;
	gd.heightHint = 250;
	wsTreeViewer.getTree().setLayoutData(gd);

	wsTreeViewer.setContentProvider(new LocationPageContentProvider());
	wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider());
	wsTreeViewer.setInput(ResourcesPlugin.getWorkspace());

	final Composite group = new Composite(composite, SWT.NONE);
	layout = new GridLayout(2, false);
	layout.marginWidth = 0;
	group.setLayout(layout);
	group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

	final Label label = new Label(group, SWT.NONE);
	label.setLayoutData(new GridData());
	label.setText(Messages.getString("dialog.WorkspaceDialog.label"));

	wsFilenameText = new Text(group, SWT.BORDER);
	wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

	setupListeners();

	return parent;
}