Search in sources :

Example 16 with IDiagramModelConnection

use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.

the class DiagramConnectionSection method createTextPositionComboControl.

private void createTextPositionComboControl(Composite parent) {
    createLabel(parent, Messages.DiagramConnectionSection_6, ITabbedLayoutConstants.STANDARD_LABEL_WIDTH, SWT.CENTER);
    fComboTextPosition = new Combo(parent, SWT.READ_ONLY);
    fComboTextPosition.setItems(comboTextPositionItems);
    GridData gd = new GridData(SWT.NONE, SWT.NONE, true, false);
    gd.minimumWidth = ITabbedLayoutConstants.COMBO_WIDTH;
    fComboTextPosition.setLayoutData(gd);
    fComboTextPosition.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CompoundCommand result = new CompoundCommand();
            for (EObject connection : getEObjects()) {
                if (isAlive(connection)) {
                    Command cmd = new ConnectionTextPositionCommand((IDiagramModelConnection) connection, fComboTextPosition.getSelectionIndex());
                    if (cmd.canExecute()) {
                        result.add(cmd);
                    }
                }
            }
            executeCommand(result.unwrap());
        }
    });
}
Also used : LineWidthCommand(com.archimatetool.editor.diagram.commands.LineWidthCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) Command(org.eclipse.gef.commands.Command) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) EObject(org.eclipse.emf.ecore.EObject) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) Combo(org.eclipse.swt.widgets.Combo) ConnectionTextPositionCommand(com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand) CompoundCommand(org.eclipse.gef.commands.CompoundCommand)

Example 17 with IDiagramModelConnection

use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.

the class DiagramConnectionSection method refreshTextPositionCombo.

protected void refreshTextPositionCombo() {
    if (fIsExecutingCommand) {
        return;
    }
    IDiagramModelConnection lastSelectedConnection = (IDiagramModelConnection) getFirstSelectedObject();
    int pos = lastSelectedConnection.getTextPosition();
    fComboTextPosition.select(pos);
    fComboTextPosition.setEnabled(!isLocked(lastSelectedConnection));
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection)

Example 18 with IDiagramModelConnection

use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.

the class SketchModelFactory method getNewObject.

public Object getNewObject() {
    Object object = IArchimateFactory.eINSTANCE.create(fTemplate);
    // Actor
    if (object instanceof ISketchModelActor) {
        ((ISketchModelActor) object).setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
    } else // Sticky
    if (object instanceof ISketchModelSticky) {
        ISketchModelSticky sticky = (ISketchModelSticky) object;
        sticky.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        sticky.setTextPosition(ITextPosition.TEXT_POSITION_TOP);
        sticky.setTextAlignment(ITextAlignment.TEXT_ALIGNMENT_LEFT);
        if (fParam instanceof Color) {
            String color = ColorFactory.convertColorToString((Color) fParam);
            sticky.setFillColor(color);
            Color lineColor = ColorFactory.getDefaultLineColor(sticky);
            if (lineColor != null) {
                sticky.setLineColor(ColorFactory.convertColorToString(lineColor));
            }
        }
    } else // Group
    if (object instanceof IDiagramModelGroup) {
        IDiagramModelGroup group = (IDiagramModelGroup) object;
        group.setName(ArchiLabelProvider.INSTANCE.getDefaultName(fTemplate));
        ColorFactory.setDefaultColors(group);
    } else // Connection
    if (object instanceof IDiagramModelConnection) {
        IDiagramModelConnection connection = (IDiagramModelConnection) object;
        if (fParam instanceof Integer) {
            connection.setType((Integer) fParam);
        }
        ColorFactory.setDefaultColors(connection);
    }
    return object;
}
Also used : ISketchModelActor(com.archimatetool.model.ISketchModelActor) Color(org.eclipse.swt.graphics.Color) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) ISketchModelSticky(com.archimatetool.model.ISketchModelSticky) IDiagramModelGroup(com.archimatetool.model.IDiagramModelGroup)

Example 19 with IDiagramModelConnection

use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.

the class SketchModelFactoryTests method testGetNewObjectConnection.

@Test
public void testGetNewObjectConnection() {
    ICreationFactory factory = new SketchModelFactory(IArchimatePackage.eINSTANCE.getDiagramModelConnection(), 2);
    IDiagramModelConnection connection = (IDiagramModelConnection) factory.getNewObject();
    assertEquals("", connection.getName());
    assertEquals(2, connection.getType());
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) ICreationFactory(com.archimatetool.editor.diagram.ICreationFactory) Test(org.junit.Test)

Example 20 with IDiagramModelConnection

use of com.archimatetool.model.IDiagramModelConnection in project archi by archimatetool.

the class ArchimateDiagramModelFactoryTests method testGetNewObjectConnection.

@Test
public void testGetNewObjectConnection() {
    ICreationFactory factory = new ArchimateDiagramModelFactory(IArchimatePackage.eINSTANCE.getDiagramModelConnection());
    IDiagramModelConnection connection = (IDiagramModelConnection) factory.getNewObject();
    assertEquals("", connection.getName());
}
Also used : IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) Test(org.junit.Test)

Aggregations

IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)34 Test (org.junit.Test)15 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)6 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)5 Command (org.eclipse.gef.commands.Command)5 IArchimateElement (com.archimatetool.model.IArchimateElement)4 IConnectable (com.archimatetool.model.IConnectable)4 IDiagramModel (com.archimatetool.model.IDiagramModel)4 EditPart (org.eclipse.gef.EditPart)4 ReconnectDiagramConnectionCommand (com.archimatetool.editor.diagram.commands.ReconnectDiagramConnectionCommand)3 EmptyEditPart (com.archimatetool.editor.diagram.editparts.diagram.EmptyEditPart)3 ArrayList (java.util.ArrayList)3 ConnectionTextPositionCommand (com.archimatetool.editor.diagram.commands.ConnectionTextPositionCommand)2 LineWidthCommand (com.archimatetool.editor.diagram.commands.LineWidthCommand)2 DiagramConnectionEditPart (com.archimatetool.editor.diagram.editparts.DiagramConnectionEditPart)2 DeleteArchimateElementCommand (com.archimatetool.editor.model.commands.DeleteArchimateElementCommand)2 DeleteArchimateRelationshipCommand (com.archimatetool.editor.model.commands.DeleteArchimateRelationshipCommand)2