Search in sources :

Example 16 with IDiagramModel

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

the class SelectElementInTreeAction method run.

@Override
public void run() {
    List<?> selection = getSelectedObjects();
    List<Object> elements = new ArrayList<Object>();
    for (Object object : selection) {
        if (object instanceof EditPart) {
            Object model = ((EditPart) object).getModel();
            if (model instanceof IDiagramModel) {
                elements.add(model);
            } else if (model instanceof IDiagramModelArchimateComponent) {
                elements.add(((IDiagramModelArchimateComponent) model).getArchimateConcept());
            }
        }
    }
    ITreeModelView view = (ITreeModelView) ViewManager.showViewPart(ITreeModelView.ID, true);
    if (view != null) {
        view.getViewer().setSelection(new StructuredSelection(elements), true);
    }
}
Also used : ITreeModelView(com.archimatetool.editor.views.tree.ITreeModelView) IDiagramModel(com.archimatetool.model.IDiagramModel) ArrayList(java.util.ArrayList) EditPart(org.eclipse.gef.EditPart) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 17 with IDiagramModel

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

the class DiagramModel method getCopy.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public EObject getCopy() {
    IDiagramModel newDiagramModel = EcoreUtil.copy(this);
    // need a new ID
    newDiagramModel.setId(null);
    // need to do this!
    newDiagramModel.getChildren().clear();
    return newDiagramModel;
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel)

Example 18 with IDiagramModel

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

the class DiagramModelReference method setReferencedModel.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setReferencedModel(IDiagramModel newReferencedModel) {
    IDiagramModel oldReferencedModel = referencedModel;
    referencedModel = newReferencedModel;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, IArchimatePackage.DIAGRAM_MODEL_REFERENCE__REFERENCED_MODEL, oldReferencedModel, referencedModel));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 19 with IDiagramModel

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

the class DiagramModelUtilsTests method findDiagramModelComponentsForArchimateConcept_Element.

@Test
public void findDiagramModelComponentsForArchimateConcept_Element() {
    IArchimateElement element = IArchimateFactory.eINSTANCE.createBusinessActor();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateComponent> list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, element);
    assertTrue(list.isEmpty());
    // Add the element to various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(element, diagramModel);
    // Should be found in diagram
    list = DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, element);
    assertEquals(4, list.size());
    assertTrue(list.contains(dmo1));
    assertTrue(list.contains(dmo2));
    assertTrue(list.contains(dmo3));
    assertTrue(list.contains(dmo4));
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateComponent(com.archimatetool.model.IDiagramModelArchimateComponent) IArchimateElement(com.archimatetool.model.IArchimateElement) Test(org.junit.Test)

Example 20 with IDiagramModel

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

the class DiagramModelUtilsTests method findDiagramModelConnectionsForRelation.

@Test
public void findDiagramModelConnectionsForRelation() {
    IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
    IDiagramModel diagramModel = tm.addNewArchimateDiagramModel();
    // Should not be found
    List<IDiagramModelArchimateConnection> list = DiagramModelUtils.findDiagramModelConnectionsForRelation(diagramModel, relationship);
    assertTrue(list.isEmpty());
    // Create various IDiagramModelArchimateObject objects
    createDataForDiagramModelArchimateObjects(IArchimateFactory.eINSTANCE.createBusinessActor(), diagramModel);
    // And make some connections using the relationship
    createDataForDiagramModelConnections(relationship);
    // Should be found in a dm
    list = DiagramModelUtils.findDiagramModelConnectionsForRelation(diagramModel, relationship);
    assertEquals(3, list.size());
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) Test(org.junit.Test)

Aggregations

IDiagramModel (com.archimatetool.model.IDiagramModel)68 Test (org.junit.Test)28 IArchimateElement (com.archimatetool.model.IArchimateElement)16 IArchimateModel (com.archimatetool.model.IArchimateModel)12 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)12 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)11 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)10 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)9 File (java.io.File)8 EObject (org.eclipse.emf.ecore.EObject)8 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)8 Image (org.eclipse.swt.graphics.Image)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)7 IDiagramModelReference (com.archimatetool.model.IDiagramModelReference)7 ArrayList (java.util.ArrayList)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7 IDiagramModelArchimateComponent (com.archimatetool.model.IDiagramModelArchimateComponent)6 Command (org.eclipse.gef.commands.Command)6 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)6 Shell (org.eclipse.swt.widgets.Shell)6