Search in sources :

Example 21 with IArchimateDiagramModel

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

the class NestedElementsChecker method findWrongNestedElements.

// Nested diagram elements without correct relationships
List<IIssue> findWrongNestedElements() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateDiagramModel dm : fViews) {
        for (Iterator<EObject> iter = dm.eAllContents(); iter.hasNext(); ) {
            EObject eObject = iter.next();
            if (eObject instanceof IDiagramModelArchimateObject) {
                IDiagramModelArchimateObject parent = (IDiagramModelArchimateObject) eObject;
                for (IDiagramModelObject dmoChild : parent.getChildren()) {
                    if (dmoChild instanceof IDiagramModelArchimateObject) {
                        IDiagramModelArchimateObject child = (IDiagramModelArchimateObject) dmoChild;
                        if (isNestedWithoutValidRelation(parent, child)) {
                            String description = NLS.bind(fDescription, new Object[] { child.getName(), parent.getName() });
                            IIssue issue = new AdviceType(fName, description, fExplanation, child);
                            issues.add(issue);
                        }
                    }
                }
            }
        }
    }
    return issues;
}
Also used : AdviceType(com.archimatetool.hammer.validation.issues.AdviceType) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 22 with IArchimateDiagramModel

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

the class ArchimateTestModel method addNewArchimateDiagramModel.

/**
 * Create and add a new blank ArchimateDiagramModel adding it to its default folder
 */
public IArchimateDiagramModel addNewArchimateDiagramModel() {
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    model.getDefaultFolderForObject(dm).getElements().add(dm);
    return dm;
}
Also used : IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Example 23 with IArchimateDiagramModel

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

the class PropertiesLabelProviderTests method testGetTextDiagramModel.

@Test
public void testGetTextDiagramModel() {
    // Text for diagram model
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    String text = provider.getText(new StructuredSelection(dm));
    assertEquals("View", text);
    // Text for EditPart
    ArchimateDiagramPart editPart = new ArchimateDiagramPart();
    editPart.setModel(dm);
    text = provider.getText(new StructuredSelection(editPart));
    assertEquals("View", text);
}
Also used : ArchimateDiagramPart(com.archimatetool.editor.diagram.editparts.ArchimateDiagramPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 24 with IArchimateDiagramModel

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

the class ArchiLabelProviderTests method testGetGraphicsIconForDiagramModel.

@Test
public void testGetGraphicsIconForDiagramModel() {
    // Null object
    assertNull(ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(null));
    // Models
    IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
    assertNotNull(ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(dm));
    ISketchModel sm = IArchimateFactory.eINSTANCE.createSketchModel();
    assertNotNull(ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(sm));
}
Also used : ISketchModel(com.archimatetool.model.ISketchModel) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) Test(org.junit.Test)

Example 25 with IArchimateDiagramModel

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

the class ViewpointSection method update.

@Override
protected void update() {
    if (fIsExecutingCommand) {
        return;
    }
    String id = ((IArchimateDiagramModel) getFirstSelectedObject()).getViewpoint();
    IViewpoint viewPoint = ViewpointManager.INSTANCE.getViewpoint(id);
    // A Viewer will get a selectionChanged event when setting it
    fIsRefreshing = true;
    fComboViewer.setSelection(new StructuredSelection(viewPoint));
    fIsRefreshing = false;
}
Also used : StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IViewpoint(com.archimatetool.model.viewpoints.IViewpoint) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel)

Aggregations

IArchimateDiagramModel (com.archimatetool.model.IArchimateDiagramModel)29 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)8 IIssue (com.archimatetool.hammer.validation.issues.IIssue)6 IArchimateModel (com.archimatetool.model.IArchimateModel)6 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)6 IViewpoint (com.archimatetool.model.viewpoints.IViewpoint)5 EObject (org.eclipse.emf.ecore.EObject)5 AdviceType (com.archimatetool.hammer.validation.issues.AdviceType)4 ISketchModel (com.archimatetool.model.ISketchModel)4 IArchimateElement (com.archimatetool.model.IArchimateElement)3 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)3 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)3 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)3 IDiagramEditorFactory (com.archimatetool.editor.diagram.IDiagramEditorFactory)2 ArchimateDiagramEditPartFactory (com.archimatetool.editor.diagram.editparts.ArchimateDiagramEditPartFactory)2 IFolder (com.archimatetool.model.IFolder)2 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)2 GraphicalViewerImpl (org.eclipse.gef.ui.parts.GraphicalViewerImpl)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2