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;
}
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;
}
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);
}
}
}
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;
}
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;
}
Aggregations