Revision 10948
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/buttonspanel/ButtonsPanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.gui.beans.buttonspanel; |
|
20 |
|
|
21 |
import java.awt.FlowLayout; |
|
22 |
import java.awt.event.ActionEvent; |
|
23 |
import java.awt.event.ActionListener; |
|
24 |
import java.util.ArrayList; |
|
25 |
import java.util.Iterator; |
|
26 |
|
|
27 |
import javax.swing.JButton; |
|
28 |
import javax.swing.JPanel; |
|
29 |
|
|
30 |
import org.gvsig.gui.beans.messages.Messages; |
|
31 |
/** |
|
32 |
* <code>ButtonsPanel</code> ofrece un widget con un conjunto de botones |
|
33 |
* preestablecidos, aunque tambi?n se pueden a?adir botones con el m?todo |
|
34 |
* {@link #addButton(String, int)} |
|
35 |
* |
|
36 |
* @version 15/03/2007 |
|
37 |
* @author Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
38 |
*/ |
|
39 |
public class ButtonsPanel extends JPanel { |
|
40 |
private static final long serialVersionUID = -7264041442217894577L; |
|
41 |
private ArrayList buttonsList = new ArrayList(); |
|
42 |
static private int eventId = Integer.MIN_VALUE; |
|
43 |
private ArrayList actionCommandListeners = new ArrayList(); |
|
44 |
|
|
45 |
public static final int BUTTON_ACCEPT = 1; |
|
46 |
public static final int BUTTON_CANCEL = 2; |
|
47 |
public static final int BUTTON_APPLY = 3; |
|
48 |
public static final int BUTTON_YES = 4; |
|
49 |
public static final int BUTTON_NO = 5; |
|
50 |
public static final int BUTTON_CLOSE = 6; |
|
51 |
public static final int BUTTON_EXIT = 7; |
|
52 |
public static final int BUTTON_SEEDETAILS = 8; |
|
53 |
public static final int BUTTON_HIDEDETAILS = 9; |
|
54 |
|
|
55 |
public static final int BUTTONS_ACCEPT = 1; |
|
56 |
public static final int BUTTONS_ACCEPTCANCEL = 2; |
|
57 |
public static final int BUTTONS_ACCEPTCANCELAPPLY = 3; |
|
58 |
public static final int BUTTONS_CANCEL = 4; |
|
59 |
public static final int BUTTONS_YESNO = 5; |
|
60 |
public static final int BUTTONS_CLOSE = 6; |
|
61 |
public static final int BUTTONS_EXIT = 7; |
|
62 |
public static final int BUTTONS_NONE = 8; |
|
63 |
|
|
64 |
/** |
|
65 |
* Crea un ButtonsPanel con un Layout por defecto. |
|
66 |
*/ |
|
67 |
public ButtonsPanel() { |
|
68 |
setLayout(new java.awt.FlowLayout(FlowLayout.RIGHT)); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* Crea un ButtonsPanel con un Layout por defecto. |
|
73 |
* |
|
74 |
* @param items Que botones vamos a usar en la creaci?n. |
|
75 |
*/ |
|
76 |
public ButtonsPanel(int items) { |
|
77 |
setLayout(new java.awt.FlowLayout(FlowLayout.RIGHT)); |
|
78 |
switch (items) { |
|
79 |
case BUTTONS_ACCEPT: |
|
80 |
addAccept(); |
|
81 |
break; |
|
82 |
case BUTTONS_ACCEPTCANCEL: |
|
83 |
addAccept(); |
|
84 |
addCancel(); |
|
85 |
break; |
|
86 |
case BUTTONS_ACCEPTCANCELAPPLY: |
|
87 |
addAccept(); |
|
88 |
addCancel(); |
|
89 |
addApply(); |
|
90 |
break; |
|
91 |
case BUTTONS_CANCEL: |
|
92 |
addCancel(); |
|
93 |
break; |
|
94 |
case BUTTONS_YESNO: |
|
95 |
addYes(); |
|
96 |
addNo(); |
|
97 |
break; |
|
98 |
case BUTTONS_CLOSE: |
|
99 |
addClose(); |
|
100 |
break; |
|
101 |
case BUTTONS_EXIT: |
|
102 |
addExit(); |
|
103 |
break; |
|
104 |
case BUTTONS_NONE: |
|
105 |
break; |
|
106 |
} |
|
107 |
} |
|
108 |
|
|
109 |
public void addActionListener(ActionListener listener) { |
|
110 |
if (!actionCommandListeners.contains(listener)) |
|
111 |
actionCommandListeners.add(listener); |
|
112 |
} |
|
113 |
|
|
114 |
public void removeActionListener(ActionListener listener) { |
|
115 |
actionCommandListeners.remove(listener); |
|
116 |
} |
|
117 |
|
|
118 |
private void callActionCommandListeners(String buttonID) { |
|
119 |
Iterator acIterator = actionCommandListeners.iterator(); |
|
120 |
while (acIterator.hasNext()) { |
|
121 |
ActionListener listener = (ActionListener) acIterator.next(); |
|
122 |
listener.actionPerformed(new ActionEvent(this, eventId, buttonID)); |
|
123 |
} |
|
124 |
eventId++; |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* A?adir el boton Aceptar. |
|
129 |
*/ |
|
130 |
public void addAccept() { |
|
131 |
addButton(Messages.getText("aceptar"), BUTTON_ACCEPT); |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* A?adir el boton Cancelar. |
|
136 |
*/ |
|
137 |
public void addCancel() { |
|
138 |
addButton(Messages.getText("cancelar"), BUTTON_CANCEL); |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* A?adir el boton S?. |
|
143 |
*/ |
|
144 |
public void addYes() { |
|
145 |
addButton(Messages.getText("si"), BUTTON_YES); |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* A?adir el boton No. |
|
150 |
*/ |
|
151 |
public void addNo() { |
|
152 |
addButton(Messages.getText("no"), BUTTON_NO); |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* A?adir el boton Aplicar. |
|
157 |
*/ |
|
158 |
public void addApply() { |
|
159 |
addButton(Messages.getText("aplicar"), BUTTON_APPLY); |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* A?adir el boton Cerrar. |
|
164 |
*/ |
|
165 |
public void addClose() { |
|
166 |
addButton(Messages.getText("cerrar"), BUTTON_CLOSE); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* A?adir el boton Salir. |
|
171 |
*/ |
|
172 |
public void addExit() { |
|
173 |
addButton(Messages.getText("salir"), BUTTON_EXIT); |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* A?adir el boton Ver detalles. |
|
178 |
*/ |
|
179 |
public void addSeeDetails() { |
|
180 |
addButton(Messages.getText("verdetalles"), BUTTON_SEEDETAILS); |
|
181 |
} |
|
182 |
|
|
183 |
/** |
|
184 |
* A?adir el boton Ocultar detalles. |
|
185 |
*/ |
|
186 |
public void addHideDetails() { |
|
187 |
addButton(Messages.getText("ocultardetalles"), BUTTON_HIDEDETAILS); |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* A?adimos un bot?n definido por el usuario. |
|
192 |
* |
|
193 |
* @param text Texto que contendr? el bot?n |
|
194 |
* @param id Entero para identificar los eventos del bot?n |
|
195 |
*/ |
|
196 |
public void addButton(String text, int id) { |
|
197 |
JButton button = new JButton(); |
|
198 |
buttonsList.add(button); |
|
199 |
button.setText(text); |
|
200 |
button.setActionCommand(id + ""); |
|
201 |
button.addActionListener(new ActionListener() { |
|
202 |
public void actionPerformed(ActionEvent e) { |
|
203 |
callActionCommandListeners(e.getActionCommand()); |
|
204 |
} |
|
205 |
}); |
|
206 |
|
|
207 |
add(button); |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* Obtener un bot?n por su Entero |
|
212 |
* @param id N?mero del disparador del bot?n |
|
213 |
* @return El bot?n especificado o <code>null</code> si no se encontr? el bot?n. |
|
214 |
*/ |
|
215 |
public JButton getButton(int id) { |
|
216 |
Iterator acIterator = buttonsList.iterator(); |
|
217 |
while (acIterator.hasNext()) { |
|
218 |
JButton button = (JButton) acIterator.next(); |
|
219 |
if (button.getActionCommand().compareTo(id + "") == 0) |
|
220 |
return button; |
|
221 |
} |
|
222 |
return null; |
|
223 |
} |
|
224 |
} |
|
0 | 225 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/coorddataInput/CoordDataInputContainer.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 |
package org.gvsig.gui.beans.coorddataInput; |
|
20 |
|
|
21 |
import java.awt.FlowLayout; |
|
22 |
import java.awt.GridBagConstraints; |
|
23 |
import java.awt.GridBagLayout; |
|
24 |
|
|
25 |
import javax.swing.JLabel; |
|
26 |
import javax.swing.JPanel; |
|
27 |
|
|
28 |
import org.gvsig.gui.beans.BaseComponent; |
|
29 |
import org.gvsig.gui.beans.dataInput.DataInputContainer; |
|
30 |
|
|
31 |
public class CoordDataInputContainer extends BaseComponent{ |
|
32 |
private static final long serialVersionUID = 3336324382874763427L; |
|
33 |
private int MARGIN = 12; |
|
34 |
private int wComp = 350, hComp = 80; |
|
35 |
private int hPanel = 24; |
|
36 |
private int wLabels = 60, hLabels = 22; |
|
37 |
private int wData = 152, hData = 24; |
|
38 |
|
|
39 |
private JPanel pCoord = null; |
|
40 |
private JPanel pData1 = null; |
|
41 |
private JPanel pData2 = null; |
|
42 |
private JLabel lTitulo1 = null; |
|
43 |
private JLabel lTitulo2 = null; |
|
44 |
private DataInputContainer pDataInput11 = null; |
|
45 |
private DataInputContainer pDataInput12 = null; |
|
46 |
private DataInputContainer pDataInput21 = null; |
|
47 |
private DataInputContainer pDataInput22 = null; |
|
48 |
|
|
49 |
private String tituloPanel = "Title"; |
|
50 |
|
|
51 |
/** |
|
52 |
* This is the default constructor |
|
53 |
*/ |
|
54 |
public CoordDataInputContainer(int w, int h) { |
|
55 |
super(); |
|
56 |
this.wComp = w; |
|
57 |
setComponentSize(wComp, hComp); |
|
58 |
initialize(); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* This method initializes this |
|
63 |
* |
|
64 |
* @return void |
|
65 |
*/ |
|
66 |
private void initialize() { |
|
67 |
FlowLayout flowLayout = new FlowLayout(); |
|
68 |
flowLayout.setHgap(0); |
|
69 |
flowLayout.setVgap(0); |
|
70 |
this.setLayout(flowLayout); |
|
71 |
this.setPreferredSize(new java.awt.Dimension(wComp, hComp)); |
|
72 |
this.add(getPCoord(), null); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* This method initializes jPanel |
|
77 |
* |
|
78 |
* @return javax.swing.JPanel |
|
79 |
*/ |
|
80 |
private JPanel getPCoord() { |
|
81 |
if (pCoord == null) { |
|
82 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
|
83 |
gridBagConstraints2.gridx = 0; |
|
84 |
gridBagConstraints2.gridy = 1; |
|
85 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
86 |
gridBagConstraints.gridx = 0; |
|
87 |
gridBagConstraints.gridy = 0; |
|
88 |
pCoord = new JPanel(); |
|
89 |
pCoord.setLayout(new GridBagLayout()); |
|
90 |
pCoord.setBorder(javax.swing.BorderFactory.createTitledBorder(null, tituloPanel, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null)); |
|
91 |
pCoord.add(getPData1(), gridBagConstraints); |
|
92 |
pCoord.add(getPData2(), gridBagConstraints2); |
|
93 |
} |
|
94 |
return pCoord; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* This method initializes jPanel |
|
99 |
* |
|
100 |
* @return javax.swing.JPanel |
|
101 |
*/ |
|
102 |
private JPanel getPData1() { |
|
103 |
if (pData1 == null) { |
|
104 |
FlowLayout flowLayout1 = new FlowLayout(); |
|
105 |
flowLayout1.setHgap(0); |
|
106 |
flowLayout1.setAlignment(java.awt.FlowLayout.LEFT); |
|
107 |
flowLayout1.setVgap(0); |
|
108 |
pData1 = new JPanel(); |
|
109 |
pData1.setLayout(flowLayout1); |
|
110 |
pData1.add(getLTitulo1(), null); |
|
111 |
pData1.add(getPDataInput11(), null); |
|
112 |
pData1.add(getPDataInput12(), null); |
|
113 |
//pData1.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); |
|
114 |
} |
|
115 |
return pData1; |
|
116 |
} |
|
117 |
|
|
118 |
private JLabel getLTitulo1(){ |
|
119 |
if (lTitulo1 == null){ |
|
120 |
lTitulo1 = new JLabel(); |
|
121 |
lTitulo1.setText("JLabel"); |
|
122 |
} |
|
123 |
return lTitulo1; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* This method initializes jPanel1 |
|
128 |
* |
|
129 |
* @return javax.swing.JPanel |
|
130 |
*/ |
|
131 |
private JPanel getPData2() { |
|
132 |
if (pData2 == null) { |
|
133 |
FlowLayout flowLayout2 = new FlowLayout(); |
|
134 |
flowLayout2.setHgap(0); |
|
135 |
flowLayout2.setAlignment(java.awt.FlowLayout.LEFT); |
|
136 |
flowLayout2.setVgap(0); |
|
137 |
pData2 = new JPanel(); |
|
138 |
pData2.setLayout(flowLayout2); |
|
139 |
pData2.add(getLTitulo2(), null); |
|
140 |
pData2.add(getPDataInput21(), null); |
|
141 |
pData2.add(getPDataInput22(), null); |
|
142 |
//pData2.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1)); |
|
143 |
} |
|
144 |
return pData2; |
|
145 |
} |
|
146 |
|
|
147 |
private JLabel getLTitulo2(){ |
|
148 |
if (lTitulo2 == null){ |
|
149 |
lTitulo2 = new JLabel(); |
|
150 |
lTitulo2.setText("JLabel"); |
|
151 |
} |
|
152 |
return lTitulo2; |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* This method initializes jPanel |
|
157 |
* |
|
158 |
* @return javax.swing.JPanel |
|
159 |
*/ |
|
160 |
public DataInputContainer getPDataInput11() { |
|
161 |
if (pDataInput11 == null) { |
|
162 |
pDataInput11 = new DataInputContainer(0); |
|
163 |
} |
|
164 |
return pDataInput11; |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* This method initializes jPanel1 |
|
169 |
* |
|
170 |
* @return javax.swing.JPanel |
|
171 |
*/ |
|
172 |
public DataInputContainer getPDataInput12() { |
|
173 |
if (pDataInput12 == null) { |
|
174 |
pDataInput12 = new DataInputContainer(0); |
|
175 |
} |
|
176 |
return pDataInput12; |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* This method initializes jPanel2 |
|
181 |
* |
|
182 |
* @return javax.swing.JPanel |
|
183 |
*/ |
|
184 |
public DataInputContainer getPDataInput21() { |
|
185 |
if (pDataInput21 == null) { |
|
186 |
pDataInput21 = new DataInputContainer(0); |
|
187 |
} |
|
188 |
return pDataInput21; |
|
189 |
} |
|
190 |
|
|
191 |
/** |
|
192 |
* This method initializes jPanel3 |
|
193 |
* |
|
194 |
* @return javax.swing.JPanel |
|
195 |
*/ |
|
196 |
public DataInputContainer getPDataInput22() { |
|
197 |
if (pDataInput22 == null) { |
|
198 |
pDataInput22 = new DataInputContainer(0); |
|
199 |
} |
|
200 |
return pDataInput22; |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* M?todo para introducir los campos del componente. Por orden de |
|
205 |
* arriba a abajo se introducen las cadenas que tienen que ir en el panel. |
|
206 |
* @param tPanel |
|
207 |
* @param titulo1 |
|
208 |
* @param celda11 |
|
209 |
* @param celda12 |
|
210 |
* @param titulo2 |
|
211 |
* @param celda21 |
|
212 |
* @param celda22 |
|
213 |
*/ |
|
214 |
public void setParameters(String tPanel, String titulo1, String celda11, String celda12, String titulo2, String celda21, String celda22){ |
|
215 |
this.tituloPanel = tPanel; |
|
216 |
this.lTitulo1.setText(titulo1); |
|
217 |
this.pDataInput11.setLabelText(celda11); |
|
218 |
this.pDataInput12.setLabelText(celda12); |
|
219 |
this.lTitulo2.setText(titulo2); |
|
220 |
this.pDataInput21.setLabelText(celda21); |
|
221 |
this.pDataInput22.setLabelText(celda22); |
|
222 |
pCoord.setBorder(javax.swing.BorderFactory.createTitledBorder(null, tituloPanel, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.PLAIN, 10), null)); |
|
223 |
|
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Modifica el tama?o del componente. |
|
228 |
* @param w |
|
229 |
* @param h |
|
230 |
*/ |
|
231 |
public void setComponentSize(int w, int h){ |
|
232 |
wComp = w; |
|
233 |
this.getPCoord().setPreferredSize(new java.awt.Dimension(wComp, hComp)); |
|
234 |
this.getLTitulo1().setPreferredSize(new java.awt.Dimension(wLabels,hLabels)); |
|
235 |
this.getLTitulo2().setPreferredSize(new java.awt.Dimension(wLabels,hLabels)); |
|
236 |
this.getPData1().setPreferredSize(new java.awt.Dimension(wComp - MARGIN, hPanel)); |
|
237 |
this.getPData2().setPreferredSize(new java.awt.Dimension(wComp - MARGIN, hPanel)); |
|
238 |
|
|
239 |
wData = (int)Math.floor((wComp - wLabels - 10) >> 1); |
|
240 |
int MARG = 2; |
|
241 |
this.getPDataInput11().setPreferredSize(new java.awt.Dimension(wData,hData)); |
|
242 |
this.pDataInput11.setComponentSize(wData - MARG, hData - MARG); |
|
243 |
this.getPDataInput12().setPreferredSize(new java.awt.Dimension(wData,hData)); |
|
244 |
this.pDataInput12.setComponentSize(wData - MARG, hData - MARG); |
|
245 |
this.getPDataInput21().setPreferredSize(new java.awt.Dimension(wData,hData)); |
|
246 |
this.pDataInput21.setComponentSize(wData - MARG, hData - MARG); |
|
247 |
this.getPDataInput22().setPreferredSize(new java.awt.Dimension(wData,hData)); |
|
248 |
this.pDataInput22.setComponentSize(wData - MARG, hData - MARG); |
|
249 |
} |
|
250 |
|
|
251 |
/** |
|
252 |
* Indica si los campos de texto admiten valores |
|
253 |
* decimales o no. |
|
254 |
* @param dec |
|
255 |
*/ |
|
256 |
public void setDecimalValues(boolean dec){ |
|
257 |
this.pDataInput11.setDecimal(dec); |
|
258 |
this.pDataInput12.setDecimal(dec); |
|
259 |
this.pDataInput21.setDecimal(dec); |
|
260 |
this.pDataInput22.setDecimal(dec); |
|
261 |
} |
|
262 |
|
|
263 |
|
|
264 |
/** |
|
265 |
* Indica si los campos de texto admiten cadenas de |
|
266 |
* de caracteres. |
|
267 |
* @param car |
|
268 |
*/ |
|
269 |
public void setCaracterValues(boolean car){ |
|
270 |
this.pDataInput11.setCaracter(car); |
|
271 |
this.pDataInput12.setCaracter(car); |
|
272 |
this.pDataInput21.setCaracter(car); |
|
273 |
this.pDataInput22.setCaracter(car); |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
/** |
|
278 |
* Devuelve los valores del panel por orden de izquierda a derecha |
|
279 |
* y de arriba a bajo. |
|
280 |
* @return |
|
281 |
*/ |
|
282 |
public String[] getValues(){ |
|
283 |
String[] values = {this.pDataInput11.getValue(), |
|
284 |
this.pDataInput12.getValue(), |
|
285 |
this.pDataInput21.getValue(), |
|
286 |
this.pDataInput22.getValue() |
|
287 |
}; |
|
288 |
return values; |
|
289 |
} |
|
290 |
|
|
291 |
/** |
|
292 |
* Asigna los valores del panel por orden de izquierda a derecha |
|
293 |
* y de arriba a bajo. |
|
294 |
* @return |
|
295 |
*/ |
|
296 |
public void setValues(String[] values){ |
|
297 |
this.pDataInput11.setValue(values[0]); |
|
298 |
this.pDataInput12.setValue(values[1]); |
|
299 |
this.pDataInput21.setValue(values[2]); |
|
300 |
this.pDataInput22.setValue(values[3]); |
|
301 |
} |
|
302 |
} |
|
0 | 303 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/defaultbuttonspanel/DefaultButtonsPanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.gui.beans.defaultbuttonspanel; |
|
20 |
|
|
21 |
import java.awt.Component; |
|
22 |
import java.awt.LayoutManager; |
|
23 |
|
|
24 |
import javax.swing.JPanel; |
|
25 |
|
|
26 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
27 |
/** |
|
28 |
* <code>DialogPanel</code> es un Panel que hereda de <code>JPanel</code> con |
|
29 |
* el a?adido de poder definir una botonera por defecto. |
|
30 |
* |
|
31 |
* @version 15/03/2007 |
|
32 |
* @author Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
33 |
*/ |
|
34 |
public class DefaultButtonsPanel extends JPanel { |
|
35 |
private static final long serialVersionUID = 1519536113682350563L; |
|
36 |
ButtonsPanel bp = null; |
|
37 |
JPanel content = null; |
|
38 |
|
|
39 |
/** |
|
40 |
* Crea el <code>DialogPanel</code> con los botones por defecto. |
|
41 |
*/ |
|
42 |
public DefaultButtonsPanel() { |
|
43 |
super.setLayout(new java.awt.BorderLayout(5, 5)); |
|
44 |
getButtonsPanel().addAccept(); |
|
45 |
getButtonsPanel().addCancel(); |
|
46 |
getButtonsPanel().addApply(); |
|
47 |
super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH); |
|
48 |
super.add(getContent(), java.awt.BorderLayout.CENTER); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Crea el <code>DialogPanel</code> con los botones que definamos de la clase |
|
53 |
* <code>ButtonsPanel</code> |
|
54 |
* |
|
55 |
* @param buttons Constante para definir que botones se crear?n |
|
56 |
*/ |
|
57 |
public DefaultButtonsPanel(int buttons) { |
|
58 |
super.setLayout(new java.awt.BorderLayout(5, 5)); |
|
59 |
bp = new ButtonsPanel(buttons); |
|
60 |
super.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH); |
|
61 |
super.add(getContent(), java.awt.BorderLayout.CENTER); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>. |
|
66 |
* En caso de no estar creado, lo crear?. |
|
67 |
* |
|
68 |
* @return El componente bp |
|
69 |
*/ |
|
70 |
public ButtonsPanel getButtonsPanel() { |
|
71 |
if (bp == null) |
|
72 |
bp = new ButtonsPanel(); |
|
73 |
return bp; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Obtener el contenido del <code>DialogPanel</code>. En caso de no estar creado, |
|
78 |
* lo crear?. |
|
79 |
* |
|
80 |
* @return El componente content |
|
81 |
*/ |
|
82 |
public JPanel getContent() { |
|
83 |
if (content == null) |
|
84 |
content = new JPanel(); |
|
85 |
return content; |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see java.awt.Container#getLayout() |
|
91 |
*/ |
|
92 |
public LayoutManager getLayout() { |
|
93 |
return getContent().getLayout(); |
|
94 |
} |
|
95 |
|
|
96 |
/* |
|
97 |
* (non-Javadoc) |
|
98 |
* @see java.awt.Container#setLayout(java.awt.LayoutManager) |
|
99 |
*/ |
|
100 |
public void setLayout(LayoutManager mgr) { |
|
101 |
getContent().setLayout(mgr); |
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* @see java.awt.Container#add(java.awt.Component) |
|
107 |
*/ |
|
108 |
public Component add(Component comp) { |
|
109 |
return getContent().add(comp); |
|
110 |
} |
|
111 |
|
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* @see java.awt.Container#add(java.awt.Component, int) |
|
115 |
*/ |
|
116 |
public Component add(Component comp, int index) { |
|
117 |
return getContent().add(comp, index); |
|
118 |
} |
|
119 |
|
|
120 |
/* |
|
121 |
* (non-Javadoc) |
|
122 |
* @see java.awt.Container#add(java.awt.Component, java.lang.Object) |
|
123 |
*/ |
|
124 |
public void add(Component comp, Object constraints) { |
|
125 |
getContent().add(comp, constraints); |
|
126 |
} |
|
127 |
|
|
128 |
/* |
|
129 |
* (non-Javadoc) |
|
130 |
* @see java.awt.Container#add(java.awt.Component, java.lang.Object, int) |
|
131 |
*/ |
|
132 |
public void add(Component comp, Object constraints, int index) { |
|
133 |
getContent().add(comp, constraints, index); |
|
134 |
} |
|
135 |
|
|
136 |
/* |
|
137 |
* (non-Javadoc) |
|
138 |
* @see java.awt.Container#add(java.lang.String, java.awt.Component) |
|
139 |
*/ |
|
140 |
public Component add(String name, Component comp) { |
|
141 |
return getContent().add(name, comp); |
|
142 |
} |
|
143 |
} |
|
0 | 144 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/progresspanel/LogControl.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.gui.beans.progresspanel; |
|
20 |
/** |
|
21 |
* <code>LogControl</code>. Objeto para un control b?sico de un log. Para a?adir |
|
22 |
* y reemplazar la ?ltima l?nea a?adida. |
|
23 |
* |
|
24 |
* @version 27/03/2007 |
|
25 |
* @author Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
26 |
*/ |
|
27 |
public class LogControl { |
|
28 |
String text = ""; |
|
29 |
|
|
30 |
/** |
|
31 |
* A?ade una l?nea al log. |
|
32 |
* @param line |
|
33 |
*/ |
|
34 |
public void addLine(String line) { |
|
35 |
if (text.length()>0) |
|
36 |
text += "\n"; |
|
37 |
text += line; |
|
38 |
} |
|
39 |
|
|
40 |
/** |
|
41 |
* Reemplaza la ?ltima l?nea a?adida al log. |
|
42 |
* @param line |
|
43 |
*/ |
|
44 |
public void replaceLastLine(String line) { |
|
45 |
int index = text.lastIndexOf("\n"); |
|
46 |
if (index<0) index = 0; |
|
47 |
text = text.substring(0, index); |
|
48 |
addLine(line); |
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* Establece el texto completo del log. |
|
53 |
* @param value |
|
54 |
*/ |
|
55 |
public void setText(String value) { |
|
56 |
text = value; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* Devuelve el contenido del log. |
|
61 |
* @return String |
|
62 |
*/ |
|
63 |
public String getText() { |
|
64 |
return text; |
|
65 |
} |
|
66 |
} |
|
0 | 67 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/progresspanel/ProgressPanel.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2007 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 |
package org.gvsig.gui.beans.progresspanel; |
|
20 |
|
|
21 |
import java.awt.Dimension; |
|
22 |
import java.awt.FlowLayout; |
|
23 |
import java.awt.Toolkit; |
|
24 |
|
|
25 |
import javax.swing.JFrame; |
|
26 |
import javax.swing.JLabel; |
|
27 |
import javax.swing.JPanel; |
|
28 |
import javax.swing.JProgressBar; |
|
29 |
import javax.swing.JScrollPane; |
|
30 |
import javax.swing.JTextPane; |
|
31 |
|
|
32 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
33 |
/** |
|
34 |
* <code>ProgressPanel</code>. Muestra una ventana de di?logo para representar |
|
35 |
* una barra de progreso con su ventana de registro. |
|
36 |
* |
|
37 |
* @version 20/03/2007 |
|
38 |
* @author Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
39 |
*/ |
|
40 |
public class ProgressPanel extends JFrame { |
|
41 |
private static final long serialVersionUID = -6930857769971064429L; |
|
42 |
private JPanel jPanel = null; |
|
43 |
private JLabel jLabel = null; |
|
44 |
private JLabel jLabel1 = null; |
|
45 |
private JPanel jPanel1 = null; |
|
46 |
private JPanel njp = null; |
|
47 |
private ButtonsPanel buttonsPanel = null; |
|
48 |
private JProgressBar jProgressBar = null; |
|
49 |
private JScrollPane jScrollPane = null; |
|
50 |
private JTextPane jTextPane = null; |
|
51 |
private LogControl text = new LogControl(); |
|
52 |
|
|
53 |
/** |
|
54 |
* Constructor |
|
55 |
*/ |
|
56 |
public ProgressPanel() { |
|
57 |
initialize(); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* This method initializes this |
|
62 |
* |
|
63 |
*/ |
|
64 |
private void initialize() { |
|
65 |
njp = new JPanel(); |
|
66 |
njp.setLayout(new java.awt.BorderLayout(5, 5)); |
|
67 |
njp.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); |
|
68 |
this.setContentPane(njp); |
|
69 |
this.setResizable(false); |
|
70 |
njp.add(getJPanel(), java.awt.BorderLayout.NORTH); |
|
71 |
njp.add(getJPanel1(), java.awt.BorderLayout.CENTER); |
|
72 |
njp.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH); |
|
73 |
showLog(false); |
|
74 |
setPercent(0); |
|
75 |
Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); |
|
76 |
this.setLocation( |
|
77 |
(int) (d.getWidth() - this.getWidth()) >> 1, |
|
78 |
(int) (d.getHeight() - this.getHeight()) >> 1); |
|
79 |
this.show(); |
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* This method initializes jPanel |
|
84 |
* |
|
85 |
* @return javax.swing.JPanel |
|
86 |
*/ |
|
87 |
private JPanel getJPanel() { |
|
88 |
if (jPanel == null) { |
|
89 |
jLabel1 = new JLabel(); |
|
90 |
jLabel = new JLabel(); |
|
91 |
jLabel.setText("Espere..."); |
|
92 |
jPanel = new JPanel(); |
|
93 |
jPanel.setLayout(new java.awt.BorderLayout(5, 5)); |
|
94 |
jPanel.add(jLabel, java.awt.BorderLayout.WEST); |
|
95 |
jPanel.add(jLabel1, java.awt.BorderLayout.EAST); |
|
96 |
} |
|
97 |
return jPanel; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* This method initializes jPanel1 |
|
102 |
* |
|
103 |
* @return javax.swing.JPanel |
|
104 |
*/ |
|
105 |
private JPanel getJPanel1() { |
|
106 |
if (jPanel1 == null) { |
|
107 |
jPanel1 = new JPanel(); |
|
108 |
jPanel1.setLayout(new java.awt.BorderLayout(5, 5)); |
|
109 |
jPanel1.add(getJProgressBar(), java.awt.BorderLayout.NORTH); |
|
110 |
jPanel1.add(getJScrollPane(), java.awt.BorderLayout.CENTER); |
|
111 |
} |
|
112 |
return jPanel1; |
|
113 |
} |
|
114 |
|
|
115 |
public void showLog(boolean visible) { |
|
116 |
buttonsPanel.getButton(ButtonsPanel.BUTTON_SEEDETAILS).setVisible(!visible); |
|
117 |
buttonsPanel.getButton(ButtonsPanel.BUTTON_HIDEDETAILS).setVisible(visible); |
|
118 |
jScrollPane.setVisible(visible); |
|
119 |
|
|
120 |
int width = 400; |
|
121 |
int height = (visible?300:120); |
|
122 |
|
|
123 |
this.setSize(width, height); |
|
124 |
this.show(); |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* This method initializes ButtonsPanel |
|
129 |
* |
|
130 |
* @return ButtonsPanel |
|
131 |
*/ |
|
132 |
public ButtonsPanel getButtonsPanel() { |
|
133 |
if (buttonsPanel == null) { |
|
134 |
buttonsPanel = new ButtonsPanel(ButtonsPanel.BUTTONS_NONE); |
|
135 |
buttonsPanel.addSeeDetails(); |
|
136 |
buttonsPanel.addHideDetails(); |
|
137 |
buttonsPanel.addCancel(); |
|
138 |
buttonsPanel.setLayout(new java.awt.FlowLayout(FlowLayout.CENTER)); |
|
139 |
buttonsPanel.addActionListener(new java.awt.event.ActionListener() { |
|
140 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
141 |
if (e.getActionCommand().compareTo(ButtonsPanel.BUTTON_SEEDETAILS + "") == 0) { |
|
142 |
showLog(true); |
|
143 |
} |
|
144 |
if (e.getActionCommand().compareTo(ButtonsPanel.BUTTON_HIDEDETAILS + "") == 0) { |
|
145 |
showLog(false); |
|
146 |
} |
|
147 |
} |
|
148 |
}); |
|
149 |
} |
|
150 |
return buttonsPanel; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* This method initializes jProgressBar |
|
155 |
* |
|
156 |
* @return javax.swing.JProgressBar |
|
157 |
*/ |
|
158 |
private JProgressBar getJProgressBar() { |
|
159 |
if (jProgressBar == null) { |
|
160 |
jProgressBar = new JProgressBar(); |
|
161 |
jProgressBar.setValue(50); |
|
162 |
} |
|
163 |
return jProgressBar; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* This method initializes jScrollPane |
|
168 |
* |
|
169 |
* @return javax.swing.JScrollPane |
|
170 |
*/ |
|
171 |
private JScrollPane getJScrollPane() { |
|
172 |
if (jScrollPane == null) { |
|
173 |
jScrollPane = new JScrollPane(); |
|
174 |
jScrollPane.setViewportView(getJTextPane()); |
|
175 |
jScrollPane.setVisible(false); |
|
176 |
} |
|
177 |
return jScrollPane; |
|
178 |
} |
|
179 |
|
|
180 |
/** |
|
181 |
* This method initializes jTextPane |
|
182 |
* |
|
183 |
* @return javax.swing.JTextPane |
|
184 |
*/ |
|
185 |
private JTextPane getJTextPane() { |
|
186 |
if (jTextPane == null) { |
|
187 |
jTextPane = new JTextPane(); |
|
188 |
jTextPane.setEditable(false); |
|
189 |
} |
|
190 |
return jTextPane; |
|
191 |
} |
|
192 |
|
|
193 |
private void updateLog() { |
|
194 |
jTextPane.setText(text.getText()); |
|
195 |
} |
|
196 |
|
|
197 |
public void addLineLog(String line) { |
|
198 |
text.addLine(line); |
|
199 |
updateLog(); |
|
200 |
} |
|
201 |
|
|
202 |
public void replaceLastLineLog(String line) { |
|
203 |
text.replaceLastLine(line); |
|
204 |
updateLog(); |
|
205 |
} |
|
206 |
|
|
207 |
public void setLog(String value) { |
|
208 |
text.setText(value); |
|
209 |
updateLog(); |
|
210 |
} |
|
211 |
|
|
212 |
public int getPercent() { |
|
213 |
return jProgressBar.getValue(); |
|
214 |
} |
|
215 |
|
|
216 |
public void setPercent(int value) { |
|
217 |
jProgressBar.setValue(value); |
|
218 |
jLabel1.setText(value + "%"); |
|
219 |
} |
|
220 |
|
|
221 |
public void setLabel(String value) { |
|
222 |
jLabel.setText(value); |
|
223 |
} |
|
224 |
} |
|
0 | 225 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/incrementabletask/IncrementableTask.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.incrementabletask; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
import java.awt.event.WindowAdapter; |
|
6 |
import java.awt.event.WindowEvent; |
|
7 |
|
|
8 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
|
9 |
import org.gvsig.gui.beans.progresspanel.ProgressPanel; |
|
10 |
|
|
11 |
public class IncrementableTask extends Thread implements ActionListener { |
|
12 |
IIncrementable iIncrementable; |
|
13 |
ProgressPanel progressPanel = null; |
|
14 |
|
|
15 |
public IncrementableTask(IIncrementable incrementable) { |
|
16 |
iIncrementable = incrementable; |
|
17 |
} |
|
18 |
|
|
19 |
/** |
|
20 |
* Este thread va leyendo el porcentaje hasta que se completa el histograma. |
|
21 |
*/ |
|
22 |
public synchronized void run(){ |
|
23 |
while(true){ |
|
24 |
showWindow(); |
|
25 |
while (iIncrementable.getPercent() < 100){ |
|
26 |
getProgressPanel().setLabel(iIncrementable.getLabel()); |
|
27 |
getProgressPanel().setPercent(iIncrementable.getPercent()); |
|
28 |
getProgressPanel().setTitle(iIncrementable.getTitle()); |
|
29 |
getProgressPanel().setLog(iIncrementable.getLog()); |
|
30 |
try { |
|
31 |
sleep(100); |
|
32 |
} catch (InterruptedException e) { |
|
33 |
e.printStackTrace(); |
|
34 |
} |
|
35 |
} |
|
36 |
//Cerramos la ventana |
|
37 |
|
|
38 |
handleClose(); |
|
39 |
|
|
40 |
this.suspend(); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
private void handleClose() { |
|
45 |
getProgressPanel().setVisible(false); |
|
46 |
getProgressPanel().hide(); |
|
47 |
progressPanel = null; |
|
48 |
System.out.println("Cerrado"); |
|
49 |
} |
|
50 |
/** |
|
51 |
* Muestra la ventana de incremento con el porcentaje de la construcci?n del |
|
52 |
* histograma. |
|
53 |
*/ |
|
54 |
public void showWindow(){ |
|
55 |
getProgressPanel().setTitle(iIncrementable.getTitle()); |
|
56 |
getProgressPanel().showLog(false); |
|
57 |
getProgressPanel().show(); |
|
58 |
|
|
59 |
if(this.isAlive()) |
|
60 |
this.resume(); |
|
61 |
else |
|
62 |
this.start(); |
|
63 |
} |
|
64 |
|
|
65 |
private ProgressPanel getProgressPanel() { |
|
66 |
if (progressPanel == null) { |
|
67 |
progressPanel = new ProgressPanel(); |
|
68 |
progressPanel.getButtonsPanel().addActionListener(this); |
|
69 |
progressPanel.addWindowListener( new WindowAdapter() { |
|
70 |
public void windowClosing(WindowEvent e) |
|
71 |
{ |
|
72 |
handleClose(); |
|
73 |
} |
|
74 |
}); |
|
75 |
} |
|
76 |
return progressPanel; |
|
77 |
} |
|
78 |
|
|
79 |
public void actionPerformed(ActionEvent e) { |
|
80 |
if (e.getActionCommand().compareTo(ButtonsPanel.BUTTON_CANCEL + "") == 0) { |
|
81 |
handleClose(); |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
0 | 85 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/incrementabletask/IIncrementable.java | ||
---|---|---|
1 |
package org.gvsig.gui.beans.incrementabletask; |
|
2 |
|
|
3 |
public interface IIncrementable { |
|
4 |
/** |
|
5 |
* Devuelve el titulo de la ventana IncrementableTask |
|
6 |
* @return String |
|
7 |
*/ |
|
8 |
public String getTitle(); |
|
9 |
|
|
10 |
/** |
|
11 |
* Devuelve el contenido del log de la ventana IncrementableTask |
|
12 |
* @return String |
|
13 |
*/ |
|
14 |
public String getLog(); |
|
15 |
|
|
16 |
/** |
|
17 |
* Devuelve la etiqueta de la ventana IncrementableTask |
|
18 |
* @return String |
|
19 |
*/ |
|
20 |
public String getLabel(); |
|
21 |
|
|
22 |
/** |
|
23 |
* Devuelve el porcentaje de 0 a 100 de la ventana IncrementableTask |
|
24 |
* @return int |
|
25 |
*/ |
|
26 |
public int getPercent(); |
|
27 |
} |
|
0 | 28 |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/buttonBar/ButtonBarContainer.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 |
package org.gvsig.gui.beans.buttonBar; |
|
20 |
|
|
21 |
import java.awt.FlowLayout; |
|
22 |
import java.util.ArrayList; |
|
23 |
|
|
24 |
import javax.swing.ImageIcon; |
|
25 |
import javax.swing.JButton; |
|
26 |
|
|
27 |
import org.gvsig.gui.beans.BaseComponent; |
|
28 |
|
|
29 |
public class ButtonBarContainer extends BaseComponent { |
|
30 |
private static final long serialVersionUID = -2556987128553063939L; |
|
31 |
private int wComp = 400, hComp = 26; |
|
32 |
private String pathToImages = "images/"; |
|
33 |
private ArrayList buttons = new ArrayList(); |
|
34 |
private boolean disableAllControls = false; |
|
35 |
private boolean[] buttonsState = null; |
|
36 |
|
|
37 |
/** |
|
38 |
* This is the default constructor |
|
39 |
*/ |
|
40 |
public ButtonBarContainer() { |
|
41 |
super(); |
|
42 |
initialize(); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* This method initializes this |
|
47 |
* |
|
48 |
* @return void |
|
49 |
*/ |
|
50 |
private void initialize() { |
|
51 |
FlowLayout flowLayout = new FlowLayout(); |
|
52 |
flowLayout.setHgap(0); |
|
53 |
flowLayout.setVgap(0); |
|
54 |
this.setLayout(flowLayout); |
|
55 |
this.setSize(wComp, hComp); |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
/** |
|
60 |
* A?ade un boton al ArrayList de los botones. |
|
61 |
* |
|
62 |
* @param iconName: nombre del icono asignado al boton. La imagen tendr?a que |
|
63 |
* estar dentro de la carpeta "images/" |
|
64 |
* @param tip: tip del boton; |
|
65 |
* @param order: orden que ocupar? el boton dentro del control |
|
66 |
*/ |
|
67 |
public void addButton(String iconName, String tip, int order){ |
|
68 |
JButton bt = new JButton(); |
|
69 |
|
|
70 |
bt.setPreferredSize(new java.awt.Dimension(22, 22)); |
|
71 |
try{ |
|
72 |
if (iconName != null) |
|
73 |
bt.setIcon(new ImageIcon(getClass().getResource(pathToImages + iconName))); |
|
74 |
}catch(NullPointerException exc){ |
|
75 |
//El icono no existe -> No se a?ade ninguno |
|
76 |
} |
|
77 |
|
|
78 |
if(tip != null) |
|
79 |
bt.setToolTipText(tip); |
|
80 |
|
|
81 |
buttons.add(order, bt); |
|
82 |
addList(); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Elimina el bot?n correspondiente al indice que le pasamos. |
|
88 |
* @param index |
|
89 |
*/ |
|
90 |
public void delButton(int index){ |
|
91 |
buttons.remove(index); |
|
92 |
this.removeAll(); |
|
93 |
addList(); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* A?ade en el panel los botones que tenemos en el ArrayList. |
|
98 |
* |
|
99 |
*/ |
|
100 |
public void addList(){ |
|
101 |
for(int i = 0 ; i < buttons.size() ; i++){ |
|
102 |
this.add((JButton)buttons.get(i)); |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
/** |
|
108 |
* Esta funci?n deshabilita todos los controles y guarda sus valores |
|
109 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue |
|
110 |
* se vuelvan a quedar como estaba |
|
111 |
*/ |
|
112 |
public void disableAllControls(){ |
|
113 |
if(!disableAllControls){ |
|
114 |
disableAllControls = true; |
|
115 |
|
|
116 |
buttonsState = new boolean[buttons.size()]; |
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
for (int i = 0 ; i < buttons.size() ; i++){ |
|
121 |
|
|
122 |
//Salvamos los estados |
|
123 |
buttonsState[i] = ((JButton)buttons.get(i)).isEnabled(); |
|
124 |
//Desactivamos controles |
|
125 |
((JButton)buttons.get(i)).setEnabled(false); |
|
126 |
} |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n |
|
132 |
* disableAllControls |
|
133 |
*/ |
|
134 |
public void restoreControlsValue(){ |
|
135 |
if(disableAllControls){ |
|
136 |
disableAllControls = false; |
|
137 |
|
|
138 |
for(int i = 0 ; i < buttons.size() ; i++){ |
|
139 |
((JButton)buttons.get(i)).setEnabled(buttonsState[i]); |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* M?todo para acceder a los botones del control; |
|
146 |
* @param index |
|
147 |
* @return |
|
148 |
*/ |
|
149 |
public JButton getButton(int index){ |
|
150 |
return (JButton)buttons.get(index); |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* M?todo para establecer la posici?n de los botones dentro del control. |
|
155 |
* @param align: "left" o "right" |
|
156 |
*/ |
|
157 |
public void setButtonAlignment(String align){ |
|
158 |
FlowLayout layout = new FlowLayout(); |
|
159 |
layout.setHgap(2); |
|
160 |
layout.setVgap(0); |
|
161 |
|
|
162 |
if (align.equals("right")) |
|
163 |
layout.setAlignment(FlowLayout.RIGHT); |
|
164 |
else |
|
165 |
layout.setAlignment(FlowLayout.LEFT); |
|
166 |
|
|
167 |
this.setLayout(layout); |
|
168 |
} |
|
169 |
|
|
170 |
public void setComponentBorder(boolean br){ |
|
171 |
if(br) |
|
172 |
this.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
|
173 |
if(!br) |
|
174 |
this.setBorder(javax.swing.BorderFactory.createEmptyBorder()); |
|
175 |
} |
|
176 |
|
|
177 |
} |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/buttonbar/ButtonBarContainer.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 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 |
package org.gvsig.gui.beans.buttonbar; |
|
20 |
|
|
21 |
import java.awt.FlowLayout; |
|
22 |
import java.util.ArrayList; |
|
23 |
|
|
24 |
import javax.swing.ImageIcon; |
|
25 |
import javax.swing.JButton; |
|
26 |
|
|
27 |
import org.gvsig.gui.beans.BaseComponent; |
|
28 |
|
|
29 |
public class ButtonBarContainer extends BaseComponent { |
|
30 |
private static final long serialVersionUID = -2556987128553063939L; |
|
31 |
private int wComp = 400, hComp = 26; |
|
32 |
private String pathToImages = "images/"; |
|
33 |
private ArrayList buttons = new ArrayList(); |
|
34 |
private boolean disableAllControls = false; |
|
35 |
private boolean[] buttonsState = null; |
|
36 |
|
|
37 |
/** |
|
38 |
* This is the default constructor |
|
39 |
*/ |
|
40 |
public ButtonBarContainer() { |
|
41 |
super(); |
|
42 |
initialize(); |
|
43 |
} |
|
44 |
|
|
45 |
/** |
|
46 |
* This method initializes this |
|
47 |
* |
|
48 |
* @return void |
|
49 |
*/ |
|
50 |
private void initialize() { |
|
51 |
FlowLayout flowLayout = new FlowLayout(); |
|
52 |
flowLayout.setHgap(0); |
|
53 |
flowLayout.setVgap(0); |
|
54 |
this.setLayout(flowLayout); |
|
55 |
this.setSize(wComp, hComp); |
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
/** |
|
60 |
* A?ade un boton al ArrayList de los botones. |
|
61 |
* |
|
62 |
* @param iconName: nombre del icono asignado al boton. La imagen tendr?a que |
|
63 |
* estar dentro de la carpeta "images/" |
|
64 |
* @param tip: tip del boton; |
|
65 |
* @param order: orden que ocupar? el boton dentro del control |
|
66 |
*/ |
|
67 |
public void addButton(String iconName, String tip, int order){ |
|
68 |
JButton bt = new JButton(); |
|
69 |
|
|
70 |
bt.setPreferredSize(new java.awt.Dimension(22, 22)); |
|
71 |
try{ |
|
72 |
if (iconName != null) |
|
73 |
bt.setIcon(new ImageIcon(getClass().getResource(pathToImages + iconName))); |
|
74 |
}catch(NullPointerException exc){ |
|
75 |
//El icono no existe -> No se a?ade ninguno |
|
76 |
} |
|
77 |
|
|
78 |
if(tip != null) |
|
79 |
bt.setToolTipText(tip); |
|
80 |
|
|
81 |
buttons.add(order, bt); |
|
82 |
addList(); |
|
83 |
|
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Elimina el bot?n correspondiente al indice que le pasamos. |
|
88 |
* @param index |
|
89 |
*/ |
|
90 |
public void delButton(int index){ |
|
91 |
buttons.remove(index); |
|
92 |
this.removeAll(); |
|
93 |
addList(); |
|
94 |
} |
|
95 |
|
|
96 |
/** |
|
97 |
* A?ade en el panel los botones que tenemos en el ArrayList. |
|
98 |
* |
|
99 |
*/ |
|
100 |
public void addList(){ |
|
101 |
for(int i = 0 ; i < buttons.size() ; i++){ |
|
102 |
this.add((JButton)buttons.get(i)); |
|
103 |
} |
|
104 |
} |
|
105 |
|
|
106 |
|
|
107 |
/** |
|
108 |
* Esta funci?n deshabilita todos los controles y guarda sus valores |
|
109 |
* de habilitado o deshabilitado para que cuando se ejecute restoreControlsValue |
|
110 |
* se vuelvan a quedar como estaba |
|
111 |
*/ |
|
112 |
public void disableAllControls(){ |
|
113 |
if(!disableAllControls){ |
|
114 |
disableAllControls = true; |
|
115 |
|
|
116 |
buttonsState = new boolean[buttons.size()]; |
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
for (int i = 0 ; i < buttons.size() ; i++){ |
|
121 |
|
|
122 |
//Salvamos los estados |
|
123 |
buttonsState[i] = ((JButton)buttons.get(i)).isEnabled(); |
|
124 |
//Desactivamos controles |
|
125 |
((JButton)buttons.get(i)).setEnabled(false); |
|
126 |
} |
|
127 |
} |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Esta funci?n deja los controles como estaban al ejecutar la funci?n |
|
132 |
* disableAllControls |
|
133 |
*/ |
|
134 |
public void restoreControlsValue(){ |
|
135 |
if(disableAllControls){ |
|
136 |
disableAllControls = false; |
|
137 |
|
|
138 |
for(int i = 0 ; i < buttons.size() ; i++){ |
|
139 |
((JButton)buttons.get(i)).setEnabled(buttonsState[i]); |
|
140 |
} |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
/** |
|
145 |
* M?todo para acceder a los botones del control; |
|
146 |
* @param index |
Also available in: Unified diff