Author: [EMAIL PROTECTED]
Date: Mon Sep  8 15:44:05 2008
New Revision: 2710

Modified:
   trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java
   trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java

Log:
Fixed the bug of the menu bar not appearing on Mac OS X when an OLAP session is begun. A new main Architect menu is created and used for each new OLAP frame.

Modified: trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java Mon Sep 8 15:44:05 2008
@@ -145,6 +145,7 @@
     private RedoAction redoAction;

     private AboutAction aboutAction;
+    private Action helpAction;
     private Action newProjectAction;
     private OpenProjectAction openProjectAction;
     private Action saveProjectAction;
@@ -304,15 +305,13 @@
     void init() throws ArchitectException {
         UserSettings sprefs = session.getUserSettings().getSwingSettings();
int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
-        ArchitectSwingSessionContext context = session.getContext();

         // Create actions

         aboutAction = new AboutAction(session);
+        helpAction = new HelpAction(session);
+ helpAction.putValue(AbstractAction.SHORT_DESCRIPTION, Messages.getString("ArchitectFrame.userGuideActionDescription")); //$NON-NLS-1$

-        Action helpAction = new HelpAction(session);
- helpAction.putValue(AbstractAction.SHORT_DESCRIPTION, Messages.getString("ArchitectFrame.userGuideActionDescription")); //$NON-NLS-1$
-        Action checkForUpdateAction = new CheckForUpdateAction(session);

newProjectAction = new AbstractAction(Messages.getString("ArchitectFrame.newProjectActionName"), //$NON-NLS-1$ SPSUtils.createIcon("new_project",Messages.getString("ArchitectFrame.newProjectActionIconDescription"),sprefs.getInt(ArchitectSwingUserSettings.ICON_SIZE, ArchitectSwingSessionContext.ICON_SIZE))) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -382,10 +381,7 @@

         compareDMAction = new CompareDMAction(session,comapareDMDialog);
         dataMoverAction = new DataMoverAction(this, session);
-        Action exportCSVAction = new ExportCSVAction(this, session);
- Action mappingReportAction = new VisualMappingReportAction(this, session);

-        Action kettleETL = new KettleJobAction(session);
         deleteSelectedAction = new DeleteSelectedAction(session);
createIdentifyingRelationshipAction = new CreateRelationshipAction(session, true, playpen.getCursorManager()); createNonIdentifyingRelationshipAction = new CreateRelationshipAction(session, false, playpen.getCursorManager());
@@ -411,7 +407,88 @@
focusToParentAction = new FocusToChildOrParentTableAction(session, Messages.getString("ArchitectFrame.setFocusToParentTableActionName"), Messages.getString("ArchitectFrame.setFocusToParentTableActionDescription"), true); //$NON-NLS-1$ //$NON-NLS-2$ focusToChildAction = new FocusToChildOrParentTableAction(session, Messages.getString("ArchitectFrame.setFocusToChildTableActionName"), Messages.getString("ArchitectFrame.setFocusToChildTableActionDescription"), false); //$NON-NLS-1$ //$NON-NLS-2$

+
+        menuBar = createNewMenuBar();
+        setJMenuBar(menuBar);
+
+        projectBar = new JToolBar(JToolBar.HORIZONTAL);
+        ppBar = new JToolBar(JToolBar.VERTICAL);
+
+        projectBar.add(newProjectAction);
+        projectBar.add(openProjectAction);
+        projectBar.add(saveProjectAction);
+        projectBar.addSeparator();
+        projectBar.add(printAction);
+        projectBar.addSeparator();
+        projectBar.add(undoAction);
+        projectBar.add(redoAction);
+        projectBar.addSeparator();
+        projectBar.add(exportDDLAction);
+        projectBar.add(compareDMAction);
+        projectBar.addSeparator();
+        projectBar.add(autoLayoutAction);
+        projectBar.add(profileAction);
+        projectBar.addSeparator();
+        projectBar.add(helpAction);
+ projectBar.setToolTipText(Messages.getString("ArchitectFrame.projectToolbarToolTip")); //$NON-NLS-1$ + projectBar.setName(Messages.getString("ArchitectFrame.projectToolbarName")); //$NON-NLS-1$
+
+        projectBar.setFocusable(false);
+        for (Component c : projectBar.getComponents()) {
+            c.setFocusable(false);
+        }
+
+ JButton tempButton = null; // shared actions need to report where they are coming from + ppBar.setToolTipText(Messages.getString("ArchitectFrame.playPenToolbarToolTip")); //$NON-NLS-1$ + ppBar.setName(Messages.getString("ArchitectFrame.playPenToolbarName")); //$NON-NLS-1$
+        ppBar.add(zoomInAction);
+        ppBar.add(zoomOutAction);
+        ppBar.add(zoomNormalAction);
+        ppBar.add(zoomToFitAction);
+        ppBar.addSeparator();
+        tempButton = ppBar.add(deleteSelectedAction);
+ tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
+        ppBar.addSeparator();
+        tempButton = ppBar.add(createTableAction);
+ tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
+        ppBar.addSeparator();
+        tempButton  = ppBar.add(insertIndexAction);
+ tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
+        ppBar.addSeparator();
+        tempButton = ppBar.add(insertColumnAction);
+ tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
+        tempButton = ppBar.add(editSelectedAction);
+ tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
+        ppBar.addSeparator();
+        ppBar.add(createNonIdentifyingRelationshipAction);
+        ppBar.add(createIdentifyingRelationshipAction);
+        tempButton = ppBar.add(editRelationshipAction);
+ tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
+
+        ppBar.setFocusable(false);
+        for (Component c : ppBar.getComponents()) {
+            c.setFocusable(false);
+        }

+        Container projectBarPane = getContentPane();
+        projectBarPane.setLayout(new BorderLayout());
+        projectBarPane.add(projectBar, BorderLayout.NORTH);
+
+        JPanel cp = new JPanel(new BorderLayout());
+        cp.add(ppBar, BorderLayout.EAST);
+        projectBarPane.add(cp, BorderLayout.CENTER);
+
+        cp.add(splitPane, BorderLayout.CENTER);
+        logger.debug("Added splitpane to content pane"); //$NON-NLS-1$
+    }
+
+    public JMenuBar createNewMenuBar() {
+        ArchitectSwingSessionContext context = session.getContext();
+        Action checkForUpdateAction = new CheckForUpdateAction(session);
+        Action exportCSVAction = new ExportCSVAction(this, session);
+ Action mappingReportAction = new VisualMappingReportAction(this, session);
+        Action kettleETL = new KettleJobAction(session);
+
         menuBar = new JMenuBar();

JMenu fileMenu = new JMenu(Messages.getString("ArchitectFrame.fileMenu")); //$NON-NLS-1$
@@ -590,80 +667,10 @@
         helpMenu.addSeparator();
         helpMenu.add(checkForUpdateAction);
         menuBar.add(helpMenu);
-
-        setJMenuBar(menuBar);
-
-        projectBar = new JToolBar(JToolBar.HORIZONTAL);
-        ppBar = new JToolBar(JToolBar.VERTICAL);
-
-        projectBar.add(newProjectAction);
-        projectBar.add(openProjectAction);
-        projectBar.add(saveProjectAction);
-        projectBar.addSeparator();
-        projectBar.add(printAction);
-        projectBar.addSeparator();
-        projectBar.add(undoAction);
-        projectBar.add(redoAction);
-        projectBar.addSeparator();
-        projectBar.add(exportDDLAction);
-        projectBar.add(compareDMAction);
-        projectBar.addSeparator();
-        projectBar.add(autoLayoutAction);
-        projectBar.add(profileAction);
-        projectBar.addSeparator();
-        projectBar.add(helpAction);
- projectBar.setToolTipText(Messages.getString("ArchitectFrame.projectToolbarToolTip")); //$NON-NLS-1$ - projectBar.setName(Messages.getString("ArchitectFrame.projectToolbarName")); //$NON-NLS-1$
-
-        projectBar.setFocusable(false);
-        for (Component c : projectBar.getComponents()) {
-            c.setFocusable(false);
-        }
-
- JButton tempButton = null; // shared actions need to report where they are coming from - ppBar.setToolTipText(Messages.getString("ArchitectFrame.playPenToolbarToolTip")); //$NON-NLS-1$ - ppBar.setName(Messages.getString("ArchitectFrame.playPenToolbarName")); //$NON-NLS-1$
-        ppBar.add(zoomInAction);
-        ppBar.add(zoomOutAction);
-        ppBar.add(zoomNormalAction);
-        ppBar.add(zoomToFitAction);
-        ppBar.addSeparator();
-        tempButton = ppBar.add(deleteSelectedAction);
- tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
-        ppBar.addSeparator();
-        tempButton = ppBar.add(createTableAction);
- tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
-        ppBar.addSeparator();
-        tempButton  = ppBar.add(insertIndexAction);
- tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
-        ppBar.addSeparator();
-        tempButton = ppBar.add(insertColumnAction);
- tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
-        tempButton = ppBar.add(editSelectedAction);
- tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);
-        ppBar.addSeparator();
-        ppBar.add(createNonIdentifyingRelationshipAction);
-        ppBar.add(createIdentifyingRelationshipAction);
-        tempButton = ppBar.add(editRelationshipAction);
- tempButton.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN);

-        ppBar.setFocusable(false);
-        for (Component c : ppBar.getComponents()) {
-            c.setFocusable(false);
-        }
-
-        Container projectBarPane = getContentPane();
-        projectBarPane.setLayout(new BorderLayout());
-        projectBarPane.add(projectBar, BorderLayout.NORTH);
-
-        JPanel cp = new JPanel(new BorderLayout());
-        cp.add(ppBar, BorderLayout.EAST);
-        projectBarPane.add(cp, BorderLayout.CENTER);
-
-        cp.add(splitPane, BorderLayout.CENTER);
-        logger.debug("Added splitpane to content pane"); //$NON-NLS-1$
+        return menuBar;
     }
-
+
     private JMenu buildOLAPEditMenu() {
         JMenu menu = new JMenu("Edit Schema");
         menu.add(new JMenuItem(new OLAPEditAction(session, null)));

Modified: trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java Mon Sep 8 15:44:05 2008
@@ -25,6 +25,7 @@

 import javax.swing.AbstractAction;
 import javax.swing.JFrame;
+import javax.swing.JMenuBar;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
@@ -32,6 +33,8 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;

+import org.apache.log4j.Logger;
+
 import ca.sqlpower.architect.layout.FruchtermanReingoldForceLayout;
 import ca.sqlpower.architect.olap.OLAPChildEvent;
 import ca.sqlpower.architect.olap.OLAPChildListener;
@@ -39,6 +42,7 @@
 import ca.sqlpower.architect.olap.MondrianModel.Schema;
 import ca.sqlpower.architect.olap.undo.OLAPUndoManager;
 import ca.sqlpower.architect.swingui.ArchitectSwingSession;
+import ca.sqlpower.architect.swingui.ArchitectSwingSessionContext;
 import ca.sqlpower.architect.swingui.Messages;
 import ca.sqlpower.architect.swingui.PlayPen;
 import ca.sqlpower.architect.swingui.action.AutoLayoutAction;
@@ -89,6 +93,10 @@
      */
     private final OLAPUndoManager undoManager;

+    /**
+     * The menu bar for this OLAP edit session's frame.
+     */
+    private final JMenuBar newMenuBar;

     public static final double ZOOM_STEP = 0.25;

@@ -111,6 +119,9 @@
     private RedoAction redoAction;

     private final ArchitectSwingSession swingSession;
+
+ private static final Logger logger = Logger.getLogger(OLAPPlayPenFactory.class);
+

     /**
* Creates a new editor for the given OLAP schema. The schema's OLAPObjects should
@@ -135,12 +146,13 @@
         undoManager = new OLAPUndoManager(olapSession);
pp = OLAPPlayPenFactory.createPlayPen(swingSession, this, undoManager);

-        undoManager.addChangeListener(new ChangeListener() {
+        newMenuBar = swingSession.getArchitectFrame().createNewMenuBar();
+
+        undoManager.addChangeListener(new ChangeListener() {
             public void stateChanged(ChangeEvent e) {
- // this can be called before initGUI() has had a chance to create the dialog + // this can be called before initGUI() has had a chance to create the frame
                 if (frame != null) {
                     frame.setTitle(generateDialogTitle());
-                    frame.setIconImage(OSUtils.SCHEMA_ICON.getImage());
                 }
             }
         });
@@ -241,6 +253,15 @@
         });
         frame.setContentPane(panel);
         frame.pack();
+
+        frame.setIconImage(OSUtils.SCHEMA_ICON.getImage());
+
+ // show a new top menu bar for a new OLAP Frame if on MacOSX, as it will be
+        // gone otherwise
+        ArchitectSwingSessionContext context = swingSession.getContext();
+        if (context.isMacOSX()) {
+            frame.setJMenuBar(newMenuBar);
+        }

         OLAPPlayPenFactory.setupOLAPMouseWheelActions(pp, this);
         OLAPPlayPenFactory.setupOLAPKeyboardActions(pp, this);

Reply via email to