Hi Kianwee,
My comments are interspersed with your text below.

On 10/24/11 8:39 AM, Edward A. Lee wrote:

The documentation for FileParameter says:

"If this attribute contains a parameter named allowFiles with value false, then when a file browser is used to select a file, that file browser will be set to not show files (only directories will be shown). If this attribute contains a parameter named allowDirectories with value true, then the file browser will permit the user to select directories (the default behavior is that when a directory is selected, that directory is opened and its contained files and directories are listed)."

(I'm not sure about Kepler, but in Ptolemy, just drag in a FileParameter
from the Utilities menu, right click on it, and select Documentation.)

I'm not sure what you mean by "list parameter." Can you cite a specific
example?

Edward


On 10/24/11 3:22 AM, kianwee chen wrote:
Hi everyone, I am trying to create a composite actor and trying to setup
the parameters for the composite actor. Thus I have some question on
adding parameters in composite actors.

1.) Directory parameter:

-I would like to let the users specify a directory on the composite
actor parameters interface, I know there is a file parameter but I need
a directory parameter. How can I customise a directory parameter ?

See Edward's explanation above.

-I have a problem with relative path too, when I setup a file parameter
it returns the string of the path relative to my current kepler file
that is open. Is there a way to get the base file path ? Something like
$CWD, but instead the file path of my currently open file ?

The FileParameter documentation says:

<p>If the model containing this
 attribute has been saved to a MoML file, then the file name can be
 given relative to the directory containing that MoML file.
 If the model has not been saved to a file,
 then the classpath is used for identifying relative file names.</p>

<p>Files can be given relative to a <i>base</i>, where the baseis
 the URI of the first container above this one that has a URIAttribute.
 Normally, this URI specifies the file or URL containing the model
 definition. Thus, files that are referred to here can be kept in the
 same directory as the model, or in a related directory, and can
 moved together with the model.</p>

So, if you type in a relative path, then the file should be relative to the model.

There is a Ptolemy test at
ptolemy/actor/lib/io/test/auto/FileReader.xml
that illustrates the various possibilities. If this test is run in the ptolemy/actor/lib/io/test directory, then it will work. If the test is run elsewhere, then the "FileReader Relative to CWD" actor will fail because that actor uses $CWD, which is expected to be ptolemy/actor/lib/io/test
in that test.

In Java, the value of the user.dir property is the " User's current working directory". However, when a Java program is opened in a graphical windowing system by clicking on a menu choice, then the value of user.dir is not clearly defined. It should probably be
the same value as the user's home directory, but I've seen various values.
For a FileParameter, the value of $CWD is set to the value of the user.dir property, which is probably not what you want. I often end up using $CLASSPATH, which looks in the classpath for the resource. The file chooser does not have a way to add $CLASSPATH,
you have to type it in manually.



2.) List Parameter:
- I have seen some actor have List parameters how do I customise one for
my composite actor too ?

For atomic actors, the ptolemy/actor/lib/MathFunction.java uses the addChoice() method:

       // Parameters
        function = new StringParameter(this, "function");
        function.setExpression("exp");
        function.addChoice("exp");
        function.addChoice("log");
        function.addChoice("modulo");
        function.addChoice("sign");
        function.addChoice("square");
        function.addChoice("sqrt");
        _function = _EXP;

I believe that addChoice() is defined in ptolemy/gui/Query.java

For a CompositeActor, you would probably need to edit the MoML by hand and add a Parameter:

<property name="function" class="ptolemy.data.expr.StringParameter" value="square">
<property name="style" class="ptolemy.actor.gui.style.ChoiceStyle">
<property name="exp" class="ptolemy.kernel.util.StringAttribute" value="exp">
</property>
<property name="log" class="ptolemy.kernel.util.StringAttribute" value="log">
</property>
<property name="modulo" class="ptolemy.kernel.util.StringAttribute" value="modulo">
</property>
<property name="sign" class="ptolemy.kernel.util.StringAttribute" value="sign">
</property>
<property name="square" class="ptolemy.kernel.util.StringAttribute" value="square">
</property>
<property name="sqrt" class="ptolemy.kernel.util.StringAttribute" value="sqrt">
</property>
</property>
</property>

_Christopher

Thanks alot !!
ckw


_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users


_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

--
Christopher Brooks, PMP                       University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841                                (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 cell: 707.332.0670

_______________________________________________
Kepler-users mailing list
Kepler-users@kepler-project.org
http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users

Reply via email to