use of com.archimatetool.model.IArchimateElement 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.IArchimateElement in project archi by archimatetool.
the class GenerateViewAction method run.
@Override
public void run() {
List<IArchimateElement> selected = getValidSelectedObjects(getSelection());
if (!selected.isEmpty()) {
GenerateViewCommand command = new GenerateViewCommand(selected);
if (command.openDialog(Display.getCurrent().getActiveShell())) {
CommandStack commandStack = (CommandStack) ((IAdapter) selected.get(0)).getAdapter(CommandStack.class);
commandStack.execute(command);
}
}
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class UnusedElementsChecker method findUnusedElements.
List<IIssue> findUnusedElements() {
List<IIssue> issues = new ArrayList<IIssue>();
for (IArchimateElement element : fArchimateElements) {
if (!DiagramModelUtils.isArchimateConceptReferencedInDiagrams(element)) {
String name = ArchiLabelProvider.INSTANCE.getLabel(element);
String description = NLS.bind(DESCRIPTION, name);
String explanation = NLS.bind(EXPLANATION, name);
IIssue issue = new WarningType(NAME, description, explanation, element);
issues.add(issue);
}
}
return issues;
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ViewpointChecker method findComponentsInWrongViewpoints.
List<IIssue> findComponentsInWrongViewpoints() {
List<IIssue> issues = new ArrayList<IIssue>();
for (IArchimateDiagramModel dm : fViews) {
String id = dm.getViewpoint();
IViewpoint viewPoint = ViewpointManager.INSTANCE.getViewpoint(id);
for (Iterator<EObject> iter = dm.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IDiagramModelArchimateObject) {
IDiagramModelArchimateObject dmo = (IDiagramModelArchimateObject) eObject;
IArchimateElement element = dmo.getArchimateElement();
if (!viewPoint.isAllowedConcept(element.eClass())) {
IIssue issue = createIssue(dmo, dm.getName(), viewPoint.getName());
issues.add(issue);
}
}
}
}
return issues;
}
use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.
the class ArchimateModelUtilsTests method testGetAllRelationshipsForConcept_NoRelations.
@Test
public void testGetAllRelationshipsForConcept_NoRelations() {
IArchimateModel model = IArchimateFactory.eINSTANCE.createArchimateModel();
model.setDefaults();
IArchimateElement element1 = IArchimateFactory.eINSTANCE.createBusinessActor();
model.getDefaultFolderForObject(element1).getElements().add(element1);
IArchimateElement element2 = IArchimateFactory.eINSTANCE.createBusinessRole();
model.getDefaultFolderForObject(element2).getElements().add(element2);
assertTrue(ArchimateModelUtils.getAllRelationshipsForConcept(element1).isEmpty());
assertTrue(ArchimateModelUtils.getAllRelationshipsForConcept(element2).isEmpty());
}
Aggregations