root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / FPanelExtentSelector.java @ 6877
History | View | Annotate | Download (9.49 KB)
1 |
/* 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 |
package com.iver.cit.gvsig.gui; |
42 |
|
43 |
import java.awt.BorderLayout; |
44 |
import java.awt.FlowLayout; |
45 |
import java.awt.GridLayout; |
46 |
import java.util.ArrayList; |
47 |
|
48 |
import javax.swing.JPanel; |
49 |
import javax.swing.ListModel; |
50 |
|
51 |
import org.gvsig.gui.beans.swing.JButton; |
52 |
|
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.andami.ui.mdiManager.IWindow; |
55 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
56 |
|
57 |
|
58 |
/**
|
59 |
* DOCUMENT ME!
|
60 |
*
|
61 |
* @author Fernando Gonz?lez Cort?s
|
62 |
*/
|
63 |
public class FPanelExtentSelector extends JPanel implements IWindow { |
64 |
private javax.swing.JScrollPane jScrollPane = null; |
65 |
private javax.swing.JList lista = null; |
66 |
private JButton btnAceptar = null; |
67 |
private ListModel modelo = null; |
68 |
private ArrayList selectionListeners = new ArrayList(); |
69 |
private JButton btnEliminar = null; |
70 |
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 |
private JButton btnGuardar = null; |
75 |
private ViewInfo m_viewinfo = null; |
76 |
private JPanel jPanel2 = null; |
77 |
private JPanel jPanel3 = null; |
78 |
/**
|
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 |
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 |
} |
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 |
jScrollPane.setBounds(11, 26, 508, 150); |
108 |
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 |
modelo = model; |
137 |
getLista().setModel(modelo); |
138 |
} |
139 |
|
140 |
public void addSelectionListener(ListSelectorListener listener){ |
141 |
getSelectionListeners().add(listener); |
142 |
} |
143 |
|
144 |
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 |
* @return JButton
|
170 |
*/
|
171 |
private JButton getBtnAceptar() { |
172 |
if (btnAceptar == null) { |
173 |
btnAceptar = new JButton(); |
174 |
btnAceptar.setText(PluginServices.getText(this,"Seleccionar")); |
175 |
btnAceptar.addActionListener(new java.awt.event.ActionListener() {
|
176 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
177 |
int[] indices = lista.getSelectedIndices(); |
178 |
|
179 |
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 |
*
|
198 |
* @return JButton
|
199 |
*/
|
200 |
private JButton getBtnEliminar() { |
201 |
if(btnEliminar == null) { |
202 |
btnEliminar = new JButton(); |
203 |
btnEliminar.setText(PluginServices.getText(this,"Eliminar")); |
204 |
//btnEliminar.setPreferredSize(new java.awt.Dimension(102,26));
|
205 |
btnEliminar.addActionListener(new java.awt.event.ActionListener() {
|
206 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
207 |
int[] indices = lista.getSelectedIndices(); |
208 |
|
209 |
if (indices.length != 0) |
210 |
callIndexesRemoved(indices); |
211 |
} |
212 |
}); |
213 |
} |
214 |
return btnEliminar;
|
215 |
} |
216 |
/**
|
217 |
* This method initializes jPanel
|
218 |
*
|
219 |
* @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 |
|
226 |
jPanel.add(getJLabel(), null);
|
227 |
jPanel.add(getTxtGuardar(), null);
|
228 |
jPanel.setPreferredSize(new java.awt.Dimension(530,100)); |
229 |
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 |
jPanel.add(getJPanel3(), null);
|
231 |
} |
232 |
return jPanel;
|
233 |
} |
234 |
/**
|
235 |
* This method initializes jPanel1
|
236 |
*
|
237 |
* @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 |
jPanel1.setPreferredSize(new java.awt.Dimension(530,220)); |
245 |
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 |
jPanel1.add(getJPanel2(), null);
|
247 |
} |
248 |
return jPanel1;
|
249 |
} |
250 |
/**
|
251 |
* This method initializes jLabel
|
252 |
*
|
253 |
* @return javax.swing.JLabel
|
254 |
*/
|
255 |
private javax.swing.JLabel getJLabel() {
|
256 |
if(jLabel == null) { |
257 |
jLabel = new javax.swing.JLabel();
|
258 |
jLabel.setBounds(7, 35, 248, 16); |
259 |
jLabel.setText(PluginServices.getText(this,"Nombre_que_se_le_dara_al_zoom")+":"); |
260 |
} |
261 |
return jLabel;
|
262 |
} |
263 |
/**
|
264 |
* This method initializes txtGuardar
|
265 |
*
|
266 |
* @return javax.swing.JTextField
|
267 |
*/
|
268 |
private javax.swing.JTextField getTxtGuardar() {
|
269 |
if(txtGuardar == null) { |
270 |
txtGuardar = new javax.swing.JTextField();
|
271 |
txtGuardar.setBounds(250, 34, 269, 20); |
272 |
txtGuardar.setPreferredSize(new java.awt.Dimension(330,20)); |
273 |
} |
274 |
return txtGuardar;
|
275 |
} |
276 |
/**
|
277 |
* This method initializes btnGuardar
|
278 |
*
|
279 |
* @return JButton
|
280 |
*/
|
281 |
private JButton getBtnGuardar() { |
282 |
if(btnGuardar == null) { |
283 |
btnGuardar = new JButton(); |
284 |
btnGuardar.setText(PluginServices.getText(this,"Guardar")); |
285 |
btnGuardar.addActionListener(new java.awt.event.ActionListener() {
|
286 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
287 |
String text = txtGuardar.getText().trim();
|
288 |
if (text.length() > 0) |
289 |
callNewElement(text); |
290 |
} |
291 |
}); |
292 |
} |
293 |
return btnGuardar;
|
294 |
} |
295 |
|
296 |
/**
|
297 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getViewInfo()
|
298 |
*/
|
299 |
public ViewInfo getViewInfo() {
|
300 |
if (m_viewinfo==null){ |
301 |
m_viewinfo=new ViewInfo(ViewInfo.MODELESSDIALOG);
|
302 |
m_viewinfo.setWidth(this.getWidth()+8); |
303 |
m_viewinfo.setHeight(this. getHeight());
|
304 |
m_viewinfo.setTitle(PluginServices.getText(this, "Encuadre")); |
305 |
} |
306 |
return m_viewinfo;
|
307 |
} |
308 |
|
309 |
/**
|
310 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#viewActivated()
|
311 |
*/
|
312 |
public void viewActivated() { |
313 |
} |
314 |
|
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"
|