Hide Sirius legacy tabs in Properties view [message #1782251] |
Tue, 20 February 2018 22:06 |
Emmanuel Chebbi 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 #1800829 is a reply to message #1782425] |
Tue, 08 January 2019 19:42 |
Emmanuel Chebbi 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:
- 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>
- 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,
|
|
|
Powered by
FUDForum. Page generated in 0.03612 seconds