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