Search in sources :

Example 1 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project translationstudio8 by heartsome.

the class WorkbenchLabelProvider method getText.

/*
	 * (non-Javadoc) Method declared on ILabelProvider
	 */
public final String getText(Object element) {
    // query the element for its label
    IWorkbenchAdapter adapter = getAdapter(element);
    if (adapter == null) {
        //$NON-NLS-1$
        return "";
    }
    String label = adapter.getLabel(element);
    // return the decorated label
    return decorateText(label, element);
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) StyledString(org.eclipse.jface.viewers.StyledString)

Example 2 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project translationstudio8 by heartsome.

the class ProjectExplorer method updateTitle.

/**
	 * The superclass does not deal with the content description, handle it
	 * here.
	 * 
	 * @noreference
	 */
public void updateTitle() {
    super.updateTitle();
    Object input = getCommonViewer().getInput();
    if (input == null || input instanceof IAggregateWorkingSet) {
        //$NON-NLS-1$
        setContentDescription("");
        return;
    }
    if (!(input instanceof IResource)) {
        if (input instanceof IAdaptable) {
            IWorkbenchAdapter wbadapter = (IWorkbenchAdapter) ((IAdaptable) input).getAdapter(IWorkbenchAdapter.class);
            if (wbadapter != null) {
                setContentDescription(wbadapter.getLabel(input));
                return;
            }
        }
        setContentDescription(input.toString());
        return;
    }
    IResource res = (IResource) input;
    setContentDescription(res.getName());
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) IAggregateWorkingSet(org.eclipse.ui.IAggregateWorkingSet) IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) IResource(org.eclipse.core.resources.IResource)

Example 3 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project knime-core by knime.

the class KnimeResourceLabelProvider method getText.

/**
 * {@inheritDoc}
 */
@Override
public String getText(final Object element) {
    if (element instanceof NodeContainerUI) {
        String output = ((NodeContainerUI) element).getName() + " (#" + ((NodeContainerUI) element).getID().getIndex() + ")";
        // then it cannot be found
        return output.replace(":", "_");
    }
    // query the element for its label
    IWorkbenchAdapter adapter = getAdapter(element);
    if (adapter == null) {
        // $NON-NLS-1$
        return "";
    }
    String label = adapter.getLabel(element);
    // return the decorated label
    return decorateText(label, element);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter)

Example 4 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project yamcs-studio by yamcs.

the class OPIColor method getAdapter.

@Override
public <T> T getAdapter(Class<T> adapter) {
    if (adapter == IWorkbenchAdapter.class)
        return adapter.cast(new IWorkbenchAdapter() {

            @Override
            public Object getParent(Object o) {
                return null;
            }

            @Override
            public String getLabel(Object o) {
                return getColorName();
            }

            @Override
            public ImageDescriptor getImageDescriptor(Object object) {
                Image image = imageRegistry.get(getID());
                if (image == null) {
                    image = createIcon(getRGBValue());
                    if (imageCount >= MAX_IMG_COUNT) {
                        imageRegistry.dispose();
                        imageCount = 0;
                    }
                    imageRegistry.put(getID(), image);
                    imageCount++;
                }
                return ImageDescriptor.createFromImage(image);
            }

            @Override
            public Object[] getChildren(Object o) {
                return new Object[0];
            }
        });
    return null;
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) Image(org.eclipse.swt.graphics.Image)

Example 5 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project erlide_eclipse by erlang.

the class ErlangElementImageProvider method getWorkbenchImageDescriptor.

/**
 * Returns an image descriptor for a IAdaptable. The descriptor includes
 * overlays, if specified (only error ticks apply). Returns
 * <code>null</code> if no image could be found.
 */
public ImageDescriptor getWorkbenchImageDescriptor(final IAdaptable adaptable, final int flags) {
    final IWorkbenchAdapter wbAdapter = adaptable.getAdapter(IWorkbenchAdapter.class);
    if (wbAdapter == null) {
        return null;
    }
    final ImageDescriptor descriptor = wbAdapter.getImageDescriptor(adaptable);
    if (descriptor == null) {
        return null;
    }
    final Point size = ErlangElementImageProvider.useSmallSize(flags) ? ErlangElementImageProvider.SMALL_SIZE : ErlangElementImageProvider.BIG_SIZE;
    return new ErlangElementImageDescriptor(descriptor, 0, size);
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Point(org.eclipse.swt.graphics.Point)

Aggregations

IWorkbenchAdapter (org.eclipse.ui.model.IWorkbenchAdapter)21 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)6 Image (org.eclipse.swt.graphics.Image)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 Iterator (java.util.Iterator)3 IResource (org.eclipse.core.resources.IResource)3 IPreferenceNode (org.eclipse.jface.preference.IPreferenceNode)3 PropertyPageManager (org.eclipse.ui.internal.dialogs.PropertyPageManager)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 IOException (java.io.IOException)1 LinkedList (java.util.LinkedList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 IContainer (org.eclipse.core.resources.IContainer)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1