use of com.archimatetool.model.IArchimateConcept 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.IArchimateConcept in project archi by archimatetool.
the class ValidatorView method selectObjects.
void selectObjects(IStructuredSelection selection) {
if (selection != null) {
List<IArchimateConcept> treeList = new ArrayList<IArchimateConcept>();
List<IDiagramModel> viewList = new ArrayList<IDiagramModel>();
List<IDiagramModelComponent> viewComponentList = new ArrayList<IDiagramModelComponent>();
for (Object o : selection.toArray()) {
if (o instanceof IIssue) {
IIssue issue = (IIssue) o;
if (issue.getObject() instanceof IArchimateConcept) {
treeList.add((IArchimateConcept) issue.getObject());
} else if (issue.getObject() instanceof IDiagramModel) {
viewList.add((IDiagramModel) issue.getObject());
} else if (issue.getObject() instanceof IDiagramModelComponent) {
viewList.add(((IDiagramModelComponent) issue.getObject()).getDiagramModel());
viewComponentList.add(((IDiagramModelComponent) issue.getObject()));
}
}
}
if (!treeList.isEmpty()) {
ITreeModelView view = (ITreeModelView) ViewManager.showViewPart(ITreeModelView.ID, false);
if (view != null) {
view.getViewer().setSelection(new StructuredSelection(treeList), true);
}
}
if (!viewList.isEmpty()) {
for (IDiagramModel dm : viewList) {
IDiagramModelEditor editor = EditorManager.openDiagramEditor(dm);
if (editor instanceof IArchimateDiagramEditor) {
((IArchimateDiagramEditor) editor).selectObjects(viewComponentList.toArray());
}
}
}
}
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class TreeViewpointFilterProvider method getTextColor.
/**
* If the element is disallowed in a Viewpoint grey it out
* @param element
* @return Color or null
*/
Color getTextColor(Object element) {
if (isActive() && fActiveDiagramModel != null && element instanceof IArchimateConcept) {
String id = fActiveDiagramModel.getViewpoint();
IViewpoint viewpoint = ViewpointManager.INSTANCE.getViewpoint(id);
if (viewpoint != null) {
// From same model as active diagram
IArchimateModel model = ((IArchimateConcept) element).getArchimateModel();
if (model == fActiveDiagramModel.getArchimateModel()) {
if (element instanceof IArchimateRelationship) {
IArchimateConcept source = ((IArchimateRelationship) element).getSource();
IArchimateConcept target = ((IArchimateRelationship) element).getTarget();
if (!viewpoint.isAllowedConcept(source.eClass()) || !viewpoint.isAllowedConcept(target.eClass())) {
return ColorFactory.get(128, 128, 128);
}
} else if (element instanceof IArchimateElement) {
if (!viewpoint.isAllowedConcept(((IArchimateElement) element).eClass())) {
return ColorFactory.get(128, 128, 128);
}
}
}
}
}
return null;
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class ArchimateModelUtilsTests method testHasDirectRelationship.
/*
* NOTE - Tests for ArchimateModelUtils.isValidRelationshipStart() and ArchimateModelUtils.isValidRelationship() are in ViewpointTests
*/
@Test
public void testHasDirectRelationship() {
IArchimateConcept sourceConcept = IArchimateFactory.eINSTANCE.createBusinessActor();
IArchimateConcept someTarget = IArchimateFactory.eINSTANCE.createBusinessRole();
IArchimateRelationship relationship = IArchimateFactory.eINSTANCE.createAssociationRelationship();
assertFalse(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
assertFalse(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
relationship.connect(sourceConcept, someTarget);
assertTrue(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
assertTrue(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
relationship.connect(someTarget, sourceConcept);
assertTrue(ArchimateModelUtils.hasDirectRelationship(sourceConcept, relationship));
assertTrue(ArchimateModelUtils.hasDirectRelationship(relationship, sourceConcept));
}
use of com.archimatetool.model.IArchimateConcept in project archi by archimatetool.
the class HTMLReportExporterTests method testCreateReport.
@Test
public void testCreateReport() throws Exception {
// Create test model
ArchimateTestModel tm = new ArchimateTestModel(TestData.TEST_MODEL_FILE_ARCHISURANCE);
IArchimateModel model = tm.loadModel();
// Create Exporter and output folder
HTMLReportExporter exporter = new HTMLReportExporter(model);
File targetFolder = TestUtils.createTempFolder("archi-html-report");
File outputFile = exporter.createReport(targetFolder, "index.html");
// Check main file and folders exist
assertTrue(outputFile.exists());
File modelFolder = new File(targetFolder, model.getId());
assertTrue(modelFolder.exists());
File elementsFolder = new File(modelFolder, "elements");
assertTrue(elementsFolder.exists());
File imagesFolder = new File(modelFolder, "images");
assertTrue(imagesFolder.exists());
File viewsFolder = new File(modelFolder, "views");
assertTrue(viewsFolder.exists());
assertTrue(new File(targetFolder, "css").exists());
assertTrue(new File(targetFolder, "elements").exists());
assertTrue(new File(targetFolder, "hints").exists());
assertTrue(new File(targetFolder, "js").exists());
assertTrue(new File(targetFolder, "lib").exists());
// Check element and view files created
assertTrue(new File(elementsFolder, "model.html").exists());
for (Iterator<EObject> iter = model.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
// Concepts
if (eObject instanceof IArchimateConcept) {
assertTrue(new File(elementsFolder, ((IArchimateConcept) eObject).getId() + ".html").exists());
}
// Views & Images
if (eObject instanceof IArchimateDiagramModel) {
assertTrue(new File(imagesFolder, ((IArchimateDiagramModel) eObject).getId() + ".png").exists());
assertTrue(new File(viewsFolder, ((IArchimateDiagramModel) eObject).getId() + ".html").exists());
}
}
// Clean up
FileUtils.deleteFolder(TestUtils.TMP_FOLDER);
}
Aggregations