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 @ 2035
History | View | Annotate | Download (22.5 KB)
1 |
package org.gvsig.tools.swing.impl; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Color; |
5 |
import java.awt.Cursor; |
6 |
import java.awt.Dimension; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.image.BufferedImage; |
10 |
import java.awt.image.WritableRaster; |
11 |
import java.beans.PropertyChangeEvent; |
12 |
import java.beans.PropertyChangeListener; |
13 |
import java.io.File; |
14 |
import java.lang.reflect.InvocationTargetException; |
15 |
import java.lang.reflect.Method; |
16 |
import javax.swing.AbstractAction; |
17 |
import javax.swing.AbstractButton; |
18 |
import javax.swing.Action; |
19 |
import javax.swing.ComboBoxModel; |
20 |
import javax.swing.Icon; |
21 |
import javax.swing.ImageIcon; |
22 |
import javax.swing.JButton; |
23 |
import javax.swing.JComboBox; |
24 |
import javax.swing.JComponent; |
25 |
import javax.swing.JLabel; |
26 |
import javax.swing.JList; |
27 |
import javax.swing.JMenuItem; |
28 |
import javax.swing.JPopupMenu; |
29 |
import javax.swing.JScrollPane; |
30 |
import javax.swing.JSlider; |
31 |
import javax.swing.JTabbedPane; |
32 |
import javax.swing.JTextField; |
33 |
import javax.swing.JViewport; |
34 |
import javax.swing.border.TitledBorder; |
35 |
import javax.swing.table.TableModel; |
36 |
import javax.swing.text.DefaultEditorKit; |
37 |
import javax.swing.text.JTextComponent; |
38 |
import javax.swing.tree.TreeModel; |
39 |
import org.apache.commons.lang3.StringUtils; |
40 |
import org.gvsig.tools.ToolsLocator; |
41 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
42 |
import org.gvsig.tools.bookmarksandhistory.History; |
43 |
import org.gvsig.tools.i18n.I18nManager; |
44 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
45 |
import org.gvsig.tools.swing.api.ChangeListenerHelper; |
46 |
import org.gvsig.tools.swing.api.ColorChooserController; |
47 |
import org.gvsig.tools.swing.api.CompoundIcon; |
48 |
import org.gvsig.tools.swing.api.DropDown; |
49 |
import org.gvsig.tools.swing.api.FilteredTableModel; |
50 |
import org.gvsig.tools.swing.api.JListWithCheckbox; |
51 |
import org.gvsig.tools.swing.api.SimpleImage; |
52 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
53 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
54 |
import org.gvsig.tools.swing.api.pickercontroller.ColorPickerController; |
55 |
import org.gvsig.tools.swing.api.pickercontroller.DatePickerController; |
56 |
import org.gvsig.tools.swing.api.pickercontroller.FilePickerController; |
57 |
import org.gvsig.tools.swing.api.pickercontroller.FolderPickerController; |
58 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
59 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
60 |
import org.gvsig.tools.swing.icontheme.IconThemeManager; |
61 |
import org.gvsig.tools.swing.impl.bufferedImage.VirtualBufferedImageHelper; |
62 |
import org.gvsig.tools.swing.impl.bufferedImage.VirtualBufferedImageHelper.VirtualDataBuffer; |
63 |
import org.gvsig.tools.swing.impl.pickercontroller.BytearrayPickerControllerImpl; |
64 |
import org.gvsig.tools.swing.impl.pickercontroller.ColorPickerControllerImpl; |
65 |
import org.gvsig.tools.swing.impl.pickercontroller.DatePickerControllerImpl; |
66 |
import org.gvsig.tools.swing.impl.pickercontroller.FilePickerControllerImpl; |
67 |
import org.gvsig.tools.swing.impl.pickercontroller.FolderPickerControllerImpl; |
68 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
69 |
import org.gvsig.tools.swing.api.bookmarkshistory.HistoryController; |
70 |
import org.gvsig.tools.swing.impl.bookmarkshistory.DefaultBookmarksController; |
71 |
import org.gvsig.tools.swing.impl.bookmarkshistory.DefaultHistoryController; |
72 |
|
73 |
public class DefaultToolsSwingManager implements ToolsSwingManager { |
74 |
|
75 |
private Dimension maxPhysicalSizeOfBufferedImage; |
76 |
|
77 |
@Override
|
78 |
public ActionListenerSupport createActionListenerSupport() {
|
79 |
return new DefaultActionListenerSupport(); |
80 |
} |
81 |
|
82 |
@Override
|
83 |
public JListWithCheckbox createJListWithCheckbox(JList wrappedList) { |
84 |
return new DefaultJListWithCheckbox(wrappedList); |
85 |
} |
86 |
|
87 |
@Override
|
88 |
public void setTreeModel(JComboBox comboBox, TreeModel aTreeModel) { |
89 |
TreeComboUtils.setTreeModel(comboBox, aTreeModel); |
90 |
} |
91 |
|
92 |
@Override
|
93 |
public ComboBoxModel createComboBoxModel(TreeModel treeModel) { |
94 |
return TreeComboUtils.createComboBoxModel(treeModel);
|
95 |
} |
96 |
|
97 |
@Override
|
98 |
public BufferedImage createBufferedImage(int w, int h, int type) { |
99 |
if (getMaxPhysicalSizeOfBufferedImage().getWidth() < w || getMaxPhysicalSizeOfBufferedImage().getHeight() < h) {
|
100 |
return createVirtualBufferedImage(w, h, type);
|
101 |
} |
102 |
return new BufferedImage(w, h, type); |
103 |
} |
104 |
|
105 |
@Override
|
106 |
public BufferedImage createVirtualBufferedImage(int w, int h, int type) { |
107 |
return VirtualBufferedImageHelper.createVirtualBufferedImage(w, h, type);
|
108 |
} |
109 |
|
110 |
@Override
|
111 |
public BufferedImage copyBufferedImage(BufferedImage img) { |
112 |
WritableRaster sourceRaster = img.getRaster();
|
113 |
|
114 |
BufferedImage newImage;
|
115 |
if (sourceRaster.getDataBuffer() instanceof VirtualDataBuffer) { |
116 |
newImage = VirtualBufferedImageHelper.createVirtualBufferedImage( |
117 |
img.getWidth(), |
118 |
img.getHeight(), |
119 |
img.getSampleModel(), |
120 |
img.getColorModel() |
121 |
); |
122 |
} else {
|
123 |
newImage = createBufferedImage(img.getWidth(), img.getHeight(), img.getType()); |
124 |
} |
125 |
|
126 |
WritableRaster raster = newImage.getRaster();
|
127 |
img.copyData(raster); |
128 |
return newImage;
|
129 |
} |
130 |
|
131 |
@Override
|
132 |
public void setMaxPhysicalSizeOfBufferedImage(Dimension dimension) { |
133 |
this.maxPhysicalSizeOfBufferedImage = dimension;
|
134 |
} |
135 |
|
136 |
@Override
|
137 |
public Dimension getMaxPhysicalSizeOfBufferedImage() { |
138 |
if (this.maxPhysicalSizeOfBufferedImage == null) { |
139 |
this.maxPhysicalSizeOfBufferedImage = new Dimension(2000, 2000); |
140 |
} |
141 |
return this.maxPhysicalSizeOfBufferedImage; |
142 |
} |
143 |
|
144 |
@Override
|
145 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
146 |
return new DefaultColorChooserController(txtLabel, btnShowDialog, sldAlpha, allowNull); |
147 |
} |
148 |
|
149 |
@Override
|
150 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog) { |
151 |
return new DefaultColorChooserController(txtLabel, btnShowDialog); |
152 |
} |
153 |
|
154 |
@Override
|
155 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
156 |
return new DefaultColorChooserController(txtLabel, btnShowDialog, sldAlpha); |
157 |
} |
158 |
|
159 |
@Override
|
160 |
public Color alphaBlendingWithOpaqueBackground(Color bgColor, Color fgColor) { |
161 |
// https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
|
162 |
Color src = fgColor;
|
163 |
Color dst = bgColor;
|
164 |
|
165 |
// double outa = 1;
|
166 |
double srca = src.getAlpha() / 255.0; |
167 |
double srca_1 = (1 - srca); |
168 |
|
169 |
Color color = new Color( |
170 |
(int) (src.getRed() * srca + dst.getRed() * srca_1) & 0xff, |
171 |
(int) (src.getGreen() * srca + dst.getGreen() * srca_1) & 0xff, |
172 |
(int) (src.getBlue() * srca + dst.getBlue() * srca_1) & 0xff |
173 |
); |
174 |
return color;
|
175 |
} |
176 |
|
177 |
@Override
|
178 |
public Color opaqueColor(Color src) { |
179 |
// https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending
|
180 |
double srca = src.getAlpha() / 255.0; |
181 |
double srca_1 = (1 - srca); |
182 |
|
183 |
Color color = new Color( |
184 |
(int) (src.getRed() * srca + 255 * srca_1) & 0xff, |
185 |
(int) (src.getGreen() * srca + 255 * srca_1) & 0xff, |
186 |
(int) (src.getBlue() * srca + 255 * srca_1) & 0xff |
187 |
); |
188 |
return color;
|
189 |
} |
190 |
|
191 |
private Object call(Object obj, String name, Object... params) { |
192 |
Class[] types = null; |
193 |
if (params != null) { |
194 |
types = new Class[params.length]; |
195 |
for (int i = 0; i < params.length; i++) { |
196 |
types[i] = params[i].getClass(); |
197 |
} |
198 |
} |
199 |
Method method;
|
200 |
try {
|
201 |
method = obj.getClass().getMethod(name, types); |
202 |
Object r = method.invoke(obj, params);
|
203 |
return r;
|
204 |
} catch (NoSuchMethodException |
205 |
| SecurityException
|
206 |
| IllegalAccessException
|
207 |
| IllegalArgumentException
|
208 |
| InvocationTargetException ex) {
|
209 |
} |
210 |
return null; |
211 |
} |
212 |
|
213 |
@Override
|
214 |
public void translate(JComponent component) { |
215 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
216 |
String s = (String) call(component, "getText", (Object[]) null); |
217 |
if (!StringUtils.isEmpty(s)) {
|
218 |
call(component, "setText", i18n.getTranslation(s));
|
219 |
} |
220 |
s = (String) call(component, "getToolTipText", (Object[]) null); |
221 |
if (!StringUtils.isEmpty(s)) {
|
222 |
call(component, "setToolTipText", i18n.getTranslation(s));
|
223 |
} |
224 |
} |
225 |
|
226 |
@Override
|
227 |
public void translate(AbstractButton component) { |
228 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
229 |
String s = component.getText();
|
230 |
if (!StringUtils.isEmpty(s)) {
|
231 |
component.setText(i18n.getTranslation(s)); |
232 |
} |
233 |
s = component.getToolTipText(); |
234 |
if (!StringUtils.isEmpty(s)) {
|
235 |
component.setToolTipText(i18n.getTranslation(s)); |
236 |
} |
237 |
} |
238 |
|
239 |
@Override
|
240 |
public void translate(JLabel component) { |
241 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
242 |
String s = component.getText();
|
243 |
if (!StringUtils.isEmpty(s)) {
|
244 |
component.setText(i18n.getTranslation(s)); |
245 |
} |
246 |
s = component.getToolTipText(); |
247 |
if (!StringUtils.isEmpty(s)) {
|
248 |
component.setToolTipText(i18n.getTranslation(s)); |
249 |
} |
250 |
} |
251 |
|
252 |
@Override
|
253 |
public void translate(JTabbedPane component) { |
254 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
255 |
|
256 |
for (int i = 0; i < component.getTabCount(); i++) { |
257 |
String text = component.getTitleAt(i);
|
258 |
if (!StringUtils.isEmpty(text)) {
|
259 |
component.setTitleAt(i, i18n.getTranslation(text)); |
260 |
} |
261 |
text = component.getToolTipTextAt(i); |
262 |
if (!StringUtils.isEmpty(text)) {
|
263 |
component.setToolTipTextAt(i, i18n.getTranslation(text)); |
264 |
} |
265 |
} |
266 |
} |
267 |
|
268 |
@Override
|
269 |
public void setDefaultPopupMenu(final JTextComponent component) { |
270 |
this.setDefaultPopupMenu(component, null); |
271 |
} |
272 |
|
273 |
@Override
|
274 |
public void setDefaultPopupMenu(final JTextComponent component, String title) { |
275 |
JPopupMenu popupMenu = new JPopupMenu(); |
276 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
277 |
|
278 |
Action copyAction = component.getActionMap().get(DefaultEditorKit.copyAction); |
279 |
Action cutAction = component.getActionMap().get(DefaultEditorKit.cutAction); |
280 |
Action pasteAction = component.getActionMap().get(DefaultEditorKit.pasteAction); |
281 |
Action selectAllAction = component.getActionMap().get(DefaultEditorKit.selectAllAction); |
282 |
|
283 |
if (copyAction == null |
284 |
&& cutAction == null
|
285 |
&& pasteAction == null
|
286 |
&& selectAllAction == null) {
|
287 |
copyAction = component.getActionMap().get(i18nManager.getTranslation("copy"));
|
288 |
cutAction = component.getActionMap().get(i18nManager.getTranslation("cut"));
|
289 |
pasteAction = component.getActionMap().get(i18nManager.getTranslation("paste"));
|
290 |
selectAllAction = component.getActionMap().get(i18nManager.getTranslation("SelectAll"));
|
291 |
} else {
|
292 |
copyAction.putValue(Action.NAME, i18nManager.getTranslation("copy")); |
293 |
cutAction.putValue(Action.NAME, i18nManager.getTranslation("cut")); |
294 |
pasteAction.putValue(Action.NAME, i18nManager.getTranslation("paste")); |
295 |
selectAllAction.putValue(Action.NAME, i18nManager.getTranslation("SelectAll")); |
296 |
} |
297 |
|
298 |
final String title2; |
299 |
if (title == null) { |
300 |
title2 = i18nManager.getTranslation("text_editor");
|
301 |
} else {
|
302 |
title2 = title; |
303 |
} |
304 |
Action textEditorAction = new AbstractAction(i18nManager.getTranslation("text_editor")) { |
305 |
@Override
|
306 |
public void actionPerformed(ActionEvent e) { |
307 |
DefaultZoomDialog dialog = new DefaultZoomDialog(component, title2, component.getText());
|
308 |
dialog.setEditable(component.isEditable()); |
309 |
dialog.setAlwaysOnTop(true);
|
310 |
dialog.setVisible(true);
|
311 |
if (component.isEditable() && component.isEnabled()) {
|
312 |
component.setText(dialog.getText()); |
313 |
} |
314 |
} |
315 |
}; |
316 |
final JMenuItem menuCut = new JMenuItem(cutAction); |
317 |
final JMenuItem menuPaste = new JMenuItem(pasteAction); |
318 |
|
319 |
popupMenu.add(textEditorAction); |
320 |
popupMenu.addSeparator(); |
321 |
|
322 |
popupMenu.add(menuCut); |
323 |
popupMenu.add(copyAction); |
324 |
popupMenu.add(menuPaste); |
325 |
popupMenu.add(selectAllAction); |
326 |
|
327 |
if (component.isEnabled() && component.isEditable()) {
|
328 |
menuCut.setEnabled(true);
|
329 |
menuPaste.setEnabled(true);
|
330 |
} else {
|
331 |
menuCut.setEnabled(false);
|
332 |
menuPaste.setEnabled(false);
|
333 |
} |
334 |
component.addPropertyChangeListener(new PropertyChangeListener() { |
335 |
@Override
|
336 |
public void propertyChange(PropertyChangeEvent evt) { |
337 |
if (evt == null) { |
338 |
return;
|
339 |
} |
340 |
if (evt.getPropertyName().equalsIgnoreCase("enabled")) { |
341 |
boolean enabled = component.isEnabled();
|
342 |
menuCut.setEnabled(enabled); |
343 |
menuPaste.setEnabled(enabled); |
344 |
} else if (evt.getPropertyName().equalsIgnoreCase("editable")) { |
345 |
boolean editable = component.isEditable();
|
346 |
menuCut.setEnabled(editable); |
347 |
menuPaste.setEnabled(editable); |
348 |
} |
349 |
} |
350 |
}); |
351 |
component.setComponentPopupMenu(popupMenu); |
352 |
} |
353 |
|
354 |
@Override
|
355 |
public void setDefaultPopupMenu(JComboBox component) { |
356 |
this.setDefaultPopupMenu((JTextComponent) component.getEditor().getEditorComponent(), null); |
357 |
} |
358 |
|
359 |
@Override
|
360 |
public void setDefaultPopupMenu(JComboBox component, String title) { |
361 |
this.setDefaultPopupMenu((JTextComponent) component.getEditor().getEditorComponent(), title); |
362 |
} |
363 |
|
364 |
@Override
|
365 |
public ChangeListenerHelper createChangeListenerHelper() {
|
366 |
DefaultChangeListenerHelper x = new DefaultChangeListenerHelper();
|
367 |
return x;
|
368 |
} |
369 |
|
370 |
@Override
|
371 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
372 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog, sldAlpha, allowNull); |
373 |
} |
374 |
|
375 |
@Override
|
376 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog) { |
377 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog); |
378 |
} |
379 |
|
380 |
@Override
|
381 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
382 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog, sldAlpha); |
383 |
} |
384 |
|
385 |
@Override
|
386 |
public DatePickerController createDatePickerController(JTextField txtDate, JButton btnDate) { |
387 |
return new DatePickerControllerImpl(txtDate, btnDate); |
388 |
} |
389 |
|
390 |
@Override
|
391 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) { |
392 |
return new FilePickerControllerImpl(txtFile, btnFile, dialogTitle, fileChooserID, initialPath, seticon); |
393 |
} |
394 |
|
395 |
@Override
|
396 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile) { |
397 |
return new FilePickerControllerImpl(txtFile, btnFile); |
398 |
} |
399 |
|
400 |
@Override
|
401 |
public PickerController<byte[]> createByteArrayPickerController(JTextField txtText, JButton btnUpload, JButton btnDownload, String fileChooserID, File initialPath) { |
402 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, fileChooserID, initialPath); |
403 |
} |
404 |
|
405 |
@Override
|
406 |
public PickerController<byte[]> createByteArrayPickerController(JTextField txtText, JButton btnUpload, JButton btnDownload) { |
407 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, null, null); |
408 |
} |
409 |
|
410 |
@Override
|
411 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile, String dialogTitle) { |
412 |
return new FilePickerControllerImpl(txtFile, btnFile, dialogTitle); |
413 |
} |
414 |
|
415 |
@Override
|
416 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) { |
417 |
return new FolderPickerControllerImpl(txtFile, btnFile, dialogTitle, fileChooserID, initialPath, seticon); |
418 |
} |
419 |
|
420 |
@Override
|
421 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile) { |
422 |
return new FolderPickerControllerImpl(txtFile, btnFile); |
423 |
} |
424 |
|
425 |
@Override
|
426 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile, String dialogTitle) { |
427 |
return new FolderPickerControllerImpl(txtFile, btnFile, dialogTitle); |
428 |
} |
429 |
|
430 |
@Override
|
431 |
public void removeBorder(JComponent component) { |
432 |
try {
|
433 |
component.setBorder(null);
|
434 |
JComponent p1 = (JComponent) component.getParent(); |
435 |
if (p1 instanceof JViewport) { |
436 |
p1 = (JComponent) component.getParent();
|
437 |
} |
438 |
if (p1 instanceof JScrollPane) { |
439 |
JScrollPane scrollPanel = (JScrollPane) component.getParent(); |
440 |
scrollPanel.setBorder(null);
|
441 |
} |
442 |
} catch (Exception ex) { |
443 |
|
444 |
} |
445 |
} |
446 |
|
447 |
protected ImageIcon getIcon(String name) { |
448 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
449 |
IconTheme theme = iconThemeManager.getCurrent(); |
450 |
ImageIcon icon = theme.get(name);
|
451 |
return icon;
|
452 |
} |
453 |
|
454 |
@Override
|
455 |
public void addClearButton(JTextComponent text) { |
456 |
this.addClearButton(text, null); |
457 |
} |
458 |
|
459 |
@Override
|
460 |
public void addClearButton(JComboBox combo) { |
461 |
try {
|
462 |
JTextComponent text = (JTextComponent) combo.getEditor().getEditorComponent(); |
463 |
this.addClearButton(text, null); |
464 |
} catch (Throwable th) { |
465 |
// Si no puede a?adir el boton no hace nada.
|
466 |
} |
467 |
} |
468 |
|
469 |
@Override
|
470 |
public void addClearButton(final JTextComponent text, final ActionListener action) { |
471 |
final JButton btnClear = new JButton(getIcon("picker-cleartext")); |
472 |
btnClear.setBorderPainted(false);
|
473 |
btnClear.setFocusPainted(false);
|
474 |
btnClear.setContentAreaFilled(false);
|
475 |
btnClear.setOpaque(false);
|
476 |
btnClear.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
477 |
if (action == null) { |
478 |
btnClear.addActionListener(new ActionListener() { |
479 |
@Override
|
480 |
public void actionPerformed(ActionEvent e) { |
481 |
text.setText("");
|
482 |
} |
483 |
}); |
484 |
} else {
|
485 |
btnClear.addActionListener(action); |
486 |
} |
487 |
text.setLayout(new BorderLayout()); |
488 |
text.add(btnClear, BorderLayout.EAST);
|
489 |
text.addPropertyChangeListener(new PropertyChangeListener() { |
490 |
@Override
|
491 |
public void propertyChange(PropertyChangeEvent evt) { |
492 |
if (evt == null) { |
493 |
return;
|
494 |
} |
495 |
if (evt.getPropertyName().equalsIgnoreCase("enabled")) { |
496 |
boolean enabled = text.isEnabled();
|
497 |
btnClear.setEnabled(enabled); |
498 |
} else if (evt.getPropertyName().equalsIgnoreCase("editable")) { |
499 |
boolean editable = text.isEditable();
|
500 |
btnClear.setEnabled(editable); |
501 |
} |
502 |
} |
503 |
}); |
504 |
} |
505 |
|
506 |
@Override
|
507 |
public SimpleImage createSimpleImage() {
|
508 |
SimpleImage x = new DefaultSimpleImage();
|
509 |
return x;
|
510 |
} |
511 |
|
512 |
@Override
|
513 |
public SimpleImage createSimpleImage(Object source) { |
514 |
SimpleImage x = new DefaultSimpleImage(source);
|
515 |
return x;
|
516 |
} |
517 |
|
518 |
@Override
|
519 |
public DropDown createDropDown(JComboBox combo) { |
520 |
DropDown c = new DropDownComboBox(combo);
|
521 |
return c;
|
522 |
} |
523 |
|
524 |
@Override
|
525 |
public DropDown createDropDown(JLabel label) { |
526 |
DropDown c = new DropDownLabel(label);
|
527 |
return c;
|
528 |
} |
529 |
|
530 |
@Override
|
531 |
public DropDown createDropDown(AbstractButton button) { |
532 |
DropDown c = new DropDownButton(button);
|
533 |
return c;
|
534 |
} |
535 |
|
536 |
@Override
|
537 |
public DropDown createDropDown(JComponent component) { |
538 |
DropDown c = new DropDownLabel(component);
|
539 |
return c;
|
540 |
} |
541 |
|
542 |
@Override
|
543 |
public CompoundIcon createCompoundIcon(Icon... icons) { |
544 |
DefaultCompoundIcon i = new DefaultCompoundIcon(icons);
|
545 |
return i;
|
546 |
} |
547 |
|
548 |
@Override
|
549 |
public CompoundIcon createCompoundIcon(int orientation, Icon... icons) { |
550 |
DefaultCompoundIcon i = new DefaultCompoundIcon(orientation, icons);
|
551 |
return i;
|
552 |
} |
553 |
|
554 |
@Override
|
555 |
public CompoundIcon createCompoundIcon(int orientation, int gap, Icon... icons) { |
556 |
DefaultCompoundIcon i = new DefaultCompoundIcon(orientation, gap, icons);
|
557 |
return i;
|
558 |
} |
559 |
|
560 |
@Override
|
561 |
public CompoundIcon createCompoundIcon(int orientation, int gap, int alignmentX, int alignmentY, Icon... icons) { |
562 |
DefaultCompoundIcon i = new DefaultCompoundIcon(orientation, gap, alignmentX, alignmentY, icons);
|
563 |
return i;
|
564 |
} |
565 |
|
566 |
@Override
|
567 |
public BookmarksController createBookmarksController(Bookmarks bookmarks, JButton button) { |
568 |
BookmarksController controller; |
569 |
controller = new DefaultBookmarksController(bookmarks, button);
|
570 |
return controller;
|
571 |
} |
572 |
|
573 |
@Override
|
574 |
public HistoryController createHistoryController(History history, JButton button) { |
575 |
DefaultHistoryController controller; |
576 |
controller = new DefaultHistoryController(history, button);
|
577 |
return controller;
|
578 |
} |
579 |
|
580 |
@Override
|
581 |
public FilteredTableModel createFilteredTableModel(TableModel tableModel, int filterColumn) { |
582 |
FilteredTableModelImpl model = new FilteredTableModelImpl(tableModel, filterColumn);
|
583 |
return model;
|
584 |
} |
585 |
|
586 |
@Override
|
587 |
public JLabel createTitledSeparator(String title, int height, int titlePosition, int titleJustification) { |
588 |
TitledSeparator c = new TitledSeparator(title, height, titlePosition, titleJustification);
|
589 |
return c;
|
590 |
} |
591 |
|
592 |
@Override
|
593 |
public JLabel createTitledSeparator(String title) { |
594 |
TitledSeparator c = new TitledSeparator(
|
595 |
title, |
596 |
2,
|
597 |
TitledBorder.DEFAULT_POSITION,
|
598 |
TitledBorder.DEFAULT_JUSTIFICATION
|
599 |
); |
600 |
return c;
|
601 |
} |
602 |
} |