org.eclipse.jface.viewers.DecoratingLabelProvider Java Examples

The following examples show how to use org.eclipse.jface.viewers.DecoratingLabelProvider. 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: 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 #2
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 #3
Source File: JarManifestWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates and returns a dialog to choose an existing workspace file.
 * @param title the title
 * @param message the dialog message
 * @return the dialog
 */
protected ElementTreeSelectionDialog createWorkspaceFileSelectionDialog(String title, String message) {
	int labelFlags= JavaElementLabelProvider.SHOW_BASICS
					| JavaElementLabelProvider.SHOW_OVERLAY_ICONS
					| JavaElementLabelProvider.SHOW_SMALL_ICONS;
	final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(labelFlags), new ProblemsLabelDecorator(null));
	ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getShell(), provider, new StandardJavaElementContentProvider());
	dialog.setComparator(new JavaElementComparator());
	dialog.setAllowMultiple(false);
	dialog.setValidator(new ISelectionStatusValidator() {
		public IStatus validate(Object[] selection) {
			StatusInfo res= new StatusInfo();
			// only single selection
			if (selection.length == 1 && (selection[0] instanceof IFile))
				res.setOK();
			else
				res.setError(""); //$NON-NLS-1$
			return res;
		}
	});
	dialog.addFilter(new EmptyInnerPackageFilter());
	dialog.addFilter(new LibraryFilter());
	dialog.setTitle(title);
	dialog.setMessage(message);
	dialog.setStatusLineAboveButtons(true);
	dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
	return dialog;
}
 
Example #4
Source File: FileSearchPage.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void setSortOrder(int sortOrder) {
    fCurrentSortOrder = sortOrder;
    DecoratingLabelProvider lpWrapper = (DecoratingLabelProvider) getViewer().getLabelProvider();
    ((FileLabelProvider) lpWrapper.getLabelProvider()).setOrder(sortOrder);
    getViewer().refresh();
    getSettings().put(KEY_SORTING, fCurrentSortOrder);
}
 
Example #5
Source File: ConfigurationWizardDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createPageChooserComposite(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().span(1, 2).create());
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 10).create());

    pageChooserViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION);
    pageChooserViewer.getTable().setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.FILL).grab(false, true).create());
    pageChooserViewer.setContentProvider(new WizardPageContentProvider());
    ILabelDecorator decorator = new WizardPageDecorator(this);
    pageChooserViewer.setLabelProvider(new DecoratingLabelProvider(new WizardPageLabelProvider(this), decorator));
    pageChooserViewer.setInput(getWizard().getPages());
    pageChooserViewer.addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            IProcessConfigurationWizardPage page = (IProcessConfigurationWizardPage) element;
            if (!isSimpleMode) {
                return true;
            }
            return page.isDefault() || page.isConfigurationPageValid(getConfiguration()) != null;
        }
    });
    pageChooserViewer.addSelectionChangedListener(this);
    pageChooserViewer.getTable().setEnabled(false);

    addPageChangedListener(this);
}
 
Example #6
Source File: TaxonomyCheckboxListView.java    From slr-toolkit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.
 */
@Override
public void createPartControl(Composite parent) {
	Optional<Model> m = ModelRegistryPlugin.getModelRegistry().getActiveTaxonomy();
	contentProvider = new TermContentProvider(viewer);
	viewer = new ContainerCheckedTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(contentProvider);
	DecoratingLabelProvider p = new DecoratingLabelProvider(new DefaultEObjectLabelProvider(), new TaxonomyLabelDecorator());
	viewer.setLabelProvider(p);
	viewer.addCheckStateListener(this);
	viewer.setSorter(null);

	cellEditor = new MyTextCellEditor(viewer.getTree());

	TreeViewerEditor.create(
			viewer,
			new ColumnViewerEditorActivationStrategy(viewer){
				protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) {
					return event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION ||
							(event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.F2);
				}
			},
			TreeViewerEditor.DEFAULT
	);
	enableEditing();

	if(m.isPresent()){
		viewer.setInput(m.get());
	}
	viewer.expandAll();

	//Create right-click menu
       MenuManager menuManager = new MenuManager();
       Menu menu = menuManager.createContextMenu(viewer.getTree());
       viewer.getTree().setMenu(menu);
       getSite().registerContextMenu(menuManager, viewer);
	getSite().setSelectionProvider(viewer);
	// Create the help context id for the viewer's control
	PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "de.tudresden.slr.model.taxonomy.ui.viewer");
	getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(this);
}
 
Example #7
Source File: JarManifestWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a selection dialog that lists all packages under the given package
 * fragment root.
 * The caller is responsible for opening the dialog with <code>Window.open</code>,
 * and subsequently extracting the selected packages (of type
 * <code>IPackageFragment</code>) via <code>SelectionDialog.getResult</code>.
 *
 * @param packageFragments the package fragments
 * @return a new selection dialog
 */
protected SelectionDialog createPackageDialog(Set<IJavaElement> packageFragments) {
	List<IPackageFragment> packages= new ArrayList<IPackageFragment>(packageFragments.size());
	for (Iterator<IJavaElement> iter= packageFragments.iterator(); iter.hasNext();) {
		IPackageFragment fragment= (IPackageFragment)iter.next();
		boolean containsJavaElements= false;
		int kind;
		try {
			kind= fragment.getKind();
			containsJavaElements= fragment.getChildren().length > 0;
		} catch (JavaModelException ex) {
			ExceptionHandler.handle(ex, getContainer().getShell(), JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_title, Messages.format(JarPackagerMessages.JarManifestWizardPage_error_jarPackageWizardError_message, JavaElementLabels.getElementLabel(fragment, JavaElementLabels.ALL_DEFAULT)));
			continue;
		}
		if (kind != IPackageFragmentRoot.K_BINARY && containsJavaElements)
			packages.add(fragment);
	}
	StandardJavaElementContentProvider cp= new StandardJavaElementContentProvider() {
		@Override
		public boolean hasChildren(Object element) {
			// prevent the + from being shown in front of packages
			return !(element instanceof IPackageFragment) && super.hasChildren(element);
		}
	};
	final DecoratingLabelProvider provider= new DecoratingLabelProvider(new JavaElementLabelProvider(JavaElementLabelProvider.SHOW_DEFAULT), new ProblemsLabelDecorator(null));
	ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(getContainer().getShell(), provider, cp);
	dialog.setDoubleClickSelects(false);
	dialog.setComparator(new JavaElementComparator());
	dialog.setInput(JavaCore.create(JavaPlugin.getWorkspace().getRoot()));
	dialog.addFilter(new EmptyInnerPackageFilter());
	dialog.addFilter(new LibraryFilter());
	dialog.addFilter(new SealPackagesFilter(packages));
	dialog.setValidator(new ISelectionStatusValidator() {
		public IStatus validate(Object[] selection) {
			StatusInfo res= new StatusInfo();
			for (int i= 0; i < selection.length; i++) {
				if (!(selection[i] instanceof IPackageFragment)) {
					res.setError(JarPackagerMessages.JarManifestWizardPage_error_mustContainPackages);
					return res;
				}
			}
			res.setOK();
			return res;
		}
	});
	return dialog;
}
 
Example #8
Source File: XPathOperatorEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Composite createOpeartorEditor(Composite parent,final Operator operator,final Expression sourceExpression) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ;
    composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 5).create());

    final XMLData data = (XMLData) sourceExpression.getReferencedElements().get(0) ;
    String namespace = data.getNamespace() ;
    String element = data.getType();
    XSDRepositoryStore xsdStore = (XSDRepositoryStore) RepositoryManager.getInstance().getRepositoryStore(XSDRepositoryStore.class) ;

    XSDElementDeclaration root = xsdStore.findElementDeclaration(namespace, element);
    final XSDContentProvider provider =   new XSDContentProvider(true) ;
    provider.setElement(root);

    xsdViewer = new TreeViewer(composite);
    xsdViewer.setContentProvider(provider);
    XSDLabelProvider labelProvider = new XSDLabelProvider();
    xsdViewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
    xsdViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    xsdViewer.setInput(new Object());

    String content = operator.getExpression() ;
    if(content == null){
        content = "" ;
    }
    xsdViewer.setSelection(new StructuredSelection(createTreePath(content, provider)));

    xpathText = new Text(composite, SWT.WRAP | SWT.BORDER);
    xpathText.setLayoutData(GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 40).grab(true, false).create());
    xpathText.addModifyListener(new ModifyListener() {
        @Override
        public void modifyText(ModifyEvent e) {
            operator.setExpression(xpathText.getText()) ;
        }
    });


    xsdViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ITreeSelection selection = (ITreeSelection) xsdViewer.getSelection();
            String xpath = computeXPath(selection, false);
            if(xpath == null || xpath.isEmpty()){
                xpathText.setText(data.getName());
            }else{
                xpathText.setText(xpath);
            }

            xpathText.redraw();
            fireSelectionChange(event) ;
        }
    });
    return composite ;
}
 
Example #9
Source File: XPathExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createXPathChooser(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final GridLayout gl = new GridLayout(1, false);
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    composite.setLayout(gl);
    final Label label = new Label(composite, SWT.WRAP);
    label.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 30).create());
    label.setText(Messages.selectElementLabel);

    xsdViewer = new TreeViewer(composite);
    provider = new XSDContentProvider(true);
    xsdViewer.setComparer(new IElementComparer() {

        @Override
        public int hashCode(final Object element) {
            return element.hashCode();
        }

        @Override
        public boolean equals(final Object a, final Object b) {
            if (a instanceof XSDFeature && b instanceof XSDFeature) {
                final String aName = ((XSDFeature) a).getName();
                final String bName = ((XSDFeature) b).getName();
                if (aName.equals(bName)) {
                    return EcoreUtil.equals(((XSDFeature) a).getType(), ((XSDFeature) b).getType());
                }
            }
            return a.equals(b);
        }
    });
    xsdViewer.setContentProvider(provider);
    final XSDLabelProvider labelProvider = new XSDLabelProvider();
    xsdViewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
    final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.minimumHeight = 100;
    xsdViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 150).create());
    xsdViewer.setInput(new Object());

    text = new Text(composite, SWT.WRAP | SWT.BORDER);
    text.setLayoutData(GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 40).create());

    xsdViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final ITreeSelection selection = (ITreeSelection) xsdViewer.getSelection();
            //                final String xpath = computeXPath(selection, false);
            //                if (dataName != null) {
            //                    if (xpath == null || xpath.isEmpty()) {
            //                        text.setText(dataName);
            //                    } else {
            //                        text.setText(xpath);
            //                    }
            //                }
            text.redraw();
            //                typeCombo.setSelection(new StructuredSelection(XPathReturnType.getType(selection.getFirstElement())));
            XPathExpressionEditor.this.fireSelectionChanged();
        }
    });

}
 
Example #10
Source File: WorkbenchLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a workbench label provider that is hooked up to the decorator mechanism.
 * @return a new <code>DecoratingLabelProvider</code> which wraps a <code>
 *   new <code>WorkbenchLabelProvider</code>
 */
public static ILabelProvider getDecoratingWorkbenchLabelProvider() {
	return new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench()
			.getDecoratorManager().getLabelDecorator());
}
 
Example #11
Source File: WorkbenchLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a workbench label provider that is hooked up to the decorator mechanism.
 * @return a new <code>DecoratingLabelProvider</code> which wraps a <code>
 *   new <code>WorkbenchLabelProvider</code>
 */
public static ILabelProvider getDecoratingWorkbenchLabelProvider() {
	return new DecoratingLabelProvider(new WorkbenchLabelProvider(), PlatformUI.getWorkbench()
			.getDecoratorManager().getLabelDecorator());
}
 
Example #12
Source File: CopiedWorkbenchLabelProvider.java    From Pydev with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns a workbench label provider that is hooked up to the decorator
 * mechanism.
 *
 * @return a new <code>DecoratingLabelProvider</code> which wraps a <code>
 *   new <code>CopiedWorkbenchLabelProvider</code>
 */
public static ILabelProvider getDecoratingCopiedWorkbenchLabelProvider() {
    return new DecoratingLabelProvider(new CopiedWorkbenchLabelProvider(), PlatformUI.getWorkbench()
            .getDecoratorManager().getLabelDecorator());
}