Package ptolemy.kernel

Examples of ptolemy.kernel.Entity$ContainedObjectsIterator


        //Hierarchy h = Scene.v().getActiveHierarchy();

        for (Iterator entities = _model.deepEntityList().iterator(); entities
                .hasNext();) {
            Entity entity = (Entity) entities.next();
            String className = ModelTransformer.getInstanceClassName(entity,
                    options);
            SootClass theClass = Scene.v().loadClassAndSupport(className);

            Set unsafeLocalSet = new HashSet();
View Full Code Here


     *   is defined in the class definition.
     */
    private Port _deletePort(String portName, String entityName)
            throws Exception {
        Port toDelete = null;
        Entity portContainer = null;

        if (entityName == null) {
            toDelete = _searchForPort(portName);

            if (toDelete != null) {
                portContainer = (Entity) toDelete.getContainer();
            }
        } else {
            portContainer = _searchForEntity(entityName, _current);

            if (portContainer != null) {
                toDelete = portContainer.getPort(portName);
            }
        }

        if (toDelete == null) {
            return null;
View Full Code Here

            CompositeEntity toplevel = (CompositeEntity) _toplevel;
            TypeListener typeListener = new PortTypeListener();
            Iterator entities = toplevel.entityList().iterator();

            while (entities.hasNext()) {
                Entity entity = (Entity) entities.next();
                Iterator ports = entity.portList().iterator();

                while (ports.hasNext()) {
                    TypedIOPort port = (TypedIOPort) ports.next();
                    port.addTypeListener(typeListener);
                }
View Full Code Here

        if (_toplevel instanceof CompositeEntity) {
            CompositeEntity toplevel = (CompositeEntity) _toplevel;
            Iterator entities = toplevel.entityList().iterator();

            while (entities.hasNext()) {
                Entity entity = (Entity) entities.next();
                Iterator ports = entity.portList().iterator();

                while (ports.hasNext()) {
                    TypedIOPort port = (TypedIOPort) ports.next();
                    _updateTypeDisplay(port);
                }
View Full Code Here

            // partially completed.
            Iterator ports = linkedPortList().iterator();

            while (ports.hasNext()) {
                IOPort p = (IOPort) ports.next();
                Entity portContainer = (Entity) p.getContainer();

                if (portContainer != null) {
                    portContainer.connectionsChanged(p);
                }
            }

            // Invalidate schedule and type resolution.
            Nameable container = getContainer();
View Full Code Here

    private void _eliminateAllComparisons(CompositeActor model) {
        // Loop over all the actor instance classes.
        for (Iterator entities = model.deepEntityList().iterator(); entities
                .hasNext();) {
            Entity entity = (Entity) entities.next();
            String className = ModelTransformer.getInstanceClassName(entity,
                    _options);
            SootClass entityClass = Scene.v().loadClassAndSupport(className);

            for (Iterator methods = entityClass.getMethods().iterator(); methods
View Full Code Here

        // is available, but before we add the correct initialization.
        // FIXME: This needs to look at all code that is reachable
        // from a constructor.
        _removeAttributeInitialization(theClass);

        Entity classEntity = null;

        try {
            classEntity = (Entity) ModelTransformer._findDeferredInstance(
                    entity).clone(null);

            // The cloning process results an object that defers change
            // requests.  By default, we do not want to defer change
            // requests, but more importantly, we need to execute
            // any change requests that may have been queued
            // during cloning. The following call does that.
            classEntity.setDeferringChangeRequests(false);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

        ModelTransformer.updateCreatedSet(entity.getFullName(), classEntity,
View Full Code Here

                // Findbugs wants us to check for null
                throw new IllegalActionException(getComponent(),
                        "Internal Error, inputPort '" + inputPort
                                + "': currentState == null");
            }
            Entity refinement = (Entity) currentState.getRefinement()[0];
            IOPort refinementPort = (IOPort) refinement.getPort(inputPort
                    .getName());
            IOPort[] sinkPorts = { controllerPort, refinementPort };

            code.append("case " + configurationNumber + ":" + _eol);
View Full Code Here

        return actor;
    }

    public void fire() throws IllegalActionException {
        try {
            Entity entity;
            if (moml.getWidth() > 0 && moml.hasToken(0)) {
                String momlString = ((StringToken) moml.get(0)).stringValue();
                _parser.reset();
                entity = (Entity) _parser.parse(momlString);
            } else {
                if (_emptyModel == null) {
                    _emptyModel = new TypedCompositeActor(workspace());
                }
                entity = _emptyModel;
            }

            if (modelName.getWidth() > 0 && modelName.hasToken(0)) {
                String name = ((StringToken) modelName.get(0)).stringValue();
                entity.setName(name);
            }

            model.send(0, new ActorToken(entity));
        } catch (Exception e) {
            throw new IllegalActionException(this, "Unable to parse moml.");
View Full Code Here

            query.addLine("Name", "Name", defaultName);

            // See whether the configuration offers state refinements.
            Configuration configuration = ((FSMGraphController) getController())
                    .getConfiguration();
            Entity refinements = configuration.getEntity("_stateRefinements");

            // Default choices.
            String[] choiceClasses = { "ptolemy.domains.fsm.modal.Refinement",
                    "ptolemy.domains.fsm.modal.ModalController" };
            String[] choiceNames = { "Default Refinement",
                    "State Machine Refinement" };

            // Check the configuration to see whether the default is overridden.
            if (refinements instanceof CompositeEntity) {
                // There is a specification.
                List refinementList = ((CompositeEntity) refinements)
                        .entityList();
                choiceNames = new String[refinementList.size()];
                choiceClasses = new String[refinementList.size()];

                Iterator iterator = refinementList.iterator();
                int count = 0;

                while (iterator.hasNext()) {
                    Entity entity = (Entity) iterator.next();
                    choiceNames[count] = entity.getName();
                    choiceClasses[count++] = entity.getClass().getName();
                }
            }

            query
                    .addChoice("Class", "Class", choiceNames, choiceNames[0],
                            true);

            // FIXME: Need a frame owner for first arg.
            // Perhaps calling getController(), which returns a GraphController
            // will be a good start.
            ComponentDialog dialog = new ComponentDialog(null,
                    "Specify Refinement", query);

            if (!dialog.buttonPressed().equals("OK")) {
                return;
            }

            final String newName = query.getStringValue("Name");

            if (container.getEntity(newName) != null) {
                MessageHandler.error("There is already a refinement with name "
                        + newName + ".");
                return;
            }

            int choiceIndex = query.getIntValue("Class");
            String newClass = choiceClasses[choiceIndex];

            String currentRefinements = state.refinementName.getExpression();

            if ((currentRefinements == null) || currentRefinements.equals("")) {
                currentRefinements = newName;
            } else {
                currentRefinements = currentRefinements.trim() + ", " + newName;
            }

            String moml;

            // The MoML we create depends on whether the configuration
            // specified a set of prototype refinements.
            if (refinements instanceof CompositeEntity) {
                String choiceName = choiceNames[choiceIndex];
                Entity template = ((CompositeEntity) refinements)
                        .getEntity(choiceName);
                String templateDescription = template.exportMoML(newName);
                moml = "<group>" + templateDescription + "<entity name=\""
                        + state.getName(container)
                        + "\"><property name=\"refinementName\" value=\""
                        + currentRefinements + "\"/></entity></group>";
            } else {
                moml = "<group><entity name=\"" + newName + "\" class=\""
                        + newClass + "\"/>" + "<entity name=\""
                        + state.getName(container)
                        + "\"><property name=\"refinementName\" value=\""
                        + currentRefinements + "\"/></entity></group>";
            }

            MoMLChangeRequest change = new MoMLChangeRequest(this, container,
                    moml) {
                protected void _execute() throws Exception {
                    super._execute();

                    // Mirror the ports of the container in the refinement.
                    // Note that this is done here rather than as part of
                    // the MoML because we have set protected variables
                    // in the refinement to prevent it from trying to again
                    // mirror the changes in the container.
                    Entity entity = container.getEntity(newName);

                    // Get the initial port configuration from the container.
                    Iterator ports = container.portList().iterator();

                    while (ports.hasNext()) {
                        Port port = (Port) ports.next();

                        try {
                            // NOTE: This is awkward.
                            if (entity instanceof Refinement) {
                                ((Refinement) entity).setMirrorDisable(true);
                            } else if (entity instanceof ModalController) {
                                ((ModalController) entity)
                                        .setMirrorDisable(true);
                            }

                            Port newPort = entity.newPort(port.getName());

                            if (newPort instanceof RefinementPort
                                    && port instanceof IOPort) {
                                try {
                                    ((RefinementPort) newPort)
View Full Code Here

TOP

Related Classes of ptolemy.kernel.Entity$ContainedObjectsIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.