Christopher, Thanks for the response. I'm sorry I wasn't clearer. I did not expect the default undo to undo the additions to the choice lists - I expect to have to manage that myself in the CloseListener implementation.
For me the value change assigned to the parameter is not undone by cancel. I'm working with the ptII4.0.1 code base. If that makes any difference. Thanks Kevin Christopher Brooks wrote: >Hi, > >Hmm, this is a bit of a mind bender. I'm probably misunderstanding >something here. . . > >You have a actor uses EditorPaneFactory that has a ChangeOption >button. If you double click on the actor and press the ChangeOption >button in the "Edit Parameters" window, it adds choices to the entry >in the Editor Pane. > >Then, when you hit Cancel, what do you expect to have happen? > >I don't think the Cancel mechanism will handle removing the new >choices that were added. You would need to include this logic in your >Pane. > >For me, hitting Cancel seems to revert the value I typed in or >select from the list. > >Have a look at >ptolemy/actor/gui/EditParametersDialog.java and see how that works. > >I suspect that you will need to create MoMLChangeRequests to >properly get this to work. Note further that EditParametersDialog >is a model dialog: > > <p> The dialog is modal, so that (in lieu of a proper undo mechanism) > the Cancel button can properly undo any modifications that are made. > This means that the statement that creates the dialog will not return > until the user dismisses the dialog. The method buttonPressed() can > then be called to find out whether the user clicked the Commit button > or the Cancel button (or any other button specified in the > constructor). Then you can access the component to determine what > values were set by the user. > >Anyway, forgive me if I'm missing something here. > >_Christopher >-------- > > > Hi. > > I've been messing with custom EditorPanes and have come up with this > really simple Actor to demonstrate what I'm up to. > > The Actor has a single StringParameter. The editor pane displays this > value and an additional JButton. When the button is pressed two more > choices are added to the StringParameter. The ChangeListener isn't > being used yet in the ConfigTestEditorPane class. > > For some reason, the Cancel button is no longer working. I suspect the > generated undo change is not being executed in the correct context. Any > ideas how I can correct this? > > Thanks > > Kevin Ruland > University of Kansas. > > > > package edu.tutorial; > > import java.awt.Component; > import java.awt.Window; > import java.awt.event.ActionEvent; > import java.awt.event.ActionListener; > > import javax.swing.BoxLayout; > import javax.swing.JButton; > import javax.swing.JPanel; > > import ptolemy.actor.TypedAtomicActor; > import ptolemy.actor.gui.EditorPaneFactory; > import ptolemy.actor.gui.PtolemyQuery; > import ptolemy.data.expr.StringParameter; > import ptolemy.gui.CloseListener; > import ptolemy.gui.QueryListener; > import ptolemy.kernel.CompositeEntity; > import ptolemy.kernel.util.IllegalActionException; > import ptolemy.kernel.util.NameDuplicationException; > import ptolemy.kernel.util.NamedObj; > > public class ConfigTest extends TypedAtomicActor { > > public ConfigTest(CompositeEntity container, String name) > throws IllegalActionException, NameDuplicationException { > super(container, name); > MainValue = new StringParameter(this,"MainValue" ); > new ConfigEditorPaneFactory( this, ""); > } > > private StringParameter MainValue; > private static int optionCounter = 0; > > private class ConfigEditorPaneFactory extends EditorPaneFactory { > > public ConfigEditorPaneFactory(NamedObj container, String name) > throws IllegalActionException, NameDuplicationException { > super(container, name); > } > public Component createEditorPane() { > return new ConfigPane( (ConfigTest) getContainer() ); > } > > private class ConfigPane extends JPanel implements QueryListener, C > loseListener { > > private ConfigPane( ConfigTest container ) { > parent = container; > setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); > query = new PtolemyQuery( parent ); > query.setTextWidth(40); > query.addStyledEntry( parent.MainValue ); > add(query); > JButton update = new JButton("ChangeOptions"); > update.addActionListener( new ActionListener() { > public void actionPerformed(ActionEvent e) { > changeOptions(); > } > }); > add( update ); > > } > public void changed(String name) { > System.out.println("QueryListener.changed: " + name); > } > public void windowClosed(Window window, String button) { > System.out.println( "CloseListener.windowClosed"); > query.windowClosed(window,button); > } > private ConfigTest parent; > private PtolemyQuery query; > > private void changeOptions( ) { > StringParameter p = parent.MainValue; > for( int i=0; i < 2; i++ ) { > p.addChoice( Integer.toString(optionCounter++) ); > } > } > > } > } > } > >-------- > > ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]