use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ZestViewerContentProvider method getElements.
@Override
public Object[] getElements(Object inputElement) {
if (inputElement instanceof IArchimateConcept) {
IArchimateConcept archimateConcept = (IArchimateConcept) inputElement;
// Check if it was deleted
if (archimateConcept.eContainer() == null) {
return new Object[0];
}
// Relationship
if (archimateConcept instanceof IArchimateRelationship) {
return new Object[] { inputElement };
}
// Element - Get its relationships
if (archimateConcept instanceof IArchimateElement) {
List<IArchimateRelationship> mainList = new ArrayList<IArchimateRelationship>();
getRelations(mainList, new ArrayList<IArchimateConcept>(), archimateConcept, 0);
return mainList.toArray();
}
}
return new Object[0];
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class ZestViewerLabelProvider method getTooltip.
public IFigure getTooltip(Object entity) {
if (entity instanceof IArchimateConcept) {
ToolTipFigure l = new ToolTipFigure();
String type = ArchiLabelProvider.INSTANCE.getDefaultName(((EObject) entity).eClass());
l.setText(ArchiLabelProvider.INSTANCE.getLabel(entity));
// $NON-NLS-1$
l.setType(Messages.ZestViewerLabelProvider_0 + " " + type);
if (entity instanceof IArchimateRelationship) {
l.setRubric(ArchiLabelProvider.INSTANCE.getRelationshipSentence((IArchimateRelationship) entity));
}
return l;
}
return null;
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CSVExporterTests method testCreateRelationshipRow.
@Test
public void testCreateRelationshipRow() {
IArchimateElement elementSource = IArchimateFactory.eINSTANCE.createBusinessActor();
elementSource.setId("cfde5463e");
IArchimateElement elementTarget = IArchimateFactory.eINSTANCE.createBusinessActor();
elementTarget.setId("b1234dff");
IArchimateRelationship relation = IArchimateFactory.eINSTANCE.createAccessRelationship();
relation.setId("56435fd6");
relation.setName("My relation");
relation.setDocumentation("This is the Documentation");
relation.setSource(elementSource);
relation.setTarget(elementTarget);
assertEquals("\"56435fd6\",\"AccessRelationship\",\"My relation\",\"This is the Documentation\",\"cfde5463e\",\"b1234dff\"", exporter.createRelationshipRow(relation));
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CSVImporterTests method testDoImportWithUpdatedElements.
@Test
public void testDoImportWithUpdatedElements() throws Exception {
// Set up with original data
importer.doImport(elements1File);
testDoImportPart1();
// Import data that is edited
importer = new CSVImporter(model);
importer.doImport(elements2File);
// Ensure new concepts is empty
assertTrue(importer.newConcepts.isEmpty());
// Ensure new properties is empty
assertTrue(importer.newProperties.isEmpty());
// Model information
assertEquals("Test Model changed", model.getName());
assertEquals("Model Documentation Changed", model.getPurpose());
assertEquals(2, model.getProperties().size());
IArchimateElement element = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "f00aa5b4");
assertEquals(IArchimatePackage.eINSTANCE.getBusinessActor(), element.eClass());
assertEquals("Name changed", element.getName());
assertEquals("This is the Business Actor\r\nDocumentation\r\nHere \"\"\r\n", element.getDocumentation());
assertEquals(4, element.getProperties().size());
element = (IArchimateElement) ArchimateModelUtils.getObjectByID(model, "d9fe8c17");
assertEquals(IArchimatePackage.eINSTANCE.getBusinessInterface(), element.eClass());
assertEquals("Business Interface", element.getName());
assertEquals("", element.getDocumentation());
assertEquals(0, element.getProperties().size());
IArchimateRelationship relation = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "cdbfc933");
assertEquals(IArchimatePackage.eINSTANCE.getAssignmentRelationship(), relation.eClass());
assertEquals("Assignment relation changed", relation.getName());
assertEquals("Assignment documentation changed", relation.getDocumentation());
assertEquals(0, relation.getProperties().size());
relation = (IArchimateRelationship) ArchimateModelUtils.getObjectByID(model, "5854f8a3");
assertEquals(IArchimatePackage.eINSTANCE.getCompositionRelationship(), relation.eClass());
assertEquals("5854f8a3", relation.getId());
assertEquals("Compo", relation.getName());
assertEquals("Here it is\r\nagain\r\n\r\n\r\n", relation.getDocumentation());
assertEquals(1, relation.getProperties().size());
IProperty property = relation.getProperties().get(0);
assertEquals("This", property.getKey());
assertEquals("value changes", property.getValue());
}
use of com.archimatetool.model.IArchimateRelationship in project archi by archimatetool.
the class CopySnapshot method createPasteConnections.
private List<IDiagramModelConnection> createPasteConnections() {
List<IDiagramModelConnection> connections = new ArrayList<IDiagramModelConnection>();
// Create new connections from basis of snapshot
for (IConnectable connectable : fOriginalToSnapshotComponentsMapping.values()) {
if (connectable instanceof IDiagramModelConnection) {
IDiagramModelConnection snapshotConnection = (IDiagramModelConnection) connectable;
IDiagramModelConnection newConnection = (IDiagramModelConnection) snapshotConnection.getCopy();
createID(newConnection);
connections.add(newConnection);
// Mapping
fSnapshotToNewComponentMapping.put(snapshotConnection, newConnection);
// Re-use original Archimate relationship if required
if (!fDoCreateNewArchimateComponents && snapshotConnection instanceof IDiagramModelArchimateConnection) {
IDiagramModelArchimateConnection originalDiagramConnection = (IDiagramModelArchimateConnection) fOriginalToSnapshotComponentsMapping.getKey(snapshotConnection);
IArchimateRelationship relationship = originalDiagramConnection.getArchimateRelationship();
((IDiagramModelArchimateConnection) newConnection).setArchimateRelationship(relationship);
}
}
}
// Connect them
for (Entry<IConnectable, IConnectable> entry : fSnapshotToNewComponentMapping.entrySet()) {
if (entry.getKey() instanceof IDiagramModelConnection) {
IDiagramModelConnection snapshotConnection = (IDiagramModelConnection) entry.getKey();
IConnectable newSource = fSnapshotToNewComponentMapping.get(snapshotConnection.getSource());
IConnectable newTarget = fSnapshotToNewComponentMapping.get(snapshotConnection.getTarget());
if (newSource != null && newTarget != null) {
IDiagramModelConnection newConnection = (IDiagramModelConnection) entry.getValue();
newConnection.connect(newSource, newTarget);
}
}
}
return connections;
}
Aggregations