[kepler-dev] Style Configurer bug fix to go in to Kepler 1.0

Christopher Brooks cxh at eecs.berkeley.edu
Mon Jun 5 12:22:04 PDT 2006


Hi Dan,
If you have a chance, please consider folding this change into
the Kepler 1.0 release:

2006-06-04 19:00  eal

	* ptolemy/actor/gui/style/StyleConfigurer.java (1.50): Put style
	objects inside a container.

The bug it fixes is that changing the parameter style on a transition in a state 
machine gives a stack exception.

Details below.

_Christopher

> From: "Edward A. Lee" <eal at eecs.berkeley.edu>
> To: "Christopher Brooks" <cxh at eecs.berkeley.edu>
> Subject: Re: Fwd: bug 
> Date: Sun, 04 Jun 2006 19:01:44 -0700
> 
> 
> Thanks for the detailed diagnosis.
> I've checked in a fix (which simply creates a Parameter container).
> 
> Edward
> 
> At 03:49 PM 6/1/2006, Christopher Brooks wrote:
> >The problem is that ptolemy.actor.gui.StyleConfigurer.changed()
> >ends up queuing a ChangeRequest with:
> >
> ><group><property name="guardExpression"><group name="auto"><?xml
> >version="1.0" standalone="no"?>
> ><!DOCTYPE property PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
> >     "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd">
> ><property name="style" class="ptolemy.actor.gui.style.LineStyle">
> ></property>
> ></group></property></group>
> >
> >The offending <!DOCTYPE text comes from StyleConfigurer.changed():
> >
> >             ParameterEditorStyle found = null;
> >
> >             for (int i = 0; (i < _parameterStyles.length) && (found 
> > == null); i++) {
> >                 if 
> > (getStringValue(name).equals(_parameterStyles[i].getName())) {
> >                     found = _parameterStyles[i];
> >                 }
> >             }
> >
> >...
> >
> >             moml.append(found.exportMoML("style"));
> >
> >
> >The offending code is in NamedObj.exportMoML(Writer, int, String):
> >
> >
> >         if ((depth == 0) && (getContainer() == null)) {
> >             // No container, and this is a top level moml element.
> >             // Generate header information.
> >             // NOTE: Used to generate this only if the top-level
> >             // was an entity, with the following test:
> >             // if (_elementName.equals("entity")) {}
> >             // However, this meant that when saving icons,
> >             // they would not have the header information,
> >             // and when opened, would open as a text file
> >             // instead of in the icon editor.
> >             output.write("<?xml version=\"1.0\" standalone=\"no\"?>\n"
> >                     + "<!DOCTYPE " + _elementName + " PUBLIC "
> >                     + "\"-//UC Berkeley//DTD MoML 1//EN\"\n"
> >                     + "    \"http://ptolemy.eecs.berkeley.edu"
> >                     + "/xml/dtd/MoML_1.dtd\">\n");
> >         }
> >
> >This change comes from:
> >
> >revision 1.312
> >date: 2006/02/22 04:47:16;  author: eal;  state: Exp;  lines: +15 -8
> >Generate XML header even if the top-level is not an entity.
> >
> >
> >So, what should we do here?
> >We could override this exportMoML method in ParameterEditorStyle, but
> >I suspect there are similar problems elsewhere.
> >Or, we could try setting the container of the found object.
> >
> >_parameterStyles is set in the StyleConfigurer constructor
> >to an array:
> >
> >
> >             // FIXME this list should not be statically specified.
> >             // Note that fixing this will probably move the accept method
> >             // into some sort of factory object (instead of cloning
> >             // existing styles).
> >             _parameterStyles = new ParameterEditorStyle[7];
> >             _parameterStyles[0] = new LineStyle();
> >             _parameterStyles[0].setName("Line");
> >             _parameterStyles[1] = new CheckBoxStyle();
> >             _parameterStyles[1].setName("Check Box");
> >             _parameterStyles[2] = new ChoiceStyle();
> >             _parameterStyles[2].setName("Choice");
> >             _parameterStyles[3] = new EditableChoiceStyle();
> >             _parameterStyles[3].setName("EditableChoice");
> >             _parameterStyles[4] = new TextStyle();
> >             _parameterStyles[4].setName("Text");
> >             _parameterStyles[5] = new FileChooserStyle();
> >             _parameterStyles[5].setName("FileChooser");
> >             _parameterStyles[6] = new NotEditableLineStyle();
> >             _parameterStyles[6].setName("Fixed");
> >
> >I tried setting the container, but ran in to problems because
> >CheckBoxStyle wants a parameter, not a NamedObj.  Changing the
> >constructor causes an exception to be thrown.
> >
> >_Christopher
> >--------
> >
> >
> >     Trying to change parameter style on a transition in a state 
> > machine gives:
> >
> >     >To: eal
> >     >From: "Edward A. Lee" <eal at eecs.berkeley.edu>
> >     >Subject: bug
> >     >
> >     >
> >     >Try to change reset action to text style
> >     >
> >     >com.microstar.xml.XmlException: expected comment or CDATA section
> >     >(found "D") in [external stream] at line 2 and column 4
> >     >         at ptolemy.moml.MoMLParser.error(MoMLParser.java:989)
> >     >         at com.microstar.xml.XmlParser.error(XmlParser.java:446)
> >     >         at com.microstar.xml.XmlParser.error(XmlParser.java:457)
> >     >         at 
> > com.microstar.xml.XmlParser.parseContent(XmlParser.java:1082)
> >     >         at com.microstar.xml.XmlParser.parseElement(XmlParser.java:921)
> >     >         at 
> > com.microstar.xml.XmlParser.parseContent(XmlParser.java:1101)
> >     >         at com.microstar.xml.XmlParser.parseElement(XmlParser.java:921)
> >     >         at 
> > com.microstar.xml.XmlParser.parseContent(XmlParser.java:1101)
> >     >         at com.microstar.xml.XmlParser.parseElement(XmlParser.java:921)
> >     >         at 
> > com.microstar.xml.XmlParser.parseDocument(XmlParser.java:479)
> >     >         at com.microstar.xml.XmlParser.doParse(XmlParser.java:157)
> >     >         at com.microstar.xml.XmlParser.parse(XmlParser.java:130)
> >     >         at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1289)
> >     >         at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1417)
> >     >         at
> >     > ptolemy.moml.MoMLChangeRequest._execute(MoMLChangeRequest.java:270)
> >     >         at 
> > ptolemy.kernel.util.ChangeRequest.execute(ChangeRequest.java:1
> >    39)
> >     >         at
> >     > ptolemy.kernel.util.NamedObj.executeChangeRequests(NamedObj.java:685)
> >     >         at 
> > ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1631)
> >     >         at
> >     > ptolemy.actor.CompositeActor.requestChange(CompositeActor.java:914)
> >     >         at 
> > ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1614)
> >     >         at
> >     > ptolemy.actor.CompositeActor.requestChange(CompositeActor.java:914)
> >     >         at 
> > ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1614)
> >     >         at 
> > ptolemy.kernel.util.NamedObj.requestChange(NamedObj.java:1614)
> >     >         at
> >     > 
> > ptolemy.actor.gui.style.StyleConfigurer.changed(StyleConfigurer.java:249)
> >     >         at ptolemy.gui.Query._notifyListeners(Query.java:1528)
> >     >         at
> >     > ptolemy.gui.Query$QueryItemListener.itemStateChanged(Query.java:1897)
> >     >         at 
> > javax.swing.JComboBox.fireItemStateChanged(JComboBox.java:1162
> >    )
> >     >         at 
> > javax.swing.JComboBox.selectedItemChanged(JComboBox.java:1210)
> >     >         at javax.swing.JComboBox.contentsChanged(JComboBox.java:1266)
> >     >         at
> >     > 
> > javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:
> >    100)
> >     >         at
> >     > 
> > javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.jav
> >    a:88)
> >     >         at javax.swing.JComboBox.setSelectedItem(JComboBox.java:551)
> >     >         at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:597)
> >     >         at
> >     > 
> > javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPo
> >    pup.java:808)
> >     >         at
> >     > 
> > java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:232)
> >     >         at java.awt.Component.processMouseEvent(Component.java:5488)
> >     >         at 
> > javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
> >     >         at
> >     > 
> > javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopu
> >    p.java:476)
> >     >         at java.awt.Component.processEvent(Component.java:5253)
> >     >         at java.awt.Container.processEvent(Container.java:1966)
> >     >         at java.awt.Component.dispatchEventImpl(Component.java:3955)
> >     >         at java.awt.Container.dispatchEventImpl(Container.java:2024)
> >     >         at java.awt.Component.dispatchEvent(Component.java:3803)
> >     >         at
> >     > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
> >     >         at
> >     > java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> >     >         at 
> > java.awt.LightweightDispatcher.dispatchEvent(Container.java:38
> >    22)
> >     >         at java.awt.Container.dispatchEventImpl(Container.java:2010)
> >     >         at java.awt.Window.dispatchEventImpl(Window.java:1774)
> >     >         at java.awt.Component.dispatchEvent(Component.java:3803)
> >     >         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> >     >         at
> >     > 
> > java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread
> >    .java:242)
> >     >         at
> >     > 
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j
> >    ava:163)
> >     >         at
> >     > 
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j
> >    ava:153)
> >     >         at java.awt.Dialog$1.run(Dialog.java:515)
> >     >         at java.awt.Dialog.show(Dialog.java:536)
> >     >         at java.awt.Component.show(Component.java:1300)
> >     >         at java.awt.Component.setVisible(Component.java:1253)
> >     >         at ptolemy.gui.ComponentDialog.<init>(ComponentDialog.java:233)
> >     >         at ptolemy.gui.ComponentDialog.<init>(ComponentDialog.java:83)
> >     >         at
> >     > 
> > ptolemy.actor.gui.EditParametersDialog.<init>(EditParametersDialog.java:1
> >    76)
> >     >         at
> >     > 
> > ptolemy.actor.gui.EditParametersDialog.<init>(EditParametersDialog.java:9
> >    3)
> >     >         at
> >     > 
> > ptolemy.actor.gui.EditParametersDialog.<init>(EditParametersDialog.java:1
> >    84)
> >     >         at
> >     > 
> > ptolemy.actor.gui.EditParametersDialog.<init>(EditParametersDialog.java:9
> >    3)
> >     >         at
> >     > 
> > ptolemy.vergil.toolbox.ConfigureAction.openDialog(ConfigureAction.java:11
> >    7)
> >     >         at
> >     > 
> > ptolemy.vergil.toolbox.ConfigureAction.actionPerformed(ConfigureAction.ja
> >    va:94)
> >     >         at
> >     > 
> > diva.canvas.interactor.ActionInteractor.mousePressed(ActionInteractor.jav
> >    a:74)
> >     >         at
> >     > 
> > diva.canvas.interactor.CompositeInteractor.mousePressed(CompositeInteract
> >    or.java:207)
> >     >         at
> >     > 
> > diva.canvas.interactor.SelectionInteractor.mousePressed(SelectionInteract
> >    or.java:202)
> >     >         at 
> > diva.canvas.FigureLayer.dispatchEventUpTree(FigureLayer.java:5
> >    51)
> >     >         at diva.canvas.FigureLayer.grabPointer(FigureLayer.java:319)
> >     >         at 
> > diva.canvas.FigureLayer.processLayerEvent(FigureLayer.java:673
> >    )
> >     >         at diva.canvas.FigureLayer.dispatchEvent(FigureLayer.java:203)
> >     >         at 
> > diva.canvas.CanvasPane.processLayerEvent(CanvasPane.java:280)
> >     >         at diva.canvas.CanvasPane.dispatchEvent(CanvasPane.java:89)
> >     >         at 
> > diva.canvas.JCanvas.internalProcessMouseEvent(JCanvas.java:465
> >    )
> >     >         at diva.canvas.JCanvas.processMouseEvent(JCanvas.java:419)
> >     >         at java.awt.Component.processEvent(Component.java:5253)
> >     >         at java.awt.Container.processEvent(Container.java:1966)
> >     >         at java.awt.Component.dispatchEventImpl(Component.java:3955)
> >     >         at java.awt.Container.dispatchEventImpl(Container.java:2024)
> >     >         at java.awt.Component.dispatchEvent(Component.java:3803)
> >     >         at
> >     > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
> >     >         at
> >     > java.awt.LightweightDispatcher.processMouseEvent(Container.java:3889)
> >     >         at 
> > java.awt.LightweightDispatcher.dispatchEvent(Container.java:38
> >    22)
> >     >         at java.awt.Container.dispatchEventImpl(Container.java:2010)
> >     >         at java.awt.Window.dispatchEventImpl(Window.java:1774)
> >     >         at java.awt.Component.dispatchEvent(Component.java:3803)
> >     >         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> >     >         at
> >     > 
> > java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread
> >    .java:242)
> >     >         at
> >     > 
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j
> >    ava:163)
> >     >         at
> >     > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
> >     >         at
> >     > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
> >     >         at 
> > java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> >     >
> >     >------------
> >     >Edward A. Lee
> >     >Professor, Chair of the EE Division, Associate Chair of EECS
> >     >231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
> >     >phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
> >     >eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
> >
> >     ------------
> >     Edward A. Lee
> >     Professor, Chair of the EE Division, Associate Chair of EECS
> >     231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
> >     phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
> >     eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal
> >--------
> 
> ------------
> Edward A. Lee
> Professor, Chair of the EE Division, Associate Chair of EECS
> 231 Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
> phone: 510-642-0253 or 510-642-0455, fax: 510-642-2845
> eal at eecs.Berkeley.EDU, http://ptolemy.eecs.berkeley.edu/~eal  


More information about the Kepler-dev mailing list