<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Kianwee,<br>
    My comments are interspersed with your text below.<br>
    <br>
    On 10/24/11 8:39 AM, Edward A. Lee wrote:
    <blockquote cite="mid:4EA586C6.3010904@eecs.berkeley.edu"
      type="cite">
      <br>
      The documentation for FileParameter says:
      <br>
      <br>
      "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)."
      <br>
      <br>
      (I'm not sure about Kepler, but in Ptolemy, just drag in a
      FileParameter
      <br>
      from the Utilities menu, right click on it, and select
      Documentation.)
      <br>
      <br>
      I'm not sure what you mean by "list parameter." Can you cite a
      specific
      <br>
      example?
      <br>
      <br>
      Edward
      <br>
      <br>
      <br>
      On 10/24/11 3:22 AM, kianwee chen wrote:
      <br>
      <blockquote type="cite">Hi everyone, I am trying to create a
        composite actor and trying to setup
        <br>
        the parameters for the composite actor. Thus I have some
        question on
        <br>
        adding parameters in composite actors.
        <br>
        <br>
        1.) Directory parameter:
        <br>
        <br>
        -I would like to let the users specify a directory on the
        composite
        <br>
        actor parameters interface, I know there is a file parameter but
        I need
        <br>
        a directory parameter. How can I customise a directory parameter
        ?
        <br>
      </blockquote>
    </blockquote>
    <br>
    See Edward's explanation above.<br>
    <blockquote cite="mid:4EA586C6.3010904@eecs.berkeley.edu"
      type="cite">
      <blockquote type="cite">
        <br>
        -I have a problem with relative path too, when I setup a file
        parameter
        <br>
        it returns the string of the path relative to my current kepler
        file
        <br>
        that is open. Is there a way to get the base file path ?
        Something like
        <br>
        $CWD, but instead the file path of my currently open file ?
        <br>
      </blockquote>
    </blockquote>
    <br>
    The FileParameter documentation says:<br>
    <br>
    <p>If the model containing
    this                                                                                                                              
    <br>
     attribute has been saved to a MoML file, then the file name can
    be                                                                                           
    <br>
     given relative to the directory containing that MoML
    file.                                                                                                   
    <br>
     If the model has not been saved to a
    file,                                                                                                                   
    <br>
     then the classpath is used for identifying relative file
    names.</p>                                                                                          
    <br>
                                                                                                                                                                  
    <br>
     <p>Files can be given relative to a <i>base</i>,
    where the
    baseis                                                                                           
    <br>
     the URI of the first container above this one that has a
    URIAttribute.                                                                                       
    <br>
     Normally, this URI specifies the file or URL containing the
    model                                                                                            
    <br>
     definition. Thus, files that are referred to here can be kept in
    the                                                                                         
    <br>
     same directory as the model, or in a related directory, and
    can                                                                                              
    <br>
     moved together with the
    model.</p>                                                                                                                           
    <br>
                                                                              
    <br>
    So, if you type in a relative path, then the file should be relative
    to the model.<br>
     <br>
    There is a Ptolemy test at<br>
    ptolemy/actor/lib/io/test/auto/FileReader.xml <br>
    that illustrates the various possibilities.  If this test is run in
    the ptolemy/actor/lib/io/test<br>
    directory, then it will work.  If the test is run elsewhere, then
    the "FileReader Relative to CWD"<br>
    actor will fail because that actor uses $CWD, which is expected to
    be ptolemy/actor/lib/io/test<br>
    in that test.<br>
    <br>
    In Java, the value of the user.dir property is the "
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    User's current working directory".<br>
    However, when a Java program is opened in a graphical windowing
    system by clicking on<br>
    a menu choice, then the value of user.dir is not clearly defined. 
    It should probably be<br>
    the same value as the user's home directory, but I've seen various
    values.<br>
    For a FileParameter, the value of $CWD is set to the value of the
    user.dir property,<br>
    which is probably not what you want.  I often end up using
    $CLASSPATH, which looks in<br>
    the classpath for the resource.  The file chooser does not have a
    way to add $CLASSPATH,<br>
    you have to type it in manually.<br>
    <br>
    <br>
    <blockquote cite="mid:4EA586C6.3010904@eecs.berkeley.edu"
      type="cite">
      <blockquote type="cite">
        <br>
        2.) List Parameter:
        <br>
        - I have seen some actor have List parameters how do I customise
        one for
        <br>
        my composite actor too ?
        <br>
      </blockquote>
    </blockquote>
    <br>
    For atomic actors, the ptolemy/actor/lib/MathFunction.java uses the
    addChoice() method:<br>
    <br>
           //
    Parameters                                                                                                                                         
    <br>
            function = new StringParameter(this, "function");<br>
            function.setExpression("exp");<br>
            function.addChoice("exp");<br>
            function.addChoice("log");<br>
            function.addChoice("modulo");<br>
            function.addChoice("sign");<br>
            function.addChoice("square");<br>
            function.addChoice("sqrt");<br>
            _function = _EXP;<br>
    <br>
    I believe that addChoice() is defined in ptolemy/gui/Query.java<br>
    <br>
    For a CompositeActor, you would probably need to edit the MoML by
    hand and add a Parameter:<br>
    <br>
    <property name="function"
    class="ptolemy.data.expr.StringParameter" value="square"><br>
                <property name="style"
    class="ptolemy.actor.gui.style.ChoiceStyle"><br>
                    <property name="exp"
    class="ptolemy.kernel.util.StringAttribute" value="exp"><br>
                    </property><br>
            <property name="log"
    class="ptolemy.kernel.util.StringAttribute" value="log"><br>
                    </property><br>
                    <property name="modulo"
    class="ptolemy.kernel.util.StringAttribute" value="modulo"><br>
            </property><br>
                    <property name="sign"
    class="ptolemy.kernel.util.StringAttribute" value="sign"><br>
                    </property><br>
            <property name="square"
    class="ptolemy.kernel.util.StringAttribute" value="square"><br>
                    </property><br>
                    <property name="sqrt"
    class="ptolemy.kernel.util.StringAttribute" value="sqrt"><br>
                    </property><br>
                </property><br>
            </property><br>
    <br>
    _Christopher<br>
    <blockquote cite="mid:4EA586C6.3010904@eecs.berkeley.edu"
      type="cite">
      <blockquote type="cite">
        <br>
        Thanks alot !!
        <br>
        ckw
        <br>
        <br>
        <br>
        _______________________________________________
        <br>
        Kepler-users mailing list
        <br>
        <a class="moz-txt-link-abbreviated" href="mailto:Kepler-users@kepler-project.org">Kepler-users@kepler-project.org</a>
        <br>
        <a class="moz-txt-link-freetext" href="http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users">http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a>
        <br>
      </blockquote>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kepler-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kepler-users@kepler-project.org">Kepler-users@kepler-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users">http://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
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 </pre>
  </body>
</html>