Custom icons for workbench content [message #34178] |
Sat, 22 November 2008 09:29 |
Eclipse User |
|
|
|
Originally posted by: jkan.tzi.de
Hi,
For a custom project nature, i have to replace the default icon of
certain folders in the project explorer view, depending on its contents
(files und subfolders).
My current approach is to extend org.eclipse.ui.decorators using a
ILightweightLabelDecorator to add a replace overlay to the respective
icons:
public class ProjectLabelDecorator extends LabelProvider
implements ILightweightLabelDecorator {
...
public void decorate(Object element, IDecoration decoration) {
if (element instanceof IFolder) {
IFolder folder = (IFolder) element;
try {
if (folder.getProject().hasNature("rttdt.nature")) {
if (ProjectNature.isTestcase(folder)) {
IDecorationContext context =
decoration.getDecorationContext();
if (context instanceof DecorationContext) {
((DecorationContext) context).putProperty(
IDecoration.ENABLE_REPLACE, Boolean.TRUE);
}
decoration.addOverlay(fTestcaseOverlay,
IDecoration.REPLACE);
}
} catch (CoreException e) {
}
}
}
...
}
I'm not happy with this solution, since there is a delay between the
expansion of a folder and the display of the custom icon.
My question: is there a better way for conditionally replacing resource
icons, without the need for extending
org.eclipse.ui.navigator.navigatorContent and providing a custom content
provider?
Johannes
|
|
|
Powered by
FUDForum. Page generated in 0.02972 seconds