一个人怎么会用从Eclipse中的JFace IDecorationContext API [英] How would one use IDecorationContext api from Eclipse JFace

查看:261
本文介绍了一个人怎么会用从Eclipse中的JFace IDecorationContext API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个例子在那里使用 IDecorationContext 为标签的装饰?

Is there an example out there for using IDecorationContext for label decorations?

这是它的外观, IDecorationContext 类似乎提供了某种语境装修支持,但对我的生命,我找不到任何样品code。使用此功能...

By the looks of it, IDecorationContext class seems to provide some sort of contextual decoration support, but for the life of me, I can not find any sample code using this feature...

有没有人实际使用的装饰方面的特征,如果是的话,它解决哪些用例?

Has anybody actually used decoration context feature and if so, what use cases did it solve?

PS:我要寻找一种方式来应用图像装饰对象的标签,并根据显示对象,其中,底座图标的大小而变化(如表 - 传统的小图标树项目和内容头部较大的图标)。

PS: I am looking for a way to apply image decorations to object labels and depending on where the object is displayed, the base icon size varies (e.g. traditional "small" icons in table- and tree items and larger icons for content headers).

适用于原来的图标的装饰应该相应地选择合适大小的装饰品。

The decorations applied to the original icons should choose appropriate size decorations accordingly.

IDecorationContext 似乎适应什么,我需要它的法案,但该文件是稀疏的人们可以从一个开源库,并有一个小的功能期待在被发现没有例子。

IDecorationContext seems to fit the bill for what I need it for, but the documentation is as sparse as one can expect from a minor feature of an open source library and there are no examples to be found.

谷歌搜索的的IDecorationContext的并没有透露什么有趣或者,让我转向StackOverflow的人群的智慧,希望未来的家伙得到的问题是能够得到他们的回答快;)

Googling for the "IDecorationContext" did not reveal anything interesting either, so I turn to StackOverflow crowd wisdom in hopes next guy getting the question would be able to get their answer faster ;)

推荐答案

我没有用IDecorationContext,但你可以看到它在使用<一个href=\"http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface/src/org/eclipse/jface/viewers/LabelDecorator.java?view=co\"><$c$c>org.eclipse.jface.viewers.LabelDecorator.

I did not use IDecorationContext, but you can see it used in org.eclipse.jface.viewers.LabelDecorator.

这也是在讨论这个线程(即使没有答案,那至少可以给你一个起点)

It is also discussed in this thread (even if there are no answer, that can at least give you a starting point)

我目前的做法是延长使用org.eclipse.ui.decorators
ILightweightLabelDecorator添加更换叠加到相应
图标:

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) {
         }
      }
   }

   ...
}

这篇关于一个人怎么会用从Eclipse中的JFace IDecorationContext API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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