Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Custom LabelProvider for Tree Descriptions
Custom LabelProvider for Tree Descriptions [message #1752905] Mon, 30 January 2017 13:48 Go to next message
Hendrik Buender is currently offline Hendrik BuenderFriend
Messages: 13
Registered: January 2017
Location: Bonn
Junior Member
Hi,

I've been using Sirius for a few days now to create a graphical editor for an Xtext DSL and I am very impressed by the variety of extensible features. However, I am currently struggling with dynamically providing icons for tree elements.
By using the IStyleConfigurationProvider as described by [1] I was able to reuse the DSL's LabelProvider so that icons could be provided dynamically. While that approach works for diagrams I didn't find a way to reuse the DSL's LabelProvider for a tree description.
Is there a way to make the Tree description as described by [2] reuse an existing LabelProvider to provide text and icons for the Tree View?

Thanks for any help.

Hendrik

[1] https://www.eclipse.org/sirius/doc/developer/extensions-provide_custom_style.html
[2] https://www.eclipse.org/sirius/doc/specifier/trees/Trees.html
Re: Custom LabelProvider for Tree Descriptions [message #1753022 is a reply to message #1752905] Wed, 01 February 2017 08:42 Go to previous messageGo to next message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Hi Hendrick,

Actually this behavior was broken in diagrams and has been fixed with this bugzilla: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475685
This feature is not properly handled in the Tree representation and the current workaround is defining conditional styles to reproduce the same logic.
I don't think there is a bugzilla about this issue so please feel free to raise a new one.

Regards,

Florian
Re: Custom LabelProvider for Tree Descriptions [message #1753075 is a reply to message #1753022] Wed, 01 February 2017 16:35 Go to previous messageGo to next message
Hendrik Buender is currently offline Hendrik BuenderFriend
Messages: 13
Registered: January 2017
Location: Bonn
Junior Member
Hi Florian,

thanks for your quick reply. Using conditional styles as workaround sounds promising.

Before I create a bugzilla report I want to make sure that we are on the same page. I want to be able to dynamically (meaning programatically) change the label of an element in a Tree or Table representation. That would be similiar to the following code snippet showing that feature for diagrams as described by [1]

public class SimpleStyleConfiguration implements StyleConfiguration {

 public Image getLabelIcon(DDiagramElement vpElement) {
        EObject target = vpElement;
        if (vpElement instanceof DSemanticDecorator) {
            target = ((DSemanticDecorator) vpElement).getTarget();
        }
        if (isShowIcon(vpElement)) {
            if (target != null) {
                IItemLabelProvider labelProvider = (IItemLabelProvider) SiriusDiagramEditorPlugin.getInstance()
                		.getItemProvidersAdapterFactory().adapt(target, IItemLabelProvider.class);
                if (labelProvider != null) {
                    ImageDescriptor descriptor = ExtendedImageRegistry.getInstance().getImageDescriptor(labelProvider.getImage(target));
                    if (descriptor == null) {
                        descriptor = ImageDescriptor.getMissingImageDescriptor();
                    }
                    return SiriusDiagramEditorPlugin.getInstance().getImage(descriptor);
                }
            }
        }
        return null;
    }
}



Cheers,

Hendrik

[1] https://www.eclipse.org/sirius/doc/developer/extensions-provide_custom_style.html



Re: Custom LabelProvider for Tree Descriptions [message #1753293 is a reply to message #1753075] Fri, 03 February 2017 11:11 Go to previous message
Florian Barbin is currently offline Florian BarbinFriend
Messages: 270
Registered: August 2010
Senior Member
Ok, there is 2 things:
- Tree representations are not properly refreshed when the label or icon returned by the LabelItemProvider change.
- The StyleConfiguration is probably not supported in Tree representation. This extension has been initially created for diagrams a long time ago Smile

Regards,

Florian
Previous Topic:Potential Performance Leak when using an Xtext + Xbase DSL
Next Topic:Java Services in diagram exported as update site
Goto Forum:
  


Current Time: Mon Sep 23 19:47:36 GMT 2024

Powered by FUDForum. Page generated in 0.03650 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top