Package ptolemy.kernel.util

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


        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

     @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

     *  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

     *  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();
        query.addDisplay(name, container.getDisplayName(), defaultValue);
        query.attachParameter(container, name);
    }
View Full Code Here

        }

        Iterator parameters = object.attributeList(Settable.class).iterator();

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

            // Skip if the parameter is not visible.
            if (!Configurer.isVisible(_object, param)) {
                continue;
            }

            // Get the current style.
            boolean foundOne = false;
            Iterator styles = ((NamedObj) param).attributeList(
                    ParameterEditorStyle.class).iterator();
            ParameterEditorStyle foundStyle = null;

            while (styles.hasNext()) {
                foundOne = true;
                foundStyle = (ParameterEditorStyle) styles.next();
            }

            List styleList = new ArrayList();

            // The index of the default;
            int defaultIndex = 0;

            if (param.getVisibility() == Settable.NOT_EDITABLE) {
                // If the parameter is set to NOT_EDITABLE visibility,
                // then only a fixed style is possible.
                styleList.add("Fixed");
                defaultIndex = 0;
            } else {
                int count = 0;

                // Reduce the list of parameters
                for (int i = 0; (i < _parameterStyles.length)
                        && (_parameterStyles[i] != null); i++) {
                    if (foundOne
                            && (_parameterStyles[i].getClass() == foundStyle
                                    .getClass())) {
                        defaultIndex = count;

                        if (foundStyle.acceptable(param)) {
                            styleList.add(_parameterStyles[i].getName());
                            count++;
                        }
                    } else if (_parameterStyles[i].acceptable(param)) {
                        styleList.add(_parameterStyles[i].getName());
                        count++;
                    }
                }
            }

            String[] styleArray = (String[]) styleList
                    .toArray(new String[styleList.size()]);

            addChoice(param.getName(), param.getName(), styleArray,
                    styleArray[defaultIndex]);
        }

        // Add the expert mode box.
        _originalExpertMode = _object.getAttribute("_expertMode") != null;
View Full Code Here

                // gets anything added to it!
                Iterator entries = _originalValues.entrySet().iterator();

                while (entries.hasNext()) {
                    Map.Entry entry = (Map.Entry) entries.next();
                    Settable param = (Settable) _object
                            .getAttribute((String) entry.getKey());

                    try {
                        param.setExpression((String) entry.getValue());
                    } catch (IllegalActionException ex) {
                        throw new InternalErrorException(
                                "Cannot restore style value!");
                    }
                }
View Full Code Here

     @param query The query into which to add the entry.
     *  @exception IllegalActionException If the containing attribute
     *   has a value that cannot be edited using this style.
     */
    public void addEntry(PtolemyQuery query) throws IllegalActionException {
        Settable container = (Settable) getContainer();
        String name = container.getName();
        List paramList = attributeList(Settable.class);
        Settable[] choices = (Settable[]) paramList
                .toArray(new Settable[paramList.size()]);
        String[] values = new String[choices.length];

        for (int i = 0; i < choices.length; i++) {
            values[i] = choices[i].getExpression();
        }

        String defaultChoice = container.getExpression();
        query.addChoice(name, container.getDisplayName(), values,
                defaultChoice, _isEditable, PtolemyQuery
                        .preferredBackgroundColor(container), PtolemyQuery
                        .preferredForegroundColor(container));
        query.attachParameter(container, name);
    }
View Full Code Here

     *  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();
        query.addLine(name, container.getDisplayName(), defaultValue,
                PtolemyQuery.preferredBackgroundColor(container), PtolemyQuery
                        .preferredForegroundColor(container));
        query.attachParameter(container, name);
    }
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.Settable

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.