org.eclipse.ui.model.IWorkbenchAdapter2 Java Examples

The following examples show how to use org.eclipse.ui.model.IWorkbenchAdapter2. 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 Font getFont(Object element) {
    IWorkbenchAdapter2 adapter = getAdapter2(element);
    if (adapter == null) {
        return null;
    }

    FontData descriptor = adapter.getFont(element);
    if (descriptor == null) {
        return null;
    }

    try {
        return resourceManager.createFont(FontDescriptor.createFrom(descriptor));
    } catch (Exception e) {
        Log.log(e);
        return null;
    }

}
 
Example #2
Source File: CopiedWorkbenchLabelProvider.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private Color getColor(Object element, boolean forground) {
    IWorkbenchAdapter2 adapter = getAdapter2(element);
    if (adapter == null) {
        return null;
    }
    RGB descriptor = forground ? adapter.getForeground(element) : adapter.getBackground(element);
    if (descriptor == null) {
        return null;
    }

    try {
        return resourceManager.createColor(ColorDescriptor.createFrom(descriptor));
    } catch (Exception e) {
        Log.log(e);
        return null;
    }

}
 
Example #3
Source File: WorkbenchLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Font getFont(Object element) {
	IWorkbenchAdapter2 adapter = getAdapter2(element);
	if (adapter == null) {
		return null;
	}

	FontData descriptor = adapter.getFont(element);
	if (descriptor == null) {
		return null;
	}

	return (Font) getResourceManager().get(FontDescriptor.createFrom(descriptor));
}
 
Example #4
Source File: WorkbenchLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Object element, boolean forground) {
	IWorkbenchAdapter2 adapter = getAdapter2(element);
	if (adapter == null) {
		return null;
	}
	RGB descriptor = forground ? adapter.getForeground(element) : adapter.getBackground(element);
	if (descriptor == null) {
		return null;
	}

	return (Color) getResourceManager().get(ColorDescriptor.createFrom(descriptor));
}
 
Example #5
Source File: WorkbenchLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
public Font getFont(Object element) {
	IWorkbenchAdapter2 adapter = getAdapter2(element);
	if (adapter == null) {
		return null;
	}

	FontData descriptor = adapter.getFont(element);
	if (descriptor == null) {
		return null;
	}

	return (Font) getResourceManager().get(FontDescriptor.createFrom(descriptor));
}
 
Example #6
Source File: WorkbenchLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private Color getColor(Object element, boolean forground) {
	IWorkbenchAdapter2 adapter = getAdapter2(element);
	if (adapter == null) {
		return null;
	}
	RGB descriptor = forground ? adapter.getForeground(element) : adapter.getBackground(element);
	if (descriptor == null) {
		return null;
	}

	return (Color) getResourceManager().get(ColorDescriptor.createFrom(descriptor));
}
 
Example #7
Source File: WrappedResource.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public static <T> T getAdapterFromActualObject(IResource actualObject2, Class<T> adapter) {
    if (IDeferredWorkbenchAdapter.class.equals(adapter) || IWorkbenchAdapter2.class.equals(adapter)
            || IWorkbenchAdapter.class.equals(adapter)) {
        return null;
    }
    return actualObject2.getAdapter(adapter);
}
 
Example #8
Source File: WorkbenchLabelProvider.java    From translationstudio8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the implementation of IWorkbenchAdapter2 for the given object.
 * @param o
 *            the object to look up.
 * @return IWorkbenchAdapter2 or<code>null</code> if the adapter is not defined or the object is not adaptable.
 */
protected final IWorkbenchAdapter2 getAdapter2(Object o) {
	return (IWorkbenchAdapter2) Util.getAdapter(o, IWorkbenchAdapter2.class);
}
 
Example #9
Source File: WorkbenchLabelProvider.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns the implementation of IWorkbenchAdapter2 for the given object.
 * @param o
 *            the object to look up.
 * @return IWorkbenchAdapter2 or<code>null</code> if the adapter is not defined or the object is not adaptable.
 */
protected final IWorkbenchAdapter2 getAdapter2(Object o) {
	return (IWorkbenchAdapter2) Util.getAdapter(o, IWorkbenchAdapter2.class);
}
 
Example #10
Source File: CopiedWorkbenchLabelProvider.java    From Pydev with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the implementation of IWorkbenchAdapter2 for the given
 * object.
 * @param o the object to look up.
 * @return IWorkbenchAdapter2 or<code>null</code> if the adapter is not defined or the
 * object is not adaptable.
 */
protected final IWorkbenchAdapter2 getAdapter2(Object o) {
    return utilGetAdapter(o, IWorkbenchAdapter2.class);
}