开发者

How to update the package explorer manually (Preferences)

I have added a custom LabelDecorator to an Eclipse 3.6, which re开发者_高级运维places the cryptic usernames added by the SVN Team Text Decorations. The SVN Team Decorator allows you to add an author tag. What I did was adding another Decorator replacing these author strings (which are company specific shortnames with numbers) with the actual name of the user.

While SVN Team Text Decorations extends the Package Explorer with:

... com.company.package · XY9723 · [30.02.11 19:11]

I replace that by

... com.company.package · Neil Diamond · [30.02.11 19:11]

Now, to complete the mission, I added a preference page, where users are able to specify the attributes (name, forename, birthdate, company name, telephone, etc.), which should be used as replacement. I'd like to update the package explorer (or whereever svn team decorates ressources) with the newly selected attributes whenever "Apply" or "Ok" is pressed. At the moment the ressources are only updated after you have pressed "Apply" or "Ok" and manually collapse/expand one of the ressource in the explorer.

Is there some event I could fire?


Use the IDecorationManager interface:

IWorkbench workbench = ...;
IDecoratorManager manager = workbench.getDecoratorManager();

inside of the prefernce pages LabelProvider:

ILabelDecorator decorator = manager.getLabelDecorator("com.plugin.mydecorator");
if(decorator != null){ // decorator is enabled
    LabelProviderChangedEvent event = new LabelProviderChangedEvent(demoDecorator);
    // update specific resources
    fireLabelEvent(event, arrayOfResourceToUpdate);

    // or update all resources
    fireLabelEvent(event);
}

-> see Understanding Decorators

without a LabelProvider

manager.update("com.plugin.mydecorator");

-> see DecoratorManager.java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜