← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2150: dhis-live: Added settings window binding for connections and connections type. Work in progress o...

 

------------------------------------------------------------
revno: 2150
committer: Saptarshi <sunbiz@xxxxxxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-09-17 14:48:13 +0530
message:
  dhis-live: Added settings window binding for connections and connections type. Work in progress on editing. Creates config.xml from defaultConfig.xml when starting
modified:
  dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java
  dhis-live/src/main/java/org/hisp/dhis/TrayApp.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java'
--- dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java	2010-09-15 19:58:14 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java	2010-09-17 09:18:13 +0000
@@ -24,7 +24,6 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
 package org.hisp.dhis;
 
 
@@ -32,9 +31,13 @@
 import javax.swing.UIManager;
 import javax.swing.JFileChooser;
 import java.io.File;
+import javax.swing.JFrame;
+import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.ConnectionTypes.ConnectionType;
+import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.DatabaseConnections.Connection;
 
-public class SettingsWindow extends javax.swing.JFrame
+public class SettingsWindow extends JFrame
 {
+
     public SettingsWindow()
     {
         try
@@ -71,6 +74,14 @@
         maxSizeDefaultLabel = new javax.swing.JLabel();
         unitLabel = new javax.swing.JLabel();
         databaseConfigPanel = new javax.swing.JPanel();
+        connTypePanel = new javax.swing.JPanel();
+        connTypePane = new javax.swing.JScrollPane();
+        connTypeTable = new javax.swing.JTable();
+        connTypeAddButton = new javax.swing.JButton();
+        connPanel = new javax.swing.JPanel();
+        connPane = new javax.swing.JScrollPane();
+        connTable = new javax.swing.JTable();
+        connAddButton = new javax.swing.JButton();
         saveButton = new javax.swing.JButton();
 
         setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
@@ -129,41 +140,45 @@
                 .addContainerGap()
                 .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                     .addGroup(appConfigPanelLayout.createSequentialGroup()
-                        .addGap(25, 25, 25)
-                        .addComponent(hostLabel)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
-                        .addGap(29, 29, 29)
-                        .addComponent(portLabel)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
+                        .addComponent(browserPathLabel)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                        .addComponent(browserPathField, javax.swing.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE)
+                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                        .addComponent(browserPathButton)
+                        .addGap(8, 8, 8))
+                    .addGroup(appConfigPanelLayout.createSequentialGroup()
+                        .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
+                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, appConfigPanelLayout.createSequentialGroup()
+                                .addComponent(langLabel)
+                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                                .addComponent(langField))
+                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, appConfigPanelLayout.createSequentialGroup()
+                                .addGap(25, 25, 25)
+                                .addComponent(hostLabel)
+                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                                .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)))
+                        .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                            .addGroup(appConfigPanelLayout.createSequentialGroup()
+                                .addGap(29, 29, 29)
+                                .addComponent(portLabel)
+                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                                .addComponent(portField, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
+                            .addGroup(appConfigPanelLayout.createSequentialGroup()
+                                .addGap(10, 10, 10)
+                                .addComponent(countryLabel)
+                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                                .addComponent(countryField)))
                         .addGap(18, 18, 18)
                         .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                            .addComponent(maxSizeDefaultLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
+                            .addComponent(maxSizeDefaultLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
                             .addGroup(appConfigPanelLayout.createSequentialGroup()
                                 .addComponent(maxSizeLabel)
                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                 .addComponent(maxSizeField, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                 .addComponent(unitLabel)
-                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE)))
-                        .addContainerGap())
-                    .addGroup(appConfigPanelLayout.createSequentialGroup()
-                        .addComponent(langLabel)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(langField, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
-                        .addGap(10, 10, 10)
-                        .addComponent(countryLabel)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(countryField, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
-                        .addGap(280, 280, 280))
-                    .addGroup(appConfigPanelLayout.createSequentialGroup()
-                        .addComponent(browserPathLabel)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                        .addComponent(browserPathField, javax.swing.GroupLayout.DEFAULT_SIZE, 353, Short.MAX_VALUE)
-                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
-                        .addComponent(browserPathButton)
-                        .addGap(8, 8, 8))))
+                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)))
+                        .addContainerGap())))
         );
         appConfigPanelLayout.setVerticalGroup(
             appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -184,9 +199,9 @@
                         .addGap(18, 18, 18)
                         .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                             .addComponent(langLabel)
-                            .addComponent(countryLabel)
                             .addComponent(langField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                            .addComponent(countryField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
+                            .addComponent(countryField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                            .addComponent(countryLabel))))
                 .addGap(18, 18, 18)
                 .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                     .addComponent(browserPathLabel)
@@ -197,15 +212,137 @@
 
         databaseConfigPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Database Configuration"));
 
+        connTypePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Connection Types"));
+
+        connTypeTable.setColumnSelectionAllowed(true);
+        connTypeTable.getTableHeader().setReorderingAllowed(false);
+
+        org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.connectionTypes.connectionType}");
+        org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, eLProperty, connTypeTable);
+        org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
+        columnBinding.setColumnName("ID");
+        columnBinding.setColumnClass(String.class);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${dialect}"));
+        columnBinding.setColumnName("Dialect");
+        columnBinding.setColumnClass(String.class);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${driverClass}"));
+        columnBinding.setColumnName("Driver Class");
+        columnBinding.setColumnClass(String.class);
+        bindingGroup.addBinding(jTableBinding);
+        jTableBinding.bind();
+        connTypePane.setViewportView(connTypeTable);
+        connTypeTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+
+        connTypeAddButton.setText("Add New Connection Type");
+        connTypeAddButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                connTypeAddButtonActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout connTypePanelLayout = new javax.swing.GroupLayout(connTypePanel);
+        connTypePanel.setLayout(connTypePanelLayout);
+        connTypePanelLayout.setHorizontalGroup(
+            connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connTypePanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                    .addComponent(connTypePane, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
+                    .addComponent(connTypeAddButton))
+                .addContainerGap())
+        );
+        connTypePanelLayout.setVerticalGroup(
+            connTypePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connTypePanelLayout.createSequentialGroup()
+                .addComponent(connTypePane, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addComponent(connTypeAddButton)
+                .addGap(6, 6, 6))
+        );
+
+        connPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Connections"));
+
+        connTable.setColumnSelectionAllowed(true);
+        connTable.getTableHeader().setReorderingAllowed(false);
+
+        eLProperty = org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.databaseConnections.connection}");
+        jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, eLProperty, connTable);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${id}"));
+        columnBinding.setColumnName("ID");
+        columnBinding.setColumnClass(String.class);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${type}"));
+        columnBinding.setColumnName("Type");
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${name}"));
+        columnBinding.setColumnName("Name");
+        columnBinding.setColumnClass(String.class);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${URL}"));
+        columnBinding.setColumnName("URL");
+        columnBinding.setColumnClass(String.class);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${userName}"));
+        columnBinding.setColumnName("Username");
+        columnBinding.setColumnClass(String.class);
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${password}"));
+        columnBinding.setColumnName("Password");
+        columnBinding.setColumnClass(String.class);
+        bindingGroup.addBinding(jTableBinding);
+        jTableBinding.bind();binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, config, org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.databaseConnections.selected}"), connTable, org.jdesktop.beansbinding.BeanProperty.create("selectedElement"));
+        bindingGroup.addBinding(binding);
+
+        connPane.setViewportView(connTable);
+        connTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+        connTable.getColumnModel().getColumn(3).setPreferredWidth(60);
+
+        connAddButton.setText("Add New Connection");
+        connAddButton.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                connAddButtonActionPerformed(evt);
+            }
+        });
+
+        javax.swing.GroupLayout connPanelLayout = new javax.swing.GroupLayout(connPanel);
+        connPanel.setLayout(connPanelLayout);
+        connPanelLayout.setHorizontalGroup(
+            connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connPanelLayout.createSequentialGroup()
+                .addContainerGap(450, Short.MAX_VALUE)
+                .addComponent(connAddButton)
+                .addContainerGap())
+            .addGroup(connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(connPanelLayout.createSequentialGroup()
+                    .addContainerGap()
+                    .addComponent(connPane, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
+                    .addContainerGap()))
+        );
+        connPanelLayout.setVerticalGroup(
+            connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connPanelLayout.createSequentialGroup()
+                .addContainerGap(101, Short.MAX_VALUE)
+                .addComponent(connAddButton)
+                .addContainerGap())
+            .addGroup(connPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+                .addGroup(connPanelLayout.createSequentialGroup()
+                    .addComponent(connPane, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
+                    .addContainerGap(41, Short.MAX_VALUE)))
+        );
+
         javax.swing.GroupLayout databaseConfigPanelLayout = new javax.swing.GroupLayout(databaseConfigPanel);
         databaseConfigPanel.setLayout(databaseConfigPanelLayout);
         databaseConfigPanelLayout.setHorizontalGroup(
             databaseConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGap(0, 571, Short.MAX_VALUE)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, databaseConfigPanelLayout.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(databaseConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                    .addComponent(connPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(connTypePanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                .addContainerGap())
         );
         databaseConfigPanelLayout.setVerticalGroup(
             databaseConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGap(0, 117, Short.MAX_VALUE)
+            .addGroup(databaseConfigPanelLayout.createSequentialGroup()
+                .addComponent(connTypePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(connPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addContainerGap())
         );
 
         saveButton.setText("Save and Close");
@@ -220,12 +357,12 @@
         getContentPane().setLayout(layout);
         layout.setHorizontalGroup(
             layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-            .addGroup(layout.createSequentialGroup()
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                 .addContainerGap()
-                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
-                    .addComponent(databaseConfigPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                    .addComponent(appConfigPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
-                    .addComponent(saveButton, javax.swing.GroupLayout.Alignment.TRAILING))
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+                    .addComponent(databaseConfigPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(appConfigPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(saveButton))
                 .addContainerGap())
         );
         layout.setVerticalGroup(
@@ -234,10 +371,10 @@
                 .addContainerGap()
                 .addComponent(appConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                .addComponent(databaseConfigPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
-                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+                .addComponent(databaseConfigPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                 .addComponent(saveButton)
-                .addContainerGap(13, Short.MAX_VALUE))
+                .addContainerGap())
         );
 
         bindingGroup.bind();
@@ -259,16 +396,38 @@
         if ( returnVal == JFileChooser.APPROVE_OPTION )
         {
             File file = fc.getSelectedFile();
-            browserPathField.setText( file.getAbsolutePath());
+            browserPathField.setText( file.getAbsolutePath() );
         }
     }//GEN-LAST:event_browserPathButtonActionPerformed
 
+    private void connTypeAddButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connTypeAddButtonActionPerformed
+    {//GEN-HEADEREND:event_connTypeAddButtonActionPerformed
+        TrayApp.databaseConfig.getConnectionTypes().getConnectionType().add( new ConnectionType() );
+        bindingGroup.unbind();
+        bindingGroup.bind();
+    }//GEN-LAST:event_connTypeAddButtonActionPerformed
+
+    private void connAddButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_connAddButtonActionPerformed
+    {//GEN-HEADEREND:event_connAddButtonActionPerformed
+        TrayApp.databaseConfig.getDatabaseConnections().getConnection().add( new Connection() );
+        bindingGroup.unbind();
+        bindingGroup.bind();
+    }//GEN-LAST:event_connAddButtonActionPerformed
+
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JPanel appConfigPanel;
     private javax.swing.JButton browserPathButton;
     private javax.swing.JTextField browserPathField;
     private javax.swing.JLabel browserPathLabel;
     private org.hisp.dhis.config.ConfigType config;
+    private javax.swing.JButton connAddButton;
+    private javax.swing.JScrollPane connPane;
+    private javax.swing.JPanel connPanel;
+    private javax.swing.JTable connTable;
+    private javax.swing.JButton connTypeAddButton;
+    private javax.swing.JScrollPane connTypePane;
+    private javax.swing.JPanel connTypePanel;
+    private javax.swing.JTable connTypeTable;
     private javax.swing.JTextField countryField;
     private javax.swing.JLabel countryLabel;
     private javax.swing.JPanel databaseConfigPanel;

=== modified file 'dhis-live/src/main/java/org/hisp/dhis/TrayApp.java'
--- dhis-live/src/main/java/org/hisp/dhis/TrayApp.java	2010-09-16 14:33:14 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/TrayApp.java	2010-09-17 09:18:13 +0000
@@ -97,6 +97,8 @@
 
     private TrayIcon trayIcon;
 
+    private SettingsWindow settingsWindow;
+
     private JAXBElement<ConfigType> configElement;
 
     public static ConfigType config;
@@ -167,13 +169,23 @@
         try
         {
             configStream = new java.io.FileInputStream( installDir + CONFIG_FILE_NAME );
+            readConfigFromStream( configStream );
         } catch ( FileNotFoundException ex )
         {
             log.info( "Can't locate external config - falling back to default" );
             configStream = TrayApp.class.getResourceAsStream( CONFIG_DEFAULT );
+            readConfigFromStream( configStream );
+            writeConfigToFile();
+            try
+            {
+                configStream = new java.io.FileInputStream( installDir + CONFIG_FILE_NAME );
+            } catch ( FileNotFoundException fnfex )
+            {
+                log.info( "Can't locate external config - falling back to default", fnfex );
+                JOptionPane.showMessageDialog( null, "Unexpected Error", "File Error", JOptionPane.ERROR_MESSAGE );
+                System.exit( 1 );
+            }
         }
-
-        readConfigFromStream( configStream );
         databaseConfig = config.getDatabaseConfiguration();
         appConfig = config.getAppConfiguration();
         log.info( "Locale: " + appConfig.getLocaleLanguage() + ":" + appConfig.getLocaleCountry() );
@@ -333,7 +345,7 @@
             @Override
             public void actionPerformed( ActionEvent e )
             {
-                new SettingsWindow().setVisible( true );
+                getSettingsWindow().setVisible( true );
             }
         } );
         popup.add( settingsItem );
@@ -613,7 +625,7 @@
      * Reads the config.xml and creates the Config Object
      * Uses JAXBElement to config back unmarshal the config.xml
      */
-    public void readConfigFromStream( InputStream configStream )
+    private void readConfigFromStream( InputStream configStream )
     {
         try
         {
@@ -644,15 +656,8 @@
             Marshaller m = jc.createMarshaller();
             m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
             //Marshal object into file.
-            if ( new File( installDir + CONFIG_FILE_NAME ).exists() )
-            {
-                m.marshal( configElement, new FileOutputStream( installDir + CONFIG_FILE_NAME ) );
-                log.info( "Config Saved at: " + installDir + CONFIG_FILE_NAME );
-            } else
-            {
-                m.marshal( configElement, new FileOutputStream( CONFIG_DEFAULT ) );
-                log.info( "Config Saved at: " + CONFIG_FILE_NAME );
-            }
+            m.marshal( configElement, new FileOutputStream( installDir + CONFIG_FILE_NAME ) );
+            log.info( "Config Saved at: " + installDir + CONFIG_FILE_NAME );
         } catch ( FileNotFoundException ex )
         {
             log.error( "Can't find configuration xml", ex );
@@ -703,4 +708,19 @@
             System.exit( 1 );
         }
     }
+
+    /**
+     * Writes the hibernate.properties file to the /conf folder based on the selected
+     * connection from the config.xml or the defaultConfig.xml
+     *
+     * @return  Returns whether successful in writing hibernate.properties
+     */
+    private SettingsWindow getSettingsWindow()
+    {
+        if ( settingsWindow == null )
+        {
+            settingsWindow = new SettingsWindow();
+        }
+        return settingsWindow;
+    }
 }