[kepler-dev] attempting to mimic dropdown/combobox

Unknown Madhusudan madhu at sdsc.edu
Fri Jan 23 17:29:48 PST 2009


Hi Peter,

  I shall dig into the ptolemy and see how to make some headway.
 In our case idea is not to have a new actor for dropdown, but an extension of parameter
 that would serve as a variable for Constant/String Constant. Thank you for pointing out that I am not the only one looking for this feature.

 regards
--Madhu






-----Original Message-----
From: Peter Reutemann [mailto:fracpete at gmail.com]
Sent: Fri 1/23/2009 4:31 PM
To: Unknown Madhusudan
Cc: kepler-dev at ecoinformatics.org
Subject: Re: [kepler-dev] attempting to mimic dropdown/combobox
 
>     I am working at SDSC on CAMERA project.
>   In our workflows, we need to use either a dropdown box or any other
> component
>  that could mimic its functionality at design time.

Can't you do that with a simple StringParameter in your actor?

    comboParam = new StringParameter(this, "please select");
    comboParam.setExpression("Choice 1");
    comboParam.addChoice("Choice 1");
    comboParam.addChoice("Choice 2");

>   Just like the ColorParameter gives users a choice to pick up a color. It
> is static and
> uses JColorChooser to display the choices. Is there anyway to mimic the
> dropdown functionality using same ColorParameter logic? ColorParameter
> (ptolemy.actor.gui.ColorAttribute) extends from Parameter and it has only
> one additional method asColor, which return java.awl.Color object. I am not
> sure from where to start asking question on the topic of dropdown box.
>
>  1) How is the frame added to the parameter.
>  2) How different frames are added to Parameter and ColorParameter.
>  3) Color Parameter has additional Choose button, how is it added?
>  4) Where is the code for the actionListener for this Choose button?
>
>  ...................... many questions on similar lines.
>
>   I would greatly appreciate your suggestions/pointers on this topic.

Some time ago last year, I hit a similar problem that I needed
parameters with a custom GUI (combobox, checkbox, string, file weren't
enough). So I hacked a bit and contributed some code to Ptolemy II to
enable custom query boxes (referenced website includes example code):
  http://www.scms.waikato.ac.nz/~fracpete/projects/kepler_and_ptolemy/news_2008-09-19T18:33:00-0700.html

Bottom line is, in order to get a custom GUI for a parameter, one only
needs to implement a new class derived from Parameter, by implementing
the following interface:
  ptolemy.data.expr.CustomQueryBoxParameter

And for displaying the parameter in the GUI, you'd need to derive your
class from the following superclass (which is basically a panel with a
few extra methods):
  ptolemy.gui.QueryChooser

In the example available from the above link, you get an actor
(InputDialog) with a parameter that is displayed as edit field with an
associated button. Clicking on this button brings up a simple
JOptionPane.showInputDialog(..) to enter some text which is then
displayed in the text field of the parameter.

Cheers, Peter
-- 
Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
http://www.cs.waikato.ac.nz/~fracpete/           Ph. +64 (7) 858-5174

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercury.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20090123/dfd040b9/attachment-0001.html>


More information about the Kepler-dev mailing list