use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class DiagramModelReferenceEditPart method removeECoreAdapter.
@Override
protected void removeECoreAdapter() {
super.removeECoreAdapter();
// Unlisten to referenced model
IDiagramModel ref = ((IDiagramModelReference) getModel()).getReferencedModel();
if (ref != null) {
ref.eAdapters().remove(getECoreAdapter());
}
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class DiagramModelReferenceFigure method drawIcon.
/**
* Draw the icon
*/
protected void drawIcon(Graphics graphics) {
// Draw the icon depending on the diagramModelObject
IDiagramModel dm = ((IDiagramModelReference) getDiagramModelObject()).getReferencedModel();
IGraphicsIcon graphicsIcon = ArchiLabelProvider.INSTANCE.getGraphicsIconForDiagramModel(dm);
if (graphicsIcon != null) {
graphicsIcon.drawIcon(graphics, getIconOrigin());
}
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class DeleteCommandHandler method getElementsToDelete.
/**
* Create the list of objects to delete and check
* @return
*/
private void getElementsToDelete() {
// Actual elements to delete
fElementsToDelete = new ArrayList<Object>();
// First, gather up the list of Archimate objects to be deleted...
for (Object object : fSelectedObjects) {
if (canDelete(object)) {
addToList(object, fElementsToDelete);
addFolderChildElements(object);
addElementRelationships(object);
}
}
// Gather referenced diagram objects to be deleted checking that the parent diagram model is not also selected to be deleted
for (Object object : new ArrayList<>(fElementsToDelete)) {
// Archimate Components
if (object instanceof IArchimateConcept) {
IArchimateConcept archimateConcept = (IArchimateConcept) object;
for (IDiagramModel diagramModel : archimateConcept.getArchimateModel().getDiagramModels()) {
// Check diagram model is not selected to be deleted - no point in deleting any of its children
if (!fElementsToDelete.contains(diagramModel)) {
for (IDiagramModelComponent dc : DiagramModelUtils.findDiagramModelComponentsForArchimateConcept(diagramModel, archimateConcept)) {
addToList(dc, fElementsToDelete);
}
}
}
}
// Diagram Models and their references
if (object instanceof IDiagramModel) {
IDiagramModel diagramModelDeleted = (IDiagramModel) object;
for (IDiagramModel diagramModel : diagramModelDeleted.getArchimateModel().getDiagramModels()) {
// is there one?
List<IDiagramModelReference> list = DiagramModelUtils.findDiagramModelReferences(diagramModel, diagramModelDeleted);
fElementsToDelete.addAll(list);
}
}
}
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class CreateMapViewCheatSheetActionTests method testNewMapViewCommand.
@Test
public void testNewMapViewCommand() throws IOException {
// Load ArchiMate model
ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
IArchimateModel model = tm.loadModel();
// Has 17 diagrams
assertEquals(17, model.getDiagramModels().size());
NewMapViewCommand cmd = new NewMapViewCommand(model);
cmd.execute();
assertNotNull(cmd.diagramModel);
assertNotNull(cmd.diagramModel.eContainer());
// Model now has 18 diagrams
assertEquals(18, model.getDiagramModels().size());
// New diagram has 17 children...
assertEquals(17, cmd.diagramModel.getChildren().size());
// ...all of which are IDiagramModelReference types with IDs
for (IDiagramModelObject dmo : cmd.diagramModel.getChildren()) {
assertTrue(dmo instanceof IDiagramModelReference);
assertNotNull(dmo.getId());
}
// Undo
cmd.undo();
assertEquals(17, model.getDiagramModels().size());
assertNull(cmd.diagramModel.eContainer());
}
use of com.archimatetool.model.IDiagramModelReference in project archi by archimatetool.
the class ArchimateDiagramConnectionPolicyTests method testIsValidConnection_DiagramModelConnection.
@Test
public void testIsValidConnection_DiagramModelConnection() {
EClass relationshipType = IArchimatePackage.eINSTANCE.getDiagramModelConnection();
IDiagramModelGroup group = IArchimateFactory.eINSTANCE.createDiagramModelGroup();
IDiagramModelNote note = IArchimateFactory.eINSTANCE.createDiagramModelNote();
IDiagramModelArchimateObject dmao1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
IDiagramModelArchimateObject dmao2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
IDiagramModelReference dmRef = IArchimateFactory.eINSTANCE.createDiagramModelReference();
// Source == Target
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(group, group, relationshipType));
// Both ArchiMate types
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, dmao2, relationshipType));
// Target ArchiMate type
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(group, dmao2, relationshipType));
// Target ArchiMate type
assertFalse(ArchimateDiagramConnectionPolicy.isValidConnection(dmRef, dmao2, relationshipType));
// Source ArchiMate type to Note
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(dmao1, note, relationshipType));
// OK
assertTrue(ArchimateDiagramConnectionPolicy.isValidConnection(note, group, relationshipType));
}
Aggregations