Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Hide Sirius legacy tabs in Properties view
Hide Sirius legacy tabs in Properties view [message #1782251] Tue, 20 February 2018 22:06 Go to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Hello !

By default, Sirius provides legacy tabs within the Properties view: one called Main and another called Semantic.

I would like to hide them.

I have tried two solutions:

  • Extend the extension point org.eclipse.eef.properties.ui.eefTabDescriptorFilter ;
  • Change settings in Preferences > Sirius > Sirius Properties View.

Each time I managed to hide Sirius' legacy tabs, but they were removed from every Sirius representation. For example, if I open an EMF meta-model representation and select an EClass, the Semantic tab is hidden and hence not accessible.

What I would like to do is to hide the legacy tabs only from my own Sirius representation.

Anyone knows how to achieve that ?

Thank you in advance for your help.

[Updated on: Tue, 08 January 2019 19:42]

Report message to a moderator

Re: Get rid of Sirius legacy tabs in Properties view [message #1782376 is a reply to message #1782251] Thu, 22 February 2018 13:03 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Hi,

The preference you mention is actually implemented using the eefTabDescriptorFilter extension point. Unfortunately, the API underneath (IEEFTabDescriptorFilter) was not designed with this use case in mind, and can not discriminate depending on the current selection/context. At first glance it seems that it could be modified to support this. Can you open a bugzilla to track this ?

Thanks.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

[Updated on: Thu, 22 February 2018 13:04]

Report message to a moderator

Re: Get rid of Sirius legacy tabs in Properties view [message #1782413 is a reply to message #1782376] Thu, 22 February 2018 19:09 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
Thank you for your suggestion. I've submitted bug 531547.

The Buzilla I've just opened is related to the Sirius product. Should I change this in favor of EEF ?
Re: Get rid of Sirius legacy tabs in Properties view [message #1782414 is a reply to message #1782376] Thu, 22 February 2018 19:09 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
EDIT: sorry, duplicated post

[Updated on: Thu, 22 February 2018 19:11]

Report message to a moderator

Re: Get rid of Sirius legacy tabs in Properties view [message #1782425 is a reply to message #1782413] Fri, 23 February 2018 07:45 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 703
Registered: July 2009
Senior Member
Emmanuel Chebbi wrote on Thu, 22 February 2018 20:09

The Buzilla I've just opened is related to the Sirius product. Should I change this in favor of EEF ?


No, don't worry about that. We'll do that ourselves if indeed the change only impacts EEF itself. Thanks for your feedback.


Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Get rid of Sirius legacy tabs in Properties view [message #1800829 is a reply to message #1782425] Tue, 08 January 2019 19:42 Go to previous message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
I finally had time to test the enhancement of the extension point and it works like a charm!

In case anyone interested in using it finds this thread, here is how I managed to hide Sirius tabs with Sirius 6.1.1:


  1. Contribute to the eefTabDescriptorFilter extension point
    <plugin>
      <extension
            point="org.eclipse.eef.properties.ui.eefTabDescriptorFilter">
         <descriptor
               class="legacy.sirius.tab.filter.LegacyTabFilter"
               description="Filters out Sirius' legacy tabs from the Properties view when editing custom models with a Sirius based diagram editor."
               id="legacy.sirius.tab.filter"
               label="Filter Legacy Sirius Tabs">
         </descriptor>
      </extension>
    </plugin>
    

  2. Implement the filter
    package legacy.sirius.tab.filter;
    
    import static java.util.Arrays.asList;
    
    import java.util.HashSet;
    import java.util.Set;
    
    import org.eclipse.eef.properties.ui.api.IEEFTabDescriptor;
    import org.eclipse.eef.properties.ui.api.IEEFTabDescriptorFilter;
    import org.eclipse.emf.ecore.EObject;
    import org.eclipse.gef.EditPart;
    import org.eclipse.gmf.runtime.notation.View;
    import org.eclipse.jface.viewers.ISelection;
    import org.eclipse.jface.viewers.StructuredSelection;
    import org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditor;
    import org.eclipse.sirius.viewpoint.DSemanticDecorator;
    import org.eclipse.ui.IWorkbenchPart;
    
    /**
     * Used to filter out Sirius legacy tabs from the Properties view
     * when the selection is a custom model.
     */
    public class LegacyTabFilter implements IEEFTabDescriptorFilter {
    	
    	/** IDs of the pages to filter out */
    	private static final Set<String> TABS_TO_FILTER_OUT = new HashSet<>(
    			asList("sirius_default_rules_defaultpagesirius_default_rules_defaultgroup", 
    				   "property.tab.semantic", 
    				   "property.tab.documentation",
    				   "property.tab.style",
    				   "property.tab.behaviors",
    				   "property.tab.DiagramPropertySection",
    				   "property.tab.AppearancePropertySection"
    			)
    	);
    
    	@Override
    	public boolean filter(IEEFTabDescriptor tabDescriptor, IWorkbenchPart part, ISelection selection) {
    		if (! isSiriusDiagram(part) || ! tabMustBeFilteredOut(tabDescriptor))
    			return true;
    		
    		try {
    			Object selectedElement = ((StructuredSelection) selection).getFirstElement();
    			View view = (View) ((EditPart) selectedElement).getModel();
    			DSemanticDecorator container = (DSemanticDecorator) view.getElement();
    					
    			return ! isCustomObject(container.getTarget());
    
    		} catch (ClassCastException e) {
    			// The selection does not match our expectations but that's not a problem.
    			// Using a try statement instead of instanceof makes the code clearer.
    		}
    		return true;
    	}
    	
    	private static boolean isCustomObject(EObject object) {
    		return false; // TODO implement true test, for example 'object instanceof MyModel'
    	}
    	
    	private static boolean isSiriusDiagram(IWorkbenchPart part) {
    		return part instanceof SiriusDiagramEditor;
    	}
    
    	private static boolean tabMustBeFilteredOut(IEEFTabDescriptor tabDescriptor) {
    		// 'startsWith' because the ID of the 'Main' group is dynamic and has a suffix at runtime
    		return TABS_TO_FILTER_OUT.stream()
    								 .anyMatch(id -> tabDescriptor.getId().startsWith(id));
    	}
    
    }
    


You have to implement the isCustomObjectmethod in order to make it return true if Sirius' tabs must be hidden for this object.

Note: the filter method must return true to show the tab and false to hide it.

Thank you very much for the improvement,
Regards,
Previous Topic:Header Column of Sirius table
Next Topic:Drop in Diagram from custom source
Goto Forum:
  


Current Time: Sat Apr 20 03:41:42 GMT 2024

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

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

Back to the top