/** * Move this object up by one in the list of relations of the container. If this object is already * first, do nothing. Increment the version of the workspace. * * @return The index of the specified object prior to moving it, or -1 if it is not moved. * @exception IllegalActionException If this object has no container. */ public int moveUp() throws IllegalActionException { CompositeEntity container = (CompositeEntity) getContainer(); if (container == null) { throw new IllegalActionException(this, "Has no container."); } try { _workspace.getWriteAccess(); int result = container._containedRelations.moveUp(this); // Propagate. Iterator derivedObjects = getDerivedList().iterator(); while (derivedObjects.hasNext()) { NamedObj derived = (NamedObj) derivedObjects.next(); container = (CompositeEntity) derived.getContainer(); container._containedRelations.moveUp(derived); } return result; } finally { _workspace.doneWriting(); } }
/** * Return the (presumably Settable) attribute modified by this actor. This is the attribute in the * container of this actor with the name given by the variableName attribute. If no such attribute * is found, then this method creates a new variable in the actor's container with the correct * name. This method gets write access on the workspace. * * @exception IllegalActionException If the variable cannot be found. * @return The attribute modified by this actor. */ public Attribute getModifiedVariable() throws IllegalActionException { NamedObj container = getContainer(); if (container == null) { throw new IllegalActionException(this, "No container."); } String variableNameValue = variableName.getExpression(); Attribute attribute = null; // Look for the variableName anywhere in the hierarchy while ((attribute == null) && (container != null)) { attribute = container.getAttribute(variableNameValue); if (attribute == null) { container = container.getContainer(); } } if (attribute == null) { try { workspace().getWriteAccess(); // container might be null, so create the variable // in the container of this actor. attribute = new Variable(getContainer(), variableNameValue); } catch (NameDuplicationException ex) { throw new InternalErrorException(ex); } finally { workspace().doneWriting(); } } return attribute; }
/** Refreshes the visual properties of the TreeItem for this part. */ protected void refreshVisuals() { if (getWidget() instanceof Tree) return; NamedObj model = getNamedObjectModel(); // Set Image if (model instanceof Director) setWidgetImage(DirectorEditPart.IMAGE_DESCRIPTOR_DIRECTOR, model); else if (model instanceof Parameter) setWidgetImage(ActorEditPart.IMAGE_DESCRIPTOR_PARAMETER, model); else if (model instanceof IOPort) { IOPort port = (IOPort) model; if (port.isInput()) setWidgetImage(ActorEditPart.IMAGE_DESCRIPTOR_INPUTPORT, model); else setWidgetImage(ActorEditPart.IMAGE_DESCRIPTOR_OUTPUTPORT, model); } else if (model instanceof TypedAtomicActor) { setWidgetImage(ActorEditPart.IMAGE_DESCRIPTOR_ACTOR, model); } else if (model instanceof CompositeActor) { setWidgetImage(PaletteBuilder.getInstance().getIcon(model.getClass()), model); } // Set Text if (model instanceof Parameter) { Parameter param = (Parameter) model; String name = param.getName(); String value = param.getExpression(); setWidgetText(name + "=" + (value == null ? "" : value)); } else setWidgetText(model.getName()); }
/** * Update the model with MoML that was presumably generated by generateMoML(). * * @param updatedMoML The moml from generateMoML() * @param context The context for the change. One way to get the context is by calling * basicGraphFrame.getModel(). * @return The name of the state machine that was created. * @exception Exception If thrown while synthesizing. */ public static String updateModel(String updatedMoML, NamedObj context) throws Exception { // FIXME: instantiating a new parser each time could be a // mistake. What about leaks? What about initialization of // the filters? MoMLParser parser = new MoMLParser(); NamedObj model = parser.parse(updatedMoML); String moml = ""; String updatedName = ""; if (model != null) { // Change the name of the output module to an unused name. moml = model.exportMoMLPlain(); String moduleName = "model"; int i = 1; Iterator<NamedObj> containedObjects = context.containedObjectsIterator(); while (containedObjects.hasNext()) { if (containedObjects.next().getName().equals(moduleName + String.valueOf(i))) { containedObjects = context.containedObjectsIterator(); i++; } } // Change the module to the updated name, and commit changes updatedName = moduleName + String.valueOf(i); moml = moml.replaceFirst(moduleName, updatedName); MoMLChangeRequest request = new MoMLChangeRequest(context, context, moml); context.requestChange(request); } return updatedName; }
/** * Return the container entity for the specified ASTPtRootNode. * * @param node The specified ASTPtRootNode. * @return The container entity for the specified ASTPtRootNode. */ public Entity getContainerEntity(ASTPtRootNode node) { Attribute attribute = _solver.getAttribute(node); NamedObj container = attribute.getContainer(); while (!(container instanceof Entity)) { container = container.getContainer(); } return (Entity) container; }
/** * If the attributeName is "class" and attributeValue names a class that has had its port names * changed between releases, then substitute in the new port names. * * @param container The container for this attribute. in this method. * @param element The XML element name. * @param attributeName The name of the attribute. * @param attributeValue The value of the attribute. * @param xmlFile The file currently being parsed. * @return the value of the attributeValue argument. */ public String filterAttributeValue( NamedObj container, String element, String attributeName, String attributeValue, String xmlFile) { // This method gets called many times by the MoMLParser, // so we try to be smart about the number of comparisons // and we try to group comparisons together so that we // are not making the same comparison more than once. if (attributeValue == null) { // attributeValue == null is fairly common, so we check for // that first return null; } if (attributeName.equals("name")) { // Save the name of the for later use if we see a "class" _lastNameSeen = attributeValue; if (_currentlyProcessingActorThatMayNeedAnIcon && attributeValue.equals("_icon")) { // We are processing an annotation and it already // has _icon _currentlyProcessingActorThatMayNeedAnIcon = false; } } // If you change this class, you should run before and after // timing tests on large moml files, a good command to run // is: // $PTII/bin/ptolemy -test $PTII/ptolemy/domains/ct/demo/CarTracking/CarTracking.xml // which will open up a large xml file and then close after 2 seconds. if (attributeName.equals("class")) { if (_actorsThatShouldHaveIcons.containsKey(attributeValue)) { // We found a class that needs an _icon _currentlyProcessingActorThatMayNeedAnIcon = true; if (container != null) { _currentActorFullName = container.getFullName() + "." + _lastNameSeen; } else { _currentActorFullName = "." + _lastNameSeen; } _iconMoML = (String) _actorsThatShouldHaveIcons.get(attributeValue); } else if (_currentlyProcessingActorThatMayNeedAnIcon && container != null && !container.getFullName().equals(_currentActorFullName) && !container.getFullName().startsWith(_currentActorFullName)) { // We found another class in a different container // while handling a class with port name changes, so _currentlyProcessingActorThatMayNeedAnIcon = false; } } return attributeValue; }
/////////////////////////////////////////////////////////////////// //// private methods //// private String _deletesIfNecessary(NamedObj obj) { String retv = null; Attribute color = obj.getAttribute("_color"); Attribute explanation = obj.getAttribute("_explanation"); if ((color != null) && (explanation != null)) { retv = "<deleteProperty name=\"_color\"/>" + "<deleteProperty name=\"_explanation\"/>"; } return retv; }
/** * Establish this icon as a listener for changes in attributes named "_iconDescription" and * "_smallIconDescription" in the specified container. */ private void _bindToContainer(NamedObj container) { // Get the description. ConfigurableAttribute description = (ConfigurableAttribute) container.getAttribute("_iconDescription"); // If the description has changed... if (_description != description) { if (_description != null) { // Remove this as a listener if there // was a previous description. _description.removeValueListener(this); } // update the description. _description = description; if (_description != null) { // Listen for changes in value to the icon description. _description.addValueListener(this); } } // Get the icon description. description = (ConfigurableAttribute) container.getAttribute("_smallIconDescription"); // If the description has changed... if (_smallIconDescription != description) { if (_smallIconDescription != null) { // Remove this as a listener if there // was a previous description. _smallIconDescription.removeValueListener(this); } // update the description. _smallIconDescription = description; if (_smallIconDescription != null) { // Listen for changes in value to the icon description. _smallIconDescription.addValueListener(this); } } try { _updateContents(); } catch (Exception ex) { // Regrettable, but how else to inform of error? throw new InternalErrorException(ex); } // clear the caches _recreateFigure(); }
/** * Find an attribute in the object or its container (if searchContainers is true) in the given * class. * * @param object The object to which the attribute longs. * @param attributeClass The attribute class. * @param searchContainers Whether containers of the object are searched. * @return The attribute if found, or null otherwise. */ public static Attribute findMatchingAttribute( Object object, Class<? extends Attribute> attributeClass, boolean searchContainers) { if (object instanceof NamedObj) { NamedObj namedObj = (NamedObj) object; List<?> list = namedObj.attributeList(attributeClass); if (!list.isEmpty()) { return (Attribute) list.get(0); } else if (searchContainers) { return findMatchingAttribute(namedObj.getContainer(), attributeClass, searchContainers); } } return null; }
/** * Check the validity of a link. If the link crosses levels of the hierarchy, then set the * container persistent to ensure that MoML is exported for this link. This is used in a "strategy * pattern," where the link methods call it to check the validity of a link, and derived classes * perform more elaborate checks. * * @param relation The relation to link to. * @exception IllegalActionException If this port has no container or the relation is not a * ComponentRelation, or the relation has no container, or the link crosses levels of the * hierarchy. */ protected void _checkLiberalLink(Relation relation) throws IllegalActionException { if (relation != null) { if (!(relation instanceof ComponentRelation)) { throw new IllegalActionException( this, relation, "Attempt to link to an incompatible relation " + "(expected ComponentRelation)."); } Entity container = (Entity) getContainer(); if (container == null) { throw new IllegalActionException( this, relation, "Port must have a container to establish a link."); } // Check that the container is not a class or that // if it is, that this is an inside link. if (container.isClassDefinition() && container != relation.getContainer()) { throw new IllegalActionException( this, relation, "Cannot establish a link to a port contained " + "by a class definition"); } // Throw an exception if this port is not of an acceptable // class for the relation. relation._checkPort(this); // Superclass assures that the container is not null. Nameable relationContainer = relation.getContainer(); if (container != relationContainer && container.getContainer() != relationContainer) { // Link crosses levels of the hierarchy. // Ensure that an export occurs. // If it's an inside link, then make the container // persistent. Otherwise, make the container's container // persistent. if (container.deepContains(relation)) { container.setPersistent(true); } else { NamedObj containersContainer = container.getContainer(); if (containersContainer != null) { containersContainer.setPersistent(true); } } } } }
/** * Create a copy of the given model with the given parser that is cleaned up with no execution * state left in it. * * @param model The model to be copied. * @param parser The parser. * @return A cleaned up copy of the given model. * @exception IllegalActionException If the model cannot be copied. */ public static NamedObj cleanupModel(NamedObj model, MoMLParser parser) throws IllegalActionException { try { URIAttribute uriAttribute = (URIAttribute) model.getAttribute("_uri", URIAttribute.class); NamedObj newModel; if (uriAttribute != null) { newModel = parser.parse(uriAttribute.getURL(), model.exportMoML()); } else { newModel = parser.parse(model.exportMoML()); } return newModel; } catch (Exception e) { throw new IllegalActionException(model, e, "Unable to clean up model."); } }
/** * Return the change request to delete the given object. * * @param originator The originator of the change request. * @param object The object to be deleted. * @return The change request. */ public static MoMLChangeRequest getDeletionChangeRequest(Object originator, NamedObj object) { String moml; if (object instanceof Attribute) { moml = "<deleteProperty name=\"" + object.getName() + "\"/>"; } else if (object instanceof Entity) { moml = "<deleteEntity name=\"" + object.getName() + "\"/>"; } else if (object instanceof Port) { moml = "<deletePort name=\"" + object.getName() + "\"/>"; } else if (object instanceof Relation) { moml = "<deleteRelation name=\"" + object.getName() + "\"/>"; } else { return null; } return new MoMLChangeRequest(originator, object.getContainer(), moml); }
/** * Make modifications to the specified container, which is defined in a MoML element with the * specified name. * * @param container The object created by this element. * @param elementName The element name. * @param currentCharData The character data, which appears only in the doc and configure elements * @param xmlFile The file currently being parsed. * @param parser The parser in which MoML is optionally evaluated. * @exception Exception if there is a problem substituting in the new value. */ public void filterEndElement( NamedObj container, String elementName, StringBuffer currentCharData, String xmlFile, MoMLParser parser) throws Exception { if (_currentlyProcessingActorThatMayNeedAnIcon && elementName.equals("entity") && container != null && container.getFullName().equals(_currentActorFullName)) { _currentlyProcessingActorThatMayNeedAnIcon = false; // Note that setContext() calls reset() so we don't want // to do it on the main parser. parser.setContext(container); try { // Do not call parse(_iconMoML) here, since that method // will fail if we are in an applet because it tries // to read user.dir parser.parse(null, _iconMoML); MoMLParser.setModified(true); } catch (Exception ex) { throw new IllegalActionException(null, ex, "Failed to parse\n" + _iconMoML); } } }
/** * Return a string with a MoML description of all the objects in the list. * * @return the MoML description. * @exception IOException If thrown while creating the MoML. */ public String _getMoML() throws IOException { StringWriter buffer = new StringWriter(); buffer.write("<group>\n"); Iterator elements = Collections.unmodifiableList(_objectList).iterator(); while (elements.hasNext()) { NamedObj element = (NamedObj) elements.next(); // first level to avoid obnoxiousness with toplevel translations. element.exportMoML(buffer, 1); } buffer.write("</group>\n"); return buffer.toString(); }
/** * Remove the highlighting and visible annotations for all property-able objects. * * @param colors True if the highlight colors should be cleared. * @param text True if the ontology concept annotation text should be cleared. * @exception IllegalActionException If getting the resolved concept fails. */ public void clearDisplay(boolean colors, boolean text) throws IllegalActionException { if (colors || text) { // Get the OntologySolver. OntologySolver solver = (OntologySolver) getContainer(); for (Object propertyable : solver.getAllPropertyables()) { if (propertyable instanceof NamedObj) { Concept concept = solver.getConcept(propertyable); if (concept != null || ((NamedObj) propertyable).getAttribute("_showInfo") != null && colors || ((NamedObj) propertyable).getAttribute("_highlightColor") != null && text) { String request = "<group>"; if (((NamedObj) propertyable).getAttribute("_showInfo") != null && text) { request += "<deleteProperty name=\"_showInfo\"/>"; } if (((NamedObj) propertyable).getAttribute("_highlightColor") != null && colors) { request += "<deleteProperty name=\"_highlightColor\"/>"; } request += "</group>"; MoMLChangeRequest change = new MoMLChangeRequest(this, (NamedObj) propertyable, request, false); ((NamedObj) propertyable).requestChange(change); } } } // Force a single repaint after all the above requests have been processed. solver.requestChange(new MoMLChangeRequest(this, solver, "<group/>")); } }
// private ComponentEntity cloneEntity(ComponentEntity entity) throws // IllegalActionException { private NamedObj cloneEntity(NamedObj entity) throws IllegalActionException { try { return (NamedObj) entity.clone(this.workspace); } catch (java.lang.CloneNotSupportedException cnse) { throw new IllegalActionException("clone not supported: " + cnse); } }
/** * Highlight concepts that have already been resolved, but do not run solver. Otherwise, do * nothing. * * @param objects The set of objects to highlight. * @exception IllegalActionException Thrown if there is an error getting the colors for the * resolved concept values. */ public void highlightConcepts(Set<Object> objects) throws IllegalActionException { if (objects != null) { // Get the PropertySolver. OntologySolver solver = (OntologySolver) getContainer(); for (Object object : objects) { if (object instanceof NamedObj) { Concept concept = solver.getConcept(object); if (concept != null) { ColorAttribute conceptColor = concept.getColor(); if (conceptColor != null) { String request = "<property name=\"_highlightColor\" " + "class=\"ptolemy.actor.gui.ColorAttribute\" value=\"" + conceptColor.getExpression() + "\"/>"; MoMLChangeRequest change = new MoMLChangeRequest(this, (NamedObj) object, request, false); ((NamedObj) object).requestChange(change); } } } } // Force a single repaint after all the above requests have been processed. solver.requestChange(new MoMLChangeRequest(this, solver, "<group/>")); } }
/** * Get the children of the given object. The children can be either attributes, ports, entities, * or relations if permitted by the arguments. * * @param object The object. * @param includeAttributes Whether the children can be attributes. * @param includePorts Whether the children can be ports. * @param includeEntities Whether the children can be entities. * @param includeRelations Whether the children can be relations. * @return The collection of children. */ public static Collection<NamedObj> getChildren( NamedObj object, boolean includeAttributes, boolean includePorts, boolean includeEntities, boolean includeRelations) { Collection<NamedObj> collection = new CombinedCollection<NamedObj>(); if (includeAttributes) { collection.addAll(object.attributeList()); } if (includePorts && object instanceof Entity) { Entity entity = (Entity) object; collection.addAll(entity.portList()); } if (object instanceof CompositeEntity) { CompositeEntity entity = (CompositeEntity) object; if (includeEntities) { collection.addAll(entity.entityList()); } if (includeRelations) { collection.addAll(entity.relationList()); } } return collection; }
/** * Check the class of the container in which the attribute is to be placed. If the container is * not an intended one, throw an IllegalActionException. * * @param attribute The attribute to check. * @param container The container. * @param containerClass The intended class of container. * @param deep Whether containers of the container should be checked instead, if the container * does not qualify. * @exception IllegalActionException If this attribute cannot be used with the given container. */ public static void checkContainerClass( Attribute attribute, NamedObj container, Class<? extends CompositeEntity> containerClass, boolean deep) throws IllegalActionException { while (deep && container != null && !containerClass.isInstance(container) && !(container instanceof EntityLibrary)) { container = container.getContainer(); if (container instanceof EntityLibrary) { return; } } if (container == null || !containerClass.isInstance(container) && !(container instanceof EntityLibrary)) { _delete(attribute); throw new IllegalActionException( attribute.getClass().getSimpleName() + " can only be added to " + containerClass.getSimpleName() + "."); } }
/** * Generate string of evaluated tokens of parameters of the agent. * * @param agent whether the parameters belong to. * @return string of evaluated parameters. */ private String _agentParameterTokens(NamedObj agent) throws IllegalActionException { LinkedList parameterList = (LinkedList) agent.attributeList(Parameter.class); ListIterator parameters = parameterList.listIterator(); String tokenString = ""; while (parameters.hasNext()) { Parameter parameter = (Parameter) parameters.next(); String parameterName = parameter.getName(); if (parameterName.startsWith("_")) { continue; } String tokenValue = parameter.getToken().toString(); if (tokenString == "") { tokenString += tokenValue; } else { tokenString += (", " + tokenValue); } } return tokenString; }
/** * Generate string of parameters of the agent. * * @param agent whether the parameters belong to. * @param typed indicates whether the parameters have type. * @return string of parameters. */ private String _agentParameters(NamedObj agent, boolean typed) { LinkedList parameterList = (LinkedList) agent.attributeList(Parameter.class); ListIterator parameters = parameterList.listIterator(); String prefix = ""; if (typed) { prefix = "real "; } String parameterString = ""; while (parameters.hasNext()) { String parameterName = ((NamedObj) parameters.next()).getName(); if (parameterName.startsWith("_")) { continue; } if (parameterString == "") { parameterString += (prefix + parameterName); } else { parameterString += (", " + prefix + parameterName); } } return parameterString; }
/** * Get the {@link PatternObjectAttribute} associated with the object, and if it is not found, * either return null if createNew is false, or create a new one and return it. * * @param object The object. * @param createNew Whether a new attribute should be created if it is not found. * @return The attribute. * @exception IllegalActionException If the attribute is not of an acceptable class for the * container, or if the name contains a period. * @exception NameDuplicationException If the name coincides with an attribute already in the * container. */ public static PatternObjectAttribute getPatternObjectAttribute(NamedObj object, boolean createNew) throws IllegalActionException, NameDuplicationException { Attribute attribute = object.getAttribute("patternObject"); if (createNew && (attribute == null || !(attribute instanceof PatternObjectAttribute))) { attribute = new PatternObjectAttribute(object, "patternObject"); } return (PatternObjectAttribute) attribute; }
/** * Remove the EditorIcons defined for the entity. * * @param entity The entity. * @return true if at least one EditorIcon is found and removed; false otherwise. * @exception KernelException If error occurs while removing the EditorIcons. */ private static boolean _removeEditorIcons(GTEntity entity) throws KernelException { NamedObj object = (NamedObj) entity; boolean foundPersistentIcon = false; try { object.workspace().getReadAccess(); for (Object iconObject : object.attributeList(EditorIcon.class)) { EditorIcon icon = (EditorIcon) iconObject; if (icon.isPersistent()) { foundPersistentIcon = true; } else { icon.setContainer(null); } } } finally { object.workspace().doneReading(); } return !foundPersistentIcon; }
/** * Construct a frame associated with an SCR Model. * * @param model The model to put in this frame, or null if none. * @param tableau The tableau responsible for this frame, or null if none. */ public SCRTableFrame(NamedObj model, Tableau tableau) { super(tableau); if (model instanceof FSMActor) { _model = (FSMActor) model; } else { MessageHandler.error("Cannot initialize SCRTableFrame with a " + model.getClassName()); } _init(); }
/** * Open an edit parameters dialog. This is a modal dialog, so this method returns only after the * dialog has been dismissed. * * @param parent A frame to serve as a parent for the dialog, or null if there is none. * @param target The object whose parameters are to be edited. */ public void openDialog(Frame parent, NamedObj target) { List attributeList = target.attributeList(EditorFactory.class); if (attributeList.size() > 0) { EditorFactory factory = (EditorFactory) attributeList.get(0); factory.createEditor(target, parent); } else { new EditParametersDialog(parent, target); } }
/** * Find the effigy associated with the top level of the object, and if not found but the top level * has a ContainmentExtender attribute, use that attribute to find the containment extender of the * top level and continue the search. * * @param object The object. * @return The effigy, or null if not found. * @exception IllegalActionException If attributes cannot be retrieved, or the container that an * attribute points to is invalid. */ public static Effigy findToplevelEffigy(NamedObj object) throws IllegalActionException { // FIXME: Should topEffigy call this method? NamedObj toplevel; do { toplevel = object.toplevel(); Effigy effigy = Configuration.findEffigy(toplevel); if (effigy != null) { return effigy; } ContainmentExtender extender = (ContainmentExtender) toplevel.getAttribute("_containmentExtender", ContainmentExtender.class); object = toplevel; if (extender != null) { object = extender.getExtendedContainer(); } } while (toplevel != object); return null; }
/** * Get the string to render in the icon. This string is the expression giving the value of the * attribute of the container having the name <i>attributeName</i>, truncated so that it is no * longer than <i>displayWidth</i> characters. If it is truncated, then the string has a trailing * "...". If the string is empty, then return a string with one space (diva fails on empty * strings). * * @return The string to display, or null if none is found. */ protected String _displayString() { NamedObj container = getContainer(); if (container != null) { StringBuffer buffer = new StringBuffer(); Iterator settables = container.attributeList(Settable.class).iterator(); while (settables.hasNext()) { Settable settable = (Settable) settables.next(); if ((settable.getVisibility() != Settable.FULL) && (settable.getVisibility() != Settable.NOT_EDITABLE)) { continue; } String name = settable.getDisplayName(); String value = settable.getExpression(); String line = name + ": " + value; String truncated = line; try { int width = ((IntToken) displayWidth.getToken()).intValue(); if (line.length() > width) { truncated = line.substring(0, width) + "..."; } } catch (IllegalActionException ex) { // Ignore... use whole string. } buffer.append(truncated); if (settables.hasNext()) { buffer.append("\n"); } } return buffer.toString(); } return null; }
/** * Get the change request to update the object in the host model. * * @param pattern The pattern of the transformation rule. * @param replacement The replacement of the transformation rule. * @param matchResult The match result. * @param patternObject The object in the pattern, or null. * @param replacementObject The object in the replacement that corresponds to the object in the * pattern. * @param hostObject The object in the host model corresponding to the object in the replacement. * @return The change request. * @exception IllegalActionException If error occurs in generating the change request. */ @Override public ChangeRequest getChangeRequest( Pattern pattern, Replacement replacement, MatchResult matchResult, NamedObj patternObject, NamedObj replacementObject, NamedObj hostObject) throws IllegalActionException { if (_valueParseTree == null) { _reparse(); } ParserScope scope = NamedObjVariable.getNamedObjVariable(hostObject, true).getParserScope(); GTParameter.Evaluator evaluator = new GTParameter.Evaluator(pattern, matchResult); String name; if (_valueParseTree instanceof ASTPtSumNode) { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < _valueParseTree.jjtGetNumChildren(); i++) { ASTPtRootNode child = (ASTPtRootNode) _valueParseTree.jjtGetChild(i); if (!(child.isConstant() && child.getToken() instanceof StringToken)) { ASTPtLeafNode newNode = _evaluate(child, evaluator, scope); buffer.append(_parseTreeWriter.parseTreeToExpression(newNode)); } else { buffer.append(((StringToken) child.getToken()).stringValue()); } } name = buffer.toString(); } else if (!(_valueParseTree.isConstant() && _valueParseTree.getToken() instanceof StringToken)) { ASTPtRootNode newRoot = _evaluate(_valueParseTree, evaluator, scope); name = _parseTreeWriter.parseTreeToExpression(newRoot); } else { name = _name.get(); } NamedObj parent = hostObject.getContainer(); String moml = "<entity name=\"" + hostObject.getName() + "\"><rename name=\"" + name + "\"/></entity>"; return new MoMLChangeRequest(this, parent, moml, null); }
/** * Remove the decorated attributes. * * @param target The decorated attribute to remove */ public void removeDecoratedAttributes(NamedObj target) { if (_debugging) { _debug("create decorated attributes to be called for Giotto quantityManager"); } for (Actor actor : (List<Actor>) ((TypedCompositeActor) target.getContainer()).deepEntityList()) { NamedObj temp = (NamedObj) actor; if (_debugging) { _debug("temp has name " + temp.getDisplayName()); } List<Parameter> paramList = temp.attributeList(); for (Parameter param : paramList) { if (param.getDisplayName().equals("WCET")) { param.setPersistent(false); } } } }
/** * Check whether the attribute is unique in the given container. * * @param attribute The attribute to check. * @param container The container. * @exception IllegalActionException If the container already has an attribute in the same class. */ public static void checkUniqueness(Attribute attribute, NamedObj container) throws IllegalActionException { if (container instanceof EntityLibrary) { return; } try { container.workspace().getReadAccess(); List<? extends Attribute> attributeList = container.attributeList(attribute.getClass()); for (Attribute existingAttribute : attributeList) { if (existingAttribute != attribute && existingAttribute.isPersistent()) { _delete(attribute); throw new IllegalActionException( "Only 1 " + attribute.getClass().getSimpleName() + " can be used."); } } } finally { container.workspace().doneReading(); } }