Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FPanelExtentSelector.java @ 1846

History | View | Annotate | Download (8.76 KB)

1 1103 fjp
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41 312 fernando
package com.iver.cit.gvsig.gui;
42
43
import java.util.ArrayList;
44
45
import javax.swing.JPanel;
46
import javax.swing.ListModel;
47
48 620 fjp
import com.iver.andami.PluginServices;
49
import com.iver.andami.Utilities;
50
import com.iver.andami.ui.mdiManager.View;
51
import com.iver.andami.ui.mdiManager.ViewInfo;
52 312 fernando
53
54
/**
55
 * DOCUMENT ME!
56
 *
57
 * @author Fernando Gonz?lez Cort?s
58
 */
59
public class FPanelExtentSelector extends JPanel implements View {
60
    private javax.swing.JScrollPane jScrollPane = null;
61
    private javax.swing.JList lista = null;
62
    private javax.swing.JButton btnAceptar = null;
63
    private ListModel modelo = null;
64
        private ArrayList selectionListeners = new ArrayList();
65
        private javax.swing.JButton btnEliminar = null;
66
        private javax.swing.JPanel jPanel = null;
67
        private javax.swing.JPanel jPanel1 = null;
68
        private javax.swing.JLabel jLabel = null;
69
        private javax.swing.JTextField txtGuardar = null;
70
        private javax.swing.JButton btnGuardar = null;
71
        private ViewInfo m_viewinfo = null;
72
    /**
73
     * This is the default constructor
74
     */
75
    public FPanelExtentSelector() {
76
        super();
77
        initialize();
78
    }
79
80
    /**
81
     * This method initializes this
82
     */
83
    private void initialize() {
84
        this.add(getJPanel(), null);
85
        this.add(getJPanel1(), null);
86
    }
87
88
    /**
89
     * This method initializes jScrollPane
90
     *
91
     * @return javax.swing.JScrollPane
92
     */
93
    private javax.swing.JScrollPane getJScrollPane() {
94
        if (jScrollPane == null) {
95
            jScrollPane = new javax.swing.JScrollPane();
96
            jScrollPane.setViewportView(getLista());
97
            jScrollPane.setBounds(11, 26, 400, 150);
98
            jScrollPane.setPreferredSize(new java.awt.Dimension(400,150));
99
        }
100
101
        return jScrollPane;
102
    }
103
104
    /**
105
     * This method initializes lista
106
     *
107
     * @return javax.swing.JList
108
     */
109
    private javax.swing.JList getLista() {
110
        if (lista == null) {
111
            lista = new javax.swing.JList();
112
        }
113
114
        return lista;
115
    }
116
117
    /**
118
     * Asigna el el array que se va a representar. Se crea una
119
     * copia del modelo, de forma que modificaciones en el modelo
120
     * fuera de esta clase ya no afectan al modelo copiado
121
     *
122
     * @param model DOCUMENT ME!
123
     */
124
    public void setModel(ListModel model) {
125
            //modelo de la lista
126
        modelo = model;
127
                getLista().setModel(modelo);
128
    }
129
130
    public void addSelectionListener(ListSelectorListener listener){
131
            getSelectionListeners().add(listener);
132
    }
133
134
    public void removeSelectionListener(ListSelectorListener listener){
135
            getSelectionListeners().remove(listener);
136
    }
137
138
        private void callIndexesRemoved(int[] indices){
139
                for (int i = 0; i < selectionListeners.size(); i++){
140
                        ((ListSelectorListener) selectionListeners.get(i)).indexesRemoved(indices);
141
                }
142
        }
143
144
        private void callIndexesSelected(int[] indices){
145
                for (int i = 0; i < selectionListeners.size(); i++){
146
                        ((ListSelectorListener) selectionListeners.get(i)).indexesSelected(indices);
147
                }
148
        }
149
150
        private void callNewElement(String name){
151
                for (int i = 0; i < selectionListeners.size(); i++){
152
                        ((ListSelectorListener) selectionListeners.get(i)).newElement(name);
153
                }
154
        }
155
156
    /**
157
     * This method initializes btnAceptar
158
     *
159
     * @return javax.swing.JButton
160
     */
161
    private javax.swing.JButton getBtnAceptar() {
162
        if (btnAceptar == null) {
163
            btnAceptar = new javax.swing.JButton();
164
            btnAceptar.setBounds(415, 27, 102, 26);
165 620 fjp
            btnAceptar.setText(PluginServices.getText(this,"Seleccionar"));
166 312 fernando
            btnAceptar.addActionListener(new java.awt.event.ActionListener() {
167
                    public void actionPerformed(java.awt.event.ActionEvent e) {
168
                            int[] indices = lista.getSelectedIndices();
169
170
                            if (indices.length != 0)
171
                                    callIndexesSelected(indices);
172
                    }
173
            });
174
        }
175
176
        return btnAceptar;
177
    }
178
179
        /**
180
         * @return
181
         */
182
        private ArrayList getSelectionListeners() {
183
                return selectionListeners;
184
        }
185
186
        /**
187
         * This method initializes btnEliminar
188
         *
189
         * @return javax.swing.JButton
190
         */
191
        private javax.swing.JButton getBtnEliminar() {
192
                if(btnEliminar == null) {
193
                        btnEliminar = new javax.swing.JButton();
194
                        btnEliminar.setBounds(415, 62, 102, 26);
195 620 fjp
                        btnEliminar.setText(PluginServices.getText(this,"Eliminar"));
196 312 fernando
                        btnEliminar.setPreferredSize(new java.awt.Dimension(102,26));
197
                        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
198
                                public void actionPerformed(java.awt.event.ActionEvent e) {
199
                                        int[] indices = lista.getSelectedIndices();
200
201
                                        if (indices.length != 0)
202
                                                callIndexesRemoved(indices);
203
                                }
204
                        });
205
                }
206
                return btnEliminar;
207
        }
208
        /**
209
         * This method initializes jPanel
210
         *
211
         * @return javax.swing.JPanel
212
         */
213
        private javax.swing.JPanel getJPanel() {
214
                if(jPanel == null) {
215
                        jPanel = new javax.swing.JPanel();
216
                        jPanel.setLayout(null);
217
                        jPanel.add(getTxtGuardar(), null);
218
                        jPanel.add(getJLabel(), null);
219
                        jPanel.add(getBtnGuardar(), null);
220
                        jPanel.setPreferredSize(new java.awt.Dimension(530,100));
221 620 fjp
                        jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"Guardar_el_zoom_actual"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
222 312 fernando
                }
223
                return jPanel;
224
        }
225
        /**
226
         * This method initializes jPanel1
227
         *
228
         * @return javax.swing.JPanel
229
         */
230
        private javax.swing.JPanel getJPanel1() {
231
                if(jPanel1 == null) {
232
                        jPanel1 = new javax.swing.JPanel();
233
                        jPanel1.setLayout(null);
234
                        jPanel1.add(getJScrollPane(), null);
235
                        jPanel1.add(getBtnAceptar(), null);
236
                        jPanel1.add(getBtnEliminar(), null);
237
                        jPanel1.setPreferredSize(new java.awt.Dimension(530,180));
238 620 fjp
                        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"Recuperar_y_eliminar_otros_zoom"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
239 312 fernando
                }
240
                return jPanel1;
241
        }
242
        /**
243
         * This method initializes jLabel
244
         *
245
         * @return javax.swing.JLabel
246
         */
247
        private javax.swing.JLabel getJLabel() {
248
                if(jLabel == null) {
249
                        jLabel = new javax.swing.JLabel();
250
                        jLabel.setBounds(7, 35, 178, 16);
251 620 fjp
                        jLabel.setText(PluginServices.getText(this,"Nombre_que_se_le_dara_al_zoom")+":");
252 312 fernando
                }
253
                return jLabel;
254
        }
255
        /**
256
         * This method initializes txtGuardar
257
         *
258
         * @return javax.swing.JTextField
259
         */
260
        private javax.swing.JTextField getTxtGuardar() {
261
                if(txtGuardar == null) {
262
                        txtGuardar = new javax.swing.JTextField();
263
                        txtGuardar.setBounds(187, 34, 333, 20);
264
                        txtGuardar.setPreferredSize(new java.awt.Dimension(330,20));
265
                }
266
                return txtGuardar;
267
        }
268
        /**
269
         * This method initializes btnGuardar
270
         *
271
         * @return javax.swing.JButton
272
         */
273
        private javax.swing.JButton getBtnGuardar() {
274
                if(btnGuardar == null) {
275
                        btnGuardar = new javax.swing.JButton();
276
                        btnGuardar.setSize(106, 26);
277 620 fjp
                        btnGuardar.setText(PluginServices.getText(this,"Guardar"));
278 312 fernando
                        btnGuardar.setLocation(415, 65);
279
                        btnGuardar.addActionListener(new java.awt.event.ActionListener() {
280
                                public void actionPerformed(java.awt.event.ActionEvent e) {
281
                                        String text = txtGuardar.getText().trim();
282
                                        if (text.length() > 0)
283
                                                callNewElement(text);
284
                                }
285
                        });
286
                }
287
                return btnGuardar;
288
        }
289
290
        /**
291
         * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
292
         */
293
        public ViewInfo getViewInfo() {
294
                if (m_viewinfo==null){
295 620 fjp
                    m_viewinfo=new ViewInfo(ViewInfo.MODELESSDIALOG);
296 312 fernando
                        m_viewinfo.setWidth(539);
297
                        m_viewinfo.setHeight(296);
298
                }
299
                return m_viewinfo;
300
        }
301
302
        /**
303
         * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
304
         */
305
        public void viewActivated() {
306
        }
307
}