[kepler-dev] Using PortParameter as StringParameter
Edward A. Lee
eal at eecs.berkeley.edu
Sat Nov 20 08:54:24 PST 2004
No, when I made this change I did it only for string mode, not
for file parameters... presumably, it could be done...
There is a lot more code in FileParameter, however, that would have
to be promoted to the base class...
The preferred way to handle _showName is to use a boolean-valued
parameter. You can do it in Java code like this example from the tree:
public StringReplace(CompositeEntity container, String name)
throws NameDuplicationException, IllegalActionException {
super(container, name);
pattern = new PortParameter(this, "pattern");
pattern.setStringMode(true);
pattern.setExpression("");
(new SingletonParameter(pattern.getPort(), "_showName"))
.setToken(BooleanToken.TRUE);
...
Edward
At 05:44 PM 11/19/2004 -0800, Ilkay Altintas wrote:
>Edward,
>
>Thanks for the useful information on the StringMode.
>
>Can we also do this for FileParameter? We went through the javadoc but
>couldn't find a way to set the parameter to a FileParameter that shows the
>browse button.
>
>Another trivial question is for showing the name of the port. Looks like
>we need to do more than adding a _showName attribute to the PortParameter
>to show its name. It can be done through the UI but couldn't find a way to
>do it in the actor code.
>
>Thanks very much on advance,
>Ilkay
>
>
>On Nov 8, 2004, at 3:38 PM, Edward A. Lee wrote:
>
>>
>>All you have to do is call
>>
>> setStringMode(true);
>>
>>on the PortParameter. If you look at the StringParameter class, you
>>will see:
>>
>> public StringParameter(NamedObj container, String name)
>> throws IllegalActionException, NameDuplicationException {
>> super(container, name);
>> setStringMode(true);
>> }
>>
>>The docs to this (very tiny) class say:
>>
>>"This subclass is provided mainly
>> so that string-mode parameters can be specified in MoML."
>>
>>Edward
>>
>>At 03:27 PM 11/8/2004 -0800, Ilkay Altintas wrote:
>>
>>>Hi,
>>>
>>>I was wondering if there is a way to use the parameter part of a
>>>PortParameter as a StringParameter, meaning a parameter that I don't
>>>have to put quotes around the string.
>>>
>>>Thanks,
>>>Ilkay
>>>
>>>_______________________________________________
>>>kepler-dev mailing list
>>>kepler-dev at ecoinformatics.org
>>>http://www.ecoinformatics.org/mailman/listinfo/kepler-dev
>>
>>------------
>>Edward A. Lee, Professor
>>518 Cory Hall, UC Berkeley, Berkeley, CA 94720
>>phone: 510-642-0455, fax: 510-642-2718
>>eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
>>
>>_______________________________________________
>>kepler-dev mailing list
>>kepler-dev at ecoinformatics.org
>>http://www.ecoinformatics.org/mailman/listinfo/kepler-dev
------------
Edward A. Lee, Professor
518 Cory Hall, UC Berkeley, Berkeley, CA 94720
phone: 510-642-0455, fax: 510-642-2718
eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
More information about the Kepler-dev
mailing list