[kepler-dev] attempting to mimic dropdown/combobox

Peter Reutemann fracpete at gmail.com
Fri Jan 23 16:31:25 PST 2009


>     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


More information about the Kepler-dev mailing list