[kepler-users] saving workflow from actor code

Christopher Brooks cxh at eecs.berkeley.edu
Mon Jun 22 11:59:37 PDT 2009


My guess is that effigy is set to null because the Effigy can't be found?
I'm not sure why that would be, it could be that the effigy is not
yet created for the model.  Try checking to see if effigy is null
before using effigy:

 >> import ptolemy.actor.gui.Configuration;
 >> import ptolemy.actor.gui.Effigy;
 >> ...
 >>  Effigy effigy = Configuration.findEffigy(model.toplevel());
    if (effigy != null) {
 >>  effigy.setModified(true);
    }
 >> ...
 >>

A debugger can be a big help, I recommend using Eclipse with Kepler,
see
https://kepler-project.org/developers/reference/kepler-and-eclipse

BTW - The way I solve these sorts of issues is to search the code for
calls to the method of interest, in this case "setModified(".  There
are a few examples of calling Effigy.setModified() in the code, those
might be of interest.

There is also MoMLParser.setModified(), so if you are calling
MoML.parse() or parseFile(), then take a look at that.

_Christopher


Ufuk Utku Turuncoglu wrote:
> When i tried to implement your suggestion, i got following error during 
> opening workflow. The actor CCSMConfig2 dir port is connected to diamond 
> and it causes error. The workflow is opened without error when i comment 
> this part of the code. Any suggestion?
> 
> ps: line 442 has effigy.setModified(true); definition.
> 
> Thanks,
> 
> --ufuk
> 
> link CCSMConfig2.dir to relation
> null
> null
> 
> java.lang.NullPointerException
>    at 
> org.earth.actors.model.CCSMConfig.connectionsChanged(CCSMConfig.java:442)
>    at ptolemy.kernel.ComponentPort._doLink(ComponentPort.java:1138)
>    at ptolemy.kernel.ComponentPort.link(ComponentPort.java:543)
>    at ptolemy.actor.IOPort.link(IOPort.java:2457)
>    at ptolemy.moml.MoMLParser._processLink(MoMLParser.java:5969)
>    at ptolemy.moml.MoMLParser.access$700(MoMLParser.java:204)
>    at ptolemy.moml.MoMLParser$LinkRequest.execute(MoMLParser.java:7000)
>    at ptolemy.moml.MoMLParser._processPendingRequests(MoMLParser.java:6103)
>    at ptolemy.moml.MoMLParser.endElement(MoMLParser.java:921)
>    at com.microstar.xml.XmlParser.parseETag(XmlParser.java:1026)
>    at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1098)
>    at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924)
>    at com.microstar.xml.XmlParser.parseContent(XmlParser.java:1104)
>    at com.microstar.xml.XmlParser.parseElement(XmlParser.java:924)
>    at com.microstar.xml.XmlParser.parseDocument(XmlParser.java:481)
>    at com.microstar.xml.XmlParser.doParse(XmlParser.java:159)
>    at com.microstar.xml.XmlParser.parse(XmlParser.java:132)
>    at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1410)
>    at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1347)
>    at ptolemy.moml.MoMLParser.parse(MoMLParser.java:1298)
>    at 
> ptolemy.actor.gui.PtolemyEffigy$Factory.createEffigy(PtolemyEffigy.java:417) 
> 
>    at ptolemy.actor.gui.EffigyFactory.createEffigy(EffigyFactory.java:215)
>    at ptolemy.actor.gui.Configuration.openModel(Configuration.java:666)
>    at ptolemy.actor.gui.Configuration.openModel(Configuration.java:626)
>    at ptolemy.actor.gui.TableauFrame._read(TableauFrame.java:941)
>    at ptolemy.gui.Top._open(Top.java:751)
>    at ptolemy.gui.Top$FileMenuListener.actionPerformed(Top.java:1139)
>    at org.kepler.gui.MenuMapper$1.actionPerformed(MenuMapper.java:343)
>    at 
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
>    at 
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351) 
> 
>    at 
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) 
> 
>    at 
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
>    at javax.swing.AbstractButton.doClick(AbstractButton.java:389)
>    at 
> javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)
>    at com.apple.laf.AquaMenuItemUI.doClick(AquaMenuItemUI.java:120)
>    at 
> javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266) 
> 
>    at java.awt.Component.processMouseEvent(Component.java:6301)
>    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
>    at java.awt.Component.processEvent(Component.java:6066)
>    at java.awt.Container.processEvent(Container.java:2085)
>    at java.awt.Component.dispatchEventImpl(Component.java:4667)
>    at java.awt.Container.dispatchEventImpl(Container.java:2143)
>    at java.awt.Component.dispatchEvent(Component.java:4497)
>    at 
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4600)
>    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4264)
>    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4194)
>    at java.awt.Container.dispatchEventImpl(Container.java:2129)
>    at java.awt.Window.dispatchEventImpl(Window.java:2475)
>    at java.awt.Component.dispatchEvent(Component.java:4497)
>    at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
>    at 
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) 
> 
>    at 
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) 
> 
>    at 
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) 
> 
>    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
>    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
>    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
> 
> 
> Christopher Brooks wrote:
>> Try something like:
>>
>> import ptolemy.actor.gui.Configuration;
>> import ptolemy.actor.gui.Effigy;
>> ...
>>  Effigy effigy = Configuration.findEffigy(model.toplevel());
>>  effigy.setModified(true);
>> ...
>>
>> _Christopher
>>
>> Ufuk Utku Turuncoglu wrote:
>>> Hi,
>>>
>>> Thanks for your suggestion. Is it necessary to create 
>>> MoMLChangeRequest for this purpose? Is there any example of it?
>>>
>>> Thanks,
>>>
>>> --ufuk
>>>
>>> Edward A. Lee wrote:
>>>>
>>>> Are you sure you want to do that? Saving a workflow without the user's
>>>> intervention seems dangerous.
>>>>
>>>> An alternative is to just mark the model modified so that when it is 
>>>> closed,
>>>> the user is prompted about whether to save.
>>>>
>>>> Edward
>>>>
>>>>
>>>> Ufuk Utku Turuncoglu wrote:
>>>>> Hi,
>>>>>
>>>>> Is there any way to save the workflow from actor code? My custom 
>>>>> actor changes its parameter value and i need the save the workflow 
>>>>> when parameter field changes.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> --ufuk
>>>>> _______________________________________________
>>>>> Kepler-users mailing list
>>>>> Kepler-users at kepler-project.org
>>>>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
>>>
>>> _______________________________________________
>>> Kepler-users mailing list
>>> Kepler-users at kepler-project.org
>>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
>>
> 
> 
> Christopher Brooks wrote:
>> Try something like:
>>
>> import ptolemy.actor.gui.Configuration;
>> import ptolemy.actor.gui.Effigy;
>> ...
>>  Effigy effigy = Configuration.findEffigy(model.toplevel());
>>  effigy.setModified(true);
>> ...
>>
>> _Christopher
>>
>> Ufuk Utku Turuncoglu wrote:
>>> Hi,
>>>
>>> Thanks for your suggestion. Is it necessary to create 
>>> MoMLChangeRequest for this purpose? Is there any example of it?
>>>
>>> Thanks,
>>>
>>> --ufuk
>>>
>>> Edward A. Lee wrote:
>>>>
>>>> Are you sure you want to do that? Saving a workflow without the user's
>>>> intervention seems dangerous.
>>>>
>>>> An alternative is to just mark the model modified so that when it is 
>>>> closed,
>>>> the user is prompted about whether to save.
>>>>
>>>> Edward
>>>>
>>>>
>>>> Ufuk Utku Turuncoglu wrote:
>>>>> Hi,
>>>>>
>>>>> Is there any way to save the workflow from actor code? My custom 
>>>>> actor changes its parameter value and i need the save the workflow 
>>>>> when parameter field changes.
>>>>>
>>>>> Thanks,
>>>>>
>>>>> --ufuk
>>>>> _______________________________________________
>>>>> Kepler-users mailing list
>>>>> Kepler-users at kepler-project.org
>>>>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
>>>
>>> _______________________________________________
>>> Kepler-users mailing list
>>> Kepler-users at kepler-project.org
>>> http://mercury.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-users
>>
> 

-- 
Christopher Brooks (cxh at eecs berkeley edu) University of California
CHESS Executive Director                      US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust        Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718	      (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 (W-F) 510.655.5480



More information about the Kepler-users mailing list