root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FPanelExtentSelector.java @ 6877
History | View | Annotate | Download (9.49 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 | 6133 | jaume | import java.awt.BorderLayout; |
44 | import java.awt.FlowLayout; |
||
45 | 6287 | jmvivo | import java.awt.GridLayout; |
46 | 312 | fernando | import java.util.ArrayList; |
47 | |||
48 | import javax.swing.JPanel; |
||
49 | import javax.swing.ListModel; |
||
50 | |||
51 | 6133 | jaume | import org.gvsig.gui.beans.swing.JButton; |
52 | |||
53 | 620 | fjp | import com.iver.andami.PluginServices; |
54 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
55 | 620 | fjp | import com.iver.andami.ui.mdiManager.ViewInfo; |
56 | 312 | fernando | |
57 | |||
58 | /**
|
||
59 | * DOCUMENT ME!
|
||
60 | *
|
||
61 | * @author Fernando Gonz?lez Cort?s
|
||
62 | */
|
||
63 | 6877 | cesar | public class FPanelExtentSelector extends JPanel implements IWindow { |
64 | 312 | fernando | private javax.swing.JScrollPane jScrollPane = null; |
65 | private javax.swing.JList lista = null; |
||
66 | 6133 | jaume | private JButton btnAceptar = null; |
67 | 312 | fernando | private ListModel modelo = null; |
68 | private ArrayList selectionListeners = new ArrayList(); |
||
69 | 6133 | jaume | private JButton btnEliminar = null; |
70 | 312 | fernando | private javax.swing.JPanel jPanel = null; |
71 | private javax.swing.JPanel jPanel1 = null; |
||
72 | private javax.swing.JLabel jLabel = null; |
||
73 | private javax.swing.JTextField txtGuardar = null; |
||
74 | 6133 | jaume | private JButton btnGuardar = null; |
75 | 312 | fernando | private ViewInfo m_viewinfo = null; |
76 | 6133 | jaume | private JPanel jPanel2 = null; |
77 | private JPanel jPanel3 = null; |
||
78 | 312 | fernando | /**
|
79 | * This is the default constructor
|
||
80 | */
|
||
81 | public FPanelExtentSelector() {
|
||
82 | super();
|
||
83 | initialize(); |
||
84 | } |
||
85 | |||
86 | /**
|
||
87 | * This method initializes this
|
||
88 | */
|
||
89 | private void initialize() { |
||
90 | 6133 | jaume | this.setLayout(new BorderLayout()); |
91 | this.setSize(new java.awt.Dimension(530,320)); |
||
92 | this.add(getJPanel(), java.awt.BorderLayout.NORTH);
|
||
93 | this.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
|
||
94 | |||
95 | |||
96 | 312 | fernando | } |
97 | |||
98 | /**
|
||
99 | * This method initializes jScrollPane
|
||
100 | *
|
||
101 | * @return javax.swing.JScrollPane
|
||
102 | */
|
||
103 | private javax.swing.JScrollPane getJScrollPane() {
|
||
104 | if (jScrollPane == null) { |
||
105 | jScrollPane = new javax.swing.JScrollPane();
|
||
106 | jScrollPane.setViewportView(getLista()); |
||
107 | 6133 | jaume | jScrollPane.setBounds(11, 26, 508, 150); |
108 | 312 | fernando | jScrollPane.setPreferredSize(new java.awt.Dimension(400,150)); |
109 | } |
||
110 | |||
111 | return jScrollPane;
|
||
112 | } |
||
113 | |||
114 | /**
|
||
115 | * This method initializes lista
|
||
116 | *
|
||
117 | * @return javax.swing.JList
|
||
118 | */
|
||
119 | private javax.swing.JList getLista() {
|
||
120 | if (lista == null) { |
||
121 | lista = new javax.swing.JList();
|
||
122 | } |
||
123 | |||
124 | return lista;
|
||
125 | } |
||
126 | |||
127 | /**
|
||
128 | * Asigna el el array que se va a representar. Se crea una
|
||
129 | * copia del modelo, de forma que modificaciones en el modelo
|
||
130 | * fuera de esta clase ya no afectan al modelo copiado
|
||
131 | *
|
||
132 | * @param model DOCUMENT ME!
|
||
133 | */
|
||
134 | public void setModel(ListModel model) { |
||
135 | //modelo de la lista
|
||
136 | 6133 | jaume | modelo = model; |
137 | 312 | fernando | getLista().setModel(modelo); |
138 | } |
||
139 | 6133 | jaume | |
140 | 312 | fernando | public void addSelectionListener(ListSelectorListener listener){ |
141 | getSelectionListeners().add(listener); |
||
142 | } |
||
143 | 6133 | jaume | |
144 | 312 | fernando | public void removeSelectionListener(ListSelectorListener listener){ |
145 | getSelectionListeners().remove(listener); |
||
146 | } |
||
147 | |||
148 | private void callIndexesRemoved(int[] indices){ |
||
149 | for (int i = 0; i < selectionListeners.size(); i++){ |
||
150 | ((ListSelectorListener) selectionListeners.get(i)).indexesRemoved(indices); |
||
151 | } |
||
152 | } |
||
153 | |||
154 | private void callIndexesSelected(int[] indices){ |
||
155 | for (int i = 0; i < selectionListeners.size(); i++){ |
||
156 | ((ListSelectorListener) selectionListeners.get(i)).indexesSelected(indices); |
||
157 | } |
||
158 | } |
||
159 | |||
160 | private void callNewElement(String name){ |
||
161 | for (int i = 0; i < selectionListeners.size(); i++){ |
||
162 | ((ListSelectorListener) selectionListeners.get(i)).newElement(name); |
||
163 | } |
||
164 | } |
||
165 | |||
166 | /**
|
||
167 | * This method initializes btnAceptar
|
||
168 | *
|
||
169 | 6133 | jaume | * @return JButton
|
170 | 312 | fernando | */
|
171 | 6133 | jaume | private JButton getBtnAceptar() { |
172 | 312 | fernando | if (btnAceptar == null) { |
173 | 6133 | jaume | btnAceptar = new JButton(); |
174 | 620 | fjp | btnAceptar.setText(PluginServices.getText(this,"Seleccionar")); |
175 | 6133 | jaume | btnAceptar.addActionListener(new java.awt.event.ActionListener() {
|
176 | 312 | fernando | public void actionPerformed(java.awt.event.ActionEvent e) { |
177 | int[] indices = lista.getSelectedIndices(); |
||
178 | 6133 | jaume | |
179 | 312 | fernando | if (indices.length != 0) |
180 | callIndexesSelected(indices); |
||
181 | } |
||
182 | }); |
||
183 | } |
||
184 | |||
185 | return btnAceptar;
|
||
186 | } |
||
187 | |||
188 | /**
|
||
189 | * @return
|
||
190 | */
|
||
191 | private ArrayList getSelectionListeners() { |
||
192 | return selectionListeners;
|
||
193 | } |
||
194 | |||
195 | /**
|
||
196 | * This method initializes btnEliminar
|
||
197 | 6133 | jaume | *
|
198 | * @return JButton
|
||
199 | 312 | fernando | */
|
200 | 6133 | jaume | private JButton getBtnEliminar() { |
201 | 312 | fernando | if(btnEliminar == null) { |
202 | 6133 | jaume | btnEliminar = new JButton(); |
203 | 620 | fjp | btnEliminar.setText(PluginServices.getText(this,"Eliminar")); |
204 | 6287 | jmvivo | //btnEliminar.setPreferredSize(new java.awt.Dimension(102,26));
|
205 | 6133 | jaume | btnEliminar.addActionListener(new java.awt.event.ActionListener() {
|
206 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
207 | 312 | fernando | int[] indices = lista.getSelectedIndices(); |
208 | 6133 | jaume | |
209 | 312 | fernando | if (indices.length != 0) |
210 | callIndexesRemoved(indices); |
||
211 | } |
||
212 | }); |
||
213 | } |
||
214 | return btnEliminar;
|
||
215 | } |
||
216 | /**
|
||
217 | * This method initializes jPanel
|
||
218 | 6133 | jaume | *
|
219 | 312 | fernando | * @return javax.swing.JPanel
|
220 | */
|
||
221 | private javax.swing.JPanel getJPanel() {
|
||
222 | if(jPanel == null) { |
||
223 | jPanel = new javax.swing.JPanel();
|
||
224 | jPanel.setLayout(null);
|
||
225 | 6287 | jmvivo | |
226 | jPanel.add(getJLabel(), null);
|
||
227 | 312 | fernando | jPanel.add(getTxtGuardar(), null);
|
228 | jPanel.setPreferredSize(new java.awt.Dimension(530,100)); |
||
229 | 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)); |
230 | 6133 | jaume | jPanel.add(getJPanel3(), null);
|
231 | 312 | fernando | } |
232 | return jPanel;
|
||
233 | } |
||
234 | /**
|
||
235 | * This method initializes jPanel1
|
||
236 | 6133 | jaume | *
|
237 | 312 | fernando | * @return javax.swing.JPanel
|
238 | */
|
||
239 | private javax.swing.JPanel getJPanel1() {
|
||
240 | if(jPanel1 == null) { |
||
241 | jPanel1 = new javax.swing.JPanel();
|
||
242 | jPanel1.setLayout(null);
|
||
243 | jPanel1.add(getJScrollPane(), null);
|
||
244 | 6133 | jaume | jPanel1.setPreferredSize(new java.awt.Dimension(530,220)); |
245 | 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)); |
246 | 6133 | jaume | jPanel1.add(getJPanel2(), null);
|
247 | 312 | fernando | } |
248 | return jPanel1;
|
||
249 | } |
||
250 | /**
|
||
251 | * This method initializes jLabel
|
||
252 | 6133 | jaume | *
|
253 | 312 | fernando | * @return javax.swing.JLabel
|
254 | */
|
||
255 | private javax.swing.JLabel getJLabel() {
|
||
256 | if(jLabel == null) { |
||
257 | jLabel = new javax.swing.JLabel();
|
||
258 | 6287 | jmvivo | jLabel.setBounds(7, 35, 248, 16); |
259 | 620 | fjp | jLabel.setText(PluginServices.getText(this,"Nombre_que_se_le_dara_al_zoom")+":"); |
260 | 312 | fernando | } |
261 | return jLabel;
|
||
262 | } |
||
263 | /**
|
||
264 | * This method initializes txtGuardar
|
||
265 | 6133 | jaume | *
|
266 | 312 | fernando | * @return javax.swing.JTextField
|
267 | */
|
||
268 | private javax.swing.JTextField getTxtGuardar() {
|
||
269 | if(txtGuardar == null) { |
||
270 | txtGuardar = new javax.swing.JTextField();
|
||
271 | 6287 | jmvivo | txtGuardar.setBounds(250, 34, 269, 20); |
272 | 312 | fernando | txtGuardar.setPreferredSize(new java.awt.Dimension(330,20)); |
273 | } |
||
274 | return txtGuardar;
|
||
275 | } |
||
276 | /**
|
||
277 | * This method initializes btnGuardar
|
||
278 | 6133 | jaume | *
|
279 | * @return JButton
|
||
280 | 312 | fernando | */
|
281 | 6133 | jaume | private JButton getBtnGuardar() { |
282 | 312 | fernando | if(btnGuardar == null) { |
283 | 6133 | jaume | btnGuardar = new JButton(); |
284 | 620 | fjp | btnGuardar.setText(PluginServices.getText(this,"Guardar")); |
285 | 6133 | jaume | btnGuardar.addActionListener(new java.awt.event.ActionListener() {
|
286 | 312 | fernando | public void actionPerformed(java.awt.event.ActionEvent e) { |
287 | String text = txtGuardar.getText().trim();
|
||
288 | if (text.length() > 0) |
||
289 | 6133 | jaume | callNewElement(text); |
290 | 312 | fernando | } |
291 | }); |
||
292 | } |
||
293 | return btnGuardar;
|
||
294 | } |
||
295 | |||
296 | /**
|
||
297 | 6877 | cesar | * @see com.iver.mdiApp.ui.MDIManager.IWindow#getViewInfo()
|
298 | 312 | fernando | */
|
299 | public ViewInfo getViewInfo() {
|
||
300 | if (m_viewinfo==null){ |
||
301 | 620 | fjp | m_viewinfo=new ViewInfo(ViewInfo.MODELESSDIALOG);
|
302 | 6133 | jaume | m_viewinfo.setWidth(this.getWidth()+8); |
303 | m_viewinfo.setHeight(this. getHeight());
|
||
304 | m_viewinfo.setTitle(PluginServices.getText(this, "Encuadre")); |
||
305 | 312 | fernando | } |
306 | return m_viewinfo;
|
||
307 | } |
||
308 | |||
309 | /**
|
||
310 | 6877 | cesar | * @see com.iver.mdiApp.ui.MDIManager.IWindow#viewActivated()
|
311 | 312 | fernando | */
|
312 | public void viewActivated() { |
||
313 | } |
||
314 | 6133 | jaume | |
315 | /**
|
||
316 | * This method initializes jPanel2
|
||
317 | *
|
||
318 | * @return javax.swing.JPanel
|
||
319 | */
|
||
320 | private JPanel getJPanel2() { |
||
321 | if (jPanel2 == null) { |
||
322 | jPanel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5)); |
||
323 | jPanel2.setBounds(new java.awt.Rectangle(11,180,508,33)); |
||
324 | jPanel2.add(getBtnAceptar(), null);
|
||
325 | jPanel2.add(getBtnEliminar(), null);
|
||
326 | } |
||
327 | return jPanel2;
|
||
328 | } |
||
329 | |||
330 | /**
|
||
331 | * This method initializes jPanel3
|
||
332 | *
|
||
333 | * @return javax.swing.JPanel
|
||
334 | */
|
||
335 | private JPanel getJPanel3() { |
||
336 | if (jPanel3 == null) { |
||
337 | jPanel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5)); |
||
338 | jPanel3.setBounds(new java.awt.Rectangle(8,59,511,33)); |
||
339 | jPanel3.add(getBtnGuardar(), null);
|
||
340 | } |
||
341 | return jPanel3;
|
||
342 | } |
||
343 | } // @jve:decl-index=0:visual-constraint="10,10" |