Revision 3613 trunk/applications/appCatalogYNomenclatorClient/src/es/gva/cit/gazetteer/ui/serverConnect/ServerConnectDialogPanel.java

View differences:

ServerConnectDialogPanel.java
40 40
*   dac@iver.es
41 41
*/
42 42
package es.gva.cit.gazetteer.ui.serverConnect;
43
import es.gva.cit.catalogClient.traductor.ITranslator;
44
import es.gva.cit.catalogClient.traductor.Translator;
45
import es.gva.cit.catalogClient.utils.comboServer.ServerData;
46
import es.gva.cit.gazetteer.GazetteerClient;
47
import es.gva.cit.gazetteer.ui.search.SearchDialog;
43 48
import java.awt.Dimension;
44 49
import java.awt.FlowLayout;
45 50
import java.awt.event.ActionEvent;
......
51 56
import java.io.IOException;
52 57
import java.util.Iterator;
53 58
import java.util.TreeMap;
54

  
55 59
import javax.swing.BoxLayout;
56 60
import javax.swing.JButton;
61
import javax.swing.JFrame;
57 62
import javax.swing.JPanel;
58 63

  
59
import es.gva.cit.catalogClient.traductor.ITranslator;
60
import es.gva.cit.catalogClient.traductor.Translator;
61
import es.gva.cit.catalogClient.utils.comboServer.ServerData;
62
import es.gva.cit.gazetteer.GazetteerClient;
63
import es.gva.cit.gazetteer.ui.search.SearchDialog;
64

  
65 64
/**
66 65
 * 
67 66
 * 
......
80 79
 * 
81 80
 * 
82 81
 */
83
    JPanel ppalPanel = null;
82
    private JPanel ppalPanel = null;
84 83
/**
85 84
 * 
86 85
 * 
87 86
 */
88
    ServerConnectPanel controlsPanel = null;
87
    private ServerConnectPanel controlsPanel = null;
89 88
/**
90 89
 * 
91 90
 * 
92 91
 */
93
    JPanel buttonsPanel = null;
92
    private JPanel buttonsPanel = null;
94 93
//Buttons
95 94
/**
96 95
 * 
97 96
 * 
98 97
 */
99
    JButton connect = null;
98
    private JButton connectButton = null;
100 99
/**
101 100
 * 
102 101
 * 
103 102
 */
104
    JButton search = null;
103
    private JButton searchButton = null;
104
/**
105
 * 
106
 * 
107
 */
108
    private JButton closeButton = null;
109
/**
110
 * 
111
 * 
112
 */
113
    private JFrame parent = null;
105 114
//Others
106 115
/**
107 116
 * 
......
130 139
 * 
131 140
 * 
132 141
 * 
142
 * @param parent 
133 143
 * @param translator 
134 144
 */
135
    public  ServerConnectDialogPanel(ITranslator translator) {        
145
    public  ServerConnectDialogPanel(JFrame parent, ITranslator translator) {        
136 146
        this.translator = translator;
147
        this.parent = parent;
137 148
        ppalPanel = new JPanel();
138 149
        ppalPanel.setLayout(new BoxLayout(ppalPanel, BoxLayout.Y_AXIS));
139 150
        ppalPanel.add(getControlsPanel(), null);
......
171 182
            buttonsPanel = new JPanel(new FlowLayout());
172 183
            buttonsPanel.add(getConnectButton());
173 184
            buttonsPanel.add(getSearchButton());
185
            buttonsPanel.add(getCloseButton());
174 186
        }
175 187
        return buttonsPanel;
176 188
    } 
......
182 194
 * @return 
183 195
 */
184 196
    public JButton getConnectButton() {        
185
        if (connect == null) {
186
            connect = new JButton(Translator.getText(translator,"connectButton"));
187
            connect.setSize(new Dimension(30, 20));
188
            connect.setActionCommand("Connect");
197
        if (connectButton == null) {
198
            connectButton = new JButton(Translator.getText(translator,"connectButton"));
199
            connectButton.setSize(new Dimension(30, 20));
200
            connectButton.setActionCommand("Connect");
189 201
        }
190
        return connect;
202
        return connectButton;
191 203
    } 
192 204

  
193 205
/**
......
197 209
 * @return 
198 210
 */
199 211
    public JButton getSearchButton() {        
200
        if (search == null) {
201
            search = new JButton(Translator.getText(translator,"searchButton"));
202
            search.setSize(new Dimension(30, 20));
203
            search.setActionCommand("Search");
204
            search.setEnabled(false);
212
        if (searchButton == null) {
213
            searchButton = new JButton(Translator.getText(translator,"searchButton"));
214
            searchButton.setSize(new Dimension(30, 20));
215
            searchButton.setActionCommand("Search");
216
            searchButton.setEnabled(false);
205 217
        }
206
        return search;
218
        return searchButton;
207 219
    } 
208 220

  
209 221
/**
222
 * 
223
 * 
224
 * 
225
 * @return 
226
 */
227
    public JButton getCloseButton() {        
228
            if (closeButton == null) {
229
                closeButton = new JButton(Translator.getText(translator,"close"));
230
                closeButton.setSize(new Dimension(30, 20));
231
                closeButton.setActionCommand("close");
232
               
233
            }
234
            return closeButton;
235
    } 
236

  
237
/**
210 238
 * It adds a server in the TreeMap Object
211 239
 * 
212 240
 * 
......
227 255
    public void setDefaultButtonListeners() {        
228 256
        getConnectButton().addActionListener(this);
229 257
        getSearchButton().addActionListener(this);
258
        getCloseButton().addActionListener(this);
230 259
    } 
231 260

  
232 261
/**
......
296 325
        if ((e.getActionCommand() == "WFS-G") ||
297 326
                (e.getActionCommand() == "ADL") ||
298 327
                (e.getActionCommand() == "comboBoxChanged")) {
299
            search.setEnabled(false);
328
            searchButton.setEnabled(false);
300 329
        }
301 330
        
302 331
        if (e.getActionCommand() == "servidoresCombo"){
......
307 336
            }
308 337
            
309 338
        }
339
        //Connect
340
        if (e.getActionCommand() == "close") {
341
           closeButtonActionPerformed();
342
        }
310 343
              
311 344
    } 
312 345

  
......
324 357
 * 
325 358
 */
326 359
    public void connectButtonActionPerformed() {        
327
        search.setEnabled(false);
360
        searchButton.setEnabled(false);
328 361
//      Create a new Gazetteer client
329 362
        client = new GazetteerClient(controlsPanel.getServerAddress(),
330 363
                controlsPanel.getProtocol());
331 364
        
332 365
        if (client.getCapabilities()){
333
            search.setEnabled(true);
366
            searchButton.setEnabled(true);
334 367
            currentServer = controlsPanel.getServerAddress();
335 368
        }
336 369
        
......
340 373
/**
341 374
 * 
342 375
 * 
376
 */
377
    public void closeButtonActionPerformed() {        
378
        parent.setVisible(false);
379
    } 
380

  
381
/**
343 382
 * 
383
 * 
384
 * 
344 385
 * @return Returns the serversFile.
345 386
 */
346 387
    public String getServersFile() {        

Also available in: Unified diff