Revision 1351
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/test/java/org/gvsig/tools/AppTest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools; |
|
25 |
|
|
26 |
import junit.framework.Test; |
|
27 |
import junit.framework.TestCase; |
|
28 |
import junit.framework.TestSuite; |
|
29 |
|
|
30 |
/** |
|
31 |
* Unit test for simple App. |
|
32 |
*/ |
|
33 |
public class AppTest extends TestCase { |
|
34 |
|
|
35 |
/** |
|
36 |
* @return the suite of tests being tested |
|
37 |
*/ |
|
38 |
public static Test suite() { |
|
39 |
return new TestSuite(AppTest.class); |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* Create the test case |
|
44 |
* |
|
45 |
* @param testName |
|
46 |
* name of the test case |
|
47 |
*/ |
|
48 |
public AppTest(String testName) { |
|
49 |
super(testName); |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* Rigourous Test :-) |
|
54 |
*/ |
|
55 |
public void testApp() { |
|
56 |
assertTrue(true); |
|
57 |
} |
|
58 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.tools.swing.api.ToolsSwingLibrary |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/JListWithCheckbox.java | ||
---|---|---|
1 |
/* |
|
2 |
* To change this license header, choose License Headers in Project Properties. |
|
3 |
* To change this template file, choose Tools | Templates |
|
4 |
* and open the template in the editor. |
|
5 |
*/ |
|
6 |
package org.gvsig.tools.swing.api; |
|
7 |
|
|
8 |
import java.awt.BorderLayout; |
|
9 |
import java.awt.Color; |
|
10 |
import java.awt.Component; |
|
11 |
import java.awt.Dimension; |
|
12 |
import java.awt.Point; |
|
13 |
import java.awt.Rectangle; |
|
14 |
import java.awt.event.MouseAdapter; |
|
15 |
import java.awt.event.MouseEvent; |
|
16 |
import java.beans.Transient; |
|
17 |
import java.util.HashSet; |
|
18 |
import java.util.Iterator; |
|
19 |
import java.util.List; |
|
20 |
import java.util.Set; |
|
21 |
import java.util.Vector; |
|
22 |
import javax.accessibility.AccessibleContext; |
|
23 |
import javax.swing.DefaultListSelectionModel; |
|
24 |
import javax.swing.JCheckBox; |
|
25 |
import javax.swing.JList; |
|
26 |
import javax.swing.JPanel; |
|
27 |
import javax.swing.ListCellRenderer; |
|
28 |
import javax.swing.ListModel; |
|
29 |
import javax.swing.ListSelectionModel; |
|
30 |
import javax.swing.event.ListSelectionEvent; |
|
31 |
import javax.swing.event.ListSelectionListener; |
|
32 |
import javax.swing.plaf.ListUI; |
|
33 |
import javax.swing.text.Position; |
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
public class JListWithCheckbox extends JList { |
|
38 |
|
|
39 |
private static final Logger logger = LoggerFactory.getLogger(JListWithCheckbox.class); |
|
40 |
|
|
41 |
|
|
42 |
public class CheckListCellRenderer extends JPanel implements ListCellRenderer { |
|
43 |
|
|
44 |
private ListCellRenderer delegate; |
|
45 |
private ListSelectionModel selectionModel; |
|
46 |
private JCheckBox checkBox = new JCheckBox(); |
|
47 |
|
|
48 |
public CheckListCellRenderer(ListCellRenderer renderer, ListSelectionModel selectionModel) { |
|
49 |
this.delegate = renderer; |
|
50 |
this.selectionModel = selectionModel; |
|
51 |
this.setLayout(new BorderLayout()); |
|
52 |
this.setOpaque(false); |
|
53 |
this.checkBox.setOpaque(false); |
|
54 |
checkBoxWidth = (int) this.checkBox.getPreferredSize().getWidth(); |
|
55 |
} |
|
56 |
|
|
57 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
|
58 |
Component renderer = delegate.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
|
59 |
checkBox.setSelected(selectionModel.isSelectedIndex(index)); |
|
60 |
removeAll(); |
|
61 |
add(checkBox, BorderLayout.WEST); |
|
62 |
add(renderer, BorderLayout.CENTER); |
|
63 |
return this; |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
private int checkBoxWidth = 0; |
|
68 |
private final JList wrappedList; |
|
69 |
private ListSelectionModel checkedsModel = new DefaultListSelectionModel(); |
|
70 |
private Set<ListSelectionListener> checkedsListeners; |
|
71 |
|
|
72 |
public JListWithCheckbox(final JList wrappedList) { |
|
73 |
this.wrappedList = wrappedList; |
|
74 |
this.checkedsModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
|
75 |
this.checkedsListeners = new HashSet<ListSelectionListener>(); |
|
76 |
|
|
77 |
this.wrappedList.setCellRenderer( |
|
78 |
new CheckListCellRenderer( |
|
79 |
this.wrappedList.getCellRenderer(), |
|
80 |
this.checkedsModel |
|
81 |
) |
|
82 |
); |
|
83 |
this.wrappedList.addMouseListener(new MouseAdapter() { |
|
84 |
public void mouseClicked(MouseEvent me) { |
|
85 |
int index = wrappedList.locationToIndex(me.getPoint()); |
|
86 |
if (index < 0) { |
|
87 |
return; |
|
88 |
} |
|
89 |
if (me.getX() > wrappedList.getCellBounds(index, index).getX() + checkBoxWidth) { |
|
90 |
return; |
|
91 |
} |
|
92 |
toggleCheck(index); |
|
93 |
} |
|
94 |
}); |
|
95 |
this.checkedsModel.addListSelectionListener(new ListSelectionListener() { |
|
96 |
@Override |
|
97 |
public void valueChanged(ListSelectionEvent lse) { |
|
98 |
wrappedList.repaint(); |
|
99 |
//fireCheckedsListeners(lse); |
|
100 |
} |
|
101 |
}); |
|
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
public void toggleCheck(int index) { |
|
106 |
if (index < 0) { |
|
107 |
return; |
|
108 |
} |
|
109 |
if (this.checkedsModel.isSelectedIndex(index)) { |
|
110 |
this.checkedsModel.removeSelectionInterval(index, index); |
|
111 |
} else { |
|
112 |
this.checkedsModel.addSelectionInterval(index, index); |
|
113 |
} |
|
114 |
// FIXME: isAdjusting is set to false always |
|
115 |
fireCheckedsListeners(new ListSelectionEvent(this, index, index, false)); |
|
116 |
} |
|
117 |
|
|
118 |
@Override |
|
119 |
public ListUI getUI() { |
|
120 |
return this.wrappedList.getUI(); |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public void setUI(ListUI ui) { |
|
125 |
this.wrappedList.setUI(ui); |
|
126 |
} |
|
127 |
|
|
128 |
@Override |
|
129 |
public void updateUI() { |
|
130 |
if( this.wrappedList!= null ) { |
|
131 |
this.wrappedList.updateUI(); |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public String getUIClassID() { |
|
137 |
return this.wrappedList.getUIClassID(); |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public Object getPrototypeCellValue() { |
|
142 |
return this.wrappedList.getPrototypeCellValue(); |
|
143 |
} |
|
144 |
|
|
145 |
@Override |
|
146 |
public void setPrototypeCellValue(Object prototypeCellValue) { |
|
147 |
this.wrappedList.setPrototypeCellValue(prototypeCellValue); |
|
148 |
} |
|
149 |
|
|
150 |
@Override |
|
151 |
public int getFixedCellWidth() { |
|
152 |
return this.wrappedList.getFixedCellWidth(); |
|
153 |
} |
|
154 |
|
|
155 |
@Override |
|
156 |
public void setFixedCellWidth(int width) { |
|
157 |
this.wrappedList.setFixedCellWidth(width); |
|
158 |
} |
|
159 |
|
|
160 |
@Override |
|
161 |
public int getFixedCellHeight() { |
|
162 |
return this.wrappedList.getFixedCellHeight(); |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
public void setFixedCellHeight(int height) { |
|
167 |
this.wrappedList.setFixedCellHeight(height); |
|
168 |
} |
|
169 |
|
|
170 |
@Transient |
|
171 |
@Override |
|
172 |
public ListCellRenderer getCellRenderer() { |
|
173 |
return this.wrappedList.getCellRenderer(); |
|
174 |
} |
|
175 |
|
|
176 |
@Override |
|
177 |
public void setCellRenderer(ListCellRenderer cellRenderer) { |
|
178 |
this.wrappedList.setCellRenderer(cellRenderer); |
|
179 |
} |
|
180 |
|
|
181 |
@Override |
|
182 |
public Color getSelectionForeground() { |
|
183 |
return this.wrappedList.getSelectionForeground(); |
|
184 |
} |
|
185 |
|
|
186 |
@Override |
|
187 |
public void setSelectionForeground(Color selectionForeground) { |
|
188 |
this.wrappedList.setSelectionForeground(selectionForeground); |
|
189 |
} |
|
190 |
|
|
191 |
@Override |
|
192 |
public Color getSelectionBackground() { |
|
193 |
return this.wrappedList.getSelectionBackground(); |
|
194 |
} |
|
195 |
|
|
196 |
@Override |
|
197 |
public void setSelectionBackground(Color selectionBackground) { |
|
198 |
this.wrappedList.setSelectionBackground(selectionBackground); |
|
199 |
} |
|
200 |
|
|
201 |
@Override |
|
202 |
public int getVisibleRowCount() { |
|
203 |
return this.wrappedList.getVisibleRowCount(); |
|
204 |
} |
|
205 |
|
|
206 |
@Override |
|
207 |
public void setVisibleRowCount(int visibleRowCount) { |
|
208 |
this.wrappedList.setVisibleRowCount(visibleRowCount); |
|
209 |
} |
|
210 |
|
|
211 |
@Override |
|
212 |
public int getLayoutOrientation() { |
|
213 |
return this.wrappedList.getLayoutOrientation(); |
|
214 |
} |
|
215 |
|
|
216 |
@Override |
|
217 |
public void setLayoutOrientation(int layoutOrientation) { |
|
218 |
this.wrappedList.setLayoutOrientation(layoutOrientation); |
|
219 |
} |
|
220 |
|
|
221 |
@Override |
|
222 |
public int getFirstVisibleIndex() { |
|
223 |
return this.wrappedList.getFirstVisibleIndex(); |
|
224 |
} |
|
225 |
|
|
226 |
@Override |
|
227 |
public int getLastVisibleIndex() { |
|
228 |
return this.wrappedList.getLastVisibleIndex(); |
|
229 |
} |
|
230 |
|
|
231 |
@Override |
|
232 |
public void ensureIndexIsVisible(int index) { |
|
233 |
this.wrappedList.ensureIndexIsVisible(index); |
|
234 |
} |
|
235 |
|
|
236 |
@Override |
|
237 |
public void setDragEnabled(boolean b) { |
|
238 |
this.wrappedList.setDragEnabled(b); |
|
239 |
} |
|
240 |
|
|
241 |
@Override |
|
242 |
public boolean getDragEnabled() { |
|
243 |
return this.wrappedList.getDragEnabled(); |
|
244 |
} |
|
245 |
// |
|
246 |
// public final void setDropMode(DropMode dropMode) { |
|
247 |
// this.wrappedList.setDropMode(dropMode); |
|
248 |
// } |
|
249 |
// |
|
250 |
// public final DropMode getDropMode() { |
|
251 |
// |
|
252 |
// } |
|
253 |
// |
|
254 |
// public final DropLocation getDropLocation() { |
|
255 |
// |
|
256 |
// } |
|
257 |
|
|
258 |
@Override |
|
259 |
public int getNextMatch(String prefix, int startIndex, Position.Bias bias) { |
|
260 |
return this.wrappedList.getNextMatch(prefix, startIndex, bias); |
|
261 |
} |
|
262 |
|
|
263 |
@Override |
|
264 |
public String getToolTipText(MouseEvent event) { |
|
265 |
return this.wrappedList.getToolTipText(event); |
|
266 |
} |
|
267 |
|
|
268 |
@Override |
|
269 |
public int locationToIndex(Point location) { |
|
270 |
return this.wrappedList.locationToIndex(location); |
|
271 |
} |
|
272 |
|
|
273 |
@Override |
|
274 |
public Point indexToLocation(int index) { |
|
275 |
return this.wrappedList.indexToLocation(index); |
|
276 |
} |
|
277 |
|
|
278 |
@Override |
|
279 |
public Rectangle getCellBounds(int index0, int index1) { |
|
280 |
return this.wrappedList.getCellBounds(index0, index1); |
|
281 |
} |
|
282 |
|
|
283 |
@Override |
|
284 |
public ListModel getModel() { |
|
285 |
return this.wrappedList.getModel(); |
|
286 |
} |
|
287 |
|
|
288 |
@Override |
|
289 |
public void setModel(ListModel model) { |
|
290 |
this.wrappedList.setModel(model); |
|
291 |
} |
|
292 |
|
|
293 |
@Override |
|
294 |
public void setListData(Object[] listData) { |
|
295 |
this.wrappedList.setListData(listData); |
|
296 |
} |
|
297 |
|
|
298 |
@Override |
|
299 |
public void setListData(Vector listData) { |
|
300 |
this.wrappedList.setListData(listData); |
|
301 |
} |
|
302 |
|
|
303 |
@Override |
|
304 |
public ListSelectionModel getSelectionModel() { |
|
305 |
return this.wrappedList.getSelectionModel(); |
|
306 |
} |
|
307 |
|
|
308 |
public ListSelectionModel getCheckedModel() { |
|
309 |
return this.checkedsModel; |
|
310 |
} |
|
311 |
|
|
312 |
@Override |
|
313 |
public void addListSelectionListener(ListSelectionListener listener) { |
|
314 |
this.wrappedList.addListSelectionListener(listener); |
|
315 |
} |
|
316 |
|
|
317 |
public void addChecksListener(ListSelectionListener listener) { |
|
318 |
this.checkedsListeners.add(listener); |
|
319 |
} |
|
320 |
|
|
321 |
@Override |
|
322 |
public void removeListSelectionListener(ListSelectionListener listener) { |
|
323 |
this.wrappedList.removeListSelectionListener(listener); |
|
324 |
} |
|
325 |
|
|
326 |
public void removeChecksListener(ListSelectionListener listener) { |
|
327 |
this.checkedsListeners.remove(listener); |
|
328 |
} |
|
329 |
|
|
330 |
@Override |
|
331 |
public ListSelectionListener[] getListSelectionListeners() { |
|
332 |
return this.wrappedList.getListSelectionListeners(); |
|
333 |
} |
|
334 |
|
|
335 |
public ListSelectionListener[] getChecksListeners() { |
|
336 |
return this.checkedsListeners.toArray(new ListSelectionListener[1]); |
|
337 |
} |
|
338 |
|
|
339 |
protected void fireCheckedsListeners(ListSelectionEvent event) { |
|
340 |
Iterator<ListSelectionListener> it = this.checkedsListeners.iterator(); |
|
341 |
while(it.hasNext()) { |
|
342 |
ListSelectionListener listener = it.next(); |
|
343 |
try { |
|
344 |
listener.valueChanged(event); |
|
345 |
} catch(Throwable th) { |
|
346 |
logger.warn("Problems calling check listener ("+listener+").",th); |
|
347 |
} |
|
348 |
} |
|
349 |
} |
|
350 |
|
|
351 |
@Override |
|
352 |
public void setSelectionModel(ListSelectionModel selectionModel) { |
|
353 |
this.wrappedList.setSelectionModel(selectionModel); |
|
354 |
} |
|
355 |
|
|
356 |
@Override |
|
357 |
public void setSelectionMode(int selectionMode) { |
|
358 |
this.wrappedList.setSelectionMode(selectionMode); |
|
359 |
} |
|
360 |
|
|
361 |
@Override |
|
362 |
public int getSelectionMode() { |
|
363 |
return this.wrappedList.getSelectionMode(); |
|
364 |
} |
|
365 |
|
|
366 |
@Override |
|
367 |
public int getAnchorSelectionIndex() { |
|
368 |
return this.wrappedList.getAnchorSelectionIndex(); |
|
369 |
} |
|
370 |
|
|
371 |
@Override |
|
372 |
public int getLeadSelectionIndex() { |
|
373 |
return this.wrappedList.getLeadSelectionIndex(); |
|
374 |
} |
|
375 |
|
|
376 |
@Override |
|
377 |
public int getMinSelectionIndex() { |
|
378 |
return this.wrappedList.getMinSelectionIndex(); |
|
379 |
} |
|
380 |
|
|
381 |
@Override |
|
382 |
public int getMaxSelectionIndex() { |
|
383 |
return this.wrappedList.getMaxSelectionIndex(); |
|
384 |
} |
|
385 |
|
|
386 |
@Override |
|
387 |
public boolean isSelectedIndex(int index) { |
|
388 |
return this.wrappedList.isSelectedIndex(index); |
|
389 |
} |
|
390 |
|
|
391 |
@Override |
|
392 |
public boolean isSelectionEmpty() { |
|
393 |
return this.wrappedList.isSelectionEmpty(); |
|
394 |
} |
|
395 |
|
|
396 |
@Override |
|
397 |
public void clearSelection() { |
|
398 |
this.wrappedList.clearSelection(); |
|
399 |
} |
|
400 |
|
|
401 |
@Override |
|
402 |
public void setSelectionInterval(int anchor, int lead) { |
|
403 |
this.wrappedList.setSelectionInterval(anchor, lead); |
|
404 |
} |
|
405 |
|
|
406 |
@Override |
|
407 |
public void addSelectionInterval(int anchor, int lead) { |
|
408 |
this.wrappedList.addSelectionInterval(anchor, lead); |
|
409 |
} |
|
410 |
|
|
411 |
@Override |
|
412 |
public void removeSelectionInterval(int index0, int index1) { |
|
413 |
this.wrappedList.removeSelectionInterval(index0, index1); |
|
414 |
} |
|
415 |
|
|
416 |
@Override |
|
417 |
public void setValueIsAdjusting(boolean b) { |
|
418 |
this.wrappedList.setValueIsAdjusting(b); |
|
419 |
} |
|
420 |
|
|
421 |
@Override |
|
422 |
public boolean getValueIsAdjusting() { |
|
423 |
return this.wrappedList.getValueIsAdjusting(); |
|
424 |
} |
|
425 |
|
|
426 |
@Transient |
|
427 |
@Override |
|
428 |
public int[] getSelectedIndices() { |
|
429 |
return this.wrappedList.getSelectedIndices(); |
|
430 |
} |
|
431 |
|
|
432 |
@Override |
|
433 |
public void setSelectedIndex(int index) { |
|
434 |
this.wrappedList.setSelectedIndex(index); |
|
435 |
} |
|
436 |
|
|
437 |
@Override |
|
438 |
public void setSelectedIndices(int[] indices) { |
|
439 |
this.wrappedList.setSelectedIndices(indices); |
|
440 |
} |
|
441 |
|
|
442 |
@Deprecated |
|
443 |
@Override |
|
444 |
public Object[] getSelectedValues() { |
|
445 |
return this.wrappedList.getSelectedValues(); |
|
446 |
} |
|
447 |
|
|
448 |
@Override |
|
449 |
public List getSelectedValuesList() { |
|
450 |
return this.wrappedList.getSelectedValuesList(); |
|
451 |
} |
|
452 |
|
|
453 |
@Override |
|
454 |
public int getSelectedIndex() { |
|
455 |
return this.wrappedList.getSelectedIndex(); |
|
456 |
} |
|
457 |
|
|
458 |
@Override |
|
459 |
public Object getSelectedValue() { |
|
460 |
return this.wrappedList.getSelectedValue(); |
|
461 |
} |
|
462 |
|
|
463 |
@Override |
|
464 |
public void setSelectedValue(Object anObject, boolean shouldScroll) { |
|
465 |
this.wrappedList.setSelectedValue(anObject, shouldScroll); |
|
466 |
} |
|
467 |
|
|
468 |
@Override |
|
469 |
public Dimension getPreferredScrollableViewportSize() { |
|
470 |
return this.wrappedList.getPreferredScrollableViewportSize(); |
|
471 |
} |
|
472 |
|
|
473 |
@Override |
|
474 |
public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { |
|
475 |
return this.wrappedList.getScrollableUnitIncrement(visibleRect, orientation, direction); |
|
476 |
} |
|
477 |
|
|
478 |
@Override |
|
479 |
public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { |
|
480 |
return this.wrappedList.getScrollableBlockIncrement(visibleRect, orientation, direction); |
|
481 |
} |
|
482 |
|
|
483 |
@Override |
|
484 |
public boolean getScrollableTracksViewportWidth() { |
|
485 |
return this.wrappedList.getScrollableTracksViewportWidth(); |
|
486 |
} |
|
487 |
|
|
488 |
@Override |
|
489 |
public boolean getScrollableTracksViewportHeight() { |
|
490 |
return this.wrappedList.getScrollableTracksViewportHeight(); |
|
491 |
} |
|
492 |
|
|
493 |
@Override |
|
494 |
public AccessibleContext getAccessibleContext() { |
|
495 |
return this.wrappedList.getAccessibleContext(); |
|
496 |
} |
|
497 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/threadsafedialogs/ThreadSafeDialogsManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.swing.api.threadsafedialogs; |
|
25 |
|
|
26 |
import java.awt.Component; |
|
27 |
import java.io.File; |
|
28 |
import javax.swing.filechooser.FileFilter; |
|
29 |
|
|
30 |
public interface ThreadSafeDialogsManager { |
|
31 |
|
|
32 |
/** |
|
33 |
* Create a message dialog with an ok button. |
|
34 |
* |
|
35 |
* If message or title start whit a "_" then try to translate. |
|
36 |
* |
|
37 |
* This method is thread safe to use. |
|
38 |
* |
|
39 |
* @param message to present in the dialog |
|
40 |
* @param title title of the dialog |
|
41 |
* @param messageType type of icon to use. |
|
42 |
* |
|
43 |
* @see javax.swing.JOptionPane#showMessageDialog(Component, Object, String, int) |
|
44 |
*/ |
|
45 |
public void messageDialog(String message, String title, int messageType); |
|
46 |
|
|
47 |
/** |
|
48 |
* Create a message dialog with ok button. |
|
49 |
* |
|
50 |
* If message or title start whit a "_" then try to translate. |
|
51 |
* if messageArgs not is null the message can be formated whit MessageFormat. |
|
52 |
* |
|
53 |
* This method is thread safe to use. |
|
54 |
* |
|
55 |
* @param message to present in the dialog |
|
56 |
* @param messageArgs string array of arguments used to format the message |
|
57 |
* @param title title of the dialog |
|
58 |
* @param messageType type of icon to use. |
|
59 |
* |
|
60 |
* @see javax.swing.JOptionPane#showMessageDialog(Component, Object, String, int) |
|
61 |
*/ |
|
62 |
public void messageDialog(String message, String messageArgs[], String title, int messageType); |
|
63 |
|
|
64 |
/** |
|
65 |
* Show a JOptionPane confirm dialog. |
|
66 |
* |
|
67 |
* if this method is invoked out of the event dispatch thread of swing, |
|
68 |
* the dialog is presented in the thread of swing and the calling thread |
|
69 |
* wait to close to continue. |
|
70 |
* |
|
71 |
* @param message |
|
72 |
* @param title |
|
73 |
* @param optionType |
|
74 |
* @param messageType |
|
75 |
* @return |
|
76 |
* |
|
77 |
* @see javax.swing.JOptionPane#showConfirmDialog(Component, Object, String, int, int) |
|
78 |
* |
|
79 |
*/ |
|
80 |
public int confirmDialog(String message, String title, int optionType, int messageType) ; |
|
81 |
|
|
82 |
/** |
|
83 |
* Show a JOptionPane input dialog. |
|
84 |
* |
|
85 |
* if this method is invoked out of the event dispatch thread of swing, |
|
86 |
* the dialog is presented in the thread of swing and the calling thread |
|
87 |
* wait to close to continue. |
|
88 |
* |
|
89 |
* @param message |
|
90 |
* @param title |
|
91 |
* @param optionType |
|
92 |
* an integer designating the options available on the dialog: |
|
93 |
* YES_NO_OPTION, YES_NO_CANCEL_OPTION, or OK_CANCEL_OPTION |
|
94 |
* @param messageType |
|
95 |
* an integer designating the kind of message this is; |
|
96 |
* primarily used to determine the icon from the pluggable |
|
97 |
* Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, |
|
98 |
* WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE |
|
99 |
* @return |
|
100 |
* |
|
101 |
* @see javax.swing.JOptionPane#showInputDialog(Component, Object, String, int) |
|
102 |
* |
|
103 |
*/ |
|
104 |
public String inputDialog(String message, String title, int messageType, String initialValue) ; |
|
105 |
|
|
106 |
/** |
|
107 |
* Show a JOptionPane input dialog. |
|
108 |
* |
|
109 |
* if this method is invoked out of the event dispatch thread of swing, |
|
110 |
* the dialog is presented in the thread of swing and the calling thread |
|
111 |
* wait to close to continue. |
|
112 |
* |
|
113 |
* @param message |
|
114 |
* @param title |
|
115 |
* @param optionType |
|
116 |
* @param messageType |
|
117 |
* @return |
|
118 |
* |
|
119 |
* @see javax.swing.JOptionPane#showInputDialog(Component, Object, String, int) |
|
120 |
* |
|
121 |
*/ |
|
122 |
public String inputDialog(String message, String title); |
|
123 |
|
|
124 |
/** |
|
125 |
* Creates an return a new instance of the component specified |
|
126 |
* |
|
127 |
* This method ensure that the component is created in the event dispatch thread of swing. |
|
128 |
* |
|
129 |
* @param theClass of component to be created |
|
130 |
* @param parameters passed to the constructor of the component |
|
131 |
* |
|
132 |
* @return the instance of the component created |
|
133 |
*/ |
|
134 |
public Component createComponent(final Class<? extends Component> theClass, final Object ... parameters); |
|
135 |
|
|
136 |
/** |
|
137 |
* Creates an return a new instance of the component specified |
|
138 |
* |
|
139 |
* This method ensure that the component is created in the event dispatch thread of swing. |
|
140 |
* |
|
141 |
* @param theClass of component to be created |
|
142 |
* @param parameters passed to the constructor of the component |
|
143 |
* |
|
144 |
* @return the instance of the component created |
|
145 |
*/ |
|
146 |
public Component createComponentWithParams(final Class<? extends Component> theClass, final Object[] parameters); |
|
147 |
|
|
148 |
/** |
|
149 |
* Creates and show a JFileChooser dialog. |
|
150 |
* |
|
151 |
* This method return an array whit the selected files. If multiselection is |
|
152 |
* not allowed, an array with one element is returned. |
|
153 |
* |
|
154 |
* If the user select the cancel button, null is returned. |
|
155 |
* |
|
156 |
* if this method is invoked out of the event dispatch thread of swing, |
|
157 |
* the dialog is presented in the thread of swing and the calling thread |
|
158 |
* wait to close to continue. |
|
159 |
* |
|
160 |
* @param title, title of dialog |
|
161 |
* @param type of the dialog, JFileChooser.SAVE_DIALOG or JFileChooser.OPEN_DIALOG |
|
162 |
* @param selectionMode of the dialog, values are: JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_AND_DIRECTORIES |
|
163 |
* @param multiselection, true if multiselection is allowed |
|
164 |
* @param inihelpertialPath, to show in the dialog |
|
165 |
* @param filter used to filter the files show in the dialog. |
|
166 |
* @param fileHidingEnabled, if true hidden files are show |
|
167 |
* @return an array whit the files selecteds or null. |
|
168 |
*/ |
|
169 |
public File[] showChooserDialog( |
|
170 |
final String title, |
|
171 |
final int type, |
|
172 |
final int selectionMode, |
|
173 |
final boolean multiselection, |
|
174 |
final File inihelpertialPath, |
|
175 |
final FileFilter filter, |
|
176 |
final boolean fileHidingEnabled |
|
177 |
) ; |
|
178 |
|
|
179 |
/** |
|
180 |
* Creates and show a JFileChooser dialog for folder selection. |
|
181 |
* |
|
182 |
* This is an utility method that wrap a showChooserDialog call. |
|
183 |
* |
|
184 |
* @param title, title of dialog |
|
185 |
* @param initialPath, to show in the dialog |
|
186 |
* @return an array whit the files selecteds or null. |
|
187 |
* |
|
188 |
* @see #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean) |
|
189 |
*/ |
|
190 |
public File[] showOpenDirectoryDialog(String title, File initialPath) ; |
|
191 |
|
|
192 |
/** |
|
193 |
* Creates and show a JFileChooser dialog for selection a file for open. |
|
194 |
* |
|
195 |
* This is an utility method that wrap a {@link #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)} call. |
|
196 |
* |
|
197 |
* @param title, title of dialog |
|
198 |
* @param initialPath, to show in the dialog |
|
199 |
* @return an array whit the files selecteds or null. |
|
200 |
* |
|
201 |
* @see #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean) |
|
202 |
*/ |
|
203 |
public File[] showOpenFileDialog(String title, File initialPath) ; |
|
204 |
|
|
205 |
/** |
|
206 |
* Creates and show a JFileChooser dialog for selection a file for save. |
|
207 |
* |
|
208 |
* This is an utility method that wrap a {@link #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean)} call. |
|
209 |
* |
|
210 |
* @param title, title of dialog |
|
211 |
* @param initialPath, to show in the dialog |
|
212 |
* @return an array whit the files selecteds or null. |
|
213 |
* |
|
214 |
* @see #showChooserDialog(String, int, int, boolean, File, FileFilter, boolean) |
|
215 |
*/ |
|
216 |
public File[] showSaveFileDialog(String title, File initialPath) ; |
|
217 |
|
|
218 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/ToolsSwingLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.locator.BaseLocator; |
|
27 |
import org.gvsig.tools.locator.Locator; |
|
28 |
import org.gvsig.tools.swing.api.evaluator.ComponentSwingManager; |
|
29 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
|
30 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
31 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
|
32 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
33 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
|
34 |
|
|
35 |
/** |
|
36 |
* {@link Locator} for the tools swing Library. It returns a reference to the |
|
37 |
* library's main |
|
38 |
* utilities. |
|
39 |
* |
|
40 |
* @author 2010- C?sar Ordi?ana - gvSIG team |
|
41 |
*/ |
|
42 |
public class ToolsSwingLocator extends BaseLocator { |
|
43 |
|
|
44 |
private static final String LOCATOR_NAME = "Tools.swing.locator"; |
|
45 |
|
|
46 |
public static final String USABILITY_SWING_MANAGER_NAME = |
|
47 |
"Tools.usability.swing.manager"; |
|
48 |
|
|
49 |
public static final String USABILITY_SWING_MANAGER_DESCRIPTION = |
|
50 |
"Tools Usability Swing Manager"; |
|
51 |
|
|
52 |
private static final String TASKSTATUS_SWING_MANAGER_NAME = "Tools.task.swing.manager"; |
|
53 |
|
|
54 |
private static final String TASKSTATUS_SWING_MANAGER_DESCRIPTION = "Tools Task Swing Manager"; |
|
55 |
|
|
56 |
private static final String WINDOW_MANAGER_NAME = "Tools.swing.windowmanager"; |
|
57 |
|
|
58 |
private static final String WINDOW_MANAGER_DESCRIPTION = "Tools Window Manager"; |
|
59 |
|
|
60 |
private static final String ICONTHEME_MANAGER_NAME = "Tools.swing.iconthememanager"; |
|
61 |
|
|
62 |
private static final String ICONTHEME_MANAGER_DESCRIPTION = "Tools Icon Theme Manager"; |
|
63 |
|
|
64 |
private static final String COMPONENT_SWING_MANAGER_NAME = "Tools.swing.componentmanager"; |
|
65 |
|
|
66 |
private static final String COMPONENT_SWING_MANAGER_DESCRIPTION = "Tools Swing Component Manager"; |
|
67 |
|
|
68 |
private static final String THREADSAFEDIALOGS_MANAGER_NAME = "Tools.swing.threadsafedialogs"; |
|
69 |
|
|
70 |
private static final String THREADSAFEDIALOGS_MANAGER_DESCRIPTION = "Thread safe dialogs Manager"; |
|
71 |
|
|
72 |
private static final String SWING_MANAGER_NAME = "Tools.swing.manager"; |
|
73 |
|
|
74 |
private static final String SWING_MANAGER_DESCRIPTION = "Tools Swing Manager"; |
|
75 |
|
|
76 |
/** |
|
77 |
* Unique instance. |
|
78 |
*/ |
|
79 |
private static final ToolsSwingLocator instance = new ToolsSwingLocator(); |
|
80 |
|
|
81 |
/** |
|
82 |
* Return the {@link Singleton} instance. |
|
83 |
* |
|
84 |
* @return the {@link Singleton} instance |
|
85 |
*/ |
|
86 |
public static ToolsSwingLocator getInstance() { |
|
87 |
return instance; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Return the {@link Locator}'s name |
|
92 |
* |
|
93 |
* @return a String with the {@link Locator}'s name |
|
94 |
*/ |
|
95 |
@Override |
|
96 |
public String getLocatorName() { |
|
97 |
return LOCATOR_NAME; |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Gets the instance of the {@link UsabilitySwingManager} registered. |
|
102 |
* |
|
103 |
* @return {@link UsabilitySwingManager} |
|
104 |
*/ |
|
105 |
public static UsabilitySwingManager getUsabilitySwingManager() { |
|
106 |
return (UsabilitySwingManager) getInstance().get( |
|
107 |
USABILITY_SWING_MANAGER_NAME); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Registers the Class implementing the {@link UsabilitySwingManager} |
|
112 |
* interface. |
|
113 |
* |
|
114 |
* @param clazz |
|
115 |
* implementing the {@link UsabilitySwingManager} interface |
|
116 |
*/ |
|
117 |
public static void registerUsabilitySwingManager( |
|
118 |
Class<? extends UsabilitySwingManager> clazz) { |
|
119 |
getInstance().register(USABILITY_SWING_MANAGER_NAME, |
|
120 |
USABILITY_SWING_MANAGER_DESCRIPTION, clazz); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* Gets the instance of the {@link TaskStatusSwingManager} registered. |
|
125 |
* |
|
126 |
* @return {@link TaskStatusSwingManager} |
|
127 |
*/ |
|
128 |
public static TaskStatusSwingManager getTaskStatusSwingManager() { |
|
129 |
return (TaskStatusSwingManager) getInstance().get( |
|
130 |
TASKSTATUS_SWING_MANAGER_NAME); |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Registers the Class implementing the {@link TaskStatusSwingManager} |
|
135 |
* interface. |
|
136 |
* |
|
137 |
* @param clazz |
|
138 |
* implementing the {@link TaskStatusSwingManager} interface |
|
139 |
*/ |
|
140 |
public static void registerTaskStatusSwingManager( |
|
141 |
Class<? extends TaskStatusSwingManager> clazz) { |
|
142 |
getInstance().register(TASKSTATUS_SWING_MANAGER_NAME, |
|
143 |
TASKSTATUS_SWING_MANAGER_DESCRIPTION, clazz); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Gets the instance of the {@link WindowManager} registered. |
|
148 |
* |
|
149 |
* @return {@link WindowManager} |
|
150 |
*/ |
|
151 |
public static WindowManager getWindowManager() { |
|
152 |
return (WindowManager) getInstance().get( |
|
153 |
WINDOW_MANAGER_NAME); |
|
154 |
} |
|
155 |
|
|
156 |
/** |
|
157 |
* Registers the Class implementing the {@link WindowManager} |
|
158 |
* interface. |
|
159 |
* |
|
160 |
* @param clazz |
|
161 |
* implementing the {@link WindowManager} interface |
|
162 |
*/ |
|
163 |
public static void registerWindowManager( |
|
164 |
Class<? extends WindowManager> clazz) { |
|
165 |
getInstance().register(WINDOW_MANAGER_NAME, |
|
166 |
WINDOW_MANAGER_DESCRIPTION, clazz); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Gets the instance of the {@link IconThemeManager} registered. |
|
171 |
* |
|
172 |
* @return {@link IconThemeManager} |
|
173 |
*/ |
|
174 |
public static IconThemeManager getIconThemeManager() { |
|
175 |
return (IconThemeManager) getInstance().get( |
|
176 |
ICONTHEME_MANAGER_NAME); |
|
177 |
} |
|
178 |
|
|
179 |
/** |
|
180 |
* Registers the Class implementing the {@link IconThemeManager} |
|
181 |
* interface. |
|
182 |
* |
|
183 |
* @param clazz |
|
184 |
* implementing the {@link IconThemeManager} interface |
|
185 |
*/ |
|
186 |
public static void registerIconThemeManager( |
|
187 |
Class<? extends IconThemeManager> clazz) { |
|
188 |
getInstance().register(ICONTHEME_MANAGER_NAME, |
|
189 |
ICONTHEME_MANAGER_DESCRIPTION, clazz); |
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* Gets the instance of the {@link ComponentSwingManager} registered. |
|
194 |
* |
|
195 |
* @return {@link ComponentSwingManager} |
|
196 |
*/ |
|
197 |
public static ComponentSwingManager getComponentSwingManager() { |
|
198 |
return (ComponentSwingManager) getInstance().get( |
|
199 |
COMPONENT_SWING_MANAGER_NAME); |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* Registers the Class implementing the {@link ComponentSwingManager} |
|
204 |
* interface. |
|
205 |
* |
|
206 |
* @param clazz |
|
207 |
* implementing the {@link ComponentSwingManager} interface |
|
208 |
*/ |
|
209 |
public static void registerComponentSwingManager( |
|
210 |
Class<? extends ComponentSwingManager> clazz) { |
|
211 |
getInstance().register( |
|
212 |
COMPONENT_SWING_MANAGER_NAME, |
|
213 |
COMPONENT_SWING_MANAGER_DESCRIPTION, clazz); |
|
214 |
} |
|
215 |
|
|
216 |
|
|
217 |
/** |
|
218 |
* Gets the instance of the {@link ThreadSafeDialogsManager} registered. |
|
219 |
* |
|
220 |
* @return {@link ThreadSafeDialogsManager} |
|
221 |
*/ |
|
222 |
public static ThreadSafeDialogsManager getThreadSafeDialogsManager() { |
|
223 |
return (ThreadSafeDialogsManager) getInstance().get( |
|
224 |
THREADSAFEDIALOGS_MANAGER_NAME); |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Registers the Class implementing the {@link ThreadSafeDialogsManager} |
|
229 |
* interface. |
|
230 |
* |
|
231 |
* @param clazz |
|
232 |
* implementing the {@link ThreadSafeDialogsManager} interface |
|
233 |
*/ |
|
234 |
public static void registerThreadSafeDialogsManager( |
|
235 |
Class<? extends ThreadSafeDialogsManager> clazz) { |
|
236 |
getInstance().register(THREADSAFEDIALOGS_MANAGER_NAME, |
|
237 |
THREADSAFEDIALOGS_MANAGER_DESCRIPTION, clazz); |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Gets the instance of the {@link ToolsSwingManager} registered. |
|
242 |
* |
|
243 |
* @return {@link ToolsSwingManager} |
|
244 |
*/ |
|
245 |
public static ToolsSwingManager getToolsSwingManager() { |
|
246 |
return (ToolsSwingManager) getInstance().get( |
|
247 |
SWING_MANAGER_NAME); |
|
248 |
} |
|
249 |
|
|
250 |
/** |
|
251 |
* Registers the Class implementing the {@link ToolsSwingManager} |
|
252 |
* interface. |
|
253 |
* |
|
254 |
* @param clazz |
|
255 |
* implementing the {@link ToolsSwingManager} interface |
|
256 |
*/ |
|
257 |
public static void registerToolsSwingManager( |
|
258 |
Class<? extends ToolsSwingManager> clazz) { |
|
259 |
getInstance().register(SWING_MANAGER_NAME, |
|
260 |
SWING_MANAGER_DESCRIPTION, clazz); |
|
261 |
} |
|
262 |
|
|
263 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/ToolsSwingLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.ToolsLibrary; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
30 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
|
31 |
|
|
32 |
/** |
|
33 |
* Initialization of the Tools swing library. |
|
34 |
* |
|
35 |
* @author 2010- C?sar Ordi?ana - gvSIG team |
|
36 |
*/ |
|
37 |
public class ToolsSwingLibrary extends AbstractLibrary { |
|
38 |
|
|
39 |
@Override |
|
40 |
public void doRegistration() { |
|
41 |
super.doRegistration(); |
|
42 |
registerAsAPI(ToolsSwingLibrary.class); |
|
43 |
require(ToolsLibrary.class); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void doInitialize() throws LibraryException { |
|
48 |
// Do nothing |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doPostInitialize() throws LibraryException { |
|
53 |
|
|
54 |
// Validates if there is any UsabilitySwingManager implementation |
|
55 |
// registered. |
|
56 |
UsabilitySwingManager usabilitySwingManager = |
|
57 |
ToolsSwingLocator.getUsabilitySwingManager(); |
|
58 |
|
|
59 |
if (usabilitySwingManager == null) { |
|
60 |
throw new ReferenceNotRegisteredException( |
|
61 |
ToolsSwingLocator.USABILITY_SWING_MANAGER_NAME, |
|
62 |
ToolsSwingLocator.getInstance()); |
|
63 |
} |
|
64 |
} |
|
65 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/ActionListenerSupport.java | ||
---|---|---|
1 |
package org.gvsig.tools.swing.api; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.awt.event.ActionListener; |
|
5 |
|
|
6 |
public interface ActionListenerSupport { |
|
7 |
|
|
8 |
public void addActionListener(ActionListener listener); |
|
9 |
|
|
10 |
public ActionListener[] getActionListeners(); |
|
11 |
|
|
12 |
public void removeActionListener(ActionListener listener); |
|
13 |
|
|
14 |
public void removeAllActionListener(); |
|
15 |
|
|
16 |
public void fireActionEvent(ActionEvent event); |
|
17 |
|
|
18 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/Component.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api; |
|
25 |
|
|
26 |
import javax.swing.JComponent; |
|
27 |
|
|
28 |
/** |
|
29 |
* Interface for components that allows to define interfaces for them, as |
|
30 |
* otherwise JComponent is a class and you cannot extend it with an interface. |
|
31 |
* |
|
32 |
* @author gvSIG team |
|
33 |
* @version $Id$ |
|
34 |
*/ |
|
35 |
public interface Component { |
|
36 |
|
|
37 |
/** |
|
38 |
* Returns this component as a swing {@link JComponent}. |
|
39 |
* |
|
40 |
* @return a {@link JComponent} |
|
41 |
*/ |
|
42 |
public JComponent asJComponent(); |
|
43 |
|
|
44 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/evaluator/ComponentSwingManager.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2013 gvSIG Association |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.tools.swing.api.evaluator; |
|
24 |
|
|
25 |
import org.gvsig.tools.dynobject.DynClass; |
|
26 |
import org.gvsig.tools.evaluator.EvaluatorWithDescriptions; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* This manager will provide useful Swing-based components |
|
32 |
* which can be re-used in different parts of the application |
|
33 |
* (for example, a panel to form an expression, a panel to preview |
|
34 |
* and select something, etc) |
|
35 |
* |
|
36 |
* |
|
37 |
* |
|
38 |
* @author jldominguez |
|
39 |
* |
|
40 |
*/ |
|
41 |
public interface ComponentSwingManager { |
|
42 |
|
|
43 |
public EvaluatorPanel getEvaluatorPanel( |
|
44 |
DynClass dclass, EvaluatorWithDescriptions evaluator); |
|
45 |
|
|
46 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/evaluator/EvaluatorPanel.java | ||
---|---|---|
1 |
/* gvSIG. Desktop Geographic Information System. |
|
2 |
* |
|
3 |
* Copyright ? 2007-2013 gvSIG Association |
|
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., 51 Franklin Street, Fifth Floor, Boston, |
|
18 |
* MA 02110-1301, USA. |
|
19 |
* |
|
20 |
* For any additional information, do not hesitate to contact us |
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
22 |
*/ |
|
23 |
package org.gvsig.tools.swing.api.evaluator; |
|
24 |
|
|
25 |
import javax.swing.JPanel; |
|
26 |
|
|
27 |
import org.gvsig.tools.dynobject.DynClass; |
|
28 |
import org.gvsig.tools.evaluator.EvaluatorWithDescriptions; |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* @author jldominguez |
|
33 |
* |
|
34 |
*/ |
|
35 |
public abstract class EvaluatorPanel extends JPanel { |
|
36 |
|
|
37 |
public abstract void initialize(DynClass dclass, EvaluatorWithDescriptions evaluator); |
|
38 |
public abstract String getExpression(); |
|
39 |
|
|
40 |
} |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/task/JTasksStatus.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api.task; |
|
25 |
|
|
26 |
import javax.swing.JPanel; |
|
27 |
|
|
28 |
import org.gvsig.tools.swing.api.Component; |
|
29 |
import org.gvsig.tools.task.TaskStatusManager; |
|
30 |
|
|
31 |
public abstract class JTasksStatus extends JPanel implements Component { |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
*/ |
|
36 |
private static final long serialVersionUID = 2543254823980497949L; |
|
37 |
|
|
38 |
public abstract void bind(TaskStatusManager manager); |
|
39 |
|
|
40 |
} |
|
0 | 41 |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/task/TaskStatusSwingManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api.task; |
|
25 |
|
|
26 |
import org.gvsig.tools.task.TaskStatusManager; |
|
27 |
|
|
28 |
public interface TaskStatusSwingManager { |
|
29 |
|
|
30 |
public JTasksStatus createJTasksStatus(); |
|
31 |
|
|
32 |
public JTasksStatus createJTasksStatus(TaskStatusManager manager); |
|
33 |
|
|
34 |
public JTaskStatus createJTaskStatus(); |
|
35 |
|
|
36 |
public JTasksStatusList createJTasksStatusList(TaskStatusManager manager); |
|
37 |
} |
|
0 | 38 |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/task/JTasksStatusList.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api.task; |
|
25 |
|
|
26 |
import javax.swing.JPanel; |
|
27 |
|
|
28 |
import org.gvsig.tools.task.TaskStatusManager; |
|
29 |
|
|
30 |
public abstract class JTasksStatusList extends JPanel { |
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
*/ |
|
35 |
private static final long serialVersionUID = -2712653249045541115L; |
|
36 |
|
|
37 |
public abstract TaskStatusManager getManager(); |
|
38 |
|
|
39 |
} |
|
40 |
|
|
0 | 41 |
org.gvsig.tools/library/tags/org.gvsig.tools-3.0.73/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/task/JTaskStatus.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 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.tools.swing.api.task; |
|
25 |
|
|
26 |
import javax.swing.JPanel; |
|
27 |
|
|
28 |
import org.gvsig.tools.swing.api.Component; |
|
29 |
import org.gvsig.tools.task.TaskStatus; |
|
30 |
|
|
31 |
public abstract class JTaskStatus extends JPanel implements Component { |
|
32 |
|
|
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
*/ |
|
37 |
private static final long serialVersionUID = -6606077362610993539L; |
|
38 |
|
|
39 |
public abstract void bind(TaskStatus taskStatus); |
|
40 |
|
|
41 |
public abstract boolean getShowCancelButton() ; |
|
42 |
|
|
43 |
public abstract void setShowCancelButton(boolean showCancelButton); |
|
44 |
|
|
45 |
public abstract boolean getShowRemoveTaskButton(); |
Also available in: Unified diff