[kepler-dev] [Bug 2341] - MENUS: Top-Level Menu - Some mapped menu items not working
bugzilla-daemon at ecoinformatics.org
bugzilla-daemon at ecoinformatics.org
Fri Jan 20 21:00:34 PST 2006
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2341
------- Additional Comments From brooke at nceas.ucsb.edu 2006-01-20 21:00 -------
This was happening because we were setting the Action.NAME, and the ptii code
uses the menu name to create a Factory to respond to the menu selection. I have
currently commented out the code that changes Action.NAME (since this was also
the cause of bug #2342) - however, this means that any menu items that should be
renamed for Kepler do not actually get renamed - they still have their old names
(specifically File->New->Graph Editor *should* be File->New Workflow->Blank, and
File->SaveAs *should* be File->Save As). Suggested fix shown further down the
page...
Here's the culprit code (discovered by Christopher):
It looks like
ptolemy.actor.gui.TableauFrame.ViewMenuListener.actionPerformed()
is being called but for XML view and JVM properties the factory is
null?
In the line marked --->, the factory is null for XML view
---------------------------------------------
<pre>
/** Listener for view menu commands. */
class ViewMenuListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
// Make this the default context for modal messages.
GraphicalMessageHandler.setContext(TableauFrame.this);
System.out.println("TableauFrame.actionPerformed()" + e +
" " + _factoryContainer);
if (_factoryContainer != null) {
JMenuItem target = (JMenuItem) e.getSource();
String actionCommand = target.getActionCommand();
TableauFactory factory = (TableauFactory) _factoryContainer
.getAttribute(actionCommand);
---> System.out.println("TableauFrame.actionPerformed(): factory "
+ factory);
if (factory != null) {
Effigy tableauContainer = (Effigy) _tableau.getContainer();
try {
Tableau tableau = factory
.createTableau(tableauContainer);
tableau.show();
} catch (Throwable throwable) {
// Copernicus might throw a java.lang.Error if
// jhdl.Main cannot be resolved
MessageHandler.error("Cannot create view",
throwable);
}
}
}
// NOTE: The following should not be needed, but
jdk1.3beta
// appears to have a bug in swing where repainting doesn't
// properly occur.
repaint();
}
}
</pre>
---------------------------------------------
In lieu of commenting out the Action.NAME assignment, however, it would be nice
if we could fix the above code so it looks for an Action first - something like
this:
---------------------------------------------
snippet from your quoted code, with new code added:
<pre>
//ORIGINAL CODE
JMenuItem target = (JMenuItem) e.getSource();
//NEW CODE -----------
String actionCommand = null;
Action action = target.getAction();
if (action!=null) {
//the following should be OK because GUIUtilities.addMenuItem()
//automatically adds each incoming JMenuItems as a property of
//the Action itself - see diva.gui.GUIUtilities.addMenuItem(),
//line 202, ans so does kepler/src/exp/ptolemy/vergil/basic/
// BasicGraphFrame.storeSubMenus() line 2519...
JMenuItem origMItem = (JMenuItem) action.getValue("menuitem");
if (origMItem!=null) {
actionCommand = origMItem.getActionCommand();
} else {
actionCommand = target.getActionCommand();
}
} else {
//EDIT THIS ORIGINAL CODE - delete the "String":
actionCommand = target.getActionCommand();
// String actionCommand = target.getActionCommand();
//NEW CODE - close bracket:
}
// END ---
</pre>
---------------------------------------------
More information about the Kepler-dev
mailing list