Search in sources :

Example 1 with Decoration

use of org.eclipse.sirius.viewpoint.Decoration in project InformationSystem by ObeoNetwork.

the class Activator method refreshDecorationsOnDiagram.

private void refreshDecorationsOnDiagram(final DSemanticDiagram diagram, final Session session) {
    EList<AdditionalLayer> activatedTransientLayers = diagram.getActivatedTransientLayers();
    for (final AdditionalLayer additionalLayer : activatedTransientLayers) {
        // We want the "EObjectWithRequirement" layer
        if (REQUIREMENTS_DECORATION_LAYER_NAME.equals(additionalLayer.getName())) {
            TransactionalEditingDomain ted = session.getTransactionalEditingDomain();
            ted.getCommandStack().execute(new RecordingCommand(ted) {

                @Override
                protected void doExecute() {
                    // Due to a bug in Sirius we have to remove the existing decorations before calling the update method
                    for (DDiagramElement diagElement : diagram.getDiagramElements()) {
                        Iterator<Decoration> it = diagElement.getTransientDecorations().iterator();
                        while (it.hasNext()) {
                            Decoration decoration = it.next();
                            if (REQUIREMENTS_DECORATION_NAME.equals(decoration.getDescription().getName())) {
                                it.remove();
                            }
                        }
                    }
                    List<Layer> layersToRefresh = Arrays.asList((Layer) additionalLayer);
                    new DecorationHelper(diagram).updateDecorations(layersToRefresh);
                }
            });
        }
    }
}
Also used : DecorationHelper(org.eclipse.sirius.diagram.business.api.helper.decoration.DecorationHelper) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) RecordingCommand(org.eclipse.emf.transaction.RecordingCommand) Iterator(java.util.Iterator) EList(org.eclipse.emf.common.util.EList) List(java.util.List) AdditionalLayer(org.eclipse.sirius.diagram.description.AdditionalLayer) DDiagramElement(org.eclipse.sirius.diagram.DDiagramElement) Layer(org.eclipse.sirius.diagram.description.Layer) AdditionalLayer(org.eclipse.sirius.diagram.description.AdditionalLayer) Decoration(org.eclipse.sirius.viewpoint.Decoration)

Aggregations

Iterator (java.util.Iterator)1 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 RecordingCommand (org.eclipse.emf.transaction.RecordingCommand)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 DDiagramElement (org.eclipse.sirius.diagram.DDiagramElement)1 DecorationHelper (org.eclipse.sirius.diagram.business.api.helper.decoration.DecorationHelper)1 AdditionalLayer (org.eclipse.sirius.diagram.description.AdditionalLayer)1 Layer (org.eclipse.sirius.diagram.description.Layer)1 Decoration (org.eclipse.sirius.viewpoint.Decoration)1