Revision 36475 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/gui/FPanelExtentSelector.java

View differences:

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

  
43 24
import java.awt.BorderLayout;
44 25
import java.awt.FlowLayout;
45 26
import java.util.ArrayList;
27
import java.util.List;
46 28

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

  
......
51 34
import org.gvsig.andami.ui.mdiManager.IWindow;
52 35
import org.gvsig.andami.ui.mdiManager.WindowInfo;
53 36
import org.gvsig.app.project.documents.view.ListSelectorListener;
54
import org.gvsig.gui.beans.swing.JButton;
37
import org.gvsig.tools.swing.api.ToolsSwingLocator;
55 38

  
56

  
57

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

  
46
    private static final long serialVersionUID = -8246729582621010542L;
64 47
    private javax.swing.JScrollPane jScrollPane = null;
65 48
    private javax.swing.JList lista = null;
66 49
    private JButton btnAceptar = null;
67 50
    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 WindowInfo m_viewinfo = null;
76
	private JPanel jPanel2 = null;
77
	private JPanel jPanel3 = 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

  
78 63
    /**
79 64
     * This is the default constructor
80 65
     */
......
88 73
     */
89 74
    private void initialize() {
90 75
        this.setLayout(new BorderLayout());
91
        this.setSize(new java.awt.Dimension(530,320));
76
        this.setSize(new java.awt.Dimension(530, 320));
92 77
        this.add(getJPanel(), java.awt.BorderLayout.NORTH);
93 78
        this.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
94 79

  
95

  
96 80
    }
97 81

  
98 82
    /**
99 83
     * This method initializes jScrollPane
100
     *
84
     * 
101 85
     * @return javax.swing.JScrollPane
102 86
     */
103 87
    private javax.swing.JScrollPane getJScrollPane() {
......
105 89
            jScrollPane = new javax.swing.JScrollPane();
106 90
            jScrollPane.setViewportView(getLista());
107 91
            jScrollPane.setBounds(11, 26, 508, 150);
108
            jScrollPane.setPreferredSize(new java.awt.Dimension(400,150));
92
            jScrollPane.setPreferredSize(new java.awt.Dimension(400, 150));
109 93
        }
110 94

  
111 95
        return jScrollPane;
......
113 97

  
114 98
    /**
115 99
     * This method initializes lista
116
     *
100
     * 
117 101
     * @return javax.swing.JList
118 102
     */
119 103
    private javax.swing.JList getLista() {
......
128 112
     * Asigna el el array que se va a representar. Se crea una
129 113
     * copia del modelo, de forma que modificaciones en el modelo
130 114
     * fuera de esta clase ya no afectan al modelo copiado
131
     *
132
     * @param model DOCUMENT ME!
115
     * 
116
     * @param model
117
     *            DOCUMENT ME!
133 118
     */
134 119
    public void setModel(ListModel model) {
135
    	//modelo de la lista
120
        // modelo de la lista
136 121
        modelo = model;
137
		getLista().setModel(modelo);
122
        getLista().setModel(modelo);
138 123
    }
139 124

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

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

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

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

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

  
166 151
    /**
167 152
     * This method initializes btnAceptar
168
     *
153
     * 
169 154
     * @return JButton
170 155
     */
171 156
    private JButton getBtnAceptar() {
172 157
        if (btnAceptar == null) {
173
            btnAceptar = new JButton();
174
            btnAceptar.setText(PluginServices.getText(this,"Seleccionar"));
158
            btnAceptar =
159
                ToolsSwingLocator.getUsabilitySwingManager().createJButton();
160
            btnAceptar.setText(PluginServices.getText(this, "Seleccionar"));
175 161
            btnAceptar.addActionListener(new java.awt.event.ActionListener() {
176
            	public void actionPerformed(java.awt.event.ActionEvent e) {
177
            		int[] indices = lista.getSelectedIndices();
178 162

  
179
            		if (indices.length != 0) {
180
						callIndexesSelected(indices);
181
					}
182
            	}
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
                }
183 170
            });
184 171
        }
185 172

  
186 173
        return btnAceptar;
187 174
    }
188 175

  
189
	/**
190
	 * @return
191
	 */
192
	private ArrayList getSelectionListeners() {
193
		return selectionListeners;
194
	}
176
    /**
177
     * @return
178
     */
179
    private List<ListSelectorListener> getSelectionListeners() {
180
        return selectionListeners;
181
    }
195 182

  
196
	/**
197
	 * This method initializes btnEliminar
198
	 *
199
	 * @return JButton
200
	 */
201
	private JButton getBtnEliminar() {
202
		if(btnEliminar == null) {
203
			btnEliminar = new JButton();
204
			btnEliminar.setText(PluginServices.getText(this,"Eliminar"));
205
			//btnEliminar.setPreferredSize(new java.awt.Dimension(102,26));
206
			btnEliminar.addActionListener(new java.awt.event.ActionListener() {
207
				public void actionPerformed(java.awt.event.ActionEvent e) {
208
					int[] indices = lista.getSelectedIndices();
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() {
209 194

  
210
					if (indices.length != 0) {
211
						callIndexesRemoved(indices);
212
					}
213
				}
214
			});
215
		}
216
		return btnEliminar;
217
	}
218
	/**
219
	 * This method initializes jPanel
220
	 *
221
	 * @return javax.swing.JPanel
222
	 */
223
	private javax.swing.JPanel getJPanel() {
224
		if(jPanel == null) {
225
			jPanel = new javax.swing.JPanel();
226
			jPanel.setLayout(null);
195
                public void actionPerformed(java.awt.event.ActionEvent e) {
196
                    int[] indices = lista.getSelectedIndices();
227 197

  
228
			jPanel.add(getJLabel(), null);
229
			jPanel.add(getTxtGuardar(), null);
230
			jPanel.setPreferredSize(new java.awt.Dimension(530,100));
231
			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));
232
			jPanel.add(getJPanel3(), null);
233
		}
234
		return jPanel;
235
	}
236
	/**
237
	 * This method initializes jPanel1
238
	 *
239
	 * @return javax.swing.JPanel
240
	 */
241
	private javax.swing.JPanel getJPanel1() {
242
		if(jPanel1 == null) {
243
			jPanel1 = new javax.swing.JPanel();
244
			jPanel1.setLayout(null);
245
			jPanel1.add(getJScrollPane(), null);
246
			jPanel1.setPreferredSize(new java.awt.Dimension(530,220));
247
			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));
248
			jPanel1.add(getJPanel2(), null);
249
		}
250
		return jPanel1;
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,"Nombre_que_se_le_dara_al_zoom")+":");
262
		}
263
		return jLabel;
264
	}
265
	/**
266
	 * This method initializes txtGuardar
267
	 *
268
	 * @return javax.swing.JTextField
269
	 */
270
	private javax.swing.JTextField getTxtGuardar() {
271
		if(txtGuardar == null) {
272
			txtGuardar = new javax.swing.JTextField();
273
			txtGuardar.setBounds(250, 34, 269, 20);
274
			txtGuardar.setPreferredSize(new java.awt.Dimension(330,20));
275
		}
276
		return txtGuardar;
277
	}
278
	/**
279
	 * This method initializes btnGuardar
280
	 *
281
	 * @return JButton
282
	 */
283
	private JButton getBtnGuardar() {
284
		if(btnGuardar == null) {
285
			btnGuardar = new JButton();
286
			btnGuardar.setText(PluginServices.getText(this,"Guardar"));
287
			btnGuardar.addActionListener(new java.awt.event.ActionListener() {
288
				public void actionPerformed(java.awt.event.ActionEvent e) {
289
					String text = txtGuardar.getText().trim();
290
					if (text.length() > 0) {
291
						callNewElement(text);
292
					}
293
				}
294
			});
295
		}
296
		return btnGuardar;
297
	}
198
                    if (indices.length != 0) {
199
                        callIndexesRemoved(indices);
200
                    }
201
                }
202
            });
203
        }
204
        return btnEliminar;
205
    }
298 206

  
299
	/**
300
	 * @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
301
	 */
302
	public WindowInfo getWindowInfo() {
303
		if (m_viewinfo==null){
304
    		m_viewinfo=new WindowInfo(WindowInfo.MODELESSDIALOG);
305
			m_viewinfo.setWidth(this.getWidth()+8);
306
			m_viewinfo.setHeight(this. getHeight());
307
			m_viewinfo.setTitle(PluginServices.getText(this, "Encuadre"));
308
		}
309
		return m_viewinfo;
310
	}
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);
311 216

  
312
	/**
313
	 * @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
314
	 */
315
	public void viewActivated() {
316
	}
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
    }
317 228

  
318
	/**
319
	 * This method initializes jPanel2
320
	 *
321
	 * @return javax.swing.JPanel
322
	 */
323
	private JPanel getJPanel2() {
324
		if (jPanel2 == null) {
325
			jPanel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
326
			jPanel2.setBounds(new java.awt.Rectangle(11,180,508,33));
327
			jPanel2.add(getBtnAceptar(), null);
328
			jPanel2.add(getBtnEliminar(), null);
329
		}
330
		return jPanel2;
331
	}
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
    }
332 251

  
333
	/**
334
	 * This method initializes jPanel3
335
	 *
336
	 * @return javax.swing.JPanel
337
	 */
338
	private JPanel getJPanel3() {
339
		if (jPanel3 == null) {
340
			jPanel3 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 5));
341
			jPanel3.setBounds(new java.awt.Rectangle(8,59,511,33));
342
			jPanel3.add(getBtnGuardar(), null);
343
		}
344
		return jPanel3;
345
	}
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
    }
346 266

  
347
	public Object getWindowProfile() {
348
		return WindowInfo.TOOL_PROFILE;
349
	}
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
    }
350 280

  
351
}  //  @jve:decl-index=0:visual-constraint="10,10"
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"

Also available in: Unified diff