Revision: 3276
Author: mo.jeff
Date: Mon Feb  8 14:34:01 2010
Log: ASSIGNED - bug 2402: GUI to Define Server Connections
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2402
http://code.google.com/p/power-architect/source/detail?r=3276

Modified:
 /trunk/regress/ca/sqlpower/architect/TestingArchitectSessionContext.java
/trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSessionContext.java
 /trunk/src/ca/sqlpower/architect/ArchitectSessionContext.java
 /trunk/src/ca/sqlpower/architect/ArchitectSessionContextImpl.java
 /trunk/src/ca/sqlpower/architect/swingui/ASUtils.java
 /trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java

=======================================
--- /trunk/regress/ca/sqlpower/architect/TestingArchitectSessionContext.java Fri Jan 15 15:02:04 2010 +++ /trunk/regress/ca/sqlpower/architect/TestingArchitectSessionContext.java Mon Feb 8 14:34:01 2010
@@ -27,6 +27,7 @@
 import java.util.prefs.Preferences;

 import ca.sqlpower.architect.swingui.ArchitectSwingSessionContextImpl;
+import ca.sqlpower.enterprise.client.SPServerInfoManager;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.sql.PlDotIni;
@@ -71,5 +72,10 @@
     public void setPlDotIniPath(String plDotIniPath) {
         // do nothing!
     }
+
+    public SPServerInfoManager getServerManager() {
+        // TODO Auto-generated method stub
+        return null;
+    }

 }
=======================================
--- /trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSessionContext.java Mon Jun 1 07:48:14 2009 +++ /trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSessionContext.java Mon Feb 8 14:34:01 2010
@@ -31,6 +31,7 @@

 import ca.sqlpower.architect.ArchitectSession;
 import ca.sqlpower.architect.CoreUserSettings;
+import ca.sqlpower.enterprise.client.SPServerInfoManager;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.sql.PlDotIni;
@@ -200,4 +201,9 @@
     public void setClipboardContents(Transferable t) {
throw new IllegalStateException("Setting clipboard contents not currently implemented.");
     }
-}
+
+    public SPServerInfoManager getServerManager() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectSessionContext.java Fri May 29 07:57:16 2009 +++ /trunk/src/ca/sqlpower/architect/ArchitectSessionContext.java Mon Feb 8 14:34:01 2010
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.prefs.Preferences;

+import ca.sqlpower.enterprise.client.SPServerInfoManager;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.sqlobject.SQLObjectException;
@@ -85,4 +86,9 @@
* if the given value differs from the existing one. See {...@link #plDotIniPath}.
      */
     public void setPlDotIniPath(String plDotIniPath);
-}
+
+    /**
+ * Returns the {...@link SPServerInfoManager} for this application instance.
+     */
+    public SPServerInfoManager getServerManager();
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectSessionContextImpl.java Tue Feb 2 14:19:38 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectSessionContextImpl.java Mon Feb 8 14:34:01 2010
@@ -25,10 +25,13 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;

 import org.apache.log4j.Logger;

+import ca.sqlpower.enterprise.client.SPServerInfo;
+import ca.sqlpower.enterprise.client.SPServerInfoManager;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.sql.PlDotIni;
@@ -36,6 +39,7 @@
 import ca.sqlpower.sql.SpecificDataSourceCollection;
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLObjectRuntimeException;
+import ca.sqlpower.util.Version;

public class ArchitectSessionContextImpl implements ArchitectSessionContext {

@@ -63,6 +67,8 @@
      */
     private final Collection<ArchitectSession> sessions;

+    private final SPServerInfoManager serverManager;
+
     /**
* Creates a new session context. You will normally only need one of these * per JVM, but there is no technical barrier to creating multiple contexts.
@@ -71,8 +77,9 @@
* Thread. See SwingUtilities.invokeLater() for a way of ensuring this method
      * is called on the proper thread.
      * @throws SQLObjectException
+     * @throws BackingStoreException
      */
-    public ArchitectSessionContextImpl() throws SQLObjectException {
+ public ArchitectSessionContextImpl() throws SQLObjectException, BackingStoreException {
         sessions = new HashSet<ArchitectSession>();

         ArchitectUtils.startup();
@@ -83,17 +90,22 @@
         logger.debug("pl.ini path is " + getPlDotIniPath());

setPlDotIniPath(ArchitectUtils.checkForValidPlDotIni(getPlDotIniPath(), "Architect"));
+
+ SPServerInfo defaultSettings = new SPServerInfo("", "", 8080, "/architect-enterprise/", "", ""); + serverManager = new SPServerInfoManager(getPrefs().node("servers"), new Version( + ArchitectVersion.APP_FULL_VERSION.toString()), defaultSettings);
     }

- public ArchitectSessionContextImpl(String PlDotIniPath) throws SQLObjectException { + public ArchitectSessionContextImpl(String PlDotIniPath) throws SQLObjectException, BackingStoreException {
         this(PlDotIniPath, true);
     }

     /**
      * Similar to the default constructor, but we can specify a pl.ini path
* ourselves. (This has been created in order to fully automate the JUnit test).
+     * @throws BackingStoreException
      */
- public ArchitectSessionContextImpl(String PlDotIniPath, boolean checkPath) throws SQLObjectException { + public ArchitectSessionContextImpl(String PlDotIniPath, boolean checkPath) throws SQLObjectException, BackingStoreException {
         sessions = new HashSet<ArchitectSession>();

         ArchitectUtils.startup();
@@ -105,6 +117,10 @@
         if (checkPath) {
setPlDotIniPath(ArchitectUtils.checkForValidPlDotIni(PlDotIniPath, "Architect"));
         }
+
+ SPServerInfo defaultSettings = new SPServerInfo("", "", 8080, "/architect-enterprise/", "", ""); + serverManager = new SPServerInfoManager(getPrefs().node("servers"), new Version( + ArchitectVersion.APP_FULL_VERSION.toString()), defaultSettings);
     }

     public ArchitectSession createSession() throws SQLObjectException {
@@ -202,4 +218,8 @@
     public List<JDBCDataSource> getConnections() {
         return getPlDotIni().getConnections();
     }
-}
+
+    public SPServerInfoManager getServerManager() {
+        return serverManager;
+    }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ASUtils.java Thu Jan 21 12:13:16 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/ASUtils.java Mon Feb 8 14:34:01 2010
@@ -417,7 +417,7 @@
             try {
                 context = new ArchitectSwingSessionContextImpl();
                 context.setExitAfterAllSessionsClosed(true);
-            } catch (SQLObjectException e) {
+            } catch (Exception e) {
showExceptionDialogNoReport(Messages.getString("ASUtils.couldNotLaunchPowerArchitect"), e); //$NON-NLS-1$
                 System.exit(1);
             }
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java Mon Jan 25 15:53:34 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/ArchitectFrame.java Mon Feb 8 14:34:01 2010
@@ -45,10 +45,12 @@
 import javax.swing.Action;
 import javax.swing.JButton;
 import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JDialog;
 import javax.swing.JFrame;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
@@ -121,6 +123,7 @@
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.undo.NotifyingUndoManager;
 import ca.sqlpower.swingui.SPSUtils;
+import ca.sqlpower.swingui.enterprise.client.SPServerInfoManagerPanel;

 /**
* The Main Window for the Architect Application; contains a main() method that is
@@ -211,6 +214,34 @@
         }
     };

+ private Action openServerManagerAction = new AbstractAction("Configure Server Connections...") {
+        public void actionPerformed(ActionEvent e) {
+
+ final JDialog d = SPSUtils.makeOwnedDialog(ArchitectFrame.this, "Server Connections");
+            Action closeAction = new AbstractAction("Close") {
+                public void actionPerformed(ActionEvent e) {
+                    d.dispose();
+                }
+            };
+
+            Action loginAction = new AbstractAction("Login") {
+                public void actionPerformed(ActionEvent e) {
+ JOptionPane.showMessageDialog(ArchitectFrame.this, "Login not yet supported");
+                }
+            };
+
+ SPServerInfoManagerPanel sim = new SPServerInfoManagerPanel(session.getContext().getServerManager(),
+                    ArchitectFrame.this, loginAction, closeAction);
+            d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+            d.setContentPane(sim.getPanel());
+
+            SPSUtils.makeJDialogCancellable(d, null);
+            d.pack();
+            d.setLocationRelativeTo(ArchitectFrame.this);
+            d.setVisible(true);
+        }
+    };
+
     /**
      * This constructor is used by the session implementation. To obtain an
      * Architect Frame, you have to create an
@@ -627,6 +658,10 @@
         });
         menuBar.add(olapMenu);

+        JMenu enterpriseMenu = new JMenu("Enterprise");
+        enterpriseMenu.add(openServerManagerAction);
+        menuBar.add(enterpriseMenu);
+
JMenu toolsMenu = new JMenu(Messages.getString("ArchitectFrame.toolsMenu")); //$NON-NLS-1$
         toolsMenu.setMnemonic('t');
         toolsMenu.add(exportDDLAction);
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java Tue Jan 26 10:49:55 2010 +++ /trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionContextImpl.java Mon Feb 8 14:34:01 2010
@@ -31,6 +31,7 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.prefs.BackingStoreException;
 import java.util.prefs.Preferences;

 import javax.swing.ImageIcon;
@@ -42,6 +43,7 @@
 import ca.sqlpower.architect.ArchitectSessionContext;
 import ca.sqlpower.architect.ArchitectSessionContextImpl;
 import ca.sqlpower.architect.CoreUserSettings;
+import ca.sqlpower.enterprise.client.SPServerInfoManager;
 import ca.sqlpower.sql.DataSourceCollection;
 import ca.sqlpower.sql.JDBCDataSource;
 import ca.sqlpower.sql.Olap4jDataSource;
@@ -163,8 +165,9 @@
      * is called on the proper thread.
      *
      * @throws SQLObjectException
+     * @throws BackingStoreException
      */
-    public ArchitectSwingSessionContextImpl() throws SQLObjectException {
+ public ArchitectSwingSessionContextImpl() throws SQLObjectException, BackingStoreException {
         delegateContext = new ArchitectSessionContextImpl();

System.setProperty("apple.laf.useScreenMenuBar", "true"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -423,4 +426,8 @@
         this.clipboard.setContents(dummyTransferable, this);
         logger.debug("Context lost clipboard ownership");
     }
-}
+
+    public SPServerInfoManager getServerManager() {
+        return delegateContext.getServerManager();
+    }
+}

Reply via email to