Revision 41488 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.exportto/org.gvsig.exportto.swing/org.gvsig.exportto.swing.prov/org.gvsig.exportto.swing.prov.jdbc/src/main/java/org/gvsig/exportto/swing/prov/jdbc/panel/DBConnectionPanel.java
DBConnectionPanel.java | ||
---|---|---|
5 | 5 |
*/ |
6 | 6 |
package org.gvsig.exportto.swing.prov.jdbc.panel; |
7 | 7 |
|
8 |
import java.awt.Color; |
|
8 | 9 |
import java.awt.event.ItemEvent; |
9 | 10 |
import java.awt.event.ItemListener; |
10 | 11 |
import java.util.Iterator; |
... | ... | |
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
public DBConnectionPanel() { |
51 |
|
|
52 |
initComponents(); |
|
52 | 53 |
} |
53 | 54 |
|
54 | 55 |
public void setServerExplorerParameters(Map<String, JDBCServerExplorerParameters> parameters) { |
55 | 56 |
this.parameters = parameters; |
56 | 57 |
if (parameters == null) { |
58 |
this.lblConnectionName.setVisible(false); |
|
59 |
this.cboConnections.setVisible(false); |
|
60 |
this.botManage.setVisible(false); |
|
57 | 61 |
return; |
58 | 62 |
} |
59 | 63 |
Iterator<Map.Entry<String, JDBCServerExplorerParameters>> it = parameters.entrySet().iterator(); |
... | ... | |
63 | 67 |
new ServerExplorerParametersComboItem(entry.getKey(), entry.getValue()) |
64 | 68 |
); |
65 | 69 |
} |
70 |
this.lblConnectionName.setVisible(true); |
|
71 |
this.cboConnections.setVisible(true); |
|
72 |
this.botManage.setVisible(true); |
|
66 | 73 |
} |
67 | 74 |
|
68 | 75 |
protected void initComponents() { |
... | ... | |
79 | 86 |
}); |
80 | 87 |
fillConnectors(); |
81 | 88 |
this.botManage.setEnabled(false); // TODO |
82 |
|
|
89 |
|
|
90 |
this.lblConnectionName.setVisible(false); |
|
91 |
this.cboConnections.setVisible(false); |
|
92 |
this.botManage.setVisible(false); |
|
83 | 93 |
} |
84 | 94 |
|
85 | 95 |
public void setServerExplorerParameters(JDBCServerExplorerParameters parameters) { |
86 | 96 |
this.txtServer.setText(parameters.getHost()); |
87 |
this.txtPort.setText(String.valueOf(parameters.getPort())); |
|
97 |
Integer port = parameters.getPort(); |
|
98 |
if( port == null ) { |
|
99 |
this.txtPort.setText(""); |
|
100 |
} else { |
|
101 |
this.txtPort.setText(String.valueOf(port)); |
|
102 |
} |
|
88 | 103 |
this.txtDataBase.setText(parameters.getDBName()); |
89 | 104 |
this.txtUsername.setText(parameters.getUser()); |
90 | 105 |
this.txtPassword.setText(parameters.getPassword()); |
... | ... | |
99 | 114 |
params.setUser(this.getUsername()); |
100 | 115 |
params.setPassword(this.getPassword()); |
101 | 116 |
|
102 |
this.parameters.put(this.getConnectionName(), params); |
|
117 |
if( this.getConnectionName()!=null ) { |
|
118 |
this.parameters.put(this.getConnectionName(), params); |
|
119 |
} |
|
103 | 120 |
return params; |
104 | 121 |
} |
105 | 122 |
|
... | ... | |
123 | 140 |
} |
124 | 141 |
|
125 | 142 |
public JDBCServerExplorerParameters getConnector() { |
126 |
JDBCServerExplorerParameters value = (JDBCServerExplorerParameters) this.cboConnectors.getSelectedItem(); |
|
143 |
ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem(); |
|
144 |
JDBCServerExplorerParameters value = item.getParams(); |
|
127 | 145 |
return value; |
128 | 146 |
} |
129 | 147 |
|
... | ... | |
163 | 181 |
} |
164 | 182 |
|
165 | 183 |
private void onChangeConnector() { |
166 |
JDBCServerExplorerParameters connector = (JDBCServerExplorerParameters) this.cboConnectors.getSelectedItem(); |
|
184 |
ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem(); |
|
185 |
JDBCServerExplorerParameters connector = item.getParams(); |
|
167 | 186 |
if (connector == null) { |
168 | 187 |
return; |
169 | 188 |
} |
... | ... | |
171 | 190 |
} |
172 | 191 |
|
173 | 192 |
private void onChangeConnection() { |
174 |
JDBCServerExplorerParameters connection = (JDBCServerExplorerParameters) this.cboConnections.getSelectedItem(); |
|
193 |
ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnections.getSelectedItem(); |
|
194 |
JDBCServerExplorerParameters connection = item.getParams(); |
|
175 | 195 |
if (connection == null) { |
176 | 196 |
return; |
177 | 197 |
} |
Also available in: Unified diff