Package ptolemy.kernel

Examples of ptolemy.kernel.Port


            }

            Iterator ports = entity.portList().iterator();

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

                if (portDeletes != null) {
                    moml.append("<port name=\"" + port.getName() + "\">"
                            + portDeletes + "</port>");
                }
            }

            moml.append("</entity>");
View Full Code Here


        // Determine which ports have been removed. If a port exists on the
        // target but is not represented by a row in the table then it needs
        // to be removed.
        Vector portsToBeRemoved = new Vector();
        Iterator portIterator = getTarget().portList().iterator();
        Port actualPort = null;

        while (portIterator.hasNext()) {
            Object candidate = portIterator.next();

            if (candidate instanceof Port) {
                boolean foundPort = false;
                actualPort = (Port) candidate;

                if (actualPort == null) {
                    throw new InternalErrorException(
                            "The target contains a null Port.");
                }

                for (int i = 0; i < _ports.size(); i++) {
                    Hashtable portInfo = (Hashtable) (_ports.elementAt(i));

                    if (actualPort == ((Port) portInfo
                            .get(ColumnNames.COL_ACTUAL_PORT))) {
                        foundPort = true;
                        break;
                    }
                }

                if (!foundPort) {
                    portsToBeRemoved.add(actualPort);
                }
            } else {
                throw new InternalErrorException("The target portList contains"
                        + " an object that is not of type Port.");
            }
        }

        Iterator actualPorts = portsToBeRemoved.iterator();

        while (actualPorts.hasNext()) {
            StringBuffer moml = new StringBuffer();
            actualPort = (Port) (actualPorts.next());

            // The context for the MoML should be the first container
            // above this port in the hierarchy that defers its MoML
            // definition, or the immediate parent if there is none.
            NamedObj container = actualPort.getContainer();
            NamedObj composite = container.getContainer();

            if (composite != null) {
                moml.append("<deletePort name=\"" + actualPort.getName()
                        + "\" entity=\"" + container.getName() + "\" />");
            } else {
                moml.append("<deletePort name=\""
                        + actualPort.getName(container) + "\" />");
            }

            // NOTE: the context is the composite entity containing
            // the entity if possible
            MoMLChangeRequest request = null;

            if (composite != null) {
                request = new MoMLChangeRequest(this, composite, moml
                        .toString());
            } else {
                request = new MoMLChangeRequest(this, container, moml
                        .toString());
            }

            request.setUndoable(true);
            container.addChangeListener(this);

            container.requestChange(request);
        }

        // Iterate over the table rows that represent ports.  If a row
        // corresponds to an actual port then look to see if that row
        // is different from the actual port.  If it is, then update
        // that actual port.  If a row does not correspond to an
        // actual port then that row represents a new actual port
        // which must be created.
        StringBuffer moml = new StringBuffer("<group>");
        boolean haveSomeUpdate = false;

        for (int i = 0; i < _ports.size(); i++) {
            Hashtable portInfo = (Hashtable) (_ports.elementAt(i));
            portIterator = getTarget().portList().iterator();

            // actualPort will be the Port found on the _target, if
            // there is one.
            actualPort = (Port) (portInfo.get(ColumnNames.COL_ACTUAL_PORT));

            Hashtable updates = new Hashtable();

            // FIXME is it necessary to add unchanged fields to hashtable ?
            if (actualPort != null) {
                // actualPort is a Port found on the _target. Check to
                // see if the actualPort is different and needs to be
                // updated.
                boolean havePortUpdate = false;

                if (_columnNames.contains(ColumnNames.COL_NAME)) {
                    String tableValue = (String) portInfo
                            .get(ColumnNames.COL_NAME);

                    if (!(actualPort.getName().equals(tableValue))) {
                        havePortUpdate = true;
                        updates.put(ColumnNames.COL_NAME, Boolean.TRUE);
                    }
                }

                if (actualPort instanceof IOPort) {
                    IOPort iop = (IOPort) actualPort;

                    if (_columnNames.contains(ColumnNames.COL_INPUT)) {
                        Boolean tableValue = (Boolean) portInfo
                                .get(ColumnNames.COL_INPUT);

                        if (iop.isInput() != tableValue.booleanValue()) {
                            havePortUpdate = true;
                            updates.put(ColumnNames.COL_INPUT, Boolean.TRUE);
                        }
                    }

                    if (_columnNames.contains(ColumnNames.COL_OUTPUT)) {
                        Boolean tableValue = (Boolean) portInfo
                                .get(ColumnNames.COL_OUTPUT);

                        if (iop.isOutput() != tableValue.booleanValue()) {
                            havePortUpdate = true;
                            updates.put(ColumnNames.COL_OUTPUT, Boolean.TRUE);
                        }
                    }

                    if (_columnNames.contains(ColumnNames.COL_MULTIPORT)) {
                        Boolean tableValue = (Boolean) portInfo
                                .get(ColumnNames.COL_MULTIPORT);

                        if (iop.isMultiport() != tableValue.booleanValue()) {
                            havePortUpdate = true;
                            updates
                                    .put(ColumnNames.COL_MULTIPORT,
                                            Boolean.TRUE);
                        }
                    }
                }

                if (_columnNames.contains(ColumnNames.COL_SHOW_NAME)) {
                    boolean isShowSet = _isPropertySet(actualPort, "_showName");
                    Boolean tableValue = (Boolean) portInfo
                            .get(ColumnNames.COL_SHOW_NAME);

                    if (isShowSet != tableValue.booleanValue()) {
                        havePortUpdate = true;
                        updates.put(ColumnNames.COL_SHOW_NAME, Boolean.TRUE);
                    }
                }

                if (_columnNames.contains(ColumnNames.COL_HIDE)) {
                    boolean isHideSet = _isPropertySet(actualPort, "_hide");
                    Boolean tableValue = (Boolean) portInfo
                            .get(ColumnNames.COL_HIDE);

                    if (isHideSet != tableValue.booleanValue()) {
                        havePortUpdate = true;
                        updates.put(ColumnNames.COL_HIDE, Boolean.TRUE);
                    }
                }

                if (actualPort instanceof TypedIOPort) {
                    TypedIOPort tiop = (TypedIOPort) actualPort;

                    if (_columnNames.contains(ColumnNames.COL_TYPE)) {
                        String _type = null;
                        TypeAttribute _typeAttribute = (TypeAttribute) tiop
                                .getAttribute("_type");

                        if (_typeAttribute != null) {
                            _type = _typeAttribute.getExpression();
                        }

                        String tableValue = (String) portInfo
                                .get(ColumnNames.COL_TYPE);

                        if (((_type == null) && (!tableValue.equals("")))
                                || ((_type != null) && (!tableValue
                                        .equals(_type)))) {
                            havePortUpdate = true;
                            updates.put(ColumnNames.COL_TYPE, Boolean.TRUE);
                        }
                    }
                }

                if (_columnNames.contains(ColumnNames.COL_DIRECTION)) {
                    // Look for a change in direction
                    String _direction = null;
                    String direction = (String) portInfo
                            .get(ColumnNames.COL_DIRECTION);
                    StringAttribute _cardinal = (StringAttribute) actualPort
                            .getAttribute("_cardinal");

                    if (_cardinal != null) {
                        _direction = _cardinal.getExpression().toUpperCase();
                    }

                    if (((_direction == null) && !direction.equals("DEFAULT"))
                            || ((_direction != null) && (!direction
                                    .equals(_direction)))) {
                        havePortUpdate = true;
                        updates.put(ColumnNames.COL_DIRECTION, Boolean.TRUE);
                    }
                }

                if (_columnNames.contains(ColumnNames.COL_UNITS)) {
                    String units = null;
                    UnitAttribute _unitsAttribute = (UnitAttribute) actualPort
                            .getAttribute("_units");

                    if (_unitsAttribute != null) {
                        units = _unitsAttribute.getExpression();
                    }
View Full Code Here

                    // NOTE: If there is already a property that is not
                    // a boolean-valued parameter, then remove it rather
                    // than setting it to false.  This is done for more
                    // robust backward compatibility.
                    boolean removed = false;
                    Port port = (Port) portInfo
                            .get(ColumnNames.COL_ACTUAL_PORT);

                    if (port != null) {
                        Attribute attribute = port.getAttribute("_showName");

                        if (!(attribute instanceof Parameter)) {
                            momlUpdate.append(_momlDeleteProperty("_showName"));
                            removed = true;
                        }
                    }

                    if (!removed) {
                        momlUpdate.append(_momlProperty("_showName",
                                _SINGLETON_PARAMETER, "false"));
                    }
                }
            }
        }

        if (updates.containsKey(ColumnNames.COL_HIDE)) {
            Boolean updateValue = (Boolean) updates.get(ColumnNames.COL_HIDE);

            if (updateValue.booleanValue()) {
                if (((Boolean) portInfo.get(ColumnNames.COL_HIDE))
                        .booleanValue()) {
                    momlUpdate.append(_momlProperty("_hide",
                            _SINGLETON_PARAMETER, "true"));
                } else {
                    // NOTE: If there is already a property that is not
                    // a boolean-valued parameter, then remove it rather
                    // than setting it to false.  This is done for more
                    // robust backward compatibility.
                    boolean removed = false;
                    Port port = (Port) portInfo
                            .get(ColumnNames.COL_ACTUAL_PORT);

                    if (port != null) {
                        Attribute attribute = port.getAttribute("_hide");

                        if (!(attribute instanceof Parameter)) {
                            momlUpdate.append(_momlDeleteProperty("_hide"));
                            removed = true;
                        }
View Full Code Here

        for (int i = 0; i < _ports.size(); i++) {
            Hashtable portInfo = (Hashtable) _ports.elementAt(i);
            String portName = (String) portInfo.get(ColumnNames.COL_NAME);
            Iterator portIterator = getTarget().portList().iterator();

            Port actualPort;
            boolean foundActualPort = false;

            while (portIterator.hasNext()) {
                Object candidate = portIterator.next();

                if (candidate instanceof Port) {
                    actualPort = (Port) candidate;

                    if (actualPort.getName().equals(portName)) {
                        portInfo.put(ColumnNames.COL_ACTUAL_PORT, actualPort);
                        foundActualPort = true;
                        break;
                    }
                }
View Full Code Here

        public PortTableModel(List portList) {
            Iterator ports = portList.iterator();
            _ports = new Vector();

            while (ports.hasNext()) {
                Port p = (Port) ports.next();
                Hashtable portInfo = new Hashtable();

                if (_columnNames.contains(ColumnNames.COL_NAME)) {
                    portInfo.put(ColumnNames.COL_NAME, p.getName());
                }

                if (_columnNames.contains(ColumnNames.COL_DIRECTION)) {
                    String _direction;
                    StringAttribute _cardinal = (StringAttribute) (p
                            .getAttribute("_cardinal"));

                    if (_cardinal != null) {
                        _direction = _cardinal.getExpression().toUpperCase();
                    } else {
                        _direction = "DEFAULT";
                    }

                    portInfo.put(ColumnNames.COL_DIRECTION, _direction);
                }

                if (_columnNames.contains(ColumnNames.COL_SHOW_NAME)) {
                    boolean isShowSet = _isPropertySet(p, "_showName");

                    if (isShowSet) {
                        portInfo.put(ColumnNames.COL_SHOW_NAME, Boolean.TRUE);
                    } else {
                        portInfo.put(ColumnNames.COL_SHOW_NAME, Boolean.FALSE);
                    }
                }

                if (_columnNames.contains(ColumnNames.COL_HIDE)) {
                    boolean isHideSet = _isPropertySet(p, "_hide");

                    if (isHideSet) {
                        portInfo.put(ColumnNames.COL_HIDE, Boolean.TRUE);
                    } else {
                        portInfo.put(ColumnNames.COL_HIDE, Boolean.FALSE);
                    }
                }

                if (p instanceof IOPort) {
                    IOPort iop = (IOPort) p;

                    if (_columnNames.contains(ColumnNames.COL_INPUT)) {
                        portInfo.put(ColumnNames.COL_INPUT, Boolean.valueOf(iop
                                .isInput()));
                    }

                    if (_columnNames.contains(ColumnNames.COL_OUTPUT)) {
                        portInfo.put(ColumnNames.COL_OUTPUT, Boolean
                                .valueOf(iop.isOutput()));
                    }

                    if (_columnNames.contains(ColumnNames.COL_MULTIPORT)) {
                        portInfo.put(ColumnNames.COL_MULTIPORT, Boolean
                                .valueOf(iop.isMultiport()));
                    }
                }

                if (p instanceof TypedIOPort) {
                    TypedIOPort tiop = (TypedIOPort) p;

                    if (_columnNames.contains(ColumnNames.COL_TYPE)) {
                        TypeAttribute _type = (TypeAttribute) (tiop
                                .getAttribute("_type"));

                        if (_type != null) {
                            portInfo.put(ColumnNames.COL_TYPE, _type
                                    .getExpression());
                        } else {
                            portInfo.put(ColumnNames.COL_TYPE, "");
                        }
                    }
                }

                if (_columnNames.contains(ColumnNames.COL_UNITS)) {
                    String units = "";
                    UnitAttribute _unitsAttribute = (UnitAttribute) p
                            .getAttribute("_units");

                    if (_unitsAttribute != null) {
                        units = _unitsAttribute.getExpression();
View Full Code Here

         * @return true if editable
         * @see javax.swing.table.TableModel#isCellEditable(int, int)
         */
        public boolean isCellEditable(int row, int col) {
            Hashtable portInfo = (Hashtable) (_ports.elementAt(row));
            Port port = (Port) portInfo.get(ColumnNames.COL_ACTUAL_PORT);

            if (port != null) {
                if (port.getDerivedLevel() < Integer.MAX_VALUE) {
                    if ((col == _columnNames.indexOf(ColumnNames.COL_NAME))
                            || (col == _columnNames
                                    .indexOf(ColumnNames.COL_INPUT))
                            || (col == _columnNames
                                    .indexOf(ColumnNames.COL_OUTPUT))
View Full Code Here

                    newClass.removeMethod(method);
                }

                if (newClass.declaresFieldByName("_port")) {
                    SootField field = newClass.getFieldByName("_port");
                    Port port = ((PortParameter) attribute).getPort();
                    field.addTag(new ValueTag(port));
                }

                // Add a container field to the generated class.
                // FIXME: this doesn't work for UnitSystems, e.g.,
View Full Code Here

        }

        Iterator ports = portList().iterator();

        while (ports.hasNext()) {
            Port port = (Port) ports.next();
            String mangledName = _mangleName(port.getName());

            if (_debugging) {
                _debug("set up reference to port \"" + port.getName()
                        + "\" as \"" + mangledName + "\"");
            }

            object.__setattr__(new PyString(mangledName), new PyJavaInstance(
                    port));
View Full Code Here

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

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

                    if (port instanceof WirelessIOPort) {
                        WirelessIOPort castPort = (WirelessIOPort) port;

                        if (castPort.isInput()) {
View Full Code Here

            List result = new LinkedList();
            CompositeEntity container = (CompositeEntity) getContainer();
            Iterator ports = container.portList().iterator();

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

                if (port instanceof WirelessIOPort) {
                    WirelessIOPort castPort = (WirelessIOPort) port;

                    if (castPort.isOutput()) {
View Full Code Here

TOP

Related Classes of ptolemy.kernel.Port

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.