gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.swing / org.gvsig.tools.swing.impl / src / main / java / org / gvsig / tools / swing / impl / DefaultToolsSwingManager.java @ 2847
History | View | Annotate | Download (27.7 KB)
1 |
package org.gvsig.tools.swing.impl; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Component; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.event.ActionListener; |
7 |
import java.awt.image.BufferedImage; |
8 |
import java.awt.image.WritableRaster; |
9 |
import java.io.File; |
10 |
import java.lang.reflect.InvocationTargetException; |
11 |
import java.lang.reflect.Method; |
12 |
import java.sql.Time; |
13 |
import javax.swing.AbstractButton; |
14 |
import javax.swing.ComboBoxModel; |
15 |
import javax.swing.Icon; |
16 |
import javax.swing.ImageIcon; |
17 |
import javax.swing.JButton; |
18 |
import javax.swing.JComboBox; |
19 |
import javax.swing.JComponent; |
20 |
import javax.swing.JLabel; |
21 |
import javax.swing.JList; |
22 |
import javax.swing.JOptionPane; |
23 |
import javax.swing.JScrollPane; |
24 |
import javax.swing.JSlider; |
25 |
import javax.swing.JSpinner; |
26 |
import javax.swing.JTabbedPane; |
27 |
import javax.swing.JTable; |
28 |
import javax.swing.JTree; |
29 |
import javax.swing.JViewport; |
30 |
import javax.swing.border.TitledBorder; |
31 |
import javax.swing.table.TableModel; |
32 |
import javax.swing.text.JTextComponent; |
33 |
import javax.swing.tree.TreeModel; |
34 |
import org.apache.commons.lang3.StringUtils; |
35 |
import org.gvsig.tools.ToolsLocator; |
36 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
37 |
import org.gvsig.tools.bookmarksandhistory.History; |
38 |
import org.gvsig.tools.i18n.I18nManager; |
39 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
40 |
import org.gvsig.tools.swing.api.ChangeListenerHelper; |
41 |
import org.gvsig.tools.swing.api.ColorChooserController; |
42 |
import org.gvsig.tools.swing.api.CompoundIcon; |
43 |
import org.gvsig.tools.swing.api.DropDown; |
44 |
import org.gvsig.tools.swing.api.FilteredListController; |
45 |
import org.gvsig.tools.swing.api.FilteredListModel; |
46 |
import org.gvsig.tools.swing.api.FilteredTableModel; |
47 |
import org.gvsig.tools.swing.api.FilteredTreeController; |
48 |
import org.gvsig.tools.swing.api.FilteredTreeModel; |
49 |
import org.gvsig.tools.swing.api.JListWithCheckbox; |
50 |
import org.gvsig.tools.swing.api.JWebBrowser; |
51 |
import org.gvsig.tools.swing.api.JWebBrowserFactory; |
52 |
import org.gvsig.tools.swing.api.MessageBarController; |
53 |
import org.gvsig.tools.swing.api.SimpleImage; |
54 |
import org.gvsig.tools.swing.api.TableColumnAdjuster; |
55 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
56 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
57 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
58 |
import org.gvsig.tools.swing.api.bookmarkshistory.ComponentWithHistoryAndBookmarkController; |
59 |
import org.gvsig.tools.swing.api.bookmarkshistory.HistoryController; |
60 |
import org.gvsig.tools.swing.api.bookmarkshistory.TextFieldWithHistoryAndBookmarkController; |
61 |
import org.gvsig.tools.swing.api.pickercontroller.CharsetPickerController; |
62 |
import org.gvsig.tools.swing.api.pickercontroller.ColorPickerController; |
63 |
import org.gvsig.tools.swing.api.pickercontroller.DataTypePickerController; |
64 |
import org.gvsig.tools.swing.api.pickercontroller.DatePickerController; |
65 |
import org.gvsig.tools.swing.api.pickercontroller.FilePickerController; |
66 |
import org.gvsig.tools.swing.api.pickercontroller.FolderPickerController; |
67 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
68 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
69 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
70 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
71 |
import org.gvsig.tools.swing.impl.bookmarkshistory.ComboBoxWithHistoryAndBookmarkControllerImpl; |
72 |
import org.gvsig.tools.swing.impl.bookmarkshistory.DefaultBookmarksController; |
73 |
import org.gvsig.tools.swing.impl.bookmarkshistory.DefaultHistoryController; |
74 |
import org.gvsig.tools.swing.impl.bookmarkshistory.TextFieldWithHistoryAndBookmarkControllerImpl; |
75 |
import org.gvsig.tools.swing.impl.bufferedImage.VirtualBufferedImageHelper; |
76 |
import org.gvsig.tools.swing.impl.bufferedImage.VirtualBufferedImageHelper.VirtualDataBuffer; |
77 |
import org.gvsig.tools.swing.impl.pickercontroller.BytearrayPickerControllerImpl; |
78 |
import org.gvsig.tools.swing.impl.pickercontroller.CharsetPickerControllerImpl; |
79 |
import org.gvsig.tools.swing.impl.pickercontroller.ColorPickerControllerImpl; |
80 |
import org.gvsig.tools.swing.impl.pickercontroller.DataTypePickerControllerImpl; |
81 |
import org.gvsig.tools.swing.impl.pickercontroller.DatePickerControllerImpl; |
82 |
import org.gvsig.tools.swing.impl.pickercontroller.FilePickerControllerImpl; |
83 |
import org.gvsig.tools.swing.impl.pickercontroller.FolderPickerControllerImpl; |
84 |
import org.gvsig.tools.swing.impl.pickercontroller.nullablespinner.NullableSpinnerUtils; |
85 |
|
86 |
@SuppressWarnings("UseSpecificCatch") |
87 |
public class DefaultToolsSwingManager implements ToolsSwingManager { |
88 |
|
89 |
private Dimension maxPhysicalSizeOfBufferedImage; |
90 |
private JWebBrowserFactory webBrowserfactory;
|
91 |
private Color warningBackgroundColor = new Color(255,225,232); |
92 |
|
93 |
@Override
|
94 |
public void setWarningBackgroundColor(Color warningBackgroundColor) { |
95 |
this.warningBackgroundColor = warningBackgroundColor;
|
96 |
} |
97 |
|
98 |
@Override
|
99 |
public Color getWarningBackgroundColor() { |
100 |
return this.warningBackgroundColor; |
101 |
} |
102 |
|
103 |
@Override
|
104 |
public ActionListenerSupport createActionListenerSupport() {
|
105 |
return new DefaultActionListenerSupport(); |
106 |
} |
107 |
|
108 |
@Override
|
109 |
public JListWithCheckbox createJListWithCheckbox(JList wrappedList) { |
110 |
return new DefaultJListWithCheckbox(wrappedList); |
111 |
} |
112 |
|
113 |
@Override
|
114 |
public void setTreeModel(JComboBox comboBox, TreeModel aTreeModel) { |
115 |
TreeComboUtils.setTreeModel(comboBox, aTreeModel); |
116 |
} |
117 |
|
118 |
@Override
|
119 |
public ComboBoxModel createComboBoxModel(TreeModel treeModel) { |
120 |
return TreeComboUtils.createComboBoxModel(treeModel);
|
121 |
} |
122 |
|
123 |
@Override
|
124 |
public BufferedImage createBufferedImage(int w, int h, int type) { |
125 |
if (getMaxPhysicalSizeOfBufferedImage().getWidth() < w || getMaxPhysicalSizeOfBufferedImage().getHeight() < h) {
|
126 |
return createVirtualBufferedImage(w, h, type);
|
127 |
} |
128 |
return new BufferedImage(w, h, type); |
129 |
} |
130 |
|
131 |
@Override
|
132 |
public BufferedImage createVirtualBufferedImage(int w, int h, int type) { |
133 |
return VirtualBufferedImageHelper.createVirtualBufferedImage(w, h, type);
|
134 |
} |
135 |
|
136 |
@Override
|
137 |
public BufferedImage copyBufferedImage(BufferedImage img) { |
138 |
WritableRaster sourceRaster = img.getRaster();
|
139 |
|
140 |
BufferedImage newImage;
|
141 |
if (sourceRaster.getDataBuffer() instanceof VirtualDataBuffer) { |
142 |
newImage = VirtualBufferedImageHelper.createVirtualBufferedImage( |
143 |
img.getWidth(), |
144 |
img.getHeight(), |
145 |
img.getSampleModel(), |
146 |
img.getColorModel() |
147 |
); |
148 |
} else {
|
149 |
newImage = createBufferedImage(img.getWidth(), img.getHeight(), img.getType()); |
150 |
} |
151 |
|
152 |
WritableRaster raster = newImage.getRaster();
|
153 |
img.copyData(raster); |
154 |
return newImage;
|
155 |
} |
156 |
|
157 |
@Override
|
158 |
public void setMaxPhysicalSizeOfBufferedImage(Dimension dimension) { |
159 |
this.maxPhysicalSizeOfBufferedImage = dimension;
|
160 |
} |
161 |
|
162 |
@Override
|
163 |
public Dimension getMaxPhysicalSizeOfBufferedImage() { |
164 |
if (this.maxPhysicalSizeOfBufferedImage == null) { |
165 |
this.maxPhysicalSizeOfBufferedImage = new Dimension(2000, 2000); |
166 |
} |
167 |
return this.maxPhysicalSizeOfBufferedImage; |
168 |
} |
169 |
|
170 |
@Override
|
171 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
172 |
return new DefaultColorChooserController(txtLabel, btnShowDialog, sldAlpha, allowNull); |
173 |
} |
174 |
|
175 |
@Override
|
176 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog) { |
177 |
return new DefaultColorChooserController(txtLabel, btnShowDialog); |
178 |
} |
179 |
|
180 |
@Override
|
181 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
182 |
return new DefaultColorChooserController(txtLabel, btnShowDialog, sldAlpha); |
183 |
} |
184 |
|
185 |
@Override
|
186 |
public Color alphaBlendingWithOpaqueBackground(Color bgColor, Color fgColor) { |
187 |
// https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
|
188 |
Color src = fgColor;
|
189 |
Color dst = bgColor;
|
190 |
|
191 |
// double outa = 1;
|
192 |
double srca = src.getAlpha() / 255.0; |
193 |
double srca_1 = (1 - srca); |
194 |
|
195 |
Color color = new Color( |
196 |
(int) (src.getRed() * srca + dst.getRed() * srca_1) & 0xff, |
197 |
(int) (src.getGreen() * srca + dst.getGreen() * srca_1) & 0xff, |
198 |
(int) (src.getBlue() * srca + dst.getBlue() * srca_1) & 0xff |
199 |
); |
200 |
return color;
|
201 |
} |
202 |
|
203 |
@Override
|
204 |
public Color opaqueColor(Color src) { |
205 |
// https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
|
206 |
double srca = src.getAlpha() / 255.0; |
207 |
double srca_1 = (1 - srca); |
208 |
|
209 |
Color color = new Color( |
210 |
(int) (src.getRed() * srca + 255 * srca_1) & 0xff, |
211 |
(int) (src.getGreen() * srca + 255 * srca_1) & 0xff, |
212 |
(int) (src.getBlue() * srca + 255 * srca_1) & 0xff |
213 |
); |
214 |
return color;
|
215 |
} |
216 |
|
217 |
private Object call(Object obj, String name, Object... params) { |
218 |
Class[] types = null; |
219 |
if (params != null) { |
220 |
types = new Class[params.length]; |
221 |
for (int i = 0; i < params.length; i++) { |
222 |
types[i] = params[i].getClass(); |
223 |
} |
224 |
} |
225 |
Method method;
|
226 |
try {
|
227 |
method = obj.getClass().getMethod(name, types); |
228 |
Object r = method.invoke(obj, params);
|
229 |
return r;
|
230 |
} catch (NoSuchMethodException |
231 |
| SecurityException
|
232 |
| IllegalAccessException
|
233 |
| IllegalArgumentException
|
234 |
| InvocationTargetException ex) {
|
235 |
} |
236 |
return null; |
237 |
} |
238 |
|
239 |
@Override
|
240 |
public void translate(JComponent component) { |
241 |
this.translate(component,false); |
242 |
} |
243 |
|
244 |
@Override
|
245 |
public void translate(AbstractButton component) { |
246 |
this.translate(component,false); |
247 |
} |
248 |
|
249 |
@Override
|
250 |
public void translate(JLabel component) { |
251 |
this.translate(component,false); |
252 |
} |
253 |
|
254 |
@Override
|
255 |
public void translate(JTabbedPane component) { |
256 |
this.translate(component,false); |
257 |
} |
258 |
|
259 |
@Override
|
260 |
public void translate(JComponent component, boolean wrap) { |
261 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
262 |
String text = (String) call(component, "getText", (Object[]) null); |
263 |
if (!StringUtils.isBlank(text)) {
|
264 |
text = i18n.getTranslation(text); |
265 |
if( wrap ) {
|
266 |
text = toHTML(text); |
267 |
} |
268 |
call(component, "setText", text);
|
269 |
} |
270 |
text = (String) call(component, "getToolTipText", (Object[]) null); |
271 |
if (!StringUtils.isEmpty(text)) {
|
272 |
text = i18n.getTranslation(text); |
273 |
call(component, "setToolTipText", toHTML(text));
|
274 |
} |
275 |
} |
276 |
|
277 |
@Override
|
278 |
public void translate(AbstractButton component, boolean wrap) { |
279 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
280 |
String text= component.getText();
|
281 |
if (!StringUtils.isBlank(text)) {
|
282 |
text = i18n.getTranslation(text); |
283 |
if( wrap ) {
|
284 |
text = toHTML(text); |
285 |
} |
286 |
component.setText(text); |
287 |
} |
288 |
text = component.getToolTipText(); |
289 |
if (!StringUtils.isBlank(text)) {
|
290 |
text = i18n.getTranslation(text); |
291 |
component.setToolTipText(toHTML(text)); |
292 |
} |
293 |
} |
294 |
|
295 |
@Override
|
296 |
public void translate(JLabel component, boolean wrap) { |
297 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
298 |
String text = component.getText();
|
299 |
if (!StringUtils.isBlank(text)) {
|
300 |
text = i18n.getTranslation(text); |
301 |
if( wrap ) {
|
302 |
text = toHTML(text); |
303 |
} |
304 |
component.setText(text); |
305 |
} |
306 |
text = component.getToolTipText(); |
307 |
if (!StringUtils.isBlank(text)) {
|
308 |
text = i18n.getTranslation(text); |
309 |
component.setToolTipText(toHTML(text)); |
310 |
} |
311 |
} |
312 |
|
313 |
@Override
|
314 |
public void translate(JTabbedPane component, boolean wrap) { |
315 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
316 |
|
317 |
for (int i = 0; i < component.getTabCount(); i++) { |
318 |
String text = component.getTitleAt(i);
|
319 |
if (!StringUtils.isBlank(text)) {
|
320 |
text = i18n.getTranslation(text); |
321 |
if( wrap ) {
|
322 |
text = toHTML(text); |
323 |
} |
324 |
component.setTitleAt(i, text); |
325 |
} |
326 |
text = component.getToolTipTextAt(i); |
327 |
if (!StringUtils.isBlank(text)) {
|
328 |
text = i18n.getTranslation(text); |
329 |
component.setToolTipTextAt(i, toHTML(text)); |
330 |
} |
331 |
} |
332 |
} |
333 |
|
334 |
public static String toHTML(String s) { |
335 |
s = StringUtils.replace(s, "\n", "<br>"); |
336 |
s = StringUtils.replace(s, "<html>", ""); |
337 |
s = StringUtils.replace(s, "</html>", ""); |
338 |
s = "<html>"+s+"</html>"; |
339 |
return s;
|
340 |
} |
341 |
|
342 |
@Override
|
343 |
public void setDefaultPopupMenu(final JTextComponent component) { |
344 |
ContextMenuUtils.setDefaultContextMenu(component); |
345 |
} |
346 |
|
347 |
@Override
|
348 |
public void setDefaultPopupMenu(final JTextComponent component, String title) { |
349 |
ContextMenuUtils.setDefaultContextMenu(component, title); |
350 |
} |
351 |
|
352 |
@Override
|
353 |
public void setDefaultPopupMenu(JComboBox component) { |
354 |
ContextMenuUtils.setDefaultContextMenu(component); |
355 |
} |
356 |
|
357 |
@Override
|
358 |
public void setDefaultPopupMenu(JComboBox component, String title) { |
359 |
ContextMenuUtils.setDefaultContextMenu(component, title); |
360 |
} |
361 |
|
362 |
@Override
|
363 |
public ChangeListenerHelper createChangeListenerHelper() {
|
364 |
DefaultChangeListenerHelper x = new DefaultChangeListenerHelper();
|
365 |
return x;
|
366 |
} |
367 |
|
368 |
@Override
|
369 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
370 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog, sldAlpha, allowNull); |
371 |
} |
372 |
|
373 |
@Override
|
374 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog) { |
375 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog); |
376 |
} |
377 |
|
378 |
@Override
|
379 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
380 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog, sldAlpha); |
381 |
} |
382 |
|
383 |
@Override
|
384 |
public DatePickerController createDatePickerController(JTextComponent txtDate, JButton btnDate) { |
385 |
return new DatePickerControllerImpl(txtDate, btnDate); |
386 |
} |
387 |
|
388 |
@Override
|
389 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) { |
390 |
return new FilePickerControllerImpl(txtFile, btnFile, dialogTitle, fileChooserID, initialPath, seticon); |
391 |
} |
392 |
|
393 |
@Override
|
394 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile) { |
395 |
return new FilePickerControllerImpl(txtFile, btnFile); |
396 |
} |
397 |
|
398 |
@Override
|
399 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload, JButton btnEditAsText, String fileChooserID, File initialPath) { |
400 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, btnEditAsText, fileChooserID, initialPath); |
401 |
} |
402 |
|
403 |
@Override
|
404 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload, String fileChooserID, File initialPath) { |
405 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, null, fileChooserID, initialPath); |
406 |
} |
407 |
|
408 |
@Override
|
409 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload) { |
410 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, null, null, null); |
411 |
} |
412 |
|
413 |
@Override
|
414 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle) { |
415 |
return new FilePickerControllerImpl(txtFile, btnFile, dialogTitle); |
416 |
} |
417 |
|
418 |
@Override
|
419 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) { |
420 |
return new FolderPickerControllerImpl(txtFile, btnFile, dialogTitle, fileChooserID, initialPath, seticon); |
421 |
} |
422 |
|
423 |
@Override
|
424 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile) { |
425 |
return new FolderPickerControllerImpl(txtFile, btnFile); |
426 |
} |
427 |
|
428 |
@Override
|
429 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle) { |
430 |
return new FolderPickerControllerImpl(txtFile, btnFile, dialogTitle); |
431 |
} |
432 |
|
433 |
public CharsetPickerController createCharsetPickerController(JLabel lblCharset, JComboBox cboCharset) { |
434 |
return new CharsetPickerControllerImpl(lblCharset, cboCharset); |
435 |
} |
436 |
|
437 |
@Override
|
438 |
public void removeBorder(JComponent component) { |
439 |
if( component == null ) { |
440 |
return;
|
441 |
} |
442 |
try {
|
443 |
component.setBorder(null);
|
444 |
JScrollPane scrollPanel = this.getJScrollPane(component); |
445 |
if( scrollPanel!=null ) { |
446 |
scrollPanel.setBorder(null);
|
447 |
} |
448 |
} catch (Exception ex) { |
449 |
|
450 |
} |
451 |
} |
452 |
|
453 |
@Override
|
454 |
public JScrollPane getJScrollPane(JComponent component) { |
455 |
try {
|
456 |
JComponent p1 = (JComponent) component.getParent(); |
457 |
if (p1 instanceof JViewport) { |
458 |
p1 = (JComponent) component.getParent();
|
459 |
} |
460 |
if (p1 instanceof JScrollPane) { |
461 |
return (JScrollPane) p1; |
462 |
} |
463 |
} catch (Exception ex) { |
464 |
|
465 |
} |
466 |
return null; |
467 |
} |
468 |
|
469 |
protected ImageIcon getIcon(String name) { |
470 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
471 |
IconTheme theme = iconThemeManager.getCurrent(); |
472 |
ImageIcon icon = theme.get(name);
|
473 |
return icon;
|
474 |
} |
475 |
|
476 |
@Override
|
477 |
public void addClearButton(JTextComponent text) { |
478 |
ClearButtonUtils.addClearButton(text, null);
|
479 |
} |
480 |
|
481 |
@Override
|
482 |
public void addClearButton(JComboBox combo) { |
483 |
ClearButtonUtils.addClearButton(combo); |
484 |
} |
485 |
|
486 |
@Override
|
487 |
public void addClearButton(JComboBox combo, ActionListener action) { |
488 |
ClearButtonUtils.addClearButton(combo, action); |
489 |
} |
490 |
|
491 |
|
492 |
|
493 |
@Override
|
494 |
public boolean hasClearButton(final JComboBox combo) { |
495 |
return ClearButtonUtils.hasClearButton(combo);
|
496 |
} |
497 |
|
498 |
@Override
|
499 |
public void removeClearButton(final JComboBox combo) { |
500 |
ClearButtonUtils.removeClearButton(combo); |
501 |
} |
502 |
|
503 |
@Override
|
504 |
public boolean hasClearButton(final JTextComponent text) { |
505 |
return ClearButtonUtils.hasClearButton(text);
|
506 |
} |
507 |
|
508 |
@Override
|
509 |
public void removeClearButton(final JTextComponent text) { |
510 |
ClearButtonUtils.removeClearButton(text); |
511 |
} |
512 |
|
513 |
@Override
|
514 |
public void addClearButton(final JTextComponent text, final ActionListener action) { |
515 |
ClearButtonUtils.addClearButton(text, action); |
516 |
} |
517 |
|
518 |
@Override
|
519 |
public String showZoomDialog(Component parent, String title, String text, boolean editable) { |
520 |
return showZoomDialog(parent, title, text, editable, WindowManager.MODE.DIALOG);
|
521 |
|
522 |
} |
523 |
@Override
|
524 |
public String showZoomDialog(Component parent, String title, String text, boolean editable, WindowManager.MODE mode) { |
525 |
DefaultZoomDialog dialog = new DefaultZoomDialog(parent, title, text, mode);
|
526 |
dialog.setEditable(editable); |
527 |
dialog.setAlwaysOnTop(true);
|
528 |
dialog.setVisible(true);
|
529 |
if (editable) {
|
530 |
return dialog.getText();
|
531 |
} |
532 |
return text;
|
533 |
} |
534 |
|
535 |
@Override
|
536 |
public SimpleImage createSimpleImage() {
|
537 |
SimpleImage x = new DefaultSimpleImage();
|
538 |
return x;
|
539 |
} |
540 |
|
541 |
@Override
|
542 |
public SimpleImage createSimpleImage(Object source) { |
543 |
if( source instanceof SimpleImage ) { |
544 |
return (SimpleImage) source;
|
545 |
} |
546 |
SimpleImage x = new DefaultSimpleImage(source);
|
547 |
return x;
|
548 |
} |
549 |
|
550 |
@Override
|
551 |
public DropDown createDropDown(JComboBox combo) { |
552 |
DropDown c = new DropDownComboBox(combo, this.getWarningBackgroundColor()); |
553 |
return c;
|
554 |
} |
555 |
|
556 |
@Override
|
557 |
public DropDown createDropDown(JLabel label) { |
558 |
DropDown c = new DropDownLabel(label, this.getWarningBackgroundColor()); |
559 |
return c;
|
560 |
} |
561 |
|
562 |
@Override
|
563 |
public DropDown createDropDown(AbstractButton button) { |
564 |
DropDown c = new DropDownButton(button, this.getWarningBackgroundColor()); |
565 |
return c;
|
566 |
} |
567 |
|
568 |
@Override
|
569 |
public DropDown createDropDown(JComponent component) { |
570 |
DropDown c = new DropDownLabel(component, this.getWarningBackgroundColor()); |
571 |
return c;
|
572 |
} |
573 |
|
574 |
@Override
|
575 |
public CompoundIcon createCompoundIcon(Icon... icons) { |
576 |
DefaultCompoundIcon i = new DefaultCompoundIcon(icons);
|
577 |
return i;
|
578 |
} |
579 |
|
580 |
@Override
|
581 |
public CompoundIcon createCompoundIcon(int orientation, Icon... icons) { |
582 |
DefaultCompoundIcon i = new DefaultCompoundIcon(orientation, icons);
|
583 |
return i;
|
584 |
} |
585 |
|
586 |
@Override
|
587 |
public CompoundIcon createCompoundIcon(int orientation, int gap, Icon... icons) { |
588 |
DefaultCompoundIcon i = new DefaultCompoundIcon(orientation, gap, icons);
|
589 |
return i;
|
590 |
} |
591 |
|
592 |
@Override
|
593 |
public CompoundIcon createCompoundIcon(int orientation, int gap, int alignmentX, int alignmentY, Icon... icons) { |
594 |
DefaultCompoundIcon i = new DefaultCompoundIcon(orientation, gap, alignmentX, alignmentY, icons);
|
595 |
return i;
|
596 |
} |
597 |
|
598 |
@Override
|
599 |
public BookmarksController createBookmarksController(Bookmarks bookmarks, JButton button) { |
600 |
BookmarksController controller; |
601 |
controller = new DefaultBookmarksController(bookmarks, button);
|
602 |
return controller;
|
603 |
} |
604 |
|
605 |
@Override
|
606 |
public HistoryController createHistoryController(History history, JButton button) { |
607 |
DefaultHistoryController controller; |
608 |
controller = new DefaultHistoryController(history, button);
|
609 |
return controller;
|
610 |
} |
611 |
|
612 |
@Override
|
613 |
public TextFieldWithHistoryAndBookmarkController createTextFieldWithHistoryAndBookmarkController(String name, JTextComponent text, JButton btnApply, JButton btnHistory, JButton btnBookmarks) { |
614 |
TextFieldWithHistoryAndBookmarkControllerImpl controller; |
615 |
controller = new TextFieldWithHistoryAndBookmarkControllerImpl(name, text, btnApply, btnHistory, btnBookmarks);
|
616 |
return controller;
|
617 |
} |
618 |
|
619 |
@Override
|
620 |
public ComponentWithHistoryAndBookmarkController createComboBoxWithHistoryAndBookmarkController(String name, JComboBox combo) { |
621 |
ComponentWithHistoryAndBookmarkController controller; |
622 |
controller = new ComboBoxWithHistoryAndBookmarkControllerImpl(name, combo);
|
623 |
return controller;
|
624 |
} |
625 |
|
626 |
@Override
|
627 |
public FilteredTableModel createFilteredTableModel(TableModel tableModel, int filterColumn) { |
628 |
FilteredTableModelImpl model = new FilteredTableModelImpl(tableModel, filterColumn);
|
629 |
return model;
|
630 |
} |
631 |
|
632 |
@Override
|
633 |
public JLabel createTitledSeparator(String title, int height, int titlePosition, int titleJustification) { |
634 |
TitledSeparator c = new TitledSeparator(title, height, titlePosition, titleJustification);
|
635 |
return c;
|
636 |
} |
637 |
|
638 |
@Override
|
639 |
public JLabel createTitledSeparator(String title) { |
640 |
TitledSeparator c = new TitledSeparator(
|
641 |
title, |
642 |
2,
|
643 |
TitledBorder.DEFAULT_POSITION,
|
644 |
TitledBorder.DEFAULT_JUSTIFICATION
|
645 |
); |
646 |
return c;
|
647 |
} |
648 |
|
649 |
@Override
|
650 |
public FilteredListModel createFilteredListModel() {
|
651 |
FilteredListModel model = new FilteredListModelImpl(null); |
652 |
return model;
|
653 |
} |
654 |
|
655 |
@Override
|
656 |
public FilteredTreeModel createFilteredTreeModel(JTree tree) { |
657 |
FilteredTreeModel model = new FilteredTreeModelImpl(tree.getModel());
|
658 |
return model;
|
659 |
} |
660 |
|
661 |
@Override
|
662 |
public FilteredListController createFilteredListController(JList list, JTextComponent text, JButton button) { |
663 |
FilteredListController flc = new DefaultFilteredListController(list, text, button);
|
664 |
return flc;
|
665 |
} |
666 |
|
667 |
@Override
|
668 |
public FilteredTreeController createFilteredTreeController(JTree list, JTextComponent text, JButton button) { |
669 |
FilteredTreeController ftc = new DefaultFilteredTreeController(list, text, button);
|
670 |
return ftc;
|
671 |
} |
672 |
|
673 |
@Override
|
674 |
public JWebBrowser createJWebBrowser() {
|
675 |
return this.webBrowserfactory.create(); |
676 |
} |
677 |
|
678 |
@Override
|
679 |
public void registerJWebBrowserFactory(JWebBrowserFactory factory) { |
680 |
this.webBrowserfactory = factory;
|
681 |
} |
682 |
|
683 |
public JWebBrowserFactory getJWebBrowserFactory() {
|
684 |
return this.webBrowserfactory; |
685 |
} |
686 |
|
687 |
@Override
|
688 |
public DataTypePickerController createDataTypePickerController(JComboBox cboDataType, JButton btnDataType, boolean allowNull) { |
689 |
return new DataTypePickerControllerImpl(cboDataType, btnDataType, allowNull); |
690 |
} |
691 |
|
692 |
@Override
|
693 |
public TableColumnAdjuster createTableColumnAdjuster(JTable table) { |
694 |
return TableColumnAdjusterImpl.install(table);
|
695 |
} |
696 |
|
697 |
@Override
|
698 |
public MessageBarController createMessageBarController(JLabel txtLabel, int timeDuration) { |
699 |
return new MessageBarControllerImpl(txtLabel, timeDuration); |
700 |
} |
701 |
|
702 |
@Override
|
703 |
public DropDown createDropDownIcon(JLabel lblNull) { |
704 |
|
705 |
return new DropDownLabelIcon(lblNull, this.getWarningBackgroundColor()); |
706 |
} |
707 |
|
708 |
@Override
|
709 |
public void putInClipboard(String data) { |
710 |
ClipboardMonitor.getMonitor().put(data); |
711 |
} |
712 |
|
713 |
@Override
|
714 |
public String getFromClipboard() { |
715 |
return ClipboardMonitor.getMonitor().getString();
|
716 |
} |
717 |
|
718 |
@Override
|
719 |
public boolean isClipboardEmpty() { |
720 |
return ClipboardMonitor.getMonitor().hasString();
|
721 |
} |
722 |
|
723 |
@Override
|
724 |
public void addClipboardObserver(java.util.Observer observer) { |
725 |
ClipboardMonitor.getMonitor().addObserver(observer); |
726 |
} |
727 |
|
728 |
@Override
|
729 |
public void deleteClipboardObserver(java.util.Observer observer) { |
730 |
ClipboardMonitor.getMonitor().deleteObserver(observer); |
731 |
} |
732 |
|
733 |
@Override
|
734 |
public JSpinner spinnerOfNumber(JSpinner spinner, Number value) { |
735 |
return NullableSpinnerUtils.ofNumber(spinner, value);
|
736 |
} |
737 |
|
738 |
@Override
|
739 |
public JSpinner spinnerOfNumber(JSpinner spinner, Class valueClass) { |
740 |
return NullableSpinnerUtils.ofNumber(spinner, valueClass);
|
741 |
} |
742 |
|
743 |
@Override
|
744 |
public JSpinner spinnerOfIntegers(JSpinner spinner, Integer value, int minimum, int maximum, int stepSize) { |
745 |
return NullableSpinnerUtils.ofIntegers(spinner, value, minimum, maximum, stepSize);
|
746 |
} |
747 |
|
748 |
@Override
|
749 |
public JSpinner spinnerOfTime(JSpinner spinner) { |
750 |
return NullableSpinnerUtils.ofTime(spinner);
|
751 |
} |
752 |
|
753 |
@Override
|
754 |
public JSpinner spinnerOfTime(JSpinner spinner, Time value) { |
755 |
return NullableSpinnerUtils.ofTime(spinner, value);
|
756 |
} |
757 |
|
758 |
@Override
|
759 |
public java.awt.Window findWindow(java.awt.Component c) {
|
760 |
if (c == null) { |
761 |
return JOptionPane.getRootFrame(); |
762 |
} else if (c instanceof java.awt.Window) { |
763 |
return (java.awt.Window) c;
|
764 |
} else {
|
765 |
return findWindow(c.getParent());
|
766 |
} |
767 |
} |
768 |
|
769 |
@Override
|
770 |
public boolean isModalDialogShowing() { |
771 |
java.awt.Window[] windows = java.awt.Window.getWindows();
|
772 |
if (windows != null) { // don't rely on current implementation, which at least returns [0]. |
773 |
for (java.awt.Window w : windows) {
|
774 |
if (w.isShowing() && w instanceof java.awt.Dialog && ((java.awt.Dialog) w).isModal()) { |
775 |
return true; |
776 |
} |
777 |
} |
778 |
} |
779 |
return false; |
780 |
} |
781 |
|
782 |
} |