[kepler-dev] custom query boxes in Ptolemy/Kepler

Edward A. Lee eal at eecs.berkeley.edu
Sat Aug 16 09:40:14 PDT 2008


There is no need to modify the underlying framework to do this.
Just put a subclass of ptolemy.actor.gui.ParameterEditorStyle
(an attribute) inside the attribute that you want a custom input
box for.  Your subclass can implement that custom input box,
and it will automatically appear in the query box.  This is how
the style preferences currently there are implemented.

Edward

At 09:08 AM 8/15/2008, Matt Jones wrote:
>Hi Peter,
>
>Thanks for your report.  I've added your feature request to our bug list for kepler 1.1.0, and will try to get someone to review your code changes and fold them into svn.  
>
><http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3471>http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3471
>
>Thanks,
>
>Matt
>
>On Thu, Aug 14, 2008 at 1:54 PM, Peter Reutemann <<mailto:fracpete at waikato.ac.nz>fracpete at waikato.ac.nz> wrote:
>Hi there
>
>I've encountered a similar problem as mentioned in the following thread:
> <http://groups.google.com/group/comp.soft-sys.ptolemy/browse_thread/thread/dc4c136eb6870d10/75e79a2afd7cc9ab>http://groups.google.com/group/comp.soft-sys.ptolemy/browse_thread/thread/dc4c136eb6870d10/75e79a2afd7cc9ab
>
>Though using Kepler, I needed to modify the underlying Ptolemy
>framework in order to allow custom input boxes in actor dialogs. But
>instead of hacking the ptolemy.gui.Query and
>ptolemy.actor.gui.PtolemyQuery classes whenever I'd need another
>custom query box, I modified those two classes (and added
>classes/interfaces) to make it a bit more flexible.
>
>In order to get a new query box into Ptolemy, you need to modify the
>following places:
>- ptolemy.gui.Query
> ~ set(String,String)
> ~ getStringValue(String)
>
> in those two methods the type of custom query chooser, e.g.,
> QueryColorChooser is used to determine how to obtain/set the
> string representation.
>
>- ptolemy.actor.gui.PtolemyQuery
> ~ addStyledEntry(Settable)
>
> here the type of Parameter defines what query chooser is added
> for the attribute, e.g., a QueryColorChooser in case of a
> ColorAttribute.
>
>To decouple this a bit, I've come up with an interface called
>"CustomQueryBoxParameter", to be implemented by types derived from
>Parameter that need a custom query box. The interface consists of only
>one method:
> javax.swing.Box createQueryBox(PtolemyQuery query, Settable att)
>This method returns a custom query box (fully configured), based on
>the current query and attribute this query belongs to. This swing
>element contains all the necessary logic to manipulate the data, e.g.,
>a button for popping up another dialog, etc. The addStyledEntry method
>of the PtolemyQuery class obtains a box from an attribute implementing
>CustomQueryBoxParameter and attaches it (via the _addPair method).
>
>The query box being returned, is a custom class derived from
>javax.swing.Box, which implements another interface called
>"SettableQueryChooser". This interface is used in the
>set/getStringValue methods of ptolemy.gui.Query to set/get the current
>string value. The actual query chooser class turns that into whatever
>internal representation it uses. This interface avoids having to add
>new logic to the Query class, whenever a new custom QueryChooser is
>implemented.
>
>Since I'm apparently not the only user who encountered this problem,
>I'd like to contribute my code (which will hopefully trickle down to
>Kepler at one stage, in case it gets accepted). Not exactly sure how
>contributions work around here.
>
>Note: my original post *with* attachments didn't come through
>apparently (never showed up in the Google group), you can find my
>original post including the attachments on my homepage:
> <http://www.scms.waikato.ac.nz/%7Efracpete/downloads/ptolemy/custom_query_boxes/>http://www.scms.waikato.ac.nz/~fracpete/downloads/ptolemy/custom_query_boxes/
>
>There are several files available for download from this web page:
>- ptolemy-patch.zip
> contains patches for the Query/PtolemyQuery classes
> (run against subversion repository August 14, 2008)
>- ptolemy-additional_classes.zip
> additional classes/interfaces necessary for my proposed changes
>- examples-classes.zip
> contains a simple actor that uses a custom query box with a button
> that pops up a JOptionPane for the user to enter some text; this is
> just to demonstrate how the slightly modified framework would work
>- examples.kar
> a kepler archive - I know, this is not exactly the right place, but
> I thought some Kepler people/developers read this mailing list as well
> and might be interested in this
>
>Hopefully, my ramblings made some sense, otherwise the code hopefully
>speaks for itself. ;-)
>
>Cheers, Peter
>--
>Peter Reutemann, Dept. of Computer Science, University of Waikato, NZ
><http://www.cs.waikato.ac.nz/%7Efracpete/>http://www.cs.waikato.ac.nz/~fracpete/ Ph. +64 (7) 858-5174
>
>----------------------------------------------------------------------------
>Posted to the ptolemy-hackers mailing list.  Please send administrative
>mail for this list to: <mailto:ptolemy-hackers-request at ptolemy.eecs.berkeley.edu>ptolemy-hackers-request at ptolemy.eecs.berkeley.edu
>
>
>
>
>-- 
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>Matthew B. Jones
>Director of Informatics Research and Development
>National Center for Ecological Analysis and Synthesis (NCEAS)
>UC Santa Barbara
><mailto:jones at nceas.ucsb.edu>jones at nceas.ucsb.edu Ph: 1-907-523-1960
><http://www.nceas.ucsb.edu/ecoinfo>http://www.nceas.ucsb.edu/ecoinfo
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

------------ 
Edward A. Lee
Robert S. Pepper Distinguished Professor
EECS Dept., 545Q Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-643-3728, fax: 510-642-5745
eal at eecs.Berkeley.EDU, http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html  



More information about the Kepler-dev mailing list