Revision 1743
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/DefaultRasterSwingManager.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
2 | 3 |
* |
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 | 5 |
* |
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
... | ... | |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
19 | 19 |
* MA 02110-1301, USA. |
20 | 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. |
|
21 | 23 |
*/ |
22 | 24 |
package org.gvsig.raster.swing.impl; |
23 | 25 |
|
... | ... | |
26 | 28 |
import java.util.HashMap; |
27 | 29 |
|
28 | 30 |
import javax.swing.ImageIcon; |
31 |
import javax.swing.JComponent; |
|
29 | 32 |
import javax.swing.JPanel; |
30 | 33 |
import javax.swing.table.DefaultTableModel; |
31 | 34 |
|
32 | 35 |
import org.gvsig.raster.swing.BasePanel; |
33 | 36 |
import org.gvsig.raster.swing.RasterSwingManager; |
34 | 37 |
import org.gvsig.raster.swing.RasterWindowManager; |
38 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
35 | 39 |
import org.gvsig.raster.swing.buttonbar.ButtonBar; |
36 | 40 |
import org.gvsig.raster.swing.gcanvas.GCanvas; |
41 |
import org.gvsig.raster.swing.impl.basepanel.ButtonsPanel; |
|
37 | 42 |
import org.gvsig.raster.swing.impl.buttonbar.ButtonBarContainerImpl; |
38 | 43 |
import org.gvsig.raster.swing.impl.canvas.DefaultGCanvas; |
39 | 44 |
import org.gvsig.raster.swing.impl.infobypoint.MainInfoByPointPanelImpl; |
... | ... | |
205 | 210 |
public ModelLoader createModelLoader(TableModel tableModel) { |
206 | 211 |
return new ModelLoaderImpl((DefaultTableModel)tableModel); |
207 | 212 |
} |
213 |
|
|
214 |
public IButtonsPanel createButtonsPanel(int buttons, JComponent parent) { |
|
215 |
return new ButtonsPanel(buttons, parent); |
|
216 |
} |
|
208 | 217 |
} |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/pagedtable/PagedTablePanel.java | ||
---|---|---|
269 | 269 |
pager.setSelectedPage(pager.getPageFromRow(selectedRows[0])); |
270 | 270 |
reloadPage(); |
271 | 271 |
} |
272 |
int r = selectedRows[0] % pager.getEntriesPerPage(); |
|
273 |
if(r >= 0 && r < model.getRowCount()) |
|
274 |
getJTable().setRowSelectionInterval(r, r); |
|
272 |
if(pager.getEntriesPerPage() > 0) { |
|
273 |
int r = selectedRows[0] % pager.getEntriesPerPage(); |
|
274 |
if(r >= 0 && r < model.getRowCount()) |
|
275 |
getJTable().setRowSelectionInterval(r, r); |
|
276 |
} |
|
275 | 277 |
} |
276 | 278 |
} |
277 | 279 |
|
... | ... | |
284 | 286 |
if(option == PagedTableEvent.EVENT_REMOVE_ENTRY ) { |
285 | 287 |
int[] selectedRows = pager.getSelectedRows(); |
286 | 288 |
reloadPage(); |
287 |
if(selectedRows != null) { |
|
289 |
if(selectedRows != null && pager.getEntriesPerPage() > 0) {
|
|
288 | 290 |
int r = selectedRows[0] % pager.getEntriesPerPage(); |
289 | 291 |
if(r >= 0 && r < model.getRowCount()) { |
290 | 292 |
getJTable().setRowSelectionInterval(r, r); |
... | ... | |
299 | 301 |
if(option == PagedTableEvent.EVENT_SELECTED_PAGE || option == PagedTableEvent.EVENT_MODIFY_ENTRY) { |
300 | 302 |
reloadPage(); |
301 | 303 |
int[] selectedRows = pager.getSelectedRows(); |
302 |
if(selectedRows != null) { |
|
304 |
if(selectedRows != null && pager.getEntriesPerPage() > 0) {
|
|
303 | 305 |
int r = selectedRows[0] % pager.getEntriesPerPage(); |
304 | 306 |
if(r >= 0 && r < model.getRowCount()) { |
305 | 307 |
getJTable().setRowSelectionInterval(r, r); |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/pagedtable/Pager.java | ||
---|---|---|
255 | 255 |
} |
256 | 256 |
|
257 | 257 |
public int getPageFromRow(int row) { |
258 |
return (int)(row / getEntriesPerPage()); |
|
258 |
if(getEntriesPerPage() > 0) |
|
259 |
return (int)(row / getEntriesPerPage()); |
|
260 |
return 0; |
|
259 | 261 |
} |
260 | 262 |
|
261 | 263 |
public List<Object> getSelectedPage() { |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.impl/src/main/java/org/gvsig/raster/swing/impl/basepanel/ButtonsPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 2 |
|
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.raster.swing.impl.basepanel; |
|
25 |
|
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.util.ArrayList; |
|
29 |
import java.util.Iterator; |
|
30 |
|
|
31 |
import javax.swing.JButton; |
|
32 |
import javax.swing.JComponent; |
|
33 |
import javax.swing.JPanel; |
|
34 |
|
|
35 |
import org.gvsig.i18n.Messages; |
|
36 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelEvent; |
|
37 |
import org.gvsig.raster.swing.basepanel.ButtonsPanelListener; |
|
38 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
39 |
|
|
40 |
/** |
|
41 |
* <code>ButtonsPanel</code> ofrece un widget con un conjunto de botones |
|
42 |
* preestablecidos, aunque tambi?n se pueden a?adir botones con el m?todo |
|
43 |
* {@link #addButton(String, int)} |
|
44 |
* |
|
45 |
* @version 09/05/2008 |
|
46 |
* |
|
47 |
* @author BorSanZa - Borja Sanchez Zamorano |
|
48 |
*/ |
|
49 |
public class ButtonsPanel extends JPanel implements IButtonsPanel { |
|
50 |
private static final long serialVersionUID = -1660559792086305063L; |
|
51 |
|
|
52 |
private ArrayList<ButtonsPanelListener> actionCommandListeners = new ArrayList<ButtonsPanelListener>(); |
|
53 |
private ArrayList<JButton> buttonsList = new ArrayList<JButton>(); |
|
54 |
|
|
55 |
static private int eventId = Integer.MIN_VALUE; |
|
56 |
|
|
57 |
private JComponent parent = null; |
|
58 |
|
|
59 |
/** |
|
60 |
* Crea un ButtonsPanel con un Layout por defecto. |
|
61 |
*/ |
|
62 |
public ButtonsPanel(JComponent parent) { |
|
63 |
this.parent = parent; |
|
64 |
initialize(); |
|
65 |
} |
|
66 |
|
|
67 |
private void initialize() { |
|
68 |
setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 2, 0)); |
|
69 |
setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 0, 0, 0)); |
|
70 |
} |
|
71 |
/** |
|
72 |
* Crea un ButtonsPanel con un Layout por defecto. |
|
73 |
* @param items Que botones vamos a usar en la creaci?n. |
|
74 |
*/ |
|
75 |
public ButtonsPanel(int items, JComponent parent) { |
|
76 |
this.parent = parent; |
|
77 |
initialize(); |
|
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 |
addApply(); |
|
88 |
addAccept(); |
|
89 |
addCancel(); |
|
90 |
break; |
|
91 |
case BUTTONS_APPLYCLOSE: |
|
92 |
addApply(); |
|
93 |
addClose(); |
|
94 |
break; |
|
95 |
case BUTTONS_CANCEL: |
|
96 |
addCancel(); |
|
97 |
break; |
|
98 |
case BUTTONS_YESNO: |
|
99 |
addYes(); |
|
100 |
addNo(); |
|
101 |
break; |
|
102 |
case BUTTONS_CLOSE: |
|
103 |
addClose(); |
|
104 |
break; |
|
105 |
case BUTTONS_EXIT: |
|
106 |
addExit(); |
|
107 |
break; |
|
108 |
case BUTTONS_NONE: |
|
109 |
break; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* A?adir el disparador de cuando se pulsa un bot?n. |
|
115 |
* @param listener |
|
116 |
*/ |
|
117 |
public void addButtonPressedListener(ButtonsPanelListener listener) { |
|
118 |
if (!actionCommandListeners.contains(listener)) |
|
119 |
actionCommandListeners.add(listener); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* Devuelve el array de listeners del componente |
|
124 |
* @return |
|
125 |
*/ |
|
126 |
public Object[] getButtonPressedListeners() { |
|
127 |
return actionCommandListeners.toArray(); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* Borrar el disparador de eventos de los botones. |
|
132 |
* @param listener |
|
133 |
*/ |
|
134 |
public void removeButtonPressedListener(ButtonsPanelListener listener) { |
|
135 |
actionCommandListeners.remove(listener); |
|
136 |
} |
|
137 |
|
|
138 |
private void callActionCommandListeners(int buttonID) { |
|
139 |
Iterator<ButtonsPanelListener> acIterator = actionCommandListeners.iterator(); |
|
140 |
while (acIterator.hasNext()) { |
|
141 |
ButtonsPanelListener listener = (ButtonsPanelListener) acIterator.next(); |
|
142 |
listener.actionButtonPressed(new ButtonsPanelEvent(parent, buttonID)); |
|
143 |
} |
|
144 |
eventId++; |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* A?adir el boton Aceptar. |
|
149 |
*/ |
|
150 |
public void addAccept() { |
|
151 |
addButton(Messages.getText("aceptar"), BUTTON_ACCEPT); |
|
152 |
} |
|
153 |
|
|
154 |
/** |
|
155 |
* A?adir el boton Guardar. |
|
156 |
*/ |
|
157 |
public void addSave() { |
|
158 |
addButton(Messages.getText("guardar"), BUTTON_SAVE); |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* A?adir el boton Cancelar. |
|
163 |
*/ |
|
164 |
public void addCancel() { |
|
165 |
addButton(Messages.getText("cancelar"), BUTTON_CANCEL); |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* A?adir el boton S?. |
|
170 |
*/ |
|
171 |
public void addYes() { |
|
172 |
addButton(Messages.getText("si"), BUTTON_YES); |
|
173 |
} |
|
174 |
|
|
175 |
/** |
|
176 |
* A?adir el boton No. |
|
177 |
*/ |
|
178 |
public void addNo() { |
|
179 |
addButton(Messages.getText("no"), BUTTON_NO); |
|
180 |
} |
|
181 |
|
|
182 |
/** |
|
183 |
* A?adir el boton Aplicar. |
|
184 |
*/ |
|
185 |
public void addApply() { |
|
186 |
addButton(Messages.getText("aplicar"), BUTTON_APPLY); |
|
187 |
} |
|
188 |
|
|
189 |
/** |
|
190 |
* A?adir el boton Cerrar. |
|
191 |
*/ |
|
192 |
public void addClose() { |
|
193 |
addButton(Messages.getText("cerrar"), BUTTON_CLOSE); |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* A?adir el boton Salir. |
|
198 |
*/ |
|
199 |
public void addExit() { |
|
200 |
addButton(Messages.getText("salir"), BUTTON_EXIT); |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* A?adir el boton Ver detalles. |
|
205 |
*/ |
|
206 |
public void addSeeDetails() { |
|
207 |
addButton(Messages.getText("verdetalles"), BUTTON_SEEDETAILS); |
|
208 |
} |
|
209 |
|
|
210 |
/** |
|
211 |
* A?adir el boton Ocultar detalles. |
|
212 |
*/ |
|
213 |
public void addHideDetails() { |
|
214 |
addButton(Messages.getText("ocultardetalles"), BUTTON_HIDEDETAILS); |
|
215 |
} |
|
216 |
|
|
217 |
/** |
|
218 |
* A?adir el boton Pausar. |
|
219 |
*/ |
|
220 |
public void addPause() { |
|
221 |
addButton(Messages.getText("pausar"), BUTTON_PAUSE); |
|
222 |
} |
|
223 |
|
|
224 |
/** |
|
225 |
* A?adir el boton Reanudar. |
|
226 |
*/ |
|
227 |
public void addRestart() { |
|
228 |
addButton(Messages.getText("reanudar"), BUTTON_RESTART); |
|
229 |
} |
|
230 |
|
|
231 |
/** |
|
232 |
* A?adimos un bot?n definido por el usuario. |
|
233 |
* |
|
234 |
* @param text Texto que contendr? el bot?n |
|
235 |
* @param id Entero para identificar los eventos del bot?n |
|
236 |
*/ |
|
237 |
public void addButton(String text, int id) { |
|
238 |
JButton button = new JButton(); |
|
239 |
button.setText(text); |
|
240 |
|
|
241 |
buttonsList.add(button); |
|
242 |
button.setActionCommand(id + ""); |
|
243 |
button.addActionListener(new ActionListener() { |
|
244 |
public void actionPerformed(ActionEvent e) { |
|
245 |
callActionCommandListeners(Integer.parseInt(e.getActionCommand())); |
|
246 |
} |
|
247 |
}); |
|
248 |
|
|
249 |
add(button); |
|
250 |
} |
|
251 |
|
|
252 |
/** |
|
253 |
* Obtener un bot?n por su Entero |
|
254 |
* @param id N?mero del disparador del bot?n |
|
255 |
* @return El bot?n especificado o <code>null</code> si no se encontr? el bot?n. |
|
256 |
*/ |
|
257 |
public JButton getButton(int id) { |
|
258 |
Iterator<JButton> acIterator = buttonsList.iterator(); |
|
259 |
while (acIterator.hasNext()) { |
|
260 |
JButton button = (JButton) acIterator.next(); |
|
261 |
if (Integer.parseInt(button.getActionCommand()) == id) |
|
262 |
return button; |
|
263 |
} |
|
264 |
return null; |
|
265 |
} |
|
266 |
|
|
267 |
/** |
|
268 |
* <p>Removes the button identified by <code>id</code>.</p> |
|
269 |
* |
|
270 |
* @param id identifier of the button |
|
271 |
* @return <code>true</code> if has removed the button; otherwise <code>false</code> |
|
272 |
*/ |
|
273 |
public boolean removeButton(int id) { |
|
274 |
String b_text = getButtonText(id); |
|
275 |
|
|
276 |
Iterator<JButton> acIterator = buttonsList.iterator(); |
|
277 |
while (acIterator.hasNext()) { |
|
278 |
JButton button = (JButton) acIterator.next(); |
|
279 |
if (button.getText().compareTo(b_text) == 0) { |
|
280 |
buttonsList.remove(button); |
|
281 |
return true; |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
return false; |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* <p>Returns the text of the button identified by <code>id</code>.</p> |
|
290 |
* |
|
291 |
* @param id identifier of the button |
|
292 |
* |
|
293 |
* @return text of the identified button |
|
294 |
*/ |
|
295 |
public String getButtonText(int id) { |
|
296 |
switch (id) { |
|
297 |
case BUTTON_ACCEPT: |
|
298 |
return Messages.getText("aceptar"); |
|
299 |
case BUTTON_CANCEL: |
|
300 |
return Messages.getText("cancelar"); |
|
301 |
case BUTTON_APPLY: |
|
302 |
return Messages.getText("aplicar"); |
|
303 |
case BUTTON_YES: |
|
304 |
return Messages.getText("si"); |
|
305 |
case BUTTON_NO: |
|
306 |
return Messages.getText("no"); |
|
307 |
case BUTTON_CLOSE: |
|
308 |
return Messages.getText("cerrar"); |
|
309 |
case BUTTON_EXIT: |
|
310 |
return Messages.getText("salir"); |
|
311 |
case BUTTON_SEEDETAILS: |
|
312 |
return Messages.getText("verdetalles"); |
|
313 |
case BUTTON_HIDEDETAILS: |
|
314 |
return Messages.getText("ocultardetalles"); |
|
315 |
case BUTTON_PAUSE: |
|
316 |
return Messages.getText("pausar"); |
|
317 |
case BUTTON_RESTART: |
|
318 |
return Messages.getText("reanudar"); |
|
319 |
case BUTTON_SAVE: |
|
320 |
return Messages.getText("guardar"); |
|
321 |
} |
|
322 |
|
|
323 |
return null; |
|
324 |
} |
|
325 |
|
|
326 |
/** |
|
327 |
* <p>Enables (or disables) the button identified by <code>id</code>.</p> |
|
328 |
* |
|
329 |
* @param id identifier of the button |
|
330 |
* @param b <code>true</code> to enable the button, otherwise <code>false</code> |
|
331 |
* |
|
332 |
* @return <code>true</code> if there was a button of that kind in this group, otherwise <code>false</code> |
|
333 |
*/ |
|
334 |
public boolean setEnabled(int id, boolean b) { |
|
335 |
String b_text = getButtonText(id); |
|
336 |
|
|
337 |
Iterator<JButton> acIterator = buttonsList.iterator(); |
|
338 |
while (acIterator.hasNext()) { |
|
339 |
JButton button = (JButton) acIterator.next(); |
|
340 |
if (button.getText().compareTo(b_text) == 0) { |
|
341 |
button.setEnabled(b); |
|
342 |
return true; |
|
343 |
} |
|
344 |
} |
|
345 |
|
|
346 |
return false; |
|
347 |
} |
|
348 |
} |
|
0 | 349 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/basepanel/IButtonsPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 2 |
|
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.raster.swing.basepanel; |
|
25 |
|
|
26 |
import javax.swing.JButton; |
|
27 |
|
|
28 |
public interface IButtonsPanel { |
|
29 |
public static final int BUTTON_ACCEPT = 1; |
|
30 |
public static final int BUTTON_CANCEL = 2; |
|
31 |
public static final int BUTTON_APPLY = 3; |
|
32 |
public static final int BUTTON_YES = 4; |
|
33 |
public static final int BUTTON_NO = 5; |
|
34 |
public static final int BUTTON_CLOSE = 6; |
|
35 |
public static final int BUTTON_EXIT = 7; |
|
36 |
public static final int BUTTON_SEEDETAILS = 8; |
|
37 |
public static final int BUTTON_HIDEDETAILS = 9; |
|
38 |
public static final int BUTTON_PAUSE = 10; |
|
39 |
public static final int BUTTON_RESTART = 11; |
|
40 |
public static final int BUTTON_SAVE = 12; |
|
41 |
/** |
|
42 |
* Sirve para cuando se crean botones nuevos, saber el ?ltimo n?mero usado |
|
43 |
* internamente, as? '<code>new_id = BUTTON_LAST + 1;</code>' podr?a ser |
|
44 |
* el ?ndice del nuevo bot?n. |
|
45 |
*/ |
|
46 |
public static final int BUTTON_LAST = 12; |
|
47 |
public static final int BUTTONS_ACCEPT = 1; |
|
48 |
public static final int BUTTONS_ACCEPTCANCEL = 2; |
|
49 |
public static final int BUTTONS_ACCEPTCANCELAPPLY = 3; |
|
50 |
public static final int BUTTONS_CANCEL = 4; |
|
51 |
public static final int BUTTONS_YESNO = 5; |
|
52 |
public static final int BUTTONS_CLOSE = 6; |
|
53 |
public static final int BUTTONS_EXIT = 7; |
|
54 |
public static final int BUTTONS_NONE = 8; |
|
55 |
public static final int BUTTONS_APPLYCLOSE = 9; |
|
56 |
|
|
57 |
/** |
|
58 |
* A?adir el disparador de cuando se pulsa un bot?n. |
|
59 |
* @param listener |
|
60 |
*/ |
|
61 |
public void addButtonPressedListener(ButtonsPanelListener listener); |
|
62 |
|
|
63 |
/** |
|
64 |
* Devuelve el array de listeners del componente |
|
65 |
* @return |
|
66 |
*/ |
|
67 |
public Object[] getButtonPressedListeners(); |
|
68 |
|
|
69 |
/** |
|
70 |
* Borrar el disparador de eventos de los botones. |
|
71 |
* @param listener |
|
72 |
*/ |
|
73 |
public void removeButtonPressedListener(ButtonsPanelListener listener); |
|
74 |
|
|
75 |
/** |
|
76 |
* A?adir el boton Aceptar. |
|
77 |
*/ |
|
78 |
public void addAccept(); |
|
79 |
|
|
80 |
/** |
|
81 |
* A?adir el boton Guardar. |
|
82 |
*/ |
|
83 |
public void addSave(); |
|
84 |
|
|
85 |
/** |
|
86 |
* A?adir el boton Cancelar. |
|
87 |
*/ |
|
88 |
public void addCancel(); |
|
89 |
|
|
90 |
/** |
|
91 |
* A?adir el boton S?. |
|
92 |
*/ |
|
93 |
public void addYes(); |
|
94 |
|
|
95 |
/** |
|
96 |
* A?adir el boton No. |
|
97 |
*/ |
|
98 |
public void addNo(); |
|
99 |
|
|
100 |
/** |
|
101 |
* A?adir el boton Aplicar. |
|
102 |
*/ |
|
103 |
public void addApply(); |
|
104 |
|
|
105 |
/** |
|
106 |
* A?adir el boton Cerrar. |
|
107 |
*/ |
|
108 |
public void addClose(); |
|
109 |
|
|
110 |
/** |
|
111 |
* A?adir el boton Salir. |
|
112 |
*/ |
|
113 |
public void addExit(); |
|
114 |
|
|
115 |
/** |
|
116 |
* A?adir el boton Ver detalles. |
|
117 |
*/ |
|
118 |
public void addSeeDetails(); |
|
119 |
|
|
120 |
/** |
|
121 |
* A?adir el boton Ocultar detalles. |
|
122 |
*/ |
|
123 |
public void addHideDetails(); |
|
124 |
|
|
125 |
/** |
|
126 |
* A?adir el boton Pausar. |
|
127 |
*/ |
|
128 |
public void addPause(); |
|
129 |
|
|
130 |
/** |
|
131 |
* A?adir el boton Reanudar. |
|
132 |
*/ |
|
133 |
public void addRestart(); |
|
134 |
|
|
135 |
/** |
|
136 |
* A?adimos un bot?n definido por el usuario. |
|
137 |
* |
|
138 |
* @param text Texto que contendr? el bot?n |
|
139 |
* @param id Entero para identificar los eventos del bot?n |
|
140 |
*/ |
|
141 |
public void addButton(String text, int id); |
|
142 |
|
|
143 |
/** |
|
144 |
* Obtener un bot?n por su Entero |
|
145 |
* @param id N?mero del disparador del bot?n |
|
146 |
* @return El bot?n especificado o <code>null</code> si no se encontr? el bot?n. |
|
147 |
*/ |
|
148 |
public JButton getButton(int id); |
|
149 |
|
|
150 |
/** |
|
151 |
* <p>Removes the button identified by <code>id</code>.</p> |
|
152 |
* |
|
153 |
* @param id identifier of the button |
|
154 |
* @return <code>true</code> if has removed the button; otherwise <code>false</code> |
|
155 |
*/ |
|
156 |
public boolean removeButton(int id); |
|
157 |
|
|
158 |
/** |
|
159 |
* <p>Returns the text of the button identified by <code>id</code>.</p> |
|
160 |
* |
|
161 |
* @param id identifier of the button |
|
162 |
* |
|
163 |
* @return text of the identified button |
|
164 |
*/ |
|
165 |
public String getButtonText(int id); |
|
166 |
|
|
167 |
/** |
|
168 |
* <p>Enables (or disables) the button identified by <code>id</code>.</p> |
|
169 |
* |
|
170 |
* @param id identifier of the button |
|
171 |
* @param b <code>true</code> to enable the button, otherwise <code>false</code> |
|
172 |
* |
|
173 |
* @return <code>true</code> if there was a button of that kind in this group, otherwise <code>false</code> |
|
174 |
*/ |
|
175 |
public boolean setEnabled(int id, boolean b); |
|
176 |
} |
|
0 | 177 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/basepanel/ButtonsPanelEvent.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 2 |
|
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.raster.swing.basepanel; |
|
25 |
|
|
26 |
import java.util.EventObject; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @version 09/05/2008 |
|
31 |
* |
|
32 |
* @author BorSanZa - Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
33 |
*/ |
|
34 |
public class ButtonsPanelEvent extends EventObject { |
|
35 |
private static final long serialVersionUID = 4275588038151358375L; |
|
36 |
|
|
37 |
int button = 0; |
|
38 |
|
|
39 |
public ButtonsPanelEvent(Object source, int button) { |
|
40 |
super(source); |
|
41 |
this.button = button; |
|
42 |
} |
|
43 |
|
|
44 |
public int getButton() { |
|
45 |
return button; |
|
46 |
} |
|
47 |
} |
|
0 | 48 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/basepanel/AbstractButtonsPanel.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 2 |
|
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.raster.swing.basepanel; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.awt.Container; |
|
28 |
import java.awt.LayoutManager; |
|
29 |
import java.awt.Window; |
|
30 |
|
|
31 |
import javax.swing.JPanel; |
|
32 |
|
|
33 |
import org.gvsig.raster.swing.RasterSwingLocator; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* <code>AbstractButtonsPanel</code> is a panel which inherits of <code>JPanel</code>. |
|
38 |
* That reimplemented panel permits add generic buttons of apply, accept and cancel to |
|
39 |
* a panel. |
|
40 |
* @author BorSanZa - Borja Sanchez Zamorano |
|
41 |
*/ |
|
42 |
public abstract class AbstractButtonsPanel extends JPanel { |
|
43 |
private static final long serialVersionUID = 1536590395737700551L; |
|
44 |
IButtonsPanel bp = null; |
|
45 |
JPanel content = null; |
|
46 |
private int margin = 4; |
|
47 |
|
|
48 |
/** |
|
49 |
* Crea el <code>DefaultButtonsPanel</code> con los botones por defecto. |
|
50 |
*/ |
|
51 |
public AbstractButtonsPanel() { |
|
52 |
super.setLayout(new java.awt.BorderLayout(0, 0)); |
|
53 |
getButtonsPanel().addAccept(); |
|
54 |
getButtonsPanel().addCancel(); |
|
55 |
getButtonsPanel().addApply(); |
|
56 |
super.add((JPanel)getButtonsPanel(), java.awt.BorderLayout.SOUTH); |
|
57 |
super.add(getContent(), java.awt.BorderLayout.CENTER); |
|
58 |
this.setBorder(javax.swing.BorderFactory.createEmptyBorder(margin, margin, margin, margin)); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* Crea el <code>DialogPanel</code> con los botones que definamos de la clase |
|
63 |
* <code>ButtonsPanel</code> |
|
64 |
* |
|
65 |
* @param buttons Constante para definir que botones se crear?n |
|
66 |
*/ |
|
67 |
public AbstractButtonsPanel(int buttons) { |
|
68 |
super.setLayout(new java.awt.BorderLayout(0, 0)); |
|
69 |
bp = RasterSwingLocator.getSwingManager().createButtonsPanel(buttons, this); |
|
70 |
super.add((JPanel)getButtonsPanel(), java.awt.BorderLayout.SOUTH); |
|
71 |
super.add(getContent(), java.awt.BorderLayout.CENTER); |
|
72 |
this.setBorder(javax.swing.BorderFactory.createEmptyBorder(margin, margin, margin, margin)); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
|
76 |
* Obtener el objeto <code>ButtonsPanel</code> del <code>DialogPanel</code>. |
|
77 |
* En caso de no estar creado, lo crear?. |
|
78 |
* |
|
79 |
* @return El componente bp |
|
80 |
*/ |
|
81 |
public IButtonsPanel getButtonsPanel() { |
|
82 |
if (bp == null) |
|
83 |
bp = RasterSwingLocator.getSwingManager().createButtonsPanel(IButtonsPanel.BUTTONS_NONE, this); |
|
84 |
return bp; |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* Obtener el contenido del <code>DialogPanel</code>. En caso de no estar creado, |
|
89 |
* lo crear?. |
|
90 |
* |
|
91 |
* @return El componente content |
|
92 |
*/ |
|
93 |
public JPanel getContent() { |
|
94 |
if (content == null) |
|
95 |
content = new JPanel(); |
|
96 |
return content; |
|
97 |
} |
|
98 |
|
|
99 |
public void addButtonPressedListener(ButtonsPanelListener listener) { |
|
100 |
getButtonsPanel().addButtonPressedListener(listener); |
|
101 |
} |
|
102 |
|
|
103 |
public void removeButtonPressedListener(ButtonsPanelListener listener) { |
|
104 |
getButtonsPanel().removeButtonPressedListener(listener); |
|
105 |
} |
|
106 |
|
|
107 |
/* |
|
108 |
* (non-Javadoc) |
|
109 |
* @see java.awt.Container#getLayout() |
|
110 |
*/ |
|
111 |
public LayoutManager getLayout() { |
|
112 |
return getContent().getLayout(); |
|
113 |
} |
|
114 |
|
|
115 |
/* |
|
116 |
* (non-Javadoc) |
|
117 |
* @see java.awt.Container#setLayout(java.awt.LayoutManager) |
|
118 |
*/ |
|
119 |
public void setLayout(LayoutManager mgr) { |
|
120 |
getContent().setLayout(mgr); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Devuelve el Window que contiene dicha ventana o null en caso de que no sea |
|
125 |
* asi |
|
126 |
* @return |
|
127 |
*/ |
|
128 |
public Window getWindow() { |
|
129 |
Container container = getParent(); |
|
130 |
while (container != null) { |
|
131 |
if (container instanceof Window) |
|
132 |
return (Window) container; |
|
133 |
container = container.getParent(); |
|
134 |
} |
|
135 |
return null; |
|
136 |
} |
|
137 |
|
|
138 |
/* |
|
139 |
* (non-Javadoc) |
|
140 |
* @see java.awt.Container#add(java.awt.Component) |
|
141 |
*/ |
|
142 |
public Component add(Component comp) { |
|
143 |
return getContent().add(comp); |
|
144 |
} |
|
145 |
|
|
146 |
/* |
|
147 |
* (non-Javadoc) |
|
148 |
* @see java.awt.Container#add(java.awt.Component, int) |
|
149 |
*/ |
|
150 |
public Component add(Component comp, int index) { |
|
151 |
return getContent().add(comp, index); |
|
152 |
} |
|
153 |
|
|
154 |
/* |
|
155 |
* (non-Javadoc) |
|
156 |
* @see java.awt.Container#add(java.awt.Component, java.lang.Object) |
|
157 |
*/ |
|
158 |
public void add(Component comp, Object constraints) { |
|
159 |
getContent().add(comp, constraints); |
|
160 |
} |
|
161 |
|
|
162 |
/* |
|
163 |
* (non-Javadoc) |
|
164 |
* @see java.awt.Container#add(java.awt.Component, java.lang.Object, int) |
|
165 |
*/ |
|
166 |
public void add(Component comp, Object constraints, int index) { |
|
167 |
getContent().add(comp, constraints, index); |
|
168 |
} |
|
169 |
|
|
170 |
/* |
|
171 |
* (non-Javadoc) |
|
172 |
* @see java.awt.Container#add(java.lang.String, java.awt.Component) |
|
173 |
*/ |
|
174 |
public Component add(String name, Component comp) { |
|
175 |
return getContent().add(name, comp); |
|
176 |
} |
|
177 |
} |
|
0 | 178 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/basepanel/ButtonsPanelListener.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2012 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 2 |
|
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.raster.swing.basepanel; |
|
25 |
|
|
26 |
import java.util.EventListener; |
|
27 |
|
|
28 |
/** |
|
29 |
* |
|
30 |
* @version 09/05/2008 |
|
31 |
* |
|
32 |
* @author BorSanZa - Borja Sanchez Zamorano (borja.sanchez@iver.es) |
|
33 |
*/ |
|
34 |
public interface ButtonsPanelListener extends EventListener { |
|
35 |
public void actionButtonPressed(ButtonsPanelEvent e); |
|
36 |
} |
|
0 | 37 |
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.swing/org.gvsig.raster.swing.api/src/main/java/org/gvsig/raster/swing/RasterSwingManager.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
2 | 3 |
* |
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
4 |
* Copyright (C) 2007-2012 gvSIG Association. |
|
5 | 5 |
* |
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
... | ... | |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
19 | 19 |
* MA 02110-1301, USA. |
20 | 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. |
|
21 | 23 |
*/ |
22 | 24 |
package org.gvsig.raster.swing; |
23 | 25 |
|
... | ... | |
26 | 28 |
import java.util.HashMap; |
27 | 29 |
|
28 | 30 |
import javax.swing.ImageIcon; |
31 |
import javax.swing.JComponent; |
|
29 | 32 |
import javax.swing.JPanel; |
30 | 33 |
|
34 |
import org.gvsig.raster.swing.basepanel.IButtonsPanel; |
|
31 | 35 |
import org.gvsig.raster.swing.buttonbar.ButtonBar; |
32 | 36 |
import org.gvsig.raster.swing.gcanvas.GCanvas; |
33 | 37 |
import org.gvsig.raster.swing.infobypoint.MainInfoByPointPanel; |
... | ... | |
176 | 180 |
* @return |
177 | 181 |
*/ |
178 | 182 |
public ModelLoader createModelLoader(TableModel tableModel); |
183 |
|
|
184 |
/** |
|
185 |
* Creates a buttons panel |
|
186 |
* @param parent |
|
187 |
* @return |
|
188 |
*/ |
|
189 |
public IButtonsPanel createButtonsPanel(int buttons, JComponent parent); |
|
179 | 190 |
} |
Also available in: Unified diff