Revision 41627 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

View differences:

DBConnectionPanel.java
78 78
    public void setServerExplorerParameters(JDBCServerExplorerParameters parameters) {
79 79

  
80 80
        int indexConnector = this.getIndexOfConnector(parameters);
81
        if ( indexConnector >= 0 && this.cboConnectors.getSelectedIndex()!=indexConnector ) {
81
        if (indexConnector >= 0 && this.cboConnectors.getSelectedIndex() != indexConnector) {
82 82
            this.cboConnectors.setSelectedIndex(indexConnector);
83 83
        }
84 84

  
85 85
        this.txtServer.setText(parameters.getHost());
86 86
        Integer port = parameters.getPort();
87
        if ( port == null ) {
87
        if (port == null) {
88 88
            this.txtPort.setText("");
89 89
        } else {
90 90
            this.txtPort.setText(String.valueOf(port));
......
103 103
        params.setUser(this.getUsername());
104 104
        params.setPassword(this.getPassword());
105 105

  
106
        if ( this.getConnectionName() != null ) {
106
        if (this.getConnectionName() != null) {
107 107
            DataManager dataManager = DALLocator.getDataManager();
108 108
            DataServerExplorerPool pool = dataManager.getDataServerExplorerPool();
109 109
            pool.add(this.getConnectionName(), params);
......
138 138

  
139 139
    public String getConnectorName() {
140 140
        JDBCServerExplorerParameters value = this.getConnector();
141
        if ( value == null ) {
141
        if (value == null) {
142 142
            return null;
143 143
        }
144 144
        return StringUtils.defaultIfBlank(value.getExplorerName(), null);
......
174 174
    private void onChangeConnector() {
175 175
        ServerExplorerParametersComboItem item = (ServerExplorerParametersComboItem) this.cboConnectors.getSelectedItem();
176 176
        JDBCServerExplorerParameters connector = item.getParams();
177
        if ( connector == null ) {
177
        if (connector == null) {
178 178
            return;
179 179
        }
180 180
        this.setServerExplorerParameters(connector);
......
182 182

  
183 183
    private void onChangeConnection() {
184 184
        Object item = this.cboConnections.getSelectedItem();
185
        if ( item instanceof ServerExplorerParametersComboItem ) {
185
        if (item instanceof ServerExplorerParametersComboItem) {
186 186
            JDBCServerExplorerParameters connection = ((ServerExplorerParametersComboItem) item).getParams();
187
            if ( connection == null ) {
187
            if (connection == null) {
188 188
                return;
189 189
            }
190 190
            this.setServerExplorerParameters(connection);
......
196 196
        try {
197 197
            code = explorerParameters.toString();
198 198
            ComboBoxModel model = this.cboConnectors.getModel();
199
            for ( int i = 0; i < model.getSize(); i++ ) {
199
            for (int i = 0; i < model.getSize(); i++) {
200 200
                ServerExplorerParametersComboItem x = (ServerExplorerParametersComboItem) model.getElementAt(i);
201
                if ( x.getLabel().equalsIgnoreCase(explorerParameters.getExplorerName()) ) {
201
                if (x.getLabel().equalsIgnoreCase(explorerParameters.getExplorerName())) {
202 202
                    return i;
203 203
                }
204 204
            }
......
213 213
        List<String> explorers = dataManager.getExplorerProviders();
214 214

  
215 215
        DataServerExplorerParameters params;
216

  
216
        JDBCServerExplorerParameters jdbcServerParameters = null;
217 217
        Iterator<String> it = explorers.iterator();
218
        while ( it.hasNext() ) {
218
        while (it.hasNext()) {
219 219
            String explorerName = it.next();
220 220
            try {
221 221
                params = dataManager.createServerExplorerParameters(explorerName);
222 222
            } catch (DataException e) {
223 223
                continue;
224 224
            }
225
            if ( params instanceof JDBCServerExplorerParameters ) {
226
                JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) params;
227
                this.cboConnectors.addItem(
228
                        new ServerExplorerParametersComboItem(dbParams)
229
                );
225
            if (params instanceof JDBCServerExplorerParameters) {
226
                // Skip JDBCServerExplorerParameters to add the last in the combo.
227
                if (JDBCServerExplorerParameters.class.getName().equals(params.getClass().getName())) {
228
                    jdbcServerParameters = (JDBCServerExplorerParameters) params;
229
                } else {
230
                    JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) params;
231
                    this.cboConnectors.addItem(
232
                            new ServerExplorerParametersComboItem(dbParams)
233
                    );
234
                }
230 235
            }
231 236
        }
237
        if (jdbcServerParameters != null) {
238
            this.cboConnectors.addItem(
239
                    new ServerExplorerParametersComboItem(jdbcServerParameters)
240
            );
241
        }
242

  
232 243
    }
233 244

  
234 245
    private void fillConnections() {
......
238 249
        DataServerExplorerParameters params;
239 250

  
240 251
        Iterator<DataServerExplorerPoolEntry> it = pool.iterator();
241
        while ( it.hasNext() ) {
252
        while (it.hasNext()) {
242 253
            DataServerExplorerPoolEntry entry = it.next();
243
            if ( entry.getExplorerParameters() instanceof JDBCServerExplorerParameters ) {
254
            if (entry.getExplorerParameters() instanceof JDBCServerExplorerParameters) {
244 255
                JDBCServerExplorerParameters dbParams = (JDBCServerExplorerParameters) entry.getExplorerParameters();
245 256
                this.cboConnections.addItem(
246 257
                        new ServerExplorerParametersComboItem(entry.getName(), dbParams)

Also available in: Unified diff