← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2175: dhis-live: Disabled adding new connection types as may result in unsupported dialects. Drop-downs...

 

------------------------------------------------------------
revno: 2175
committer: Saptarshi <sunbiz@xxxxxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-09-19 07:38:43 +0530
message:
  dhis-live: Disabled adding new connection types as may result in unsupported dialects. Drop-downs for available connection types when creating new connection through settings window
modified:
  dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.form
  dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java
  dhis-live/src/main/resources/defaultConfig.xml
  dhis-live/src/main/resources/messages/messages_en_GB.properties
  dhis-live/src/main/resources/messages/messages_fr.properties


--
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.form'
--- dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.form	2010-09-19 00:06:33 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.form	2010-09-19 02:08:43 +0000
@@ -96,7 +96,6 @@
                                   <Component id="hostLabel" min="-2" max="-2" attributes="0"/>
                                   <EmptySpace max="-2" attributes="0"/>
                                   <Component id="hostField" min="-2" pref="140" max="-2" attributes="1"/>
-                                  <EmptySpace max="-2" attributes="0"/>
                               </Group>
                           </Group>
                           <EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
@@ -370,6 +369,9 @@
               <SubComponents>
                 <Component class="javax.swing.JTable" name="connTypeTable">
                   <Properties>
+                    <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
+                      <Color blue="c8" green="d0" red="d4" type="rgb"/>
+                    </Property>
                     <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor">
                       <TableColumnModel selectionModel="1">
                         <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
@@ -391,7 +393,7 @@
                         </Column>
                       </TableColumnModel>
                     </Property>
-                    <Property name="columnSelectionAllowed" type="boolean" value="true"/>
+                    <Property name="enabled" type="boolean" value="false"/>
                     <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
                       <TableHeader reorderingAllowed="false" resizingAllowed="true"/>
                     </Property>
@@ -419,6 +421,7 @@
                 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
                   <Connection code="messageService.getString(&quot;settings.add&quot;)" type="code"/>
                 </Property>
+                <Property name="enabled" type="boolean" value="false"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connTypeAddButtonActionPerformed"/>
@@ -429,6 +432,7 @@
                 <Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
                   <Connection code="messageService.getString(&quot;settings.remove&quot;)" type="code"/>
                 </Property>
+                <Property name="enabled" type="boolean" value="false"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="connTypeDelButtonActionPerformed"/>
@@ -504,8 +508,12 @@
                         </Column>
                         <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
                           <Title/>
-                          <Editor/>
-                          <Renderer/>
+                          <Editor editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                            <Connection code="new DefaultCellEditor(connTypesCombo)" type="code"/>
+                          </Editor>
+                          <Renderer editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+                            <Connection code="new ConnTypesCellRenderer()" type="code"/>
+                          </Renderer>
                         </Column>
                         <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true">
                           <Title/>
@@ -529,7 +537,6 @@
                         </Column>
                       </TableColumnModel>
                     </Property>
-                    <Property name="columnSelectionAllowed" type="boolean" value="true"/>
                     <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
                       <TableHeader reorderingAllowed="false" resizingAllowed="true"/>
                     </Property>
@@ -540,9 +547,8 @@
                         <BindingParameter name="NAME" value="ID"/>
                         <BindingParameter name="javax.swing.binding.ParameterKeys.COLUMN_CLASS" value="String.class"/>
                       </Subbinding>
-                      <Subbinding sourcePath="${type.id}">
+                      <Subbinding sourcePath="${type}">
                         <BindingParameter name="NAME" value="Type"/>
-                        <BindingParameter name="javax.swing.binding.ParameterKeys.COLUMN_CLASS" value="String.class"/>
                       </Subbinding>
                       <Subbinding sourcePath="${name}">
                         <BindingParameter name="NAME" value="Name"/>

=== modified file 'dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java'
--- dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java	2010-09-19 00:06:33 +0000
+++ dhis-live/src/main/java/org/hisp/dhis/SettingsWindow.java	2010-09-19 02:08:43 +0000
@@ -26,6 +26,8 @@
  */
 package org.hisp.dhis;
 
+
+import java.awt.Component;
 import java.io.IOException;
 import java.util.Enumeration;
 import java.util.jar.JarEntry;
@@ -37,8 +39,13 @@
 import java.net.URL;
 import java.util.Vector;
 import java.util.jar.JarFile;
+import javax.swing.JComboBox;
 import javax.swing.DefaultComboBoxModel;
+import javax.swing.DefaultCellEditor;
 import javax.swing.JFrame;
+import javax.swing.JList;
+import javax.swing.plaf.basic.BasicComboBoxRenderer;
+import javax.swing.table.DefaultTableCellRenderer;
 import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.ConnectionTypes.ConnectionType;
 import org.hisp.dhis.config.ConfigType.DatabaseConfiguration.DatabaseConnections.Connection;
 
@@ -51,6 +58,8 @@
 
     private Vector countryVect = new Vector();
 
+    private JComboBox connTypesCombo;
+
     public SettingsWindow()
     {
         try
@@ -60,12 +69,46 @@
         {
             JOptionPane.showMessageDialog( null, ex.getMessage() );
         }
+        Vector connTypesVect = new Vector( TrayApp.databaseConfig.getConnectionTypes().getConnectionType() );
+        connTypesCombo = new JComboBox( connTypesVect );
+        connTypesCombo.setRenderer( new ConnTypesComboRenderer() );
         initComponents();
         langCombo.setModel( new DefaultComboBoxModel( getSupportedLanguages() ) );
         langCombo.setSelectedIndex( selectedLang );
         setLocationRelativeTo( null );
     }
 
+    class ConnTypesComboRenderer extends BasicComboBoxRenderer
+    {
+
+        @Override
+        public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus )
+        {
+            super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus );
+            if ( value != null )
+            {
+                ConnectionType item = (ConnectionType) value;
+                setText( item.getId() );
+            }
+            if ( index == -1 )
+            {
+                ConnectionType item = (ConnectionType) value;
+                setText((value == null) ? "" : item.getId());
+            }
+            return this;
+        }
+    }
+
+    class ConnTypesCellRenderer extends DefaultTableCellRenderer
+    {
+        @Override
+        public void setValue( Object value )
+        {
+            ConnectionType item = (ConnectionType) value;
+            setText((value == null) ? "" : item.getId());
+        }
+    }
+
     private String getJarfileName()
     {
         // Get the location of the jar file and the jar file name
@@ -294,8 +337,7 @@
                             .addGroup(javax.swing.GroupLayout.Alignment.LEADING, appConfigPanelLayout.createSequentialGroup()
                                 .addComponent(hostLabel)
                                 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
-                                .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
-                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
+                                .addComponent(hostField, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)))
                         .addGap(10, 10, 10)
                         .addGroup(appConfigPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                             .addComponent(countryLabel)
@@ -349,7 +391,8 @@
 
         connTypePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(messageService.getString("settings.conntypes")));
 
-        connTypeTable.setColumnSelectionAllowed(true);
+        connTypeTable.setBackground(new java.awt.Color(212, 208, 200));
+        connTypeTable.setEnabled(false);
         connTypeTable.getTableHeader().setReorderingAllowed(false);
 
         org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.connectionTypes.connectionType}");
@@ -370,6 +413,7 @@
         connTypeTable.getColumnModel().getColumn(0).setHeaderValue(messageService.getString("ID"));
 
         connTypeAddButton.setText(messageService.getString("settings.add"));
+        connTypeAddButton.setEnabled(false);
         connTypeAddButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
                 connTypeAddButtonActionPerformed(evt);
@@ -377,6 +421,7 @@
         });
 
         connTypeDelButton.setText(messageService.getString("settings.remove"));
+        connTypeDelButton.setEnabled(false);
         connTypeDelButton.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
                 connTypeDelButtonActionPerformed(evt);
@@ -410,7 +455,6 @@
 
         connPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(messageService.getString("settings.connections")));
 
-        connTable.setColumnSelectionAllowed(true);
         connTable.getTableHeader().setReorderingAllowed(false);
 
         eLProperty = org.jdesktop.beansbinding.ELProperty.create("${databaseConfiguration.databaseConnections.connection}");
@@ -418,9 +462,8 @@
         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.id}"));
+        columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${type}"));
         columnBinding.setColumnName("Type");
-        columnBinding.setColumnClass(String.class);
         columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${name}"));
         columnBinding.setColumnName("Name");
         columnBinding.setColumnClass(String.class);
@@ -437,6 +480,8 @@
         jTableBinding.bind();
         connPane.setViewportView(connTable);
         connTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
+        connTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(connTypesCombo));
+        connTable.getColumnModel().getColumn(1).setCellRenderer(new ConnTypesCellRenderer());
         connTable.getColumnModel().getColumn(3).setPreferredWidth(60);
 
         connAddButton.setText(messageService.getString("settings.add"));

=== modified file 'dhis-live/src/main/resources/defaultConfig.xml'
--- dhis-live/src/main/resources/defaultConfig.xml	2010-09-19 00:06:33 +0000
+++ dhis-live/src/main/resources/defaultConfig.xml	2010-09-19 02:08:43 +0000
@@ -19,6 +19,14 @@
                 <Dialect>org.hisp.dhis.dialect.H2Dialect</Dialect>
                 <DriverClass>org.h2.Driver</DriverClass>
             </ConnectionType>
+            <ConnectionType id="mysql">
+                <Dialect>org.hibernate.dialect.MySQLDialect</Dialect>
+                <DriverClass>com.mysql.jdbc.Driver</DriverClass>
+            </ConnectionType>
+            <ConnectionType id="postgres">
+                <Dialect>org.hibernate.dialect.PostgreSQLDialect</Dialect>
+                <DriverClass>org.postgresql.Driver</DriverClass>
+            </ConnectionType>
         </ConnectionTypes>
         <DatabaseConnections selected="conn1">
             <Connection id="conn1" type="h2">
@@ -26,16 +34,6 @@
                 <URL>jdbc:h2:./database/demo;AUTO_SERVER=TRUE</URL>
                 <UserName>sa</UserName>
             </Connection>
-            <Connection id="conn2" type="h2">
-                <Name>DHIS2 India</Name>
-                <URL>jdbc:h2:./database/india;AUTO_SERVER=TRUE</URL>
-                <UserName>india</UserName>
-            </Connection>
-            <Connection id="conn3" type="h2">
-                <Name>DHIS2 Sierra Leone</Name>
-                <URL>jdbc:h2:./database/sl;AUTO_SERVER=TRUE</URL>
-                <UserName>sl</UserName>
-            </Connection>
         </DatabaseConnections>
     </DatabaseConfiguration>
 </Config>

=== modified file 'dhis-live/src/main/resources/messages/messages_en_GB.properties'
--- dhis-live/src/main/resources/messages/messages_en_GB.properties	2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_en_GB.properties	2010-09-19 02:08:43 +0000
@@ -30,7 +30,7 @@
 settings.restartinfo=(* requires restart of DHIS 2 Live - default: 200000)
 settings.bytes=(bytes)
 settings.dbconfig= Database Configuration
-settings.conntypes=Connection Types
+settings.conntypes=Connection Types (Disabled)
 settings.remove=Remove
 settings.connections=Connections:
 settings.add=Add

=== modified file 'dhis-live/src/main/resources/messages/messages_fr.properties'
--- dhis-live/src/main/resources/messages/messages_fr.properties	2010-09-18 12:33:38 +0000
+++ dhis-live/src/main/resources/messages/messages_fr.properties	2010-09-19 02:08:43 +0000
@@ -28,7 +28,7 @@
 settings.restartinfo = (* n\u00e9cessite un red\u00e9marrage de DHIS 2 Live - par d\u00e9faut: 200000)
 settings.bytes = (octets)
 settings.dbconfig = Base de donn\u00e9es de configuration
-settings.conntypes = Les types de connexion
+settings.conntypes = Les types de connexion (Disabled)
 
 settings.connections = Connexions =:
 settings.add = Ajouter