How to remove a previously added decorator on a resource?

旧时模样 提交于 2019-12-11 07:28:35

问题


Does anyone here knows how to remove a particular decorator on a resource? I extended org.eclipse.ui.decorators to my project and created a class that implements ILightweightLabelDecorator. In the decorator class I tested if the entry was a project and other test before calling decorator.addOverlay(). I did not implemented the other functions such as removeListener, isLabelProperty, dispose, addListener since I currently do not see the use. Any idea, resources, comment on how to proceed would greatly help.

Code: decorator function

    QualifiedName decorator = new QualifiedName("decorator", "value");

    if (element instanceof IProject) {
        IProject res = (IProject) element;

        if (!res.isOpen()) {
            return;
        }

        String val = null;
        try {
            val = res.getPersistentProperty(decorator);

        } catch (CoreException e) {
            e.printStackTrace();
        }

        if (val != null && val.equals(DecoratorState.ACTIVE)) {

            decoration.addOverlay(ImageDescriptor.createFromFile(MyDecorator.class, 
                    "/icons/sample.gif"), IDecoration.BOTTOM_RIGHT);
            decoration.addSuffix(" [Using Enhancement]");

        }
    }

回答1:


For anyone who is having that same issue, it can be fixed with LabelProviderChangedEvent



来源:https://stackoverflow.com/questions/9998339/how-to-remove-a-previously-added-decorator-on-a-resource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!