Project

General

Profile

Actions

Bug #2341

closed

MENUS: Top-Level Menu - Some mapped menu items not working

Added by Matthew Brooke over 18 years ago. Updated about 18 years ago.

Status:
Resolved
Priority:
Immediate
Category:
interface
Target version:
Start date:
01/19/2006
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
2341

Description

Five of the menu items mapped from ptii menus don't work under the new kepler
menu hierarchy:

File->Save As (in ptii was: File->SaveAs)
View->XML View (in ptii was: View->XML View)
Workflow->Run Window (in ptii was: View->Run Window)
Tools->Check System Settings (in ptii was: View->JVM Properties)
Help->Documentation (in ptii was: Help->Help)

NOTE:
1) None of the above have Actions associated in PTII - they all use
ActionListeners, from which Actions are created for use in the new Kepler menus.
All remaining menus work OK
2) There are other PTII menus that have had Actions created from
ActionListeners, so that's not the problem per se, but it might be somehow
related...


Related issues

Blocked by Kepler - Bug #2337: TRACKING - MENUS: Top-Level Menu RevisionIn ProgressMatthew Brooke01/18/2006

Actions
Actions #1

Updated by Matthew Brooke over 18 years ago

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

---------------------------------------------

    /** 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();
        }
    }

---------------------------------------------
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:

//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 --- 

Actions #2

Updated by Matthew Brooke about 18 years ago

Christopher added the code changes to
ptolemy.actor.gui.TableauFrame.ViewMenuListener.actionPerformed(), which fixed
some of these menu items (the ones not in the File or Help menus. I then changed
the code in BasicGraphFrame to fix the remaining menu items.

Actions #3

Updated by Redmine Admin about 11 years ago

Original Bugzilla ID was 2341

Actions

Also available in: Atom PDF