Examples of Settable


Examples of ptolemy.kernel.util.Settable

                        .iterator();
                StringBuffer buffer = new StringBuffer("<group>\n");
                final List parametersReset = new LinkedList();

                while (parameters.hasNext()) {
                    Settable parameter = (Settable) parameters.next();

                    if (isVisible(_object, parameter)) {
                        String newValue = parameter.getExpression();
                        String defaultValue = parameter.getDefaultExpression();

                        if ((defaultValue != null)
                                && !newValue.equals(defaultValue)) {
                            buffer.append("<property name=\"");
                            buffer.append(((NamedObj) parameter)
                                    .getName(_object));
                            buffer.append("\" value=\"");
                            buffer.append(StringUtilities
                                    .escapeForXML(defaultValue));
                            buffer.append("\"/>\n");
                            parametersReset.add(parameter);
                        }
                    }
                }

                buffer.append("</group>\n");

                // If there are changes, then issue a change request.
                // Use a MoMLChangeRequest so undo works... I.e., you can undo a cancel
                // of a previous change.
                if (parametersReset.size() > 0) {
                    MoMLChangeRequest request = new MoMLChangeRequest(this, // originator
                            _object, // context
                            buffer.toString(), // MoML code
                            null) { // base
                        protected void _execute() throws Exception {
                            super._execute();

                            // Reset the derived level, which has the side
                            // effect of marking the object not overridden.
                            Iterator parameters = parametersReset.iterator();

                            while (parameters.hasNext()) {
                                Settable parameter = (Settable) parameters
                                        .next();

                                if (isVisible(_object, parameter)) {
                                    int derivedLevel = ((NamedObj) parameter)
                                            .getDerivedLevel();
View Full Code Here

Examples of ptolemy.kernel.util.Settable

                            String outputExpression = writer
                                    .printParseTree(parseTree);
                            parameter.setExpression(outputExpression);
                        }
                    } catch (ClassCastException ex) {
                        Settable parameter = (Settable) actor
                                .getAttribute(parameterName);
                        ParseTreeFreeVariableCollector collector = new ParseTreeFreeVariableCollector();
                        Set expressionVariables = collector
                                .collectFreeVariables(parseTree);
                        Set scopeVariables = _scope.identifierSet();
                        List<String> excludedVariables = new LinkedList<String>();
                        for (Object variable : expressionVariables) {
                            if (variable instanceof String) {
                                if (!scopeVariables.contains(variable)) {
                                    excludedVariables.add((String) variable);
                                }
                            }
                        }
                        ParseTreeSpecializer specializer = new ParseTreeSpecializer();
                        parseTree = specializer.specialize(parseTree,
                                excludedVariables, _scope);
                        ParseTreeWriter writer = new ParseTreeWriter();
                        String outputExpression = writer
                                .printParseTree(parseTree);
                        parameter.setExpression(outputExpression);
                    }
                }
            } catch (Exception ex) {
                throw new PtalonRuntimeException("Trouble making connections",
                        ex);
View Full Code Here

Examples of ptolemy.kernel.util.Settable

         @param row The row number.
         *  @param col The column number.
         *  @see javax.swing.table.TableModel#getValueAt(int, int)
         */
        public Object getValueAt(int row, int col) {
            Settable parameter = (Settable) _parameters.get(row);
            if (ColumnNames.COL_NAME.equals(getColumnName(col))) {
                return parameter.getDisplayName();
            } else if (ColumnNames.COL_EXPRESSION.equals(getColumnName(col))) {
                return parameter.getExpression();
            } else {
                return parameter.getValueAsString();
            }
        }
View Full Code Here

Examples of ptolemy.kernel.util.Settable

                Object value, boolean isSelected, boolean hasFocus, int row,
                int col) {
            setOpaque(true);
            setText((String) value);
            // The color depends on the properties of the parameter.
            Settable parameter = (Settable) _parameters.get(row);
            if (parameter.getVisibility() == Settable.EXPERT) {
                setBackground(_EXPERT_COLOR);
            } else if (parameter.getVisibility() == Settable.NONE) {
                setBackground(_INVISIBLE_COLOR);
            } else {
                setBackground(Color.WHITE);
            }
            return this;
View Full Code Here

Examples of ptolemy.kernel.util.Settable

        NamedObj object = getContainer();
        PtolemyQuery query = new PtolemyQuery(object);
        query.setTextWidth(25);

        if (object instanceof Settable) {
            Settable parameter = (Settable) object;
            _oldExpression = parameter.getExpression();
            query.addStyledEntry(parameter);
            return query;
        } else {
            return new JLabel(object.getName()
                    + " is not a settable attribute!");
View Full Code Here

Examples of ptolemy.kernel.util.Settable

                }
            }

            if (isAttributeTypeEnabled() || isAttributeValueEnabled()) {
                if (attribute instanceof Settable) {
                    Settable settable = (Settable) attribute;
                    String expression = settable.getExpression();
                    VariableScope scope = new VariableScope(object);
                    try {
                        ASTPtRootNode tree = _TYPE_PARSER
                                .generateParseTree(expression);
                        Token token = _TYPE_EVALUATOR.evaluateParseTree(tree,
View Full Code Here

Examples of ptolemy.kernel.util.Settable

        parameters.append(_tde);
        parameters.append(_tre);
        boolean foundOne = false;
        Iterator attributes = target.attributeList(Settable.class).iterator();
        while (attributes.hasNext()) {
            Settable parameter = (Settable) attributes.next();
            if (parameter instanceof PortParameter) {
                // Skip this one.
                continue;
            }

            String parameterName = parameter.getName();
            //check to see if this param is on the exclusion list
            for (int i = 0; i < exclusions.size(); i++) {
                String exclusion = (String) exclusions.elementAt(i);
                String type = exclusion.substring(0, exclusion.indexOf(":"));
                exclusion = exclusion.substring(exclusion.indexOf(":") + 1,
                        exclusion.length());
                if (type.equals("contains")) {
                    if (parameterName.indexOf(exclusion) != -1) {
                        parameter.setVisibility(Settable.NONE);
                    }
                } else if (type.equals("exact")) {
                    if (parameterName.equals(exclusion)) {
                        parameter.setVisibility(Settable.NONE);
                    }
                }
            }

            String doc = manager.getPropertyDoc(parameter.getName());
            if (doc == null) {
                doc = "No description.";
                // See if the next tier has documentation.
                DocManager nextTier = manager.getNextTier();
                if (nextTier != null) {
                    String nextDoc = nextTier.getPropertyDoc(parameter
                            .getName());
                    if (nextDoc != null) {
                        doc = nextDoc;
                    }
                }
            }
            if (parameter.getVisibility() == Settable.FULL) {
                parameters.append(_tr);
                parameters.append(_td);
                parameters.append("<i>" + parameter.getDisplayName() + "</i>");
                parameters.append(_tde);
                parameters.append(_td);
                parameters.append(doc);
                parameters.append(_tde);
                parameters.append(_tre);
View Full Code Here

Examples of ptolemy.kernel.util.Settable

        parameters.append(_tre);
        boolean foundOne = false;
        Iterator attributes = target.attributeList(PortParameter.class)
                .iterator();
        while (attributes.hasNext()) {
            Settable parameter = (Settable) attributes.next();
            String doc = manager.getPropertyDoc(parameter.getName());
            if (doc == null) {
                doc = "No description.";
                // See if the next tier has documentation.
                DocManager nextTier = manager.getNextTier();
                if (nextTier != null) {
                    String nextDoc = nextTier.getPropertyDoc(parameter
                            .getName());
                    if (nextDoc != null) {
                        doc = nextDoc;
                    }
                }
            }
            if (parameter.getVisibility() == Settable.FULL) {
                parameters.append(_tr);
                parameters.append(_td);
                parameters.append("<i>" + parameter.getDisplayName() + "</i>");
                parameters.append(_tde);
                parameters.append(_td);
                parameters.append(doc);
                parameters.append(_tde);
                parameters.append(_tre);
View Full Code Here

Examples of ptolemy.kernel.util.Settable

     @param query The query into which to add the entry.
     *  @exception IllegalActionException If thrown when accessing parameters
     *   specifying whether files or directories should be listed.
     */
    public void addEntry(PtolemyQuery query) throws IllegalActionException {
        Settable container = (Settable) getContainer();
        String name = container.getName();
        String defaultValue = container.getExpression();
        defaultValue = container.getExpression();

        URI modelURI = URIAttribute.getModelURI(this);
        File directory = null;

        if (modelURI != null) {
            if (modelURI.getScheme().equals("file")) {
                File modelFile = new File(modelURI);
                directory = modelFile.getParentFile();
            }
        }

        // Check to see whether the attribute being configured
        // specifies whether files or directories should be listed.
        // By default, only files are selectable.
        boolean allowFiles = true;
        boolean allowDirectories = false;

        if (container instanceof NamedObj) {
            Parameter marker = (Parameter) ((NamedObj) container).getAttribute(
                    "allowFiles", Parameter.class);

            if (marker != null) {
                Token value = marker.getToken();

                if (value instanceof BooleanToken) {
                    allowFiles = ((BooleanToken) value).booleanValue();
                }
            }

            marker = (Parameter) ((NamedObj) container).getAttribute(
                    "allowDirectories", Parameter.class);

            if (marker != null) {
                Token value = marker.getToken();

                if (value instanceof BooleanToken) {
                    allowDirectories = ((BooleanToken) value).booleanValue();
                }
            }
        }

        // FIXME: What to do when neither files nor directories are allowed?
        if (!allowFiles && !allowDirectories) {
            // The given attribute will not have a query in the dialog.
            return;
        }

        query.addFileChooser(name, container.getDisplayName(), defaultValue,
                modelURI, directory, allowFiles, allowDirectories, PtolemyQuery
                        .preferredBackgroundColor(container), PtolemyQuery
                        .preferredForegroundColor(container));
        query.attachParameter(container, name);
    }
View Full Code Here

Examples of ptolemy.kernel.util.Settable

     *  the name of the attribute.  Attach the attribute to the created entry.
     *
     *  @param query The query into which to add the entry.
     */
    public void addEntry(PtolemyQuery query) {
        Settable container = (Settable) getContainer();
        String name = container.getName();
        String defaultValue = "";
        defaultValue = container.getExpression();

        try {
            int heightValue = ((IntToken) height.getToken()).intValue();
            int widthValue = ((IntToken) width.getToken()).intValue();
            query.addTextArea(name, container.getDisplayName(), defaultValue,
                    PtolemyQuery.preferredBackgroundColor(container),
                    PtolemyQuery.preferredForegroundColor(container),
                    heightValue, widthValue);
            query.attachParameter(container, name);
        } catch (IllegalActionException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.