如何在资源上删除以前添加的装饰器? [英] How to remove a previously added decorator on a resource?

查看:268
本文介绍了如何在资源上删除以前添加的装饰器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里有人知道如何删除资源上的特定装饰器?我将 org.eclipse.ui.decorators 扩展到我的项目,并创建了一个实现 ILightweightLabelDecorator 的类。在装饰器类中,我测试了条目是否是项目,并在调用 decorator.addOverlay()之前进行其他测试。我没有实现其他功能,例如 removeListener isLabelProperty dispose addListener ,因为我目前看不到使用。
任何想法,资源,关于如何进行的评论将大有帮助。

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.

代码:装饰功能

    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]");

        }
    }


推荐答案

对于有同样问题的人,可以使用 LabelProviderChangedEvent

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

这篇关于如何在资源上删除以前添加的装饰器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆