Java Code Examples for org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor()

The following examples show how to use org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor() . 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: CopiedWorkbenchLabelProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public 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);

    try {
        return resourceManager.createImage(descriptor);
    } catch (Exception e) {
        Log.log(e);
        return null;
    }
}
 
Example 2
Source File: JavaElementImageProvider.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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.
 * @param adaptable the adaptable
 * @param flags the image flags
 * @return returns the image descriptor
 */
public ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable, int flags) {
	IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
	if (wbAdapter == null) {
		return null;
	}
	ImageDescriptor descriptor= wbAdapter.getImageDescriptor(adaptable);
	if (descriptor == null) {
		return null;
	}

	Point size= useSmallSize(flags) ? SMALL_SIZE : BIG_SIZE;
	return new JavaElementImageDescriptor(descriptor, 0, size);
}
 
Example 3
Source File: WorkbenchLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public final Image getImage(Object element) {
	// obtain the base image by querying the element
	ImageDescriptor descriptor = null;
	if (element instanceof IProject) {
		IProject project = (IProject) element;
		if (project.isOpen()) {
			descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
					"net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/prj_open.png");
		} else {
			descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
					"net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/prj_close.png");
		}
	} else if (element instanceof IFolder) {
		descriptor = AbstractUIPlugin.imageDescriptorFromPlugin("net.heartsome.cat.common.ui.navigator.resources",
				"icons/full/obj16/folder.png");
	}

	else {
		IWorkbenchAdapter adapter = getAdapter(element);
		if (adapter == null) {
			return null;
		}
		descriptor = adapter.getImageDescriptor(element);
		if (descriptor == null) {
			return null;
		}

		// add any annotations to the image descriptor
		descriptor = decorateImage(descriptor, element);
	}
	return (Image) getResourceManager().get(descriptor);
}
 
Example 4
Source File: WorkbenchLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public final Image getImage(Object element) {
	// obtain the base image by querying the element
	ImageDescriptor descriptor = null;
	if (element instanceof IProject) {
		IProject project = (IProject) element;
		if (project.isOpen()) {
			descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
					"net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/prj_open.png");
		}else {
			descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
					"net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/prj_close.png");
		}
	} else if(element instanceof IFolder){
		 descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
					"net.heartsome.cat.common.ui.navigator.resources", "icons/full/obj16/folder.png");
	}
	
	else {
		IWorkbenchAdapter adapter = getAdapter(element);
		if (adapter == null) {
			return null;
		}
		descriptor = adapter.getImageDescriptor(element);
		if (descriptor == null) {
			return null;
		}

		// add any annotations to the image descriptor
		descriptor = decorateImage(descriptor, element);
	}
	return (Image) getResourceManager().get(descriptor);
}
 
Example 5
Source File: LangNavigatorLabelProvider.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected ImageDescriptor getWorkbenchImageDescriptor(IAdaptable adaptable) {
	IWorkbenchAdapter workbenchAdapter= (IWorkbenchAdapter) adaptable.getAdapter(IWorkbenchAdapter.class);
	if (workbenchAdapter == null) {
		return null;
	}
	ImageDescriptor descriptor = workbenchAdapter.getImageDescriptor(adaptable);
	
	return descriptor;
}
 
Example 6
Source File: StorageBasedTextEditorOpener.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public ImageDescriptor getImageDescriptor() {
	IWorkbenchAdapter workbenchAdapter = adapt(storage, IWorkbenchAdapter.class);
	return workbenchAdapter != null ? workbenchAdapter.getImageDescriptor(storage) : null;
}
 
Example 7
Source File: RemoteFileEditorInput.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @see IWorkbenchAdapter#getImageDescriptor
 */
public ImageDescriptor getImageDescriptor(Object object) {
	IWorkbenchAdapter fileAdapter = (IWorkbenchAdapter)file.getAdapter(IWorkbenchAdapter.class);
	return fileAdapter == null ? null : fileAdapter.getImageDescriptor(file);
}
 
Example 8
Source File: PropertyKeyHyperlink.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public ImageDescriptor getImageDescriptor(Object object) {
	IWorkbenchAdapter wbAdapter= (IWorkbenchAdapter) resource.getAdapter(IWorkbenchAdapter.class);
	if (wbAdapter != null)
		return wbAdapter.getImageDescriptor(resource);
	return null;
}
 
Example 9
Source File: RemoteFileEditorInput.java    From APICloud-Studio with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Returns the image descriptor for this input.
 *
 * @return the image descriptor for this input
 */
public ImageDescriptor getImageDescriptor() {
	IWorkbenchAdapter fileAdapter = (IWorkbenchAdapter)file.getAdapter(IWorkbenchAdapter.class);
	return fileAdapter == null ? null : fileAdapter.getImageDescriptor(file);
}