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;
}
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;
}
Aggregations