Ah! When I first sent email, I was racking my brain for an example of an actor that used a custom editor but did not come up with one.
However, now I realize that the TM domain SchedulePlotter, the DocumentationAttribute and the GiottoCodeGenerator icon all use a custom editor by having a public createEditor() method. Interesting about changing the Parameter choices and having it reflected in the configuration. I believe you are correct in that Query does not really support that. Using a custom editor is a good solution. _Christopher -------- Christopher, There's actually two ways to hook into the configuration dialog to provide customization. If you put a ptolemy.actor.gui.EditorFactory in your actor, the createEditor() method will be envoked when the user attempts to configure the actor. The standard dialog is not displayed at all -- the createEditor() method is completely responsible for constructing the dialog. If you put one or more ptolemy.actor.gui.EditorPaneFactory instances in your actor, then Configurer will envoke createEditorPane() on each of them and pack them into its pane. The standard dialog button across the bottom are displayed, and the inner workings of ptolemy manage the "cancel" operation. Since I didn't want to mess with the whole dialg thing I opted for the EditorPaneFactory route. My Actor has a couple of phases to its configuration. First you need to specify url/user/pass information and query the server for capabilities. These capabilities then drive choices and optional parameters. The problem with using just your ordinary configuration dialog (as generated by ptolemy.actor.gui.Configurer) is, by only using the attribute change listener of the actor you are not able to change the choices of a parameter and have them reflected in the configuration dialog. What I'm saying is, the Parameter objects don't have a "choiceChangeListener" function which could be hooked to the underlying JComboBox to update the ui. Of course I could cheat and dig into the JPanel and try to find the correct combobox object and force it to update, but that would probably be pretty fragile. So, I built a custom pane which proves me better control. I have a custom button which executes the remote query, and since I handles to the various Swing components I can more easily update them. But that brought me to the last problem. I use ptolemy.actor.gui.PtolemyQuery objects internally to build the label/box objects in order to have the same L&F as the rest of the ptolemy configuration dialogs. But when you add a Parameter to the PtolemyQuery, the PtolemyQuery is added as a value listener to the Parameter. This means that the PtolemyQuery will never be garbage collected unless you explicitly remove the object from the Parameter's value change listeners. Ahh, and after all this typing I see where I can hook. I need to implement CloseListener in my panel. Then I get notified that the dialog has been closed and I can properly remove all my listeners. Thanks for the help Kevin Christopher Brooks wrote: >Hi Kevin, >I don't think Vergil supports creating custom configuration panes. >It probably should, but it does not. > >If I understand you correctly, then it looks like you are creating an >actor and then when you click on the actor, you would be able to edit >some parameters in the parent container. > >The way I would do this is to have the actor have parameters that >are set to composite actor (aka toplevel) parameters in the container. > >Usually, one would then right click on the background of the >composite actor to edit the parameters. > >You could try using ptolemy.moml.SharedParameter: > >"This parameter is shared throughout a model. Changing the expression >of any one instance of the parameter will result in all instances that >are shared being changed to the same expression. An instance elsewhere >in the model (within the same top level) is shared if it has the same >name and its container is of the class specified in the constructor >(or of the container class, if no class is specified in the constructor)." > > >Some of the early Ptolemy models don't use vergil and instead have >their own UI. See the CSP Dining Philosophers example and >the CSP Bus Contention example. You could do something similar, but >that would mean you would not be using Vergil. > >_Christopher > >Christopher Brooks (cxh at eecs berkeley edu) University of California >Programmer/Analyst Chess/Ptolemy/Trust US Mail: 558 Cory Hall #1770 >ph: 510.643.9841 fax:510.642.2739 Berkeley, CA 94720-1770 >home: (F-Tu) 707.665.0131 (W-F) 510.655.5480 (office: 400A Cory) > > > >-------- > > > Hi all, > > I'm a Ptolemy rookie so please point me to FAQ or other documentation if > available. > > I have written a TypedAtomicActor which has a few StringParameters to > control its behavour. Also, I've written an EditorPaneFactory for thi s > actor which presents some custom configuration panes. The factory > returns an object which derives from JPanel and uses code roughly like this > : > > public HelloWorldEditorPane( NamedObj container ) { > super(); > parent = (HelloWorld) container; > > PtolemyQuery hostQuery = new PtolemyQuery( container ); > hostQuery.setTextWidth( 40 ); > hostQuery.addStyledEntry( parent.url ); > hostQuery.addStyledEntry( parent.user ); > hostQuery.addStyledEntry( parent.pass ); > > this.add( hostQuery ); > > } > > This code using the PtolemyQuery has been cribbed from the > ptolemy.actor.gui.EditorPaneFactory.createEditorPane() method. > > The problem that I see, is the addStyledEntry() method (through the > PtolemyQuery.attachParameter() method ) ends up adding this to the > ValueListener list of the StringParameters such as parent.url. Since > this list is implemented as a standard LinkedList, the StringParameter > hold on tightly to the PtolemyQuery object and that object is never > freed. In order to remove this from the value listeners, I'd have to call > > parent.url.removeValueListener( hostQuery ) > > when the hostQuery object is no longer needed (such as when the > configure window is closed). But I don't think the Panel that I creat ed > ever receives notification that the configure dialog has been closed. > > Is there some way to work around this issue? Is there some actor in > there which does this properly. > > Thanks for the advice. > > Kevin Ruland > University of Kansas. > > --------------------------------------------------------------------------- - Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED] -------- ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]