Search in sources :

Example 6 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project jbosstools-hibernate by jbosstools.

the class AnyAdaptableLabelProvider 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 (element instanceof String) {
        return (String) element;
    }
    if (adapter == null) {
        String out = NLS.bind(HibernateConsoleMessages.AnyAdaptableLabelProvider_unknown, element.getClass().getName(), element);
        return out;
    }
    String label = adapter.getLabel(element);
    // return the decorated label
    return decorateText(label, element);
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter)

Example 7 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project jbosstools-hibernate by jbosstools.

the class AnyAdaptableLabelProvider method getImage.

/* (non-Javadoc)
     * Method declared on ILabelProvider
     */
public final Image getImage(Object element) {
    // obtain the base image by querying the element
    IWorkbenchAdapter adapter = getAdapter(element);
    ImageDescriptor descriptor = null;
    if (adapter == null) {
        descriptor = EclipseImages.getImageDescriptor(ImageConstants.ERROR);
    } else {
        descriptor = adapter.getImageDescriptor(element);
    }
    if (descriptor == null) {
        return null;
    }
    // add any annotations to the image descriptor
    descriptor = decorateImage(descriptor, element);
    return resourceManager.createImage(descriptor);
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

Example 8 with IWorkbenchAdapter

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

the class FileExplorerLabelProvider 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);
    // $NON-NLS-1$
    return decorateText(label.equals("") ? ((IFileStore) element).toString() : label, element);
// changed to display drive labels - end
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) IFileStore(org.eclipse.core.filesystem.IFileStore)

Example 9 with IWorkbenchAdapter

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

the class FileExplorerLabelProvider method getImage.

/*
     * (non-Javadoc) Method declared on ILabelProvider
     */
public final Image getImage(Object element) {
    // obtain the base image by querying the element
    IWorkbenchAdapter adapter = getAdapter(element);
    if (adapter == null) {
        return null;
    }
    ImageDescriptor descriptor = adapter.getImageDescriptor(element);
    if (descriptor == null) {
        return null;
    }
    // add any annotations to the image descriptor
    descriptor = decorateImage(descriptor, element);
    return (Image) resourceManager.get(descriptor);
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

Example 10 with IWorkbenchAdapter

use of org.eclipse.ui.model.IWorkbenchAdapter in project ecf by eclipse.

the class MultiRosterLabelProvider method getImage.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
	 */
public Image getImage(Object element) {
    IWorkbenchAdapter adapter = getAdapter(element);
    if (adapter == null)
        return null;
    ImageDescriptor descriptor = adapter.getImageDescriptor(element);
    if (descriptor == null)
        return null;
    Image image = (Image) imageTable.get(descriptor);
    if (image == null) {
        image = descriptor.createImage();
        imageTable.put(descriptor, image);
    }
    return image;
}
Also used : IWorkbenchAdapter(org.eclipse.ui.model.IWorkbenchAdapter) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Image(org.eclipse.swt.graphics.Image)

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