Author: jfuerth
Date: Wed Sep  3 15:06:36 2008
New Revision: 2693

Modified:
   trunk/src/ca/sqlpower/architect/swingui/olap/OLAPEditSession.java
trunk/src/ca/sqlpower/architect/swingui/olap/action/ImportSchemaAction.java trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPDeleteSelectedAction.java
   trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPEditAction.java

Log:
Changed OLAP Edit Sessions to live in a frame instead of a dialog. This makes it easier to use and less bizarre (for example, you can now get the architect frame in front of an olap editor).

One problem this has introduced is that the menu bar is attached to the Architect Frame. On Windows, this isn't a big deal: the OLAP sessions simply don't have a menu bar. But on OS X, it sucks because the screen menu bar goes blank when you're using an OLAP frame. We'll come up with a good way of dealing with this soon.

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 Wed Sep 3 15:06:36 2008
@@ -24,7 +24,7 @@
 import java.beans.PropertyChangeListener;

 import javax.swing.AbstractAction;
-import javax.swing.JDialog;
+import javax.swing.JFrame;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
@@ -57,6 +57,8 @@
 import ca.sqlpower.architect.swingui.olap.action.CreateVirtualCubeAction;
 import ca.sqlpower.architect.swingui.olap.action.ExportSchemaAction;
 import ca.sqlpower.architect.swingui.olap.action.OLAPDeleteSelectedAction;
+import ca.sqlpower.swingui.event.SessionLifecycleEvent;
+import ca.sqlpower.swingui.event.SessionLifecycleListener;

 public class OLAPEditSession implements OLAPChildListener {

@@ -68,9 +70,9 @@
     private final PlayPen pp;

     /**
-     * The dialog this edit session lives in.
+     * The frame this edit session lives in.
      */
-    private JDialog d;
+    private JFrame frame;

     /**
      * The scroll pane of which the PlayPen is in.
@@ -136,11 +138,17 @@
         undoManager.addChangeListener(new ChangeListener() {
             public void stateChanged(ChangeEvent e) {
// this can be called before initGUI() has had a chance to create the dialog
-                if (d != null) {
-                    d.setTitle(generateDialogTitle());
+                if (frame != null) {
+                    frame.setTitle(generateDialogTitle());
                 }
             }
         });
+
+ swingSession.addSessionLifecycleListener(new SessionLifecycleListener<ArchitectSwingSession>() { + public void sessionClosing(SessionLifecycleEvent<ArchitectSwingSession> e) {
+                close();
+            }
+        });
         // Don't create actions here. PlayPen is currently null.
     }

@@ -148,11 +156,11 @@
* Returns the OLAP Schema Editor dialog. It does not come with location and
      * visibility set.
      */
-    public JDialog getDialog() {
-        if (d == null) {
+    public JFrame getFrame() {
+        if (frame == null) {
             initGUI();
         }
-        return d;
+        return frame;
     }

     /**
@@ -222,16 +230,16 @@
                 BorderLayout.CENTER);
         panel.add(toolbar, BorderLayout.EAST);

- d = new JDialog(swingSession.getArchitectFrame(), generateDialogTitle());
+        frame = new JFrame(generateDialogTitle());
olapSession.getSchema().addPropertyChangeListener(new PropertyChangeListener() {
             public void propertyChange(PropertyChangeEvent evt) {
                 if (evt.getPropertyName().equals("name")) {
-                    d.setTitle(generateDialogTitle());
+                    frame.setTitle(generateDialogTitle());
                 }
             }
         });
-        d.setContentPane(panel);
-        d.pack();
+        frame.setContentPane(panel);
+        frame.pack();

         OLAPPlayPenFactory.setupOLAPMouseWheelActions(pp, this);
         OLAPPlayPenFactory.setupOLAPKeyboardActions(pp, this);
@@ -258,6 +266,14 @@
     }

     /**
+     * Cleans up all resources this session was using. This method will be
+     * called automatically when the Architect swing session closes.
+     */
+    public void close() {
+        frame.dispose();
+    }
+
+    /**
* This method must be called just after this session has been saved with
      * the project. It resets the save state, and might do other stuff that
      * client code shouldn't care about.
@@ -345,7 +361,7 @@
// remove from architect's list of edit sessions and stop listening
             swingSession.getOLAPEditSessions().remove(this);
             swingSession.getOLAPRootObject().removeChildListener(this);
-            d.dispose();
+            frame.dispose();
         }
     }


Modified: trunk/src/ca/sqlpower/architect/swingui/olap/action/ImportSchemaAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/action/ImportSchemaAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/olap/action/ImportSchemaAction.java Wed Sep 3 15:06:36 2008
@@ -28,6 +28,7 @@

 import javax.swing.JDialog;
 import javax.swing.JFileChooser;
+import javax.swing.JFrame;

 import org.apache.log4j.Logger;

@@ -105,9 +106,9 @@

                 addGUIComponents(editSession);

-                final JDialog d = editSession.getDialog();
-                d.setLocationRelativeTo(session.getArchitectFrame());
-                d.setVisible(true);
+                final JFrame frame = editSession.getFrame();
+                frame.setLocationRelativeTo(session.getArchitectFrame());
+                frame.setVisible(true);
                 try {
final SchemaEditPanel schemaEditPanel = new SchemaEditPanel(session, loadedSchema);

@@ -119,7 +120,7 @@

Callable<Boolean> cancelCall = new Callable<Boolean>() {
                         public Boolean call() throws Exception {
-                            d.dispose();
+                            frame.dispose();
session.getOLAPRootObject().removeOLAPSession(osession);
                             return true;
                         }
@@ -127,12 +128,12 @@

JDialog schemaEditDialog = DataEntryPanelBuilder.createDataEntryPanelDialog(
                             schemaEditPanel,
-                            d,
+                            frame,
                             "New Schema Properties",
                             "OK",
                             okCall,
                             cancelCall);
-                    schemaEditDialog.setLocationRelativeTo(d);
+                    schemaEditDialog.setLocationRelativeTo(frame);
                     schemaEditDialog.setVisible(true);
                 } catch (Exception ex) {
                     ASUtils.showExceptionDialogNoReport(

Modified: trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPDeleteSelectedAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPDeleteSelectedAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPDeleteSelectedAction.java Wed Sep 3 15:06:36 2008
@@ -68,7 +68,7 @@
     public void actionPerformed(ActionEvent arg0) {
         List<OLAPObject> itemsToDelete = getDeletableItems();
         if (itemsToDelete.size() > 1 ) {
- int decision = JOptionPane.showConfirmDialog(editSession.getDialog(), "Are you sure you want to delete the following " + itemsToDelete.size() + " items?", + int decision = JOptionPane.showConfirmDialog(editSession.getFrame(), "Are you sure you want to delete the following " + itemsToDelete.size() + " items?",
                             "Multiple Delete", JOptionPane.YES_NO_OPTION);
             if (decision != JOptionPane.YES_OPTION ) {
                 return;

Modified: trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPEditAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPEditAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/olap/action/OLAPEditAction.java Wed Sep 3 15:06:36 2008
@@ -23,6 +23,7 @@
 import java.util.concurrent.Callable;

 import javax.swing.JDialog;
+import javax.swing.JFrame;

 import ca.sqlpower.architect.olap.OLAPSession;
 import ca.sqlpower.architect.olap.MondrianModel.Schema;
@@ -61,9 +62,9 @@

OLAPEditSession editSession = session.getOLAPEditSession(olapSession);

-        final JDialog d = editSession.getDialog();
-        d.setLocationRelativeTo(session.getArchitectFrame());
-        d.setVisible(true);
+        final JFrame frame = editSession.getFrame();
+        frame.setLocationRelativeTo(session.getArchitectFrame());
+        frame.setVisible(true);

         if (newSchema) {
             try {
@@ -77,7 +78,7 @@

                 Callable<Boolean> cancelCall = new Callable<Boolean>() {
                     public Boolean call() throws Exception {
-                        d.dispose();
+                        frame.dispose();
session.getOLAPRootObject().removeOLAPSession(olapSession);
                         return true;
                     }
@@ -85,12 +86,12 @@

JDialog schemaEditDialog = DataEntryPanelBuilder.createDataEntryPanelDialog(
                         schemaEditPanel,
-                        d,
+                        frame,
                         "New Schema Properties",
                         "OK",
                         okCall,
                         cancelCall);
-                schemaEditDialog.setLocationRelativeTo(d);
+                schemaEditDialog.setLocationRelativeTo(frame);
                 schemaEditDialog.setVisible(true);
             } catch (Exception ex) {
                 ASUtils.showExceptionDialogNoReport(

Reply via email to