Search in sources :

Example 1 with CreateDiagramArchimateConnectionWithDialogCommand

use of com.archimatetool.editor.diagram.commands.CreateDiagramArchimateConnectionWithDialogCommand in project archi by archimatetool.

the class ArchimateDiagramConnectionPolicy method getConnectionCreateCommand.

@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
    CreateDiagramConnectionCommand cmd = null;
    EClass classType = (EClass) request.getNewObjectType();
    IConnectable source = (IConnectable) getHost().getModel();
    // Plain Connection
    if (classType == IArchimatePackage.eINSTANCE.getDiagramModelConnection()) {
        if (isValidConnectionSource(source, classType)) {
            cmd = new CreateDiagramConnectionCommand(request);
        }
    } else // Archimate Model Component Source
    if (source instanceof IDiagramModelArchimateComponent) {
        if (isValidConnectionSource(source, classType)) {
            cmd = new CreateDiagramArchimateConnectionWithDialogCommand(request);
        }
    }
    if (cmd != null) {
        cmd.setSource(source);
        request.setStartCommand(cmd);
    }
    return cmd;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IConnectable(com.archimatetool.model.IConnectable) CreateDiagramArchimateConnectionWithDialogCommand(com.archimatetool.editor.diagram.commands.CreateDiagramArchimateConnectionWithDialogCommand) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) CreateDiagramConnectionCommand(com.archimatetool.editor.diagram.commands.CreateDiagramConnectionCommand)

Example 2 with CreateDiagramArchimateConnectionWithDialogCommand

use of com.archimatetool.editor.diagram.commands.CreateDiagramArchimateConnectionWithDialogCommand in project archi by archimatetool.

the class MagicConnectionCreationTool method createConnection.

/**
 * Create just a new connection between source and target components
 */
private boolean createConnection(CreateConnectionRequest request, IDiagramModelArchimateComponent sourceDiagramModelComponent, IDiagramModelArchimateComponent targetDiagramModelComponent) {
    // Only set when a menu selection for a connection is actually made
    fSetRelationshipTypeWhenHoveringOnConnectionMenuItem = false;
    // Set this threading safety guard
    fCanSetCurrentCommand = false;
    Menu menu = new Menu(getCurrentViewer().getControl());
    addConnectionActions(menu, sourceDiagramModelComponent.getArchimateConcept(), targetDiagramModelComponent.getArchimateConcept());
    menu.setVisible(true);
    // Modal menu
    Display display = menu.getDisplay();
    while (!menu.isDisposed() && menu.isVisible()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    // SWT Menu does not fire Selection Event when Windows touch display is enabled
    if (PlatformUtils.isWindows()) {
        while (display.readAndDispatch()) ;
    }
    if (!menu.isDisposed()) {
        menu.dispose();
    }
    // Reset guard
    fCanSetCurrentCommand = true;
    eraseSourceFeedback();
    // No selection
    if (getFactory().getObjectType() == null) {
        getFactory().clear();
        return false;
    }
    // (Yes, I know this is kludgey, but you try and disentangle GEF's Request/Policy/Factory/Command dance...)
    if (getFactory().swapSourceAndTarget()) {
        CreateDiagramArchimateConnectionWithDialogCommand cmd = (CreateDiagramArchimateConnectionWithDialogCommand) getCurrentCommand();
        cmd.swapSourceAndTargetConcepts();
    }
    executeCurrentCommand();
    // Clear the factory type
    getFactory().clear();
    return true;
}
Also used : CreateDiagramArchimateConnectionWithDialogCommand(com.archimatetool.editor.diagram.commands.CreateDiagramArchimateConnectionWithDialogCommand) Menu(org.eclipse.swt.widgets.Menu) Display(org.eclipse.swt.widgets.Display)

Aggregations

CreateDiagramArchimateConnectionWithDialogCommand (com.archimatetool.editor.diagram.commands.CreateDiagramArchimateConnectionWithDialogCommand)2 CreateDiagramConnectionCommand (com.archimatetool.editor.diagram.commands.CreateDiagramConnectionCommand)1 IConnectable (com.archimatetool.model.IConnectable)1 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)1 EClass (org.eclipse.emf.ecore.EClass)1 Display (org.eclipse.swt.widgets.Display)1 Menu (org.eclipse.swt.widgets.Menu)1