Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / gui / FPanelExtentSelector.java @ 36475

History | View | Annotate | Download (10.9 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22
package org.gvsig.app.project.documents.view.gui;
23

    
24
import java.awt.BorderLayout;
25
import java.awt.FlowLayout;
26
import java.util.ArrayList;
27
import java.util.List;
28

    
29
import javax.swing.JButton;
30
import javax.swing.JPanel;
31
import javax.swing.ListModel;
32

    
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.ui.mdiManager.IWindow;
35
import org.gvsig.andami.ui.mdiManager.WindowInfo;
36
import org.gvsig.app.project.documents.view.ListSelectorListener;
37
import org.gvsig.tools.swing.api.ToolsSwingLocator;
38

    
39
/**
40
 * DOCUMENT ME!
41
 * 
42
 * @author Fernando Gonz?lez Cort?s
43
 */
44
public class FPanelExtentSelector extends JPanel implements IWindow {
45

    
46
    private static final long serialVersionUID = -8246729582621010542L;
47
    private javax.swing.JScrollPane jScrollPane = null;
48
    private javax.swing.JList lista = null;
49
    private JButton btnAceptar = null;
50
    private ListModel modelo = null;
51
    private List<ListSelectorListener> selectionListeners =
52
        new ArrayList<ListSelectorListener>();
53
    private JButton btnEliminar = null;
54
    private javax.swing.JPanel jPanel = null;
55
    private javax.swing.JPanel jPanel1 = null;
56
    private javax.swing.JLabel jLabel = null;
57
    private javax.swing.JTextField txtGuardar = null;
58
    private JButton btnGuardar = null;
59
    private WindowInfo m_viewinfo = null;
60
    private JPanel jPanel2 = null;
61
    private JPanel jPanel3 = null;
62

    
63
    /**
64
     * This is the default constructor
65
     */
66
    public FPanelExtentSelector() {
67
        super();
68
        initialize();
69
    }
70

    
71
    /**
72
     * This method initializes this
73
     */
74
    private void initialize() {
75
        this.setLayout(new BorderLayout());
76
        this.setSize(new java.awt.Dimension(530, 320));
77
        this.add(getJPanel(), java.awt.BorderLayout.NORTH);
78
        this.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
79

    
80
    }
81

    
82
    /**
83
     * This method initializes jScrollPane
84
     * 
85
     * @return javax.swing.JScrollPane
86
     */
87
    private javax.swing.JScrollPane getJScrollPane() {
88
        if (jScrollPane == null) {
89
            jScrollPane = new javax.swing.JScrollPane();
90
            jScrollPane.setViewportView(getLista());
91
            jScrollPane.setBounds(11, 26, 508, 150);
92
            jScrollPane.setPreferredSize(new java.awt.Dimension(400, 150));
93
        }
94

    
95
        return jScrollPane;
96
    }
97

    
98
    /**
99
     * This method initializes lista
100
     * 
101
     * @return javax.swing.JList
102
     */
103
    private javax.swing.JList getLista() {
104
        if (lista == null) {
105
            lista = new javax.swing.JList();
106
        }
107

    
108
        return lista;
109
    }
110

    
111
    /**
112
     * Asigna el el array que se va a representar. Se crea una
113
     * copia del modelo, de forma que modificaciones en el modelo
114
     * fuera de esta clase ya no afectan al modelo copiado
115
     * 
116
     * @param model
117
     *            DOCUMENT ME!
118
     */
119
    public void setModel(ListModel model) {
120
        // modelo de la lista
121
        modelo = model;
122
        getLista().setModel(modelo);
123
    }
124

    
125
    public void addSelectionListener(ListSelectorListener listener) {
126
        getSelectionListeners().add(listener);
127
    }
128

    
129
    public void removeSelectionListener(ListSelectorListener listener) {
130
        getSelectionListeners().remove(listener);
131
    }
132

    
133
    private void callIndexesRemoved(int[] indices) {
134
        for (int i = 0; i < selectionListeners.size(); i++) {
135
            selectionListeners.get(i).indexesRemoved(indices);
136
        }
137
    }
138

    
139
    private void callIndexesSelected(int[] indices) {
140
        for (int i = 0; i < selectionListeners.size(); i++) {
141
            selectionListeners.get(i).indexesSelected(indices);
142
        }
143
    }
144

    
145
    private void callNewElement(String name) {
146
        for (int i = 0; i < selectionListeners.size(); i++) {
147
            selectionListeners.get(i).newElement(name);
148
        }
149
    }
150

    
151
    /**
152
     * This method initializes btnAceptar
153
     * 
154
     * @return JButton
155
     */
156
    private JButton getBtnAceptar() {
157
        if (btnAceptar == null) {
158
            btnAceptar =
159
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
160
            btnAceptar.setText(PluginServices.getText(this, "Seleccionar"));
161
            btnAceptar.addActionListener(new java.awt.event.ActionListener() {
162

    
163
                public void actionPerformed(java.awt.event.ActionEvent e) {
164
                    int[] indices = lista.getSelectedIndices();
165

    
166
                    if (indices.length != 0) {
167
                        callIndexesSelected(indices);
168
                    }
169
                }
170
            });
171
        }
172

    
173
        return btnAceptar;
174
    }
175

    
176
    /**
177
     * @return
178
     */
179
    private List<ListSelectorListener> getSelectionListeners() {
180
        return selectionListeners;
181
    }
182

    
183
    /**
184
     * This method initializes btnEliminar
185
     * 
186
     * @return JButton
187
     */
188
    private JButton getBtnEliminar() {
189
        if (btnEliminar == null) {
190
            btnEliminar =
191
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
192
            btnEliminar.setText(PluginServices.getText(this, "Eliminar"));
193
            btnEliminar.addActionListener(new java.awt.event.ActionListener() {
194

    
195
                public void actionPerformed(java.awt.event.ActionEvent e) {
196
                    int[] indices = lista.getSelectedIndices();
197

    
198
                    if (indices.length != 0) {
199
                        callIndexesRemoved(indices);
200
                    }
201
                }
202
            });
203
        }
204
        return btnEliminar;
205
    }
206

    
207
    /**
208
     * This method initializes jPanel
209
     * 
210
     * @return javax.swing.JPanel
211
     */
212
    private javax.swing.JPanel getJPanel() {
213
        if (jPanel == null) {
214
            jPanel = new javax.swing.JPanel();
215
            jPanel.setLayout(null);
216

    
217
            jPanel.add(getJLabel(), null);
218
            jPanel.add(getTxtGuardar(), null);
219
            jPanel.setPreferredSize(new java.awt.Dimension(530, 100));
220
            jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
221
                PluginServices.getText(this, "Guardar_el_zoom_actual"),
222
                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
223
                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
224
            jPanel.add(getJPanel3(), null);
225
        }
226
        return jPanel;
227
    }
228

    
229
    /**
230
     * This method initializes jPanel1
231
     * 
232
     * @return javax.swing.JPanel
233
     */
234
    private javax.swing.JPanel getJPanel1() {
235
        if (jPanel1 == null) {
236
            jPanel1 = new javax.swing.JPanel();
237
            jPanel1.setLayout(null);
238
            jPanel1.add(getJScrollPane(), null);
239
            jPanel1.setPreferredSize(new java.awt.Dimension(530, 220));
240
            jPanel1
241
                .setBorder(javax.swing.BorderFactory.createTitledBorder(null,
242
                    PluginServices.getText(this,
243
                        "Recuperar_y_eliminar_otros_zoom"),
244
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
245
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
246
                    null));
247
            jPanel1.add(getJPanel2(), null);
248
        }
249
        return jPanel1;
250
    }
251

    
252
    /**
253
     * This method initializes jLabel
254
     * 
255
     * @return javax.swing.JLabel
256
     */
257
    private javax.swing.JLabel getJLabel() {
258
        if (jLabel == null) {
259
            jLabel = new javax.swing.JLabel();
260
            jLabel.setBounds(7, 35, 248, 16);
261
            jLabel.setText(PluginServices.getText(this,
262
                "Nombre_que_se_le_dara_al_zoom") + ":");
263
        }
264
        return jLabel;
265
    }
266

    
267
    /**
268
     * This method initializes txtGuardar
269
     * 
270
     * @return javax.swing.JTextField
271
     */
272
    private javax.swing.JTextField getTxtGuardar() {
273
        if (txtGuardar == null) {
274
            txtGuardar = new javax.swing.JTextField();
275
            txtGuardar.setBounds(250, 34, 269, 20);
276
            txtGuardar.setPreferredSize(new java.awt.Dimension(330, 20));
277
        }
278
        return txtGuardar;
279
    }
280

    
281
    /**
282
     * This method initializes btnGuardar
283
     * 
284
     * @return JButton
285
     */
286
    private JButton getBtnGuardar() {
287
        if (btnGuardar == null) {
288
            btnGuardar =
289
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
290
            btnGuardar.setText(PluginServices.getText(this, "Guardar"));
291
            btnGuardar.addActionListener(new java.awt.event.ActionListener() {
292

    
293
                public void actionPerformed(java.awt.event.ActionEvent e) {
294
                    String text = txtGuardar.getText().trim();
295
                    if (text.length() > 0) {
296
                        callNewElement(text);
297
                    }
298
                }
299
            });
300
        }
301
        return btnGuardar;
302
    }
303

    
304
    /**
305
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
306
     */
307
    public WindowInfo getWindowInfo() {
308
        if (m_viewinfo == null) {
309
            m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG);
310
            m_viewinfo.setWidth(this.getWidth() + 8);
311
            m_viewinfo.setHeight(this.getHeight());
312
            m_viewinfo.setTitle(PluginServices.getText(this, "Encuadre"));
313
        }
314
        return m_viewinfo;
315
    }
316

    
317
    /**
318
     * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
319
     */
320
    public void viewActivated() {
321
    }
322

    
323
    /**
324
     * This method initializes jPanel2
325
     * 
326
     * @return javax.swing.JPanel
327
     */
328
    private JPanel getJPanel2() {
329
        if (jPanel2 == null) {
330
            jPanel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
331
            jPanel2.setBounds(new java.awt.Rectangle(11, 180, 508, 33));
332
            jPanel2.add(getBtnAceptar(), null);
333
            jPanel2.add(getBtnEliminar(), null);
334
        }
335
        return jPanel2;
336
    }
337

    
338
    /**
339
     * This method initializes jPanel3
340
     * 
341
     * @return javax.swing.JPanel
342
     */
343
    private JPanel getJPanel3() {
344
        if (jPanel3 == null) {
345
            jPanel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
346
            jPanel3.setBounds(new java.awt.Rectangle(8, 59, 511, 33));
347
            jPanel3.add(getBtnGuardar(), null);
348
        }
349
        return jPanel3;
350
    }
351

    
352
    public Object getWindowProfile() {
353
        return WindowInfo.TOOL_PROFILE;
354
    }
355

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