Search in sources :

Example 1 with DDiagramElement

use of org.eclipse.sirius.diagram.DDiagramElement in project InformationSystem by ObeoNetwork.

the class DatabaseServices method getForeignKeys.

/**
 * Return ForeignKeys from tables.
 * @param tableContainer
 * @return foreignKeys
 */
public List<ForeignKey> getForeignKeys(TableContainer tableContainer, DSemanticDiagram diagram) {
    List<ForeignKey> foreignKeys = new ArrayList<ForeignKey>();
    List<AbstractTable> tables = tableContainer.getTables();
    for (AbstractTable abstractTable : tables) {
        if (abstractTable instanceof Table) {
            foreignKeys.addAll(((Table) abstractTable).getForeignKeys());
        }
    }
    // Foreign keys from external tables on diagram
    for (DDiagramElement diagramElement : diagram.getDiagramElements()) {
        EObject semanticElt = diagramElement.getTarget();
        if (semanticElt instanceof Table) {
            foreignKeys.addAll(((Table) semanticElt).getForeignKeys());
        }
    }
    return foreignKeys;
}
Also used : AbstractTable(org.obeonetwork.dsl.database.AbstractTable) Table(org.obeonetwork.dsl.database.Table) AbstractTable(org.obeonetwork.dsl.database.AbstractTable) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) ForeignKey(org.obeonetwork.dsl.database.ForeignKey) DDiagramElement(org.eclipse.sirius.diagram.DDiagramElement)

Example 2 with DDiagramElement

use of org.eclipse.sirius.diagram.DDiagramElement in project InformationSystem by ObeoNetwork.

the class TaskUtils method candidatesExpressionForExistingActors.

/**
 * Calculate the candidateExpression defines in creation tool Existing
 * Actors in Task Graph.
 *
 * @param context
 *            the context of call
 * @param diagram
 *            the representation
 * @return list of existing Actors
 */
public List<Actor> candidatesExpressionForExistingActors(EObject context, DSemanticDiagram diagram) {
    List<Actor> actors = new ArrayList<Actor>(getSystem(context).getActors());
    List<Actor> actorsInDiagam = new ArrayList<Actor>();
    List<DDiagramElement> ownedDiagramElements = diagram.getOwnedDiagramElements();
    for (DDiagramElement diagramElement : ownedDiagramElements) {
        if (diagramElement.getTarget() instanceof Actor) {
            actorsInDiagam.add((Actor) diagramElement.getTarget());
        }
    }
    actors.removeAll(actorsInDiagam);
    return actors;
}
Also used : Actor(org.obeonetwork.graal.Actor) ArrayList(java.util.ArrayList) DDiagramElement(org.eclipse.sirius.diagram.DDiagramElement)

Example 3 with DDiagramElement

use of org.eclipse.sirius.diagram.DDiagramElement 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)

Example 4 with DDiagramElement

use of org.eclipse.sirius.diagram.DDiagramElement in project Palladio-Editors-Sirius by PalladioSimulator.

the class RemoveConnectorAction method execute.

@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
    DEdge edge = (DEdge) parameters.get("elementView");
    LinkingResource linkingResource = (LinkingResource) edge.getTarget();
    EdgeTarget targetNode = edge.getTargetNode();
    ResourceContainer resourceContainer = (ResourceContainer) (((DDiagramElement) targetNode).getTarget());
    linkingResource.getConnectedResourceContainers_LinkingResource().remove(resourceContainer);
}
Also used : LinkingResource(org.palladiosimulator.pcm.resourceenvironment.LinkingResource) EdgeTarget(org.eclipse.sirius.diagram.EdgeTarget) DDiagramElement(org.eclipse.sirius.diagram.DDiagramElement) DEdge(org.eclipse.sirius.diagram.DEdge) ResourceContainer(org.palladiosimulator.pcm.resourceenvironment.ResourceContainer)

Example 5 with DDiagramElement

use of org.eclipse.sirius.diagram.DDiagramElement in project Palladio-Editors-Sirius by PalladioSimulator.

the class ReconnectTargetOfRecoveryFlow method execute.

@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
    // RecoveryActionBehaviour source = (RecoveryActionBehaviour) parameters.get("source");
    RecoveryActionBehaviour newTarget = (RecoveryActionBehaviour) parameters.get("target");
    RecoveryActionBehaviour element = (RecoveryActionBehaviour) parameters.get("element");
    // Removing the original edge
    DEdge edge = (DEdge) parameters.get("edgeView");
    RecoveryActionBehaviour source = (RecoveryActionBehaviour) edge.getTarget();
    EdgeTarget targetNode = edge.getTargetNode();
    RecoveryActionBehaviour target = (RecoveryActionBehaviour) (((DDiagramElement) targetNode).getTarget());
    // prevent self looping
    if (!element.equals(newTarget)) {
        source.getFailureHandlingAlternatives__RecoveryActionBehaviour().remove(target);
        // Adding it as new connection
        element.getFailureHandlingAlternatives__RecoveryActionBehaviour().add(newTarget);
    }
}
Also used : EdgeTarget(org.eclipse.sirius.diagram.EdgeTarget) DDiagramElement(org.eclipse.sirius.diagram.DDiagramElement) RecoveryActionBehaviour(org.palladiosimulator.pcm.seff.seff_reliability.RecoveryActionBehaviour) DEdge(org.eclipse.sirius.diagram.DEdge)

Aggregations

DDiagramElement (org.eclipse.sirius.diagram.DDiagramElement)8 DEdge (org.eclipse.sirius.diagram.DEdge)3 ArrayList (java.util.ArrayList)2 EObject (org.eclipse.emf.ecore.EObject)2 EdgeTarget (org.eclipse.sirius.diagram.EdgeTarget)2 RecoveryActionBehaviour (org.palladiosimulator.pcm.seff.seff_reliability.RecoveryActionBehaviour)2 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 EditPart (org.eclipse.gef.EditPart)1 CreateEditPoliciesOperation (org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation)1 Node (org.eclipse.gmf.runtime.notation.Node)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 AbstractTable (org.obeonetwork.dsl.database.AbstractTable)1 ForeignKey (org.obeonetwork.dsl.database.ForeignKey)1