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);
}
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());
}
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);
}
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;
}
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);
}
Aggregations