Java Code Examples for org.eclipse.ui.model.WorkbenchLabelProvider

The following examples show how to use org.eclipse.ui.model.WorkbenchLabelProvider. These examples are extracted from open source projects. 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 Project: eclipse-cs   Author: checkstyle   File: PackageFilterEditor.java    License: 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 #2
Source Project: n4js   Author: eclipse   File: N4JSProjectExplorerLabelProvider.java    License: 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 #3
Source Project: neoscada   Author: eclipse   File: HiveTab.java    License: 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 #4
Source Project: xds-ide   Author: excelsior-oss   File: AbstractLauncherTab.java    License: 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 #5
Source Project: tracecompass   Author: tracecompass   File: ImportTraceWizardPage.java    License: 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 #6
Source Project: depan   Author: google   File: CheckNodeTreeView.java    License: 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 Project: depan   Author: google   File: WorkspaceTools.java    License: 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 #8
Source Project: gwt-eclipse-plugin   Author: gwt-plugins   File: ResourceTreeSelectionDialog.java    License: 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 #9
Source Project: APICloud-Studio   Author: apicloudcom   File: SVNWizardPage.java    License: 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 #10
Source Project: APICloud-Studio   Author: apicloudcom   File: ProjectListSelectionDialog.java    License: 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 #11
Source Project: translationstudio8   Author: heartsome   File: WizardExportResourcesPage2.java    License: 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 #12
Source Project: tmxeditor8   Author: heartsome   File: WizardExportResourcesPage2.java    License: 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 #13
Source Project: goclipse   Author: GoClipse   File: ProjectField.java    License: 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 #14
/**
 * {@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 #15
Source Project: n4js   Author: eclipse   File: WorkspaceElementSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @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 #16
Source Project: n4js   Author: eclipse   File: CustomElementSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #17
Source Project: corrosion   Author: eclipse   File: InputComponent.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void createProjectSelection() {
	createSelectionButton();
	browseButton.addSelectionListener(widgetSelectedAdapter(e -> {
		ListSelectionDialog dialog = new ListSelectionDialog(browseButton.getShell(),
				ResourcesPlugin.getWorkspace().getRoot(), new BaseWorkbenchContentProvider(),
				new WorkbenchLabelProvider(), this.labelString);
		dialog.setTitle(Messages.LaunchUI_selection);
		int returnCode = dialog.open();
		Object[] results = dialog.getResult();
		if (returnCode == 0 && results.length > 0) {
			text.setText(((IProject) results[0]).getName());
			editListener.modifyText(null);
		}
	}));
}
 
Example #18
Source Project: M2Doc   Author: ObeoNetwork   File: M2DocFileSelectionDialog.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@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 #19
Source Project: xds-ide   Author: excelsior-oss   File: ModulaSearchLabelProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
public M2LabelProvider(ModulaSearchResultPage resultPage, ResourceRegistry resourceRegistry) {
    this.resultPage = resultPage;
    this.resourceRegistry = resourceRegistry;
    this.dlgFont = resultPage.getControl().getFont();
    fLabelProvider= new WorkbenchLabelProvider();
    positionStyler = new Styler() {
        @Override
        public void applyStyles(TextStyle textStyle) {
            textStyle.foreground = JFaceResources.getColorRegistry().get(JFacePreferences.QUALIFIER_COLOR);
            textStyle.font= getItalicFont(dlgFont);
        }
    };
}
 
Example #20
Source Project: typescript.java   Author: angelozerr   File: DialogUtils.java    License: MIT License 5 votes vote down vote up
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 #21
Source Project: typescript.java   Author: angelozerr   File: TypeScriptSearchLabelProvider.java    License: MIT License 5 votes vote down vote up
public TypeScriptSearchLabelProvider(AbstractTextSearchViewPage page, int orderFlag) {
	fLabelProvider= new WorkbenchLabelProvider();
	fOrder= orderFlag;
	fPage= page;
	fLineMatchImage= SearchPluginImages.get(SearchPluginImages.IMG_OBJ_TEXT_SEARCH_LINE);
	fMatchComparator= new Comparator() {
		public int compare(Object o1, Object o2) {
			return ((TypeScriptMatch) o1).getOriginalOffset() - ((TypeScriptMatch) o2).getOriginalOffset();
		}
	};
}
 
Example #22
Source Project: typescript.java   Author: angelozerr   File: WorkspaceResourceSelectionDialog.java    License: MIT License 5 votes vote down vote up
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 #23
Source Project: statecharts   Author: Yakindu   File: BuilderPropertyPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected TableViewer createBlackListViewer(Composite group) {
	TableViewer result = new TableViewer(group, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
	result.getTable().setLinesVisible(true);
	GridDataFactory.fillDefaults().grab(true, true).applyTo(result.getControl());
	result.setContentProvider(new ArrayContentProvider());
	result.setLabelProvider(new WorkbenchLabelProvider());
	values = blacklist.getValues(getActualProject());
	result.setInput(values);
	return result;
}
 
Example #24
Source Project: statecharts   Author: Yakindu   File: BuilderPropertyPage.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void addAddBtn(final Composite btnComposite) {
	Button add = new Button(btnComposite, SWT.FLAT);
	GridDataFactory.fillDefaults().grab(true, false).hint(100, SWT.DEFAULT).applyTo(add);
	add.setText("Add...");
	add.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			super.widgetSelected(e);
			ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(btnComposite.getShell(),
					new WorkbenchLabelProvider(), new BaseWorkbenchContentProvider());

			dialog.setValidator(new CheaderBlacklistSelectionStatusValidator());

			dialog.setTitle("Add blacklist item");
			dialog.setMessage("Select a blacklist item:");
			dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
			dialog.addFilter(new CHeaderViewerFilter(getActualProject()));

			if (!values.isEmpty())
				dialog.setInitialSelection(values.get(values.size() - 1));

			dialog.setDialogBoundsSettings(BuilderActivator.getDefault().getDialogSettings(),
					Dialog.DIALOG_PERSISTLOCATION);
			dialog.open();
			Object[] result = dialog.getResult();
			if (result != null) {
				for (Object selection : result) {
					if (selection instanceof IResource) {
						values.add((IResource) selection);
					}
				}
				blackListViewer.refresh();
			}
		}
	});

}
 
Example #25
Source Project: depan   Author: google   File: GraphNodeViewer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Can be overridden to provide a customized tree viewer.
 * For example, the derived type {@link CheckNodeTreeView}
 * uses a {@code CheckboxTreeViewer}.
 */
protected TreeViewer createTreeViewer(Composite parent) {
  int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER
      | SWT.H_SCROLL | SWT.V_SCROLL;
  TreeViewer result = new TreeViewer(parent, style);
  result.setLabelProvider(new WorkbenchLabelProvider());
  result.setContentProvider(new BaseWorkbenchContentProvider());
  result.setComparator(SORTER);

  setupHierarchyMenu(result);

  return result;
}
 
Example #26
Source Project: depan   Author: google   File: ProjectResourceControl.java    License: Apache License 2.0 5 votes vote down vote up
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 #27
Source Project: APICloud-Studio   Author: apicloudcom   File: AddToVersionControlDialog.java    License: GNU General Public License v3.0 5 votes vote down vote up
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 #28
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: BuildPathDialogAccess.java    License: 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 #29
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: BuildPathDialogAccess.java    License: 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 #30
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: BuildPathDialogAccess.java    License: 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;
}