Search in sources :

Example 1 with IArchimateElement

use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.

the class AbstractDiagramModelObjectFigure method getToolTip.

@Override
public IFigure getToolTip() {
    if (!Preferences.doShowViewTooltips()) {
        return null;
    }
    ToolTipFigure toolTipFigure = (ToolTipFigure) super.getToolTip();
    if (toolTipFigure == null) {
        toolTipFigure = new ToolTipFigure();
        setToolTip(toolTipFigure);
    }
    // Set text to object's default text
    String text = ArchiLabelProvider.INSTANCE.getLabel(getDiagramModelObject());
    toolTipFigure.setText(text);
    // If an ArchiMate type, set text to element type if blank
    if (fDiagramModelObject instanceof IDiagramModelArchimateObject) {
        IArchimateElement element = ((IDiagramModelArchimateObject) fDiagramModelObject).getArchimateElement();
        String type = ArchiLabelProvider.INSTANCE.getDefaultName(element.eClass());
        if (!StringUtils.isSet(text)) {
            // Name was blank
            toolTipFigure.setText(type);
        }
        // $NON-NLS-1$
        toolTipFigure.setType(Messages.AbstractDiagramModelObjectFigure_0 + " " + type);
    }
    return toolTipFigure;
}
Also used : IArchimateElement(com.archimatetool.model.IArchimateElement) IDiagramModelArchimateObject(com.archimatetool.model.IDiagramModelArchimateObject)

Example 2 with IArchimateElement

use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.

the class TreeModelViewActionFactory method getNewObjectActions.

/**
 * @param selected
 * @return A List (perhaps empty) of Actions for a given selected object
 */
public List<IAction> getNewObjectActions(Object selected) {
    List<IAction> list = new ArrayList<IAction>();
    // If we have selected a leaf object, go up to parent
    if (selected instanceof IArchimateElement || selected instanceof IDiagramModel) {
        selected = ((EObject) selected).eContainer();
    }
    // We want a folder
    if (!(selected instanceof IFolder)) {
        return list;
    }
    IFolder folder = (IFolder) selected;
    // Find topmost folder type
    IFolder f = folder;
    while (f.eContainer() instanceof IFolder) {
        f = (IFolder) f.eContainer();
    }
    switch(f.getType()) {
        case STRATEGY:
            for (EClass eClass : ArchimateModelUtils.getStrategyClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case BUSINESS:
            for (EClass eClass : ArchimateModelUtils.getBusinessClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case APPLICATION:
            for (EClass eClass : ArchimateModelUtils.getApplicationClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case MOTIVATION:
            for (EClass eClass : ArchimateModelUtils.getMotivationClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case IMPLEMENTATION_MIGRATION:
            for (EClass eClass : ArchimateModelUtils.getImplementationMigrationClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case TECHNOLOGY:
            // Technology
            for (EClass eClass : ArchimateModelUtils.getTechnologyClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            list.add(null);
            // Physical
            for (EClass eClass : ArchimateModelUtils.getPhysicalClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case OTHER:
            // Grouping and Location
            for (EClass eClass : ArchimateModelUtils.getOtherClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            list.add(null);
            // Connectors
            for (EClass eClass : ArchimateModelUtils.getConnectorClasses()) {
                IAction action = createNewElementAction(folder, eClass);
                list.add(action);
            }
            break;
        case DIAGRAMS:
            list.add(createNewArchimateDiagramAction(folder));
            list.add(createNewSketchAction(folder));
            break;
        default:
            break;
    }
    return list;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) IAction(org.eclipse.jface.action.IAction) IDiagramModel(com.archimatetool.model.IDiagramModel) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IFolder(com.archimatetool.model.IFolder)

Example 3 with IArchimateElement

use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.

the class DuplicateCommandHandler method createCommands.

private void createCommands() {
    for (Object object : fElementsToDuplicate) {
        CompoundCommand compoundCommand = getCompoundCommand((IAdapter) object);
        if (compoundCommand == null) {
            // sanity check
            // $NON-NLS-1$
            System.err.println("Could not get CompoundCommand in " + getClass());
            continue;
        }
        if (object instanceof IDiagramModel) {
            Command cmd = new DuplicateDiagramModelCommand((IDiagramModel) object);
            compoundCommand.add(cmd);
        } else if (object instanceof IArchimateElement) {
            Command cmd = new DuplicateElementCommand((IArchimateElement) object);
            compoundCommand.add(cmd);
        }
    }
}
Also used : IDiagramModel(com.archimatetool.model.IDiagramModel) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand) Command(org.eclipse.gef.commands.Command) IArchimateElement(com.archimatetool.model.IArchimateElement) EObject(org.eclipse.emf.ecore.EObject) IDiagramModelObject(com.archimatetool.model.IDiagramModelObject) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) NonNotifyingCompoundCommand(com.archimatetool.editor.model.commands.NonNotifyingCompoundCommand)

Example 4 with IArchimateElement

use of com.archimatetool.model.IArchimateElement 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;
}
Also used : UnusedElementsChecker(com.archimatetool.hammer.validation.checkers.UnusedElementsChecker) EmptyViewsChecker(com.archimatetool.hammer.validation.checkers.EmptyViewsChecker) AdviceCategory(com.archimatetool.hammer.validation.issues.AdviceCategory) ArrayList(java.util.ArrayList) DuplicateElementChecker(com.archimatetool.hammer.validation.checkers.DuplicateElementChecker) ErrorType(com.archimatetool.hammer.validation.issues.ErrorType) EObject(org.eclipse.emf.ecore.EObject) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) ViewpointChecker(com.archimatetool.hammer.validation.checkers.ViewpointChecker) WarningsCategory(com.archimatetool.hammer.validation.issues.WarningsCategory) ErrorsCategory(com.archimatetool.hammer.validation.issues.ErrorsCategory) InvalidRelationsChecker(com.archimatetool.hammer.validation.checkers.InvalidRelationsChecker) IArchimateDiagramModel(com.archimatetool.model.IArchimateDiagramModel) UnusedRelationsChecker(com.archimatetool.hammer.validation.checkers.UnusedRelationsChecker) OKType(com.archimatetool.hammer.validation.issues.OKType) JunctionsChecker(com.archimatetool.hammer.validation.checkers.JunctionsChecker) WarningType(com.archimatetool.hammer.validation.issues.WarningType) NestedElementsChecker(com.archimatetool.hammer.validation.checkers.NestedElementsChecker) AdviceType(com.archimatetool.hammer.validation.issues.AdviceType) EObject(org.eclipse.emf.ecore.EObject) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IIssueCategory(com.archimatetool.hammer.validation.issues.IIssueCategory)

Example 5 with IArchimateElement

use of com.archimatetool.model.IArchimateElement in project archi by archimatetool.

the class JunctionsChecker method findBogusJunctions.

List<IIssue> findBogusJunctions() {
    List<IIssue> issues = new ArrayList<IIssue>();
    for (IArchimateElement element : fArchimateElements) {
        if (element instanceof IJunction) {
            IArchimateRelationship rel = null;
            for (IArchimateRelationship relation : ArchimateModelUtils.getAllRelationshipsForConcept(element)) {
                if (rel != null && rel.eClass() != relation.eClass()) {
                    String name = ArchiLabelProvider.INSTANCE.getLabel(element);
                    String description = NLS.bind(DESCRIPTION, name);
                    String explanation = NLS.bind(EXPLANATION, name);
                    IIssue issue = new ErrorType(NAME, description, explanation, element);
                    issues.add(issue);
                    break;
                }
                rel = relation;
            }
        }
    }
    return issues;
}
Also used : ErrorType(com.archimatetool.hammer.validation.issues.ErrorType) ArrayList(java.util.ArrayList) IArchimateElement(com.archimatetool.model.IArchimateElement) IArchimateRelationship(com.archimatetool.model.IArchimateRelationship) IIssue(com.archimatetool.hammer.validation.issues.IIssue) IJunction(com.archimatetool.model.IJunction)

Aggregations

IArchimateElement (com.archimatetool.model.IArchimateElement)92 Test (org.junit.Test)57 IArchimateRelationship (com.archimatetool.model.IArchimateRelationship)33 IDiagramModelArchimateObject (com.archimatetool.model.IDiagramModelArchimateObject)30 ArrayList (java.util.ArrayList)19 IDiagramModel (com.archimatetool.model.IDiagramModel)16 IArchimateModel (com.archimatetool.model.IArchimateModel)14 IDiagramModelArchimateConnection (com.archimatetool.model.IDiagramModelArchimateConnection)13 IDiagramModelObject (com.archimatetool.model.IDiagramModelObject)11 IFolder (com.archimatetool.model.IFolder)11 EObject (org.eclipse.emf.ecore.EObject)11 IIssue (com.archimatetool.hammer.validation.issues.IIssue)8 ArchimateTestModel (com.archimatetool.testingtools.ArchimateTestModel)8 IArchimateConcept (com.archimatetool.model.IArchimateConcept)6 Command (org.eclipse.gef.commands.Command)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 WarningType (com.archimatetool.hammer.validation.issues.WarningType)4 IDiagramModelConnection (com.archimatetool.model.IDiagramModelConnection)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 NoteEditPart (com.archimatetool.editor.diagram.editparts.diagram.NoteEditPart)3