Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / gui / cad / panels / PostGISpanel.java @ 26311

History | View | Annotate | Download (2.2 KB)

1
package com.iver.cit.gvsig.gui.cad.panels;
2

    
3
import java.util.HashMap;
4

    
5
import jwizardcomponent.JWizardComponents;
6
import jwizardcomponent.JWizardPanel;
7

    
8
import com.iver.andami.PluginServices;
9
import com.iver.cit.gvsig.vectorialdb.ConnectionPanel;
10
import com.iver.cit.gvsig.vectorialdb.ConnectionSettings;
11
import com.iver.utiles.XMLEntity;
12
public class PostGISpanel extends JWizardPanel {
13

    
14
        public PostGISpanel(JWizardComponents wizardComponents) {
15
                super(wizardComponents);
16
                initialize();
17

    
18
        }
19

    
20
        /**
21
         *
22
         */
23
        private static final long serialVersionUID = 1L;
24
        private ConnectionPanel jPanelConex = null;
25

    
26
        /**
27
         * This method initializes this
28
         *
29
         */
30
        private void initialize() {
31
        this.setSize(new java.awt.Dimension(408,284));
32
        this.add(getJPanelConex(), null);
33

    
34
        }
35

    
36
        /**
37
         * This method initializes jPanelConex
38
         *
39
         * @return javax.swing.JPanel
40
         */
41
        private ConnectionPanel getJPanelConex() {
42
                if (jPanelConex == null) {
43
                        jPanelConex = new ConnectionPanel();
44
                        String[] drvAux = new String[1];
45
                        drvAux[0] = "PostGIS JDBC Driver";
46
                        jPanelConex.setDrivers(drvAux);
47
                        
48
                XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
49

    
50
                if (xml == null) {
51
                    xml = new XMLEntity();
52
                }
53

    
54
                if (!xml.contains("db-connections")) {
55
                    String[] servers = new String[0];
56
                    xml.putProperty("db-connections", servers);
57
                }
58
                        
59
                        
60
            String[] servers = xml.getStringArrayProperty("db-connections");
61
            HashMap settings = new HashMap();
62
            for (int i = 0; i < servers.length; i++) {
63
                ConnectionSettings cs = new ConnectionSettings();
64
                cs.setFromString(servers[i]);
65
                if (cs.getDriver().equals(drvAux[0])){
66
                        settings.put(cs.getName(), cs);
67
                }
68
            }
69
            jPanelConex.setSettings(settings);
70
                        jPanelConex.setPreferredSize(new java.awt.Dimension(400,300));
71
                }
72
                return jPanelConex;
73
        }
74

    
75
        public ConnectionSettings getConnSettings() {
76
                return getJPanelConex().getConnectionSettings();
77
        }
78
        
79
        public void saveConnectionSettings() {
80
                getJPanelConex().saveConnectionSettings();
81
        }
82
        
83

    
84
}  //  @jve:decl-index=0:visual-constraint="10,10"