Bug 527395 - Creating layer-dependent tabbar extensions should be simpler
Summary: Creating layer-dependent tabbar extensions should be simpler
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 5.1.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-11-17 05:38 EST by Felix Dorner CLA
Modified: 2017-11-21 12:36 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Dorner CLA 2017-11-17 05:38:55 EST
This is an enhancement request to make the creation for layer-dependent tabbar extensions easier. 

The general idea is that activation/deactivation of a Layer can potentially add/remove new contributions to the tabbar of the diagram editor. 

At the moment, the only way to react to layer changes is outlined by Pierre in this forum thread:

https://www.eclipse.org/forums/index.php/t/1087666/

It would be easier if this could be handled through UI mechanisms rather than listening to the model directly:

* Maybe the tabbar could be updated when layers become active/inactive automatically? 

* I have no clue about E4, but maybe something like this would also work: Provide an additional context variable (activeLayers) which could then be used in a visibleWhen expression. When a layer becomes active, sirius runtime would just update the context variable and the workbench would do the rest. This way, the tabbar would only need updating if there are actually contributions that depend on the value of that variable.. (That is however really just my mental model of how E4 works, maybe it is completely off..)
Comment 1 Felix Dorner CLA 2017-11-17 06:04:55 EST
I just found about org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.TabbarRefresher so there shouldn't be no need to add a custom resource set listener as outlined in the forum thread. Still, the visibleWhen context isn't evaluated when the tabbar refresher runs. I'll keep investigating.
Comment 2 Florian Barbin CLA 2017-11-21 12:36:06 EST
Hi Felix thanks for the bug report.
The org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.TabbarFillerWithContributions.update(ISelection) only updates the visibility of tabbar items according to the type of the selected element: a DDiagramElement or the DDiagram.
For now, contribute your own tabbar may fit your needs (the default tabbar actions can be reused). See https://www.eclipse.org/sirius/doc/developer/extensions-provide_tabbar_extensions.html#contributeFullTabbar. The extension point let you to provide a TabbarContributor that will return IContributionItems according to the selection. You are free to implement your own rule, based on the selected layer for instance.