Revision 26311

View differences:

trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/panels/PostGISpanel.java
1 1
package com.iver.cit.gvsig.gui.cad.panels;
2 2

  
3
import java.util.HashMap;
4

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

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

  
10 14
	public PostGISpanel(JWizardComponents wizardComponents) {
......
40 44
			String[] drvAux = new String[1];
41 45
			drvAux[0] = "PostGIS JDBC Driver";
42 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);
43 70
			jPanelConex.setPreferredSize(new java.awt.Dimension(400,300));
44 71
		}
45 72
		return jPanelConex;
......
48 75
	public ConnectionSettings getConnSettings() {
49 76
		return getJPanelConex().getConnectionSettings();
50 77
	}
78
	
79
	public void saveConnectionSettings() {
80
		getJPanelConex().saveConnectionSettings();
81
	}
82
	
51 83

  
52 84
}  //  @jve:decl-index=0:visual-constraint="10,10"
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/MyFinishAction.java
244 244
    	        }
245 245

  
246 246
    			lyr = (FLyrVect) LayerFactory.createDBLayer(dbDriver, layerName, proj);
247
    			postgisPanel.saveConnectionSettings();
247 248

  
248 249
			}
249 250
			else // Si no es ni lo uno ni lo otro,
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/vectorialdb/ConnectionPanel.java
8 8
import java.awt.event.ActionListener;
9 9
import java.util.HashMap;
10 10
import java.util.Iterator;
11
import java.util.Map;
11 12

  
12 13
import javax.swing.DefaultComboBoxModel;
13 14
import javax.swing.JLabel;
......
33 34
 * @author Fernando Gonz?lez Cort?s
34 35
 */
35 36
public class ConnectionPanel extends JPanel implements Step {
36
    private static String passw = null;
37
//    private static String passw = null;
38
    private static Map<String, String> passwords = new HashMap<String, String>();
37 39

  
38 40
    private JPanel jPanelLabels = null;
39 41
    private JLabel jLabel = null;
......
111 113
        this.setSize(335, 240);
112 114
        this.add(getJPanel(), null);
113 115

  
114
        if (passw != null)
115
            txtPassword.setText(passw);
116
//        if (passw != null)
117
//            txtPassword.setText(passw);
116 118

  
117 119
    }
118 120

  
......
330 332
     * @return DOCUMENT ME!
331 333
     */
332 334
    public String getPassword() {
333
        passw = String.copyValueOf(getTxtPassword().getPassword());
334
        return passw;
335
    	String curPwd = String.copyValueOf(getTxtPassword().getPassword());
336
//        passw = String.copyValueOf(getTxtPassword().getPassword());    	
337
//        return passw;
338
    	if (this.getSettingsName() != null && this.getSettingsName().length()> 0){
339
    		passwords.put(this.getSettingsName(), curPwd+"");    		
340
    	}
341
    	return curPwd;
335 342
    }
336 343

  
337 344
    /**
......
529 536
                            getTxtPort().setText(c.getPort());
530 537
                            getTxtBD().setText(c.getDb());
531 538
                            getTxtUser().setText(c.getUser());
532
                            if (c.getPassw() != null)
539
                            if (c.getPassw() != null){
533 540
                                getTxtPassword().setText(c.getPassw());
541
                            } else{
542
                            	if (passwords.containsKey(c.getName())){
543
                            		getTxtPassword().setText(passwords.get(c.getName()));
544
                            	}
545
                            }
534 546
                            getCmbDriver().setSelectedItem(c.getDriver());
535 547
                        }
536 548
                    }

Also available in: Unified diff