Search in sources :

Example 1 with NewNestedRelationDialog

use of com.archimatetool.editor.diagram.dialog.NewNestedRelationDialog in project archi by archimatetool.

the class CreateNestedArchimateConnectionsWithDialogCommand method createConnectionDialogCommands.

/**
 * Child Objects that don't have a relationship set with parent - ask user if they want one
 */
void createConnectionDialogCommands() {
    // Gather suitable child objects
    List<IDiagramModelArchimateObject> childObjectsForDialog = new ArrayList<IDiagramModelArchimateObject>();
    for (IDiagramModelArchimateObject childObject : fChildObjects) {
        if (canAddNewRelationship(fParentObject, childObject)) {
            childObjectsForDialog.add(childObject);
        }
    }
    // One child object
    if (childObjectsForDialog.size() == 1) {
        NewNestedRelationDialog dialog = new NewNestedRelationDialog(fParentObject, childObjectsForDialog.get(0));
        if (dialog.open() == Window.OK) {
            EClass eClass = dialog.getSelectedType();
            if (eClass != null) {
                Command cmd = new CreateRelationshipAndDiagramArchimateConnectionCommand(fParentObject, childObjectsForDialog.get(0), eClass);
                add(cmd);
            }
        }
    } else // More than one child object
    if (childObjectsForDialog.size() > 1) {
        NewNestedRelationsDialog dialog = new NewNestedRelationsDialog(fParentObject, childObjectsForDialog);
        if (dialog.open() == Window.OK) {
            List<SelectedRelationshipType> selectedTypes = dialog.getSelectedTypes();
            for (SelectedRelationshipType selType : selectedTypes) {
                Command cmd = new CreateRelationshipAndDiagramArchimateConnectionCommand(fParentObject, selType.childObject, selType.relationshipType);
                add(cmd);
            }
        }
    }
}
Also used : EClass(org.eclipse.emf.ecore.EClass) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) SelectedRelationshipType(com.archimatetool.editor.diagram.dialog.NewNestedRelationsDialog.SelectedRelationshipType) NewNestedRelationDialog(com.archimatetool.editor.diagram.dialog.NewNestedRelationDialog) ArrayList(java.util.ArrayList) List(java.util.List) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) NewNestedRelationsDialog(com.archimatetool.editor.diagram.dialog.NewNestedRelationsDialog)

Aggregations

NewNestedRelationDialog (com.archimatetool.editor.diagram.dialog.NewNestedRelationDialog)1 NewNestedRelationsDialog (com.archimatetool.editor.diagram.dialog.NewNestedRelationsDialog)1 SelectedRelationshipType (com.archimatetool.editor.diagram.dialog.NewNestedRelationsDialog.SelectedRelationshipType)1 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 EClass (org.eclipse.emf.ecore.EClass)1 Command (org.eclipse.gef.commands.Command)1 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)1