Search in sources :

Example 46 with IDiagramModelObject

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

the class AbstractFilteredEditPart method getFilteredModelChildren.

protected List<?> getFilteredModelChildren() {
    if (getModel() instanceof IDiagramModelContainer) {
        List<IDiagramModelObject> originalList = ((IDiagramModelContainer) getModel()).getChildren();
        IChildEditPartFilter[] filters = getRootEditPartFilterProvider().getEditPartFilters(IChildEditPartFilter.class);
        if (filters != null) {
            List<IDiagramModelObject> filteredList = new ArrayList<IDiagramModelObject>();
            for (IDiagramModelObject object : originalList) {
                boolean add = true;
                for (IChildEditPartFilter filter : filters) {
                    add = filter.isChildElementVisible(this, object);
                    if (!add) {
                        // no point in trying the next filter
                        break;
                    }
                }
                if (add) {
                    filteredList.add(object);
                }
            }
            return filteredList;
        }
        return originalList;
    }
    return Collections.EMPTY_LIST;
}
Also used : ArrayList(java.util.ArrayList) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Example 47 with IDiagramModelObject

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

the class GenerateViewCommand method createDiagramModel.

private IArchimateDiagramModel createDiagramModel() {
    // New Diagram
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    dm.setName(fViewName);
    dm.setViewpoint(fViewpoint.getID());
    fParentFolder = fSelectedElements.get(0).getArchimateModel().getDefaultFolderForObject(dm);
    fParentFolder.getElements().add(dm);
    int x = 20;
    int y = 20;
    getElementsToAdd();
    for (IArchimateElement element : fSelectedElements) {
        createDiagramNode(element, dm, x, y);
        y += 100;
    }
    x = 170;
    y = 20;
    for (IArchimateElement element : fAddedElements) {
        if (!fSelectedElements.contains(element)) {
            createDiagramNode(element, dm, x, y);
            y += 80;
            if (y > 700) {
                y = 20;
                x += 150;
            }
        }
    }
    // Add connections between elements first
    for (IDiagramModelObject dmoSource : dm.getChildren()) {
        IArchimateElement elementSource = ((IDiagramModelArchimateObject) dmoSource).getArchimateElement();
        for (IArchimateRelationship relation : elementSource.getSourceRelationships()) {
            for (IDiagramModelObject dmoTarget : dm.getChildren()) {
                IArchimateElement elementTarget = ((IDiagramModelArchimateObject) dmoTarget).getArchimateElement();
                // Don't add connections that are not connected to the main elements if option is set
                if (!fAddAllConnections && !(fSelectedElements.contains(elementSource)) && !(fSelectedElements.contains(elementTarget))) {
                    continue;
                }
                if (relation.getTarget() == elementTarget) {
                    // Create connection
                    IDiagramModelArchimateConnection newConnection = ArchimateDiagramModelFactory.createDiagramModelArchimateConnection(relation);
                    newConnection.connect(dmoSource, dmoTarget);
                }
            }
        }
    }
    // Add connections to connections
    for (Iterator<EObject> iter1 = dm.eAllContents(); iter1.hasNext(); ) {
        EObject eObject1 = iter1.next();
        if (eObject1 instanceof IDiagramModelArchimateConnection) {
            IDiagramModelArchimateConnection connection = (IDiagramModelArchimateConnection) eObject1;
            for (IDiagramModelObject dmo : dm.getChildren()) {
                IArchimateElement element = ((IDiagramModelArchimateObject) dmo).getArchimateElement();
                for (IArchimateRelationship relation : connection.getArchimateRelationship().getSourceRelationships()) {
                    if (relation.getTarget() == element) {
                        IDiagramModelArchimateConnection newConnection = ArchimateDiagramModelFactory.createDiagramModelArchimateConnection(relation);
                        newConnection.connect(connection, dmo);
                    }
                }
                for (IArchimateRelationship relation : connection.getArchimateRelationship().getTargetRelationships()) {
                    if (relation.getSource() == element) {
                        IDiagramModelArchimateConnection newConnection = ArchimateDiagramModelFactory.createDiagramModelArchimateConnection(relation);
                        newConnection.connect(dmo, connection);
                    }
                }
            }
        }
    }
    return dm;
}
Also used : IDiagramModelArchimateConnection(com.archimatetool.model.IDiagramModelArchimateConnection) EObject(org.eclipse.emf.ecore.EObject) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 48 with IDiagramModelObject

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

the class OpacitySection method update.

@Override
protected void update() {
    if (fIsExecutingCommand) {
        return;
    }
    IDiagramModelObject lastSelected = (IDiagramModelObject) getFirstSelectedObject();
    fSpinner.setSelection(lastSelected.getAlpha());
    fSpinner.setEnabled(!isLocked(lastSelected));
}
Also used : IDiagramModelObject(com.archimatetool.model.IDiagramModelObject)

Example 49 with IDiagramModelObject

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

the class DiagramModelObjectTests method testGetCopy.

@Override
@Test
public void testGetCopy() {
    super.testGetCopy();
    IDiagramModelConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelConnection();
    conn.connect(object, object);
    object.addConnection(conn);
    assertTrue(object.getSourceConnections().contains(conn));
    assertTrue(object.getTargetConnections().contains(conn));
    IBounds bounds = IArchimateFactory.eINSTANCE.createBounds(2, 4, 6, 8);
    object.setBounds(bounds);
    IDiagramModelObject copy = (IDiagramModelObject) object.getCopy();
    assertNotSame(object, copy);
    assertTrue(copy.getSourceConnections().isEmpty());
    assertTrue(copy.getTargetConnections().isEmpty());
    assertNotSame(bounds, copy.getBounds());
    assertEquals(bounds.getX(), copy.getBounds().getX());
    assertEquals(bounds.getY(), copy.getBounds().getY());
    assertEquals(bounds.getWidth(), copy.getBounds().getWidth());
    assertEquals(bounds.getHeight(), copy.getBounds().getHeight());
}
Also used : IBounds(com.archimatetool.model.IBounds) IDiagramModelConnection(com.archimatetool.model.IDiagramModelConnection) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) Test(org.junit.Test)

Example 50 with IDiagramModelObject

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

the class AbstractModelView method getDiagramElementsToUpdate.

/**
 * Find all elements contained in Diagram or Diagram objects including any child objects
 */
private void getDiagramElementsToUpdate(List<Object> list, IDiagramModelContainer container) {
    // ArchiMate element
    if (container instanceof IDiagramModelArchimateObject) {
        IArchimateElement element = ((IDiagramModelArchimateObject) container).getArchimateElement();
        if (!list.contains(element)) {
            list.add(element);
            getRelationshipsToUpdate(list, element);
        }
    }
    // Children
    for (IDiagramModelObject child : container.getChildren()) {
        if (child instanceof IDiagramModelContainer) {
            getDiagramElementsToUpdate(list, (IDiagramModelContainer) child);
        }
    }
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IDiagramModelContainer(com.archimatetool.model.IDiagramModelContainer)

Aggregations

IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)51 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)12 IDiagramModelContainer (com.archimatetool.model.IDiagramModelContainer)12 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)10 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)10 Test (org.junit.Test)10 IArchimateElement (com.archimatetool.model.IArchimateElement)9 Dimension (org.eclipse.draw2d.geometry.Dimension)9 IDiagramModel (com.archimatetool.model.IDiagramModel)8 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)7 IBounds (com.archimatetool.model.IBounds)6 Command (org.eclipse.gef.commands.Command)6 ILockable (com.archimatetool.model.ILockable)5 ArrayList (java.util.ArrayList)5 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)4 EObject (org.eclipse.emf.ecore.EObject)4 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)4 IArchimateModel (com.archimatetool.model.IArchimateModel)3 IDiagramModelGroup (com.archimatetool.model.IDiagramModelGroup)3 ILineObject (com.archimatetool.model.ILineObject)3