/** * @param fgVec the FigGroup * @param ft the FigText * @param i get the fig after fig i * @return the FigText */ protected FigText getNextVisibleFeature(FigGroup fgVec, FigText ft, int i) { if (fgVec == null || i < 1) { return null; } FigText ft2 = null; List v = fgVec.getFigs(); if (i >= v.size() || !((FigText) v.get(i)).isVisible()) { return null; } do { i++; while (i >= v.size()) { if (fgVec == getCompartment(Model.getMetaTypes().getAttribute())) { fgVec = getCompartment(Model.getMetaTypes().getOperation()); } else { fgVec = getCompartment(Model.getMetaTypes().getAttribute()); } v = new ArrayList(fgVec.getFigs()); i = 1; } ft2 = (FigText) v.get(i); if (!ft2.isVisible()) { ft2 = null; } } while (ft2 == null); return ft2; }
/** * @param fgVec the FigGroup * @param ft the Figtext * @param i get the fig before fig i * @return the FigText */ protected FigText getPreviousVisibleFeature(FigGroup fgVec, FigText ft, int i) { if (fgVec == null || i < 1) { return null; } FigText ft2 = null; List figs = fgVec.getFigs(); if (i >= figs.size() || !((FigText) figs.get(i)).isVisible()) { return null; } do { i--; while (i < 1) { if (fgVec == getCompartment(Model.getMetaTypes().getAttribute())) { fgVec = getCompartment(Model.getMetaTypes().getOperation()); } else { fgVec = getCompartment(Model.getMetaTypes().getAttribute()); } figs = fgVec.getFigs(); i = figs.size() - 1; } ft2 = (FigText) figs.get(i); if (!ft2.isVisible()) { ft2 = null; } } while (ft2 == null); return ft2; }
private Collection getApplicableTagDefinitions(Object t) { Set<List<String>> paths = new HashSet<List<String>>(); Set<Object> availableTagDefs = new TreeSet<Object>(new PathComparator()); Collection stereotypes = Model.getFacade().getStereotypes(t); Project project = ProjectManager.getManager().getCurrentProject(); for (Object model : project.getModels()) { addAllUniqueModelElementsFrom( availableTagDefs, paths, Model.getModelManagementHelper() .getAllModelElementsOfKind(model, Model.getMetaTypes().getTagDefinition())); } addAllUniqueModelElementsFrom( availableTagDefs, paths, project.getProfileConfiguration().findByMetaType(Model.getMetaTypes().getTagDefinition())); List notValids = new ArrayList(); for (Object tagDef : availableTagDefs) { Object owner = Model.getFacade().getOwner(tagDef); if (owner != null && !stereotypes.contains(owner)) { notValids.add(tagDef); } } int size = availableTagDefs.size(); availableTagDefs.removeAll(notValids); int delta = size - availableTagDefs.size(); return availableTagDefs; }
/* * @see org.argouml.uml.ui.UMLComboBoxModel2#buildModelList() */ protected void buildModelList() { Set<Object> elements = new TreeSet<Object>(new PathComparator()); Project p = ProjectManager.getManager().getCurrentProject(); for (Object model : p.getUserDefinedModelList()) { elements.addAll( Model.getModelManagementHelper() .getAllModelElementsOfKind(model, Model.getMetaTypes().getClassifier())); } elements.addAll( p.getProfileConfiguration().findByMetaType(Model.getMetaTypes().getClassifier())); removeAllElements(); addAll(elements); }
/** * Finds a type in a model by name * * <p>FIXME: duplicated from the method with the same name in * org.argouml.profile.internal.ModelUtils. * * @param s the type name * @param model the model * @return the type or <code>null</code> if the type has not been found. */ public static Object findTypeInModel(String s, Object model) { if (!Model.getFacade().isANamespace(model)) { throw new IllegalArgumentException( "Looking for the classifier " + s + " in a non-namespace object of " + model + ". A namespace was expected."); } Collection allClassifiers = Model.getModelManagementHelper() .getAllModelElementsOfKind(model, Model.getMetaTypes().getClassifier()); Object[] classifiers = allClassifiers.toArray(); Object classifier = null; for (int i = 0; i < classifiers.length; i++) { classifier = classifiers[i]; if (Model.getFacade().getName(classifier) != null && Model.getFacade().getName(classifier).equals(s)) { return classifier; } } return null; }
private Object[] getToolbarActions(Element toolbarNode) { final NodeList nl = toolbarNode.getChildNodes(); List<Element> elements = new ArrayList<Element>(); for (int i = 0; i < nl.getLength(); ++i) { final Node n = nl.item(i); if (n instanceof Element) { elements.add((Element) n); } } final Object[] toolbarActions = new Object[elements.size()]; for (int i = 0; i < elements.size(); ++i) { final Element itemNode = elements.get(i); Object o; String style = itemNode.getNodeName(); if (style.equals("dropdown")) { o = getToolbarActions(itemNode); } else if (style.equals("poly-edge")) { final String type = itemNode.getAttribute("type"); final Class<?> metaType = metaTypeByName.get(type); o = getCreateEdgeAction(metaType); } else { final String type = itemNode.getAttribute("type"); final Class<?> metaType = metaTypeByName.get(type); o = new CreateDiagramElementAction( metaType, style, Model.getMetaTypes().getName(metaType), this); } toolbarActions[i] = o; } return toolbarActions; }
/** @return Returns the actionFinalPseudoState. */ protected Action getActionFinalPseudoState() { if (actionFinalPseudoState == null) { actionFinalPseudoState = new RadioAction( new CmdCreateNode(Model.getMetaTypes().getFinalState(), "button.new-finalstate")); } return actionFinalPseudoState; }
/** @return Returns the actionSubmachineState. */ protected Action getActionStubState() { if (actionStubState == null) { actionStubState = new RadioAction( new CmdCreateNode(Model.getMetaTypes().getStubState(), "button.new-stubstate")); } return actionStubState; }
/** @return Returns the actionCompositeState. */ protected Action getActionCompositeState() { if (actionCompositeState == null) { actionCompositeState = new RadioAction( new CmdCreateNode( Model.getMetaTypes().getCompositeState(), "button.new-compositestate")); } return actionCompositeState; }
protected List getChoices() { List ret = new ArrayList(); Object model = ProjectManager.getManager().getCurrentProject().getModel(); if (getTarget() != null) { ret.addAll( Model.getModelManagementHelper() .getAllModelElementsOfKind(model, Model.getMetaTypes().getReception())); } return ret; }
/* * @see org.argouml.ui.explorer.rules.PerspectiveRule#getChildren(java.lang.Object) */ public Collection getChildren(Object parent) { Collection col = new ArrayList(); if (parent instanceof Project) { for (Object model : ((Project) parent).getUserDefinedModelList()) { col.addAll( Model.getModelManagementHelper() .getAllModelElementsOfKind(model, Model.getMetaTypes().getStateMachine())); } } return col; }
protected List getChoices() { List ret = new ArrayList(); if (getTarget() != null) { Project p = ProjectManager.getManager().getCurrentProject(); Object model = p.getRoot(); ret.addAll( Model.getModelManagementHelper() .getAllModelElementsOfKindWithModel(model, Model.getMetaTypes().getClassifier())); } return ret; }
/* * @see org.argouml.ui.explorer.rules.PerspectiveRule#getChildren(java.lang.Object) */ public Collection getChildren(Object parent) { Collection col = new ArrayList(); if (parent instanceof Project) { Iterator it = ((Project) parent).getUserDefinedModels().iterator(); while (it.hasNext()) { col.addAll( Model.getModelManagementHelper() .getAllModelElementsOfKind(it.next(), Model.getMetaTypes().getCollaboration())); } } return col; }
/** @return Returns the actionTransition. */ protected Action getActionTransition() { if (actionTransition == null) { actionTransition = new RadioAction( new ActionSetMode( ModeCreatePolyEdge.class, "edgeClass", Model.getMetaTypes().getTransition(), "button.new-transition")); } return actionTransition; }
/** * Set the fig style according to attributes. * * <p>TODO: This is never used! Can we remove? * * @param fig the fig to style. * @param attributeMap a map of name value pairs */ private void setStyleAttributes(Fig fig, Map<String, String> attributeMap) { String name; String value; for (Map.Entry<String, String> entry : attributeMap.entrySet()) { name = entry.getKey(); value = entry.getValue(); if (fig instanceof FigCompartmentBox) { FigCompartmentBox fcb = (FigCompartmentBox) fig; if ("operationsVisible".equals(name)) { fcb.showCompartment(Model.getMetaTypes().getOperation(), value.equalsIgnoreCase("true")); } else if ("attributesVisible".equals(name)) { fcb.showCompartment(Model.getMetaTypes().getAttribute(), value.equalsIgnoreCase("true")); } else if ("enumerationLiteralsVisible".equals(name)) { fcb.showCompartment( Model.getMetaTypes().getEnumerationLiteral(), value.equalsIgnoreCase("true")); } else if ("extensionPointVisible".equals(name)) { fcb.showCompartment( Model.getMetaTypes().getExtensionPoint(), value.equalsIgnoreCase("true")); } } } }
/** @see org.argouml.uml.ui.UMLComboBoxModel2#buildModelList() */ protected void buildModelList() { Object target = TargetManager.getInstance().getModelTarget(); Collection ops = new ArrayList(); if (Model.getFacade().isACallEvent(target)) { Object ns = Model.getFacade().getNamespace(target); if (Model.getFacade().isANamespace(ns)) { Collection c = Model.getModelManagementHelper() .getAllModelElementsOfKind(ns, Model.getMetaTypes().getClassifier()); Iterator i = c.iterator(); while (i.hasNext()) { ops.addAll(Model.getFacade().getOperations(i.next())); } } } setElements(ops); }
/* * @see AbstractTestActionAddDiagram#getValidNamespaceClasses() */ protected List getValidNamespaceClasses() { List rl = new ArrayList(); /* * This needs to be a concrete metatype, so we can't use * the general, but abstract, Classifier. Replace with its * concrete subtypes. */ rl.add(Model.getMetaTypes().getUMLClass()); rl.add(Model.getMetaTypes().getInterface()); rl.add(Model.getMetaTypes().getDataType()); rl.add(Model.getMetaTypes().getNode()); rl.add(Model.getMetaTypes().getComponent()); // TODO: this should fail, but it doesn't: rl.add(Model.getMetaTypes().getTransition()); return rl; }
/** * Test remove() function. This is called when a new project is created to remove the old project. * We confirm here that the users model has been emptied and that no none 'Model' model elements * are at root. * * @throws InterruptedException if there the project load was interrupted * @throws OpenException if there was an error during project load * @throws URISyntaxException when the URI can not be formed */ public void testRemove() throws OpenException, InterruptedException, URISyntaxException { String name = "/testmodels/uml14/Alittlebitofeverything.zargo"; URL url = TestProject.class.getResource(name); AbstractFilePersister persister = PersistenceManager.getInstance().getPersisterFromFileName(name); URI uri = url.toURI(); Project p = persister.doLoad(new File(uri)); p.remove(); for (Object root : Model.getFacade().getRootElements()) { assertTrue( "All roots should be a Model - but found a " + Model.getMetaTypes().getName(root), Model.getFacade().isAModel(root)); System.out.println( Model.getFacade().getName(root) + " " + Model.getFacade().getOwnedElements(root).size()); if ("untitledModel".equals(Model.getFacade().getName(root))) { assertEquals( "All root models should be empty", 0, Model.getFacade().getOwnedElements(root).size()); } } }
/** * The list of operations shall contain all operations of all classifiers contained in the same * package as the callaction itself. * * <p>TODO: In fact, we also should include operations of imported clasifiers. * * @see org.argouml.uml.ui.UMLComboBoxModel2#buildModelList() */ protected void buildModelList() { Object target = TargetManager.getInstance().getModelTarget(); Collection ops = new ArrayList(); if (Model.getFacade().isACallAction(target)) { Object ns = Model.getFacade().getModelElementContainer(target); while (!Model.getFacade().isAPackage(ns)) { ns = Model.getFacade().getModelElementContainer(ns); if (ns == null) { break; } } if (Model.getFacade().isANamespace(ns)) { Collection c = Model.getModelManagementHelper() .getAllModelElementsOfKind(ns, Model.getMetaTypes().getClassifier()); Iterator i = c.iterator(); while (i.hasNext()) { ops.addAll(Model.getFacade().getOperations(i.next())); } } /* To be really sure, let's add the operation * that is linked to the action in the model, * too - if it is not listed yet. * We need this, incase an operation is moved * out of the package, * or maybe with imported XMI... */ Object current = Model.getFacade().getOperation(target); if (Model.getFacade().isAOperation(current)) { if (!ops.contains(current)) { ops.add(current); } } } setElements(ops); }
protected Action getCreateEdgeAction(Object metaType) { String label = Model.getMetaTypes().getName(metaType); return new RadioAction( new ActionSetMode(ModeCreatePolyEdge.class, "edgeClass", metaType, label)); }
/** Init the modelelement types that we can look for. */ private void initTypes() { type.addItem(PredicateMType.create()); // Any type type.addItem(PredicateMType.create(Model.getMetaTypes().getUMLClass())); type.addItem(PredicateMType.create(Model.getMetaTypes().getInterface())); type.addItem(PredicateMType.create(Model.getMetaTypes().getAction())); // Not in UML 2.x (or metatypes) // type.addItem(PredicateMType.create( // Model.getMetaTypes().getActivityGraph())); type.addItem(PredicateMType.create(Model.getMetaTypes().getActor())); type.addItem(PredicateMType.create(Model.getMetaTypes().getAssociation())); type.addItem(PredicateMType.create(Model.getMetaTypes().getAssociationClass())); type.addItem(PredicateMType.create(Model.getMetaTypes().getAssociationEndRole())); type.addItem(PredicateMType.create(Model.getMetaTypes().getAssociationRole())); type.addItem(PredicateMType.create(Model.getMetaTypes().getArtifact())); type.addItem(PredicateMType.create(Model.getMetaTypes().getAttribute())); type.addItem(PredicateMType.create(Model.getMetaTypes().getClassifier())); type.addItem(PredicateMType.create(Model.getMetaTypes().getClassifierRole())); type.addItem(PredicateMType.create(Model.getMetaTypes().getCollaboration())); type.addItem(PredicateMType.create(Model.getMetaTypes().getComment())); type.addItem(PredicateMType.create(Model.getMetaTypes().getComponent())); type.addItem(PredicateMType.create(Model.getMetaTypes().getCompositeState())); type.addItem(PredicateMType.create(Model.getMetaTypes().getConstraint())); type.addItem(PredicateMType.create(Model.getMetaTypes().getDataType())); type.addItem(PredicateMType.create(Model.getMetaTypes().getDependency())); type.addItem(PredicateMType.create(Model.getMetaTypes().getElementImport())); type.addItem(PredicateMType.create(Model.getMetaTypes().getEnumeration())); type.addItem(PredicateMType.create(Model.getMetaTypes().getEnumerationLiteral())); type.addItem(PredicateMType.create(Model.getMetaTypes().getException())); type.addItem(PredicateMType.create(Model.getMetaTypes().getExtend())); type.addItem(PredicateMType.create(Model.getMetaTypes().getExtensionPoint())); type.addItem(PredicateMType.create(Model.getMetaTypes().getGuard())); type.addItem(PredicateMType.create(Model.getMetaTypes().getGeneralization())); type.addItem(PredicateMType.create(Model.getMetaTypes().getInclude())); type.addItem(PredicateMType.create(Model.getMetaTypes().getInstance())); type.addItem(PredicateMType.create(Model.getMetaTypes().getInteraction())); type.addItem(PredicateMType.create(Model.getMetaTypes().getInterface())); type.addItem(PredicateMType.create(Model.getMetaTypes().getLink())); type.addItem(PredicateMType.create(Model.getMetaTypes().getMessage())); type.addItem(PredicateMType.create(Model.getMetaTypes().getModel())); type.addItem(PredicateMType.create(Model.getMetaTypes().getNode())); type.addItem(PredicateMType.create(Model.getMetaTypes().getPackage())); type.addItem(PredicateMType.create(Model.getMetaTypes().getParameter())); type.addItem(PredicateMType.create(Model.getMetaTypes().getPartition())); type.addItem(PredicateMType.create(Model.getMetaTypes().getPseudostate())); type.addItem(PredicateMType.create(Model.getMetaTypes().getOperation())); type.addItem(PredicateMType.create(Model.getMetaTypes().getSimpleState())); type.addItem(PredicateMType.create(Model.getMetaTypes().getSignal())); type.addItem(PredicateMType.create(Model.getMetaTypes().getState())); type.addItem(PredicateMType.create(Model.getMetaTypes().getStateMachine())); type.addItem(PredicateMType.create(Model.getMetaTypes().getStateVertex())); type.addItem(PredicateMType.create(Model.getMetaTypes().getStereotype())); type.addItem(PredicateMType.create(Model.getMetaTypes().getTagDefinition())); // TODO: Doesn't work (perhaps because composite?), so disable for // now so user isn't misled - tfm - 20070904 // type.addItem(PredicateMType.create( // Model.getMetaTypes().getTaggedValue())); // Not in UML 2.x (or Metatypes) // type.addItem(PredicateMType.create( // Model.getMetaTypes().getTemplateArgument())); // type.addItem(PredicateMType.create( // Model.getMetaTypes().getTemplateParameter())); type.addItem(PredicateMType.create(Model.getMetaTypes().getTransition())); type.addItem(PredicateMType.create(Model.getMetaTypes().getUseCase())); }
/** The constructor. */ public ActionAddClassifierRole() { super(Model.getMetaTypes().getClassifierRole(), "button.new-classifierrole"); }
/* * @see AbstractTestActionAddDiagram#getValidNamespaceClasses() */ protected List getValidNamespaceClasses() { List rl = new ArrayList(); rl.add(Model.getMetaTypes().getUMLClass()); return rl; }
/** * Find the Icon for a given model element. * * @return The Icon or <code>null</code> if there is no Icon. * @param value The model element. * <p>TODO: This should not use string matching on classnames to do this since this means that * we have knowledge about how the model elements are implemented outside of the Model * component. */ public Icon lookupIcon(Object value) { if (value == null) { throw new IllegalArgumentException("Attempted to get an icon given a null key"); } if (value instanceof String) { return null; } Icon icon = iconCache.get(value.getClass()); try { if (Model.getFacade().isAPseudostate(value)) { Object kind = Model.getFacade().getKind(value); DataTypesHelper helper = Model.getDataTypesHelper(); if (helper.equalsINITIALKind(kind)) { icon = initialStateIcon; } if (helper.equalsDeepHistoryKind(kind)) { icon = deepIcon; } if (helper.equalsShallowHistoryKind(kind)) { icon = shallowIcon; } if (helper.equalsFORKKind(kind)) { icon = forkIcon; } if (helper.equalsJOINKind(kind)) { icon = joinIcon; } if (helper.equalsCHOICEKind(kind)) { icon = branchIcon; } if (helper.equalsJUNCTIONKind(kind)) { icon = junctionIcon; } // if (MPseudostateKind.FINAL.equals(kind)) // icon = _FinalStateIcon; } if (Model.getFacade().isAAbstraction(value)) { icon = realizeIcon; } if (Model.getFacade().isAException(value)) { icon = exceptionIcon; } else { // needs more work: sending and receiving icons if (Model.getFacade().isASignal(value)) { icon = signalIcon; } } if (Model.getFacade().isAComment(value)) { icon = commentIcon; } if (icon == null) { String cName = Model.getMetaTypes().getName(value); icon = lookupIconResource(cName); if (icon == null) { LOG.log(Level.FINE, "Can't find icon for {0}", cName); } else { synchronized (iconCache) { iconCache.put(value.getClass(), icon); } } } } catch (InvalidElementException e) { LOG.log(Level.FINE, "Attempted to get icon for deleted element"); return null; } return icon; }
/** * Returns the meta type for Attribute to indicate the type of model element within this * compartment. * * @return a model element type */ public Object getCompartmentType() { return Model.getMetaTypes().getAttribute(); }
/* * @see org.argouml.uml.cognitive.critics.CrUML#getCriticizedDesignMaterials() */ public Set<Object> getCriticizedDesignMaterials() { Set<Object> ret = new HashSet<Object>(); ret.add(Model.getMetaTypes().getClassifier()); return ret; }
/** Constructor for UMLGeneralizationPowertypeComboBoxModel. */ public UMLGeneralizationPowertypeComboBoxModel() { super("powertype", true); Model.getPump() .addClassModelEventListener(this, Model.getMetaTypes().getNamespace(), "ownedElement"); }
/** Constructor for UMLModelElementNamespaceComboBoxModel. */ public UMLModelElementNamespaceComboBoxModel() { super("namespace", true); Model.getPump() .addClassModelEventListener(this, Model.getMetaTypes().getNamespace(), "ownedElement"); }
public Object getMetaType() { return Model.getMetaTypes().getAssociationEnd(); }
/** @see org.argouml.uml.diagram.static_structure.ui.SelectionDataType#getNewNodeType(int) */ protected Object getNewNodeType(int buttonCode) { return Model.getMetaTypes().getEnumeration(); }