use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class NestedElementsCheckerTests method testGetIssues.
@Test
public void testGetIssues() {
List<IArchimateDiagramModel> views = new ArrayList<IArchimateDiagramModel>();
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
dm.setName("view");
views.add(dm);
IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createGrouping());
dm.getChildren().add(dmo1);
IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createLocation());
dmo1.getChildren().add(dmo2);
NestedElementsChecker checker = new NestedElementsChecker(views);
// Should not be ok
List<IIssue> issues = checker.getIssues();
assertEquals(1, issues.size());
assertSame(dmo2, issues.get(0).getObject());
// With this relationship should also not be OK
IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAssociationRelationship();
relation.connect(dmo1.getArchimateElement(), dmo2.getArchimateElement());
conn.setArchimateRelationship(relation);
conn.connect(dmo1, dmo2);
issues = checker.getIssues();
assertEquals(1, issues.size());
assertSame(dmo2, issues.get(0).getObject());
// With a valid relationship should be OK
relation = IArchimateFactory.eINSTANCE.createCompositionRelationship();
relation.connect(dmo1.getArchimateElement(), dmo2.getArchimateElement());
conn.setArchimateRelationship(relation);
issues = checker.getIssues();
assertEquals(0, issues.size());
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ViewpointCheckerTests method testGetIssues.
@Test
public void testGetIssues() {
List<IArchimateDiagramModel> views = new ArrayList<IArchimateDiagramModel>();
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
dm.setName("view");
views.add(dm);
IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createNode());
dm.getChildren().add(dmo1);
ViewpointChecker checker = new ViewpointChecker(views);
// Should be ok
List<IIssue> issues = checker.getIssues();
assertEquals(0, issues.size());
// Set viewpoint
dm.setViewpoint("organization");
issues = checker.getIssues();
assertEquals(1, issues.size());
assertSame(dmo1, issues.get(0).getObject());
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class FixDefaultSizesHandler method getDefaultSize.
Dimension getDefaultSize(IDiagramModelObject dmo) {
IBounds bounds = dmo.getBounds();
if (bounds.getWidth() != -1 && bounds.getHeight() != -1) {
return new Dimension(bounds.getWidth(), bounds.getHeight());
}
// Legacy size of ArchiMate figure
if (dmo instanceof IDiagramModelArchimateObject) {
if (!(((IDiagramModelArchimateObject) dmo).getArchimateElement() instanceof IJunction)) {
return new Dimension(120, 55);
}
}
IGraphicalObjectUIProvider provider = (IGraphicalObjectUIProvider) ObjectUIFactory.INSTANCE.getProvider(dmo);
return provider != null ? provider.getUserDefaultSize() : new Dimension(120, 55);
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class DiagramModelUtils method findDiagramModelObjectsForElementByReference.
/**
* Find all (visible and extant) Diagram Model Objects for a given Archimate element in a Diagram Model.
* This is the faster method.
* @param diagramModel The parent diagram model to search in.
* @param element The element to check on.
* @return The list of active Diagram Model Objects. May be empty, but never null.
*/
static List<IDiagramModelArchimateObject> findDiagramModelObjectsForElementByReference(IDiagramModel diagramModel, IArchimateElement element) {
// This is the faster method
List<IDiagramModelArchimateObject> list = new ArrayList<IDiagramModelArchimateObject>();
List<IDiagramModelArchimateObject> dmos = findDiagramModelObjectsForElement(element);
for (IDiagramModelArchimateObject dmo : dmos) {
if (dmo.getDiagramModel() == diagramModel) {
list.add(dmo);
}
}
return list;
}
use of com.archimatetool.model.IDiagramModelArchimateObject in project archi by archimatetool.
the class ModelChecker method checkDiagramObjectsReferences.
List<String> checkDiagramObjectsReferences() {
List<String> messages = new ArrayList<String>();
for (Iterator<EObject> iter = fModel.getFolder(FolderType.DIAGRAMS).eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) eObject;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = dmo.getDiagramModel() == null ? Messages.ModelChecker_11 : " '" + dmo.getDiagramModel().getName() + "' (" + dmo.getId() + ")";
IArchimateElement element = dmo.getArchimateElement();
if (element == null) {
messages.add(Messages.ModelChecker_12 + name);
} else if (element.getArchimateModel() == null) {
messages.add(Messages.ModelChecker_13 + name);
}
}
if (eObject instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateConnection conn = (IDiagramModelArchimateConnection) eObject;
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String name = conn.getDiagramModel() == null ? Messages.ModelChecker_14 : " '" + conn.getDiagramModel().getName() + "' (" + conn.getId() + ")";
IArchimateRelationship relation = conn.getArchimateRelationship();
if (relation == null) {
messages.add(Messages.ModelChecker_15 + name);
} else {
if (relation.getArchimateModel() == null) {
messages.add(Messages.ModelChecker_16 + name);
}
if (relation.getSource() != null && relation.getSource().getArchimateModel() == null) {
messages.add(Messages.ModelChecker_17 + name);
}
if (relation.getTarget() != null && relation.getTarget().getArchimateModel() == null) {
messages.add(Messages.ModelChecker_18 + name);
}
}
}
}
return messages;
}
Aggregations