use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.
the class Validator method validate.
/**
* @return The list of Issue Categories and Issues
*/
public List<Object> validate() {
if (fModel == null) {
return null;
}
// Collect interesting objects
fElements = new ArrayList<IArchimateElement>();
fRelations = new ArrayList<IArchimateRelationship>();
fViews = new ArrayList<IArchimateDiagramModel>();
for (Iterator<EObject> iter = fModel.eAllContents(); iter.hasNext(); ) {
EObject eObject = iter.next();
if (eObject instanceof IArchimateRelationship) {
fRelations.add((IArchimateRelationship) eObject);
} else if (eObject instanceof IArchimateElement) {
fElements.add((IArchimateElement) eObject);
} else if (eObject instanceof IArchimateDiagramModel) {
fViews.add((IArchimateDiagramModel) eObject);
}
}
// Analyse
List<Object> result = new ArrayList<Object>();
fErrorList = new ArrayList<ErrorType>();
fWarningList = new ArrayList<WarningType>();
fAdviceList = new ArrayList<AdviceType>();
// ------------------ Checkers -----------------------------
IPreferenceStore store = ArchiHammerPlugin.INSTANCE.getPreferenceStore();
// Invalid Relations
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_INVALID_RELATIONS)) {
collectIssues(new InvalidRelationsChecker(getArchimateRelationships()));
}
// Unused Elements
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_UNUSED_ELEMENTS)) {
collectIssues(new UnusedElementsChecker(getArchimateElements()));
}
// Unused Relations
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_UNUSED_RELATIONS)) {
collectIssues(new UnusedRelationsChecker(getArchimateRelationships()));
}
// Empty Views
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_EMPTY_VIEWS)) {
collectIssues(new EmptyViewsChecker(getArchimateViews()));
}
// Components in wrong Viewpoints
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_VIEWPOINT)) {
collectIssues(new ViewpointChecker(getArchimateViews()));
}
// Nested elements
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_NESTING)) {
collectIssues(new NestedElementsChecker(getArchimateViews()));
}
// Possible Duplicates
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_DUPLICATE_ELEMENTS)) {
collectIssues(new DuplicateElementChecker(getArchimateElements()));
}
// Junctions
if (store.getBoolean(IPreferenceConstants.PREFS_HAMMER_CHECK_JUNCTIONS)) {
collectIssues(new JunctionsChecker(getArchimateElements()));
}
if (!fErrorList.isEmpty()) {
IIssueCategory category = new ErrorsCategory(fErrorList);
result.add(category);
}
if (!fWarningList.isEmpty()) {
IIssueCategory category = new WarningsCategory(fWarningList);
result.add(category);
}
if (!fAdviceList.isEmpty()) {
IIssueCategory category = new AdviceCategory(fAdviceList);
result.add(category);
}
if (result.isEmpty()) {
result.add(new OKType());
}
return result;
}
use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.
the class TreeViewpointFilterProvider method partActivated.
@Override
public void partActivated(IWorkbenchPart part) {
/*
* Refresh Tree only if an IEditorPart is activated.
*
* If we call refresh() when a ViewPart is activated then a problem occurs when:
* 1. User adds a new Diagram View to the Tree
* 2. Element is added to model - refresh() is called on Tree
* 3. Diagram Editor is opened and activated
* 4. This is notified of Diagram Editor Part activation and calls refresh() on Tree
* 5. NewDiagramCommand.execute() calls TreeModelViewer.editElement() to edit the cell name
* 6. The Tree is then activated and This is notified of Diagram Editor Part activation and calls refresh() on Tree
* 7. TreeModelViewer.refresh(element) then cancels editing
*/
if (part instanceof IEditorPart) {
IArchimateDiagramModel previous = fActiveDiagramModel;
// Archimate editor
if (part instanceof IArchimateDiagramEditor) {
IArchimateDiagramModel dm = (IArchimateDiagramModel) ((IArchimateDiagramEditor) part).getModel();
if (previous == dm) {
return;
}
fActiveDiagramModel = dm;
} else // Other type of editor (sketch, canvas)
{
fActiveDiagramModel = null;
}
// Refresh previous model
refreshTreeModel(previous);
// Refresh selected model
refreshTreeModel(fActiveDiagramModel);
}
}
use of com.archimatetool.model.IArchimateDiagramModel in project archi by archimatetool.
the class HintsView method selectionChanged.
public void selectionChanged(Object source, Object selected) {
if (fActionPinContent.isChecked()) {
return;
}
Object object = null;
String key = null;
// EClass (selected from Diagram Palette) so get Java class
if (selected instanceof EClass) {
EClass eClass = (EClass) selected;
object = eClass.getInstanceClass();
} else // Adaptable, dig in to get to get Element...
if (selected instanceof IAdaptable) {
// This first
object = ((IAdaptable) selected).getAdapter(IHelpHintProvider.class);
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IArchimateConcept.class);
}
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IDiagramModelObject.class);
}
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IDiagramModelConnection.class);
}
if (object == null) {
object = ((IAdaptable) selected).getAdapter(IDiagramModel.class);
}
} else // Default
{
object = selected;
}
// Hint Provider, if set
if (object instanceof IHelpHintProvider) {
String title = ((IHelpHintProvider) object).getHelpHintTitle();
String text = ((IHelpHintProvider) object).getHelpHintContent();
if (StringUtils.isSet(title) || StringUtils.isSet(text)) {
fTitleLabel.setText(title);
Color color = getTitleColor(object);
fTitleLabel.setBackground(new Color[] { color, ColorConstants.white }, new int[] { 80 }, false);
text = makeHTMLEntry(text);
fBrowser.setText(text);
// $NON-NLS-1$
fLastPath = "";
return;
}
}
// Archimate Diagram Model use Viewpoint as key
if (object instanceof IArchimateDiagramModel) {
key = ((IArchimateDiagramModel) object).getViewpoint();
}
Hint hint = getHintFromObject(object, key);
if (hint != null) {
if (fLastPath != hint.path) {
// Title and Color
Color color = getTitleColor(object);
fTitleLabel.setBackground(new Color[] { color, ColorConstants.white }, new int[] { 80 }, false);
fTitleLabel.setText(hint.title);
// Load page
fPageLoaded = false;
fBrowser.setUrl(hint.path);
fLastPath = hint.path;
// Kludge for Mac/Safari when displaying hint on mouse rollover menu item in MagicConnectionCreationTool
if (PlatformUtils.isMac() && source instanceof MenuItem) {
_doMacWaitKludge();
}
}
} else {
// $NON-NLS-1$
fBrowser.setText("");
// $NON-NLS-1$
fLastPath = "";
// $NON-NLS-1$
fTitleLabel.setText("");
fTitleLabel.setBackground(ColorConstants.white);
}
}
use of com.archimatetool.model.IArchimateDiagramModel 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.IArchimateDiagramModel in project archi by archimatetool.
the class ViewpointManagerTests method testIsAllowedDiagramModelComponent.
@Test
public void testIsAllowedDiagramModelComponent() {
IArchimateDiagramModel dm = IArchimateFactory.eINSTANCE.createArchimateDiagramModel();
dm.setViewpoint("organization");
IDiagramModelArchimateObject dmo1 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo1.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessActor());
dm.getChildren().add(dmo1);
assertTrue(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(dmo1));
IDiagramModelArchimateObject dmo2 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo2.setArchimateElement(IArchimateFactory.eINSTANCE.createNode());
dm.getChildren().add(dmo2);
assertFalse(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(dmo2));
IDiagramModelArchimateConnection conn = IArchimateFactory.eINSTANCE.createDiagramModelArchimateConnection();
conn.setArchimateRelationship(IArchimateFactory.eINSTANCE.createAssociationRelationship());
conn.connect(dmo1, dmo2);
assertFalse(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(conn));
IDiagramModelArchimateObject dmo3 = IArchimateFactory.eINSTANCE.createDiagramModelArchimateObject();
dmo3.setArchimateElement(IArchimateFactory.eINSTANCE.createBusinessRole());
dm.getChildren().add(dmo3);
conn.connect(dmo1, dmo3);
assertTrue(ViewpointManager.INSTANCE.isAllowedDiagramModelComponent(conn));
}
Aggregations