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