Revision 2165
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/pickercontroller/DatePickerController.java | ||
---|---|---|
7 | 7 |
* @author jjdelcerro |
8 | 8 |
*/ |
9 | 9 |
public interface DatePickerController extends PickerController<Date> { |
10 |
|
|
10 |
public void uninstall(); |
|
11 | 11 |
} |
org.gvsig.tools/library/trunk/org.gvsig.tools/org.gvsig.tools.swing/org.gvsig.tools.swing.api/src/main/java/org/gvsig/tools/swing/api/ToolsSwingManager.java | ||
---|---|---|
51 | 51 |
* @return |
52 | 52 |
* @deprecated use createColorPickerController |
53 | 53 |
*/ |
54 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull);
|
|
54 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull);
|
|
55 | 55 |
/** |
56 | 56 |
* @param txtLabel |
57 | 57 |
* @param btnShowDialog |
58 | 58 |
* @return |
59 | 59 |
* @deprecated use createColorPickerController |
60 | 60 |
*/ |
61 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog);
|
|
61 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog);
|
|
62 | 62 |
/** |
63 | 63 |
* @param txtLabel |
64 | 64 |
* @param btnShowDialog |
... | ... | |
66 | 66 |
* @return |
67 | 67 |
* @deprecated use createColorPickerController |
68 | 68 |
*/ |
69 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha);
|
|
69 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha);
|
|
70 | 70 |
|
71 | 71 |
|
72 | 72 |
/** |
... | ... | |
147 | 147 |
|
148 | 148 |
public ChangeListenerHelper createChangeListenerHelper(); |
149 | 149 |
|
150 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull);
|
|
150 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull);
|
|
151 | 151 |
|
152 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog);
|
|
152 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog);
|
|
153 | 153 |
|
154 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha);
|
|
154 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha);
|
|
155 | 155 |
|
156 |
public DatePickerController createDatePickerController(JTextField txtDate, JButton btnDate);
|
|
156 |
public DatePickerController createDatePickerController(JTextComponent txtDate, JButton btnDate);
|
|
157 | 157 |
|
158 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon);
|
|
158 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon);
|
|
159 | 159 |
|
160 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile);
|
|
160 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile);
|
|
161 | 161 |
|
162 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile, String dialogTitle);
|
|
162 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle);
|
|
163 | 163 |
|
164 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon);
|
|
164 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon);
|
|
165 | 165 |
|
166 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile);
|
|
166 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile);
|
|
167 | 167 |
|
168 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile, String dialogTitle);
|
|
168 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle);
|
|
169 | 169 |
|
170 |
public PickerController<byte[]> createByteArrayPickerController(JTextField txtText, JButton btnUpload, JButton btnDownload, String fileChooserID, File initialPath);
|
|
170 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload, String fileChooserID, File initialPath);
|
|
171 | 171 |
|
172 |
public PickerController<byte[]> createByteArrayPickerController(JTextField txtText, JButton btnUpload, JButton btnDownload);
|
|
172 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload);
|
|
173 | 173 |
|
174 | 174 |
public void removeBorder(JComponent component); |
175 | 175 |
|
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 | ||
---|---|---|
10 | 10 |
import java.awt.image.BufferedImage; |
11 | 11 |
import java.awt.image.WritableRaster; |
12 | 12 |
import java.beans.PropertyChangeEvent; |
13 |
import java.beans.PropertyChangeListener; |
|
14 | 13 |
import java.io.File; |
15 | 14 |
import java.lang.reflect.InvocationTargetException; |
16 | 15 |
import java.lang.reflect.Method; |
... | ... | |
30 | 29 |
import javax.swing.JScrollPane; |
31 | 30 |
import javax.swing.JSlider; |
32 | 31 |
import javax.swing.JTabbedPane; |
33 |
import javax.swing.JTextField; |
|
34 | 32 |
import javax.swing.JTree; |
35 | 33 |
import javax.swing.JViewport; |
36 | 34 |
import javax.swing.border.TitledBorder; |
... | ... | |
150 | 148 |
} |
151 | 149 |
|
152 | 150 |
@Override |
153 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
151 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
154 | 152 |
return new DefaultColorChooserController(txtLabel, btnShowDialog, sldAlpha, allowNull); |
155 | 153 |
} |
156 | 154 |
|
157 | 155 |
@Override |
158 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog) {
|
|
156 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog) {
|
|
159 | 157 |
return new DefaultColorChooserController(txtLabel, btnShowDialog); |
160 | 158 |
} |
161 | 159 |
|
162 | 160 |
@Override |
163 |
public ColorChooserController createColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
161 |
public ColorChooserController createColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
164 | 162 |
return new DefaultColorChooserController(txtLabel, btnShowDialog, sldAlpha); |
165 | 163 |
} |
166 | 164 |
|
... | ... | |
339 | 337 |
menuCut.setEnabled(false); |
340 | 338 |
menuPaste.setEnabled(false); |
341 | 339 |
} |
342 |
component.addPropertyChangeListener(new PropertyChangeListener() { |
|
343 |
@Override |
|
344 |
public void propertyChange(PropertyChangeEvent evt) { |
|
345 |
if (evt == null) { |
|
346 |
return; |
|
347 |
} |
|
348 |
if (evt.getPropertyName().equalsIgnoreCase("enabled")) { |
|
349 |
boolean enabled = component.isEnabled(); |
|
350 |
menuCut.setEnabled(enabled); |
|
351 |
menuPaste.setEnabled(enabled); |
|
352 |
} else if (evt.getPropertyName().equalsIgnoreCase("editable")) { |
|
353 |
boolean editable = component.isEditable(); |
|
354 |
menuCut.setEnabled(editable); |
|
355 |
menuPaste.setEnabled(editable); |
|
356 |
} |
|
357 |
} |
|
340 |
component.addPropertyChangeListener((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 |
} |
|
358 | 353 |
}); |
359 | 354 |
component.setComponentPopupMenu(popupMenu); |
360 | 355 |
} |
... | ... | |
376 | 371 |
} |
377 | 372 |
|
378 | 373 |
@Override |
379 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
374 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
380 | 375 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog, sldAlpha, allowNull); |
381 | 376 |
} |
382 | 377 |
|
383 | 378 |
@Override |
384 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog) {
|
|
379 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog) {
|
|
385 | 380 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog); |
386 | 381 |
} |
387 | 382 |
|
388 | 383 |
@Override |
389 |
public ColorPickerController createColorPickerController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
384 |
public ColorPickerController createColorPickerController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
390 | 385 |
return new ColorPickerControllerImpl(txtLabel, btnShowDialog, sldAlpha); |
391 | 386 |
} |
392 | 387 |
|
393 | 388 |
@Override |
394 |
public DatePickerController createDatePickerController(JTextField txtDate, JButton btnDate) {
|
|
389 |
public DatePickerController createDatePickerController(JTextComponent txtDate, JButton btnDate) {
|
|
395 | 390 |
return new DatePickerControllerImpl(txtDate, btnDate); |
396 | 391 |
} |
397 | 392 |
|
398 | 393 |
@Override |
399 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
394 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
400 | 395 |
return new FilePickerControllerImpl(txtFile, btnFile, dialogTitle, fileChooserID, initialPath, seticon); |
401 | 396 |
} |
402 | 397 |
|
403 | 398 |
@Override |
404 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile) {
|
|
399 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile) {
|
|
405 | 400 |
return new FilePickerControllerImpl(txtFile, btnFile); |
406 | 401 |
} |
407 | 402 |
|
408 | 403 |
@Override |
409 |
public PickerController<byte[]> createByteArrayPickerController(JTextField txtText, JButton btnUpload, JButton btnDownload, String fileChooserID, File initialPath) {
|
|
404 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload, String fileChooserID, File initialPath) {
|
|
410 | 405 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, fileChooserID, initialPath); |
411 | 406 |
} |
412 | 407 |
|
413 | 408 |
@Override |
414 |
public PickerController<byte[]> createByteArrayPickerController(JTextField txtText, JButton btnUpload, JButton btnDownload) {
|
|
409 |
public PickerController<byte[]> createByteArrayPickerController(JTextComponent txtText, JButton btnUpload, JButton btnDownload) {
|
|
415 | 410 |
return new BytearrayPickerControllerImpl(txtText, btnUpload, btnDownload, null, null); |
416 | 411 |
} |
417 | 412 |
|
418 | 413 |
@Override |
419 |
public FilePickerController createFilePickerController(JTextField txtFile, JButton btnFile, String dialogTitle) {
|
|
414 |
public FilePickerController createFilePickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle) {
|
|
420 | 415 |
return new FilePickerControllerImpl(txtFile, btnFile, dialogTitle); |
421 | 416 |
} |
422 | 417 |
|
423 | 418 |
@Override |
424 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
419 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
425 | 420 |
return new FolderPickerControllerImpl(txtFile, btnFile, dialogTitle, fileChooserID, initialPath, seticon); |
426 | 421 |
} |
427 | 422 |
|
428 | 423 |
@Override |
429 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile) {
|
|
424 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile) {
|
|
430 | 425 |
return new FolderPickerControllerImpl(txtFile, btnFile); |
431 | 426 |
} |
432 | 427 |
|
433 | 428 |
@Override |
434 |
public FolderPickerController createFolderPickerController(JTextField txtFile, JButton btnFile, String dialogTitle) {
|
|
429 |
public FolderPickerController createFolderPickerController(JTextComponent txtFile, JButton btnFile, String dialogTitle) {
|
|
435 | 430 |
return new FolderPickerControllerImpl(txtFile, btnFile, dialogTitle); |
436 | 431 |
} |
437 | 432 |
|
... | ... | |
483 | 478 |
btnClear.setOpaque(false); |
484 | 479 |
btnClear.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
485 | 480 |
if (action == null) { |
486 |
btnClear.addActionListener(new ActionListener() { |
|
487 |
@Override |
|
488 |
public void actionPerformed(ActionEvent e) { |
|
489 |
text.setText(""); |
|
490 |
} |
|
481 |
btnClear.addActionListener((ActionEvent e) -> { |
|
482 |
text.setText(""); |
|
491 | 483 |
}); |
492 | 484 |
} else { |
493 | 485 |
btnClear.addActionListener(action); |
494 | 486 |
} |
495 | 487 |
text.setLayout(new BorderLayout()); |
496 | 488 |
text.add(btnClear, BorderLayout.EAST); |
497 |
text.addPropertyChangeListener(new PropertyChangeListener() { |
|
498 |
@Override |
|
499 |
public void propertyChange(PropertyChangeEvent evt) { |
|
500 |
if (evt == null) { |
|
501 |
return; |
|
502 |
} |
|
503 |
if (evt.getPropertyName().equalsIgnoreCase("enabled")) { |
|
504 |
boolean enabled = text.isEnabled(); |
|
505 |
btnClear.setEnabled(enabled); |
|
506 |
} else if (evt.getPropertyName().equalsIgnoreCase("editable")) { |
|
507 |
boolean editable = text.isEditable(); |
|
508 |
btnClear.setEnabled(editable); |
|
509 |
} |
|
510 |
} |
|
489 |
text.addPropertyChangeListener((PropertyChangeEvent evt) -> { |
|
490 |
if (evt == null) { |
|
491 |
return; |
|
492 |
} |
|
493 |
if (evt.getPropertyName().equalsIgnoreCase("enabled")) { |
|
494 |
boolean enabled = text.isEnabled(); |
|
495 |
btnClear.setEnabled(enabled); |
|
496 |
} else if (evt.getPropertyName().equalsIgnoreCase("editable")) { |
|
497 |
boolean editable = text.isEditable(); |
|
498 |
btnClear.setEnabled(editable); |
|
499 |
} |
|
511 | 500 |
}); |
512 | 501 |
} |
513 | 502 |
|
... | ... | |
626 | 615 |
return flc; |
627 | 616 |
} |
628 | 617 |
|
618 |
@Override |
|
629 | 619 |
public FilteredTreeController createFilteredTreeController(JTree list, JTextComponent text, JButton button) { |
630 | 620 |
FilteredTreeController ftc = new DefaultFilteredTreeController(list, text, button); |
631 | 621 |
return ftc; |
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/pickercontroller/BytearrayPickerControllerImpl.java | ||
---|---|---|
1 | 1 |
package org.gvsig.tools.swing.impl.pickercontroller; |
2 | 2 |
|
3 | 3 |
import java.awt.event.ActionEvent; |
4 |
import java.awt.event.ActionListener; |
|
5 | 4 |
import java.io.File; |
6 | 5 |
import java.net.URL; |
7 | 6 |
import javax.swing.ImageIcon; |
8 | 7 |
import javax.swing.JButton; |
9 | 8 |
import javax.swing.JFileChooser; |
10 |
import javax.swing.JTextField;
|
|
9 |
import javax.swing.text.JTextComponent;
|
|
11 | 10 |
import org.apache.commons.io.FileUtils; |
12 | 11 |
import org.apache.commons.lang3.ArrayUtils; |
13 | 12 |
import org.gvsig.tools.ToolsLocator; |
... | ... | |
28 | 27 |
extends AbstractPickerController<byte[]> |
29 | 28 |
{ |
30 | 29 |
|
31 |
private final JTextField jtext;
|
|
30 |
private final JTextComponent jtext;
|
|
32 | 31 |
private final JButton btnUpload; |
33 | 32 |
private final JButton btnDownload; |
34 | 33 |
|
... | ... | |
37 | 36 |
private final File initialPath; |
38 | 37 |
|
39 | 38 |
public BytearrayPickerControllerImpl( |
40 |
JTextField jtext,
|
|
39 |
JTextComponent jtext,
|
|
41 | 40 |
JButton btnUpload, |
42 | 41 |
JButton btnDownload, |
43 | 42 |
String fileChooserID, |
... | ... | |
51 | 50 |
|
52 | 51 |
this.btnDownload.setText(""); |
53 | 52 |
this.btnDownload.setIcon(this.getIcon("picker-bytearray-download")); |
54 |
this.btnDownload.addActionListener(new ActionListener() { |
|
55 |
@Override |
|
56 |
public void actionPerformed(ActionEvent e) { |
|
57 |
doDownload(); |
|
58 |
} |
|
53 |
this.btnDownload.addActionListener((ActionEvent e) -> { |
|
54 |
doDownload(); |
|
59 | 55 |
}); |
60 | 56 |
this.btnUpload.setText(""); |
61 | 57 |
this.btnUpload.setIcon(this.getIcon("picker-bytearray-upload")); |
62 |
this.btnUpload.addActionListener(new ActionListener() { |
|
63 |
@Override |
|
64 |
public void actionPerformed(ActionEvent e) { |
|
65 |
doUpload(); |
|
66 |
} |
|
58 |
this.btnUpload.addActionListener((ActionEvent e) -> { |
|
59 |
doUpload(); |
|
67 | 60 |
}); |
68 | 61 |
|
69 | 62 |
this.jtext.setEditable(false); |
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/pickercontroller/FolderPickerControllerImpl.java | ||
---|---|---|
7 | 7 |
import javax.swing.ImageIcon; |
8 | 8 |
import javax.swing.JButton; |
9 | 9 |
import javax.swing.JFileChooser; |
10 |
import javax.swing.JTextField; |
|
11 | 10 |
import javax.swing.filechooser.FileFilter; |
11 |
import javax.swing.text.JTextComponent; |
|
12 | 12 |
import org.apache.commons.lang3.ArrayUtils; |
13 | 13 |
import org.gvsig.tools.ToolsLocator; |
14 | 14 |
import org.gvsig.tools.dataTypes.DataTypes; |
... | ... | |
32 | 32 |
{ |
33 | 33 |
|
34 | 34 |
private final JButton btnFolder; |
35 |
private final JTextField txtFolder;
|
|
35 |
private final JTextComponent txtFolder;
|
|
36 | 36 |
private final File initialPath; |
37 | 37 |
private final String fileChooserID; |
38 | 38 |
private final String dialogTitle; |
... | ... | |
49 | 49 |
} |
50 | 50 |
} |
51 | 51 |
|
52 |
public FolderPickerControllerImpl(JTextField txtFolder, JButton btnFolder, String dialogTitle) {
|
|
52 |
public FolderPickerControllerImpl(JTextComponent txtFolder, JButton btnFolder, String dialogTitle) {
|
|
53 | 53 |
this(txtFolder, btnFolder, dialogTitle, null, null, true); |
54 | 54 |
} |
55 | 55 |
|
56 |
public FolderPickerControllerImpl(JTextField txtFolder, JButton btnFolder) {
|
|
56 |
public FolderPickerControllerImpl(JTextComponent txtFolder, JButton btnFolder) {
|
|
57 | 57 |
this(txtFolder, btnFolder, null, null, null, true); |
58 | 58 |
} |
59 | 59 |
|
60 |
public FolderPickerControllerImpl(JTextField txtFolder, JButton btnFolder, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
60 |
public FolderPickerControllerImpl(JTextComponent txtFolder, JButton btnFolder, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
61 | 61 |
this.value = null; |
62 | 62 |
this.txtFolder = txtFolder; |
63 | 63 |
this.btnFolder = btnFolder; |
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/pickercontroller/Test.java | ||
---|---|---|
11 | 11 |
import java.awt.ComponentOrientation; |
12 | 12 |
import java.awt.Container; |
13 | 13 |
import java.awt.Dimension; |
14 |
import java.awt.event.ActionEvent; |
|
15 |
import java.awt.event.ActionListener; |
|
14 | 16 |
import javax.swing.Box; |
15 | 17 |
import javax.swing.ImageIcon; |
16 | 18 |
import javax.swing.JButton; |
... | ... | |
196 | 198 |
this.pickerDate = new DatePickerControllerImpl(txtDate, btnDate); |
197 | 199 |
this.pickerFile = new FilePickerControllerImpl(txtFile1, btnFile1); |
198 | 200 |
this.pickerColor = new ColorPickerControllerImpl(txtColor1, btnColor1); |
201 |
|
|
202 |
this.setPreferredSize(new Dimension(300, 200)); |
|
199 | 203 |
} |
200 | 204 |
} |
201 | 205 |
/** |
... | ... | |
217 | 221 |
null, |
218 | 222 |
WindowManager_v2.BUTTONS_OK_CANCEL |
219 | 223 |
); |
224 |
dialog.addActionListener(new ActionListener() { |
|
225 |
@Override |
|
226 |
public void actionPerformed(ActionEvent e) { |
|
227 |
System.out.println("Date:"+panel.pickerDate.get()); |
|
228 |
} |
|
229 |
}); |
|
220 | 230 |
dialog.show(WindowManager.MODE.WINDOW); |
221 | 231 |
} |
222 | 232 |
|
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/pickercontroller/DatePickerControllerImpl.java | ||
---|---|---|
1 | 1 |
package org.gvsig.tools.swing.impl.pickercontroller; |
2 | 2 |
|
3 |
import java.awt.Color; |
|
3 | 4 |
import static java.awt.Component.RIGHT_ALIGNMENT; |
4 | 5 |
import java.awt.event.ActionEvent; |
5 | 6 |
import java.net.URL; |
... | ... | |
12 | 13 |
import javax.swing.JButton; |
13 | 14 |
import javax.swing.JFormattedTextField; |
14 | 15 |
import javax.swing.JPopupMenu; |
16 |
import javax.swing.event.DocumentEvent; |
|
17 |
import javax.swing.event.DocumentListener; |
|
18 |
import javax.swing.text.Document; |
|
15 | 19 |
import javax.swing.text.JTextComponent; |
16 |
import javax.swing.text.DateFormatter; |
|
17 |
import javax.swing.text.DefaultFormatterFactory; |
|
18 | 20 |
import javax.swing.text.MaskFormatter; |
19 | 21 |
import org.apache.commons.lang3.StringUtils; |
20 | 22 |
import org.freixas.jcalendar.DateEvent; |
... | ... | |
33 | 35 |
* @author jjdelcerro |
34 | 36 |
*/ |
35 | 37 |
@SuppressWarnings("UseSpecificCatch") |
36 |
public class DatePickerControllerImpl |
|
37 |
extends AbstractPickerController<Date> |
|
38 |
implements DatePickerController |
|
39 |
{ |
|
40 |
|
|
41 |
private final JButton btnDate; |
|
42 |
private final JTextComponent txtDate; |
|
43 |
private JCalendar jcalendar; |
|
44 |
private DateFormat df; |
|
45 |
private static final Logger LOG = LoggerFactory.getLogger(DatePickerControllerImpl.class); |
|
46 |
|
|
47 |
public static void selfRegister() { |
|
48 |
URL imageResource = DatePickerControllerImpl.class.getClassLoader().getResource("org/gvsig/tools/swing/picker/picker-date.png"); |
|
49 |
if (imageResource != null) { |
|
50 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
|
51 |
IconTheme theme = iconThemeManager.getCurrent(); |
|
52 |
ImageIcon icon = new ImageIcon(imageResource); |
|
53 |
theme.registerDefault("tools", "picker", "picker-date", icon, imageResource); |
|
54 |
} |
|
38 |
public class DatePickerControllerImpl |
|
39 |
extends AbstractPickerController<Date> |
|
40 |
implements DatePickerController { |
|
41 |
|
|
42 |
private final JButton btnDate; |
|
43 |
private final JTextComponent txtDate; |
|
44 |
private JCalendar jcalendar; |
|
45 |
private DateFormat df; |
|
46 |
private static final Logger LOG = LoggerFactory.getLogger(DatePickerControllerImpl.class); |
|
47 |
|
|
48 |
public static void selfRegister() { |
|
49 |
URL imageResource = DatePickerControllerImpl.class.getClassLoader().getResource("org/gvsig/tools/swing/picker/picker-date.png"); |
|
50 |
if (imageResource != null) { |
|
51 |
IconThemeManager iconThemeManager = ToolsSwingLocator.getIconThemeManager(); |
|
52 |
IconTheme theme = iconThemeManager.getCurrent(); |
|
53 |
ImageIcon icon = new ImageIcon(imageResource); |
|
54 |
theme.registerDefault("tools", "picker", "picker-date", icon, imageResource); |
|
55 | 55 |
} |
56 |
|
|
57 |
public DatePickerControllerImpl(JTextComponent txtDate, JButton btnDate) { |
|
58 |
this.txtDate = txtDate; |
|
59 |
ToolsSwingLocator.getToolsSwingManager().addClearButton(txtDate, (ActionEvent e) -> { |
|
60 |
set(null); |
|
61 |
txtDate.setText(""); |
|
62 |
}); |
|
63 |
this.df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); |
|
64 |
if( this.txtDate instanceof JFormattedTextField ) { |
|
65 |
JFormattedTextField ftf = (JFormattedTextField) this.txtDate; |
|
66 |
DefaultFormatterFactory formatterFactory = new DefaultFormatterFactory(new DateFormatter(df)); |
|
67 |
ftf.setFormatterFactory(formatterFactory); |
|
68 |
ftf.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT); |
|
69 |
if( df instanceof SimpleDateFormat ) { |
|
70 |
try { |
|
71 |
SimpleDateFormat sdf = (SimpleDateFormat) this.df; |
|
72 |
String s = sdf.toPattern(); // d/M/yy H:mm:ss |
|
73 |
s = s.replace("d", "##"); |
|
74 |
s = s.replace("MM", "##"); |
|
75 |
s = s.replace("M", "##"); |
|
76 |
s = s.replace("y", "#"); |
|
77 |
s = s.replace("HH", "##"); |
|
78 |
s = s.replace("H", "##"); |
|
79 |
s = s.replace("m", "#"); |
|
80 |
|
|
81 |
s = s.replace("s", "#"); |
|
82 |
MaskFormatter mask = new MaskFormatter(s); |
|
83 |
mask.setPlaceholderCharacter('_'); |
|
84 |
//mask.setPlaceholder(sdf.format(new Date())); |
|
85 |
mask.setAllowsInvalid(false); |
|
86 |
mask.install(ftf); |
|
87 |
} catch (Exception ex) { |
|
88 |
LOG.warn("Not been able to create mask", ex); |
|
89 |
} |
|
56 |
} |
|
57 |
private final Document document; |
|
58 |
private final DocumentListener documentListener; |
|
59 |
private final Color colorOk; |
|
60 |
private final Color colorErr; |
|
61 |
private String emptyValue; |
|
62 |
|
|
63 |
public DatePickerControllerImpl(JTextComponent txtDate, JButton btnDate) { |
|
64 |
this.txtDate = txtDate; |
|
65 |
if (btnDate == null) { |
|
66 |
btnDate = new JButton(); |
|
67 |
} |
|
68 |
ToolsSwingLocator.getToolsSwingManager().addClearButton(txtDate, (ActionEvent e) -> { |
|
69 |
set(null); |
|
70 |
}); |
|
71 |
this.df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.getDefault()); |
|
72 |
this.df.setLenient(false); |
|
73 |
if (this.txtDate instanceof JFormattedTextField) { |
|
74 |
JFormattedTextField ftf = (JFormattedTextField) this.txtDate; |
|
75 |
if (df instanceof SimpleDateFormat) { |
|
76 |
try { |
|
77 |
SimpleDateFormat sdf = (SimpleDateFormat) this.df; |
|
78 |
String s = sdf.toPattern(); |
|
79 |
if( !s.contains("yyyy") ) { |
|
80 |
if( s.contains("yy") ) { |
|
81 |
s = s.replace("yy", "yyyy"); |
|
82 |
} else if( s.contains("y") ) { |
|
83 |
s = s.replace("y", "yyyy"); |
|
90 | 84 |
} |
85 |
} |
|
86 |
if( !s.contains("dd") ) { |
|
87 |
if( s.contains("d") ) { |
|
88 |
s = s.replace("d", "dd"); |
|
89 |
} |
|
90 |
} |
|
91 |
if( !s.contains("MM") ) { |
|
92 |
if( s.contains("M") ) { |
|
93 |
s = s.replace("M", "MM"); |
|
94 |
} |
|
95 |
} |
|
96 |
sdf.applyPattern(s); |
|
97 |
s = s.replace("y", "#"); |
|
98 |
s = s.replace("d", "#"); |
|
99 |
s = s.replace("M", "#"); |
|
100 |
MaskFormatter mask = new MaskFormatter(s); |
|
101 |
mask.setPlaceholderCharacter('_'); |
|
102 |
this.emptyValue = s.replace("#","_"); |
|
103 |
mask.setAllowsInvalid(false); |
|
104 |
mask.install(ftf); |
|
105 |
} catch (Exception ex) { |
|
106 |
LOG.warn("Not been able to create mask", ex); |
|
91 | 107 |
} |
92 |
this.btnDate = btnDate; |
|
93 |
this.txtDate.setAlignmentX(RIGHT_ALIGNMENT); |
|
94 |
this.txtDate.setEditable(true); |
|
95 |
|
|
96 |
this.btnDate.setIcon(this.getIcon("picker-date")); |
|
97 |
this.btnDate.setText(""); |
|
98 |
|
|
99 |
this.btnDate.addActionListener((ActionEvent e) -> { |
|
100 |
doShowCalendar(); |
|
101 |
}); |
|
108 |
} |
|
102 | 109 |
} |
110 |
this.colorOk = this.txtDate.getBackground(); |
|
111 |
this.colorErr = new Color(255,225,232); |
|
112 |
this.btnDate = btnDate; |
|
113 |
this.txtDate.setAlignmentX(RIGHT_ALIGNMENT); |
|
114 |
this.txtDate.setEditable(true); |
|
115 |
this.document = this.txtDate.getDocument(); |
|
116 |
this.documentListener = new DocumentListener() { |
|
117 |
@Override |
|
118 |
public void insertUpdate(DocumentEvent e) { |
|
119 |
checkContents(); |
|
120 |
} |
|
103 | 121 |
|
104 |
@Override |
|
105 |
public boolean isValid() { |
|
106 |
if( StringUtils.isBlank(this.txtDate.getText()) ) { |
|
107 |
return true; |
|
122 |
@Override |
|
123 |
public void removeUpdate(DocumentEvent e) { |
|
124 |
checkContents(); |
|
108 | 125 |
} |
109 |
try { |
|
110 |
Date date = this.df.parse(this.txtDate.getText()); |
|
111 |
return true; |
|
112 |
} catch (ParseException ex) { |
|
113 |
return false; |
|
126 |
|
|
127 |
@Override |
|
128 |
public void changedUpdate(DocumentEvent e) { |
|
129 |
checkContents(); |
|
114 | 130 |
} |
131 |
}; |
|
132 |
document.addDocumentListener(this.documentListener); |
|
133 |
|
|
134 |
this.btnDate.setIcon(this.getIcon("picker-date")); |
|
135 |
if (this.btnDate.getText().equals("...")) { |
|
136 |
this.btnDate.setText(""); |
|
115 | 137 |
} |
116 | 138 |
|
117 |
@Override |
|
118 |
public boolean isEmpty() { |
|
119 |
if( StringUtils.isBlank(this.txtDate.getText()) ) { |
|
120 |
return true; |
|
121 |
} |
|
122 |
try { |
|
123 |
Date date = this.df.parse(this.txtDate.getText()); |
|
124 |
return false; |
|
125 |
} catch (ParseException ex) { |
|
126 |
return true; |
|
127 |
} |
|
139 |
this.btnDate.addActionListener((ActionEvent e) -> { |
|
140 |
doShowCalendar(); |
|
141 |
}); |
|
142 |
} |
|
143 |
|
|
144 |
@Override |
|
145 |
public void uninstall() { |
|
146 |
|
|
147 |
} |
|
148 |
|
|
149 |
private String getText() { |
|
150 |
String s = this.txtDate.getText(); |
|
151 |
if( this.emptyValue!=null && this.emptyValue.equals(s) ) { |
|
152 |
return ""; |
|
128 | 153 |
} |
154 |
s = s.replace("_", ""); |
|
155 |
return s; |
|
156 |
} |
|
129 | 157 |
|
130 |
@Override |
|
131 |
public Date get() { |
|
132 |
if( StringUtils.isBlank(this.txtDate.getText()) ) { |
|
133 |
return null; |
|
134 |
} |
|
135 |
try { |
|
136 |
Date date = this.df.parse(this.txtDate.getText()); |
|
137 |
return date; |
|
138 |
} catch (ParseException ex) { |
|
139 |
return null; |
|
140 |
} |
|
158 |
private void checkContents() { |
|
159 |
if( this.isValid() ) { |
|
160 |
this.txtDate.setBackground(colorOk); |
|
161 |
} else { |
|
162 |
this.txtDate.setBackground(colorErr); |
|
141 | 163 |
} |
164 |
} |
|
142 | 165 |
|
143 |
@Override |
|
144 |
public void set(Date date) { |
|
145 |
if (txtDate instanceof JFormattedTextField) { |
|
146 |
((JFormattedTextField) txtDate).setValue(date); |
|
147 |
} else { |
|
148 |
this.txtDate.setText(this.df.format(date)); |
|
149 |
} |
|
166 |
@Override |
|
167 |
public boolean isValid() { |
|
168 |
if (StringUtils.isBlank(this.getText())) { |
|
169 |
return true; |
|
150 | 170 |
} |
171 |
try { |
|
172 |
Date date = this.df.parse(this.getText()); |
|
173 |
return true; |
|
174 |
} catch (ParseException ex) { |
|
175 |
return false; |
|
176 |
} |
|
177 |
} |
|
151 | 178 |
|
152 |
@Override
|
|
153 |
public void setEnabled(boolean enabled) {
|
|
154 |
this.btnDate.setEnabled(enabled);
|
|
155 |
this.txtDate.setEnabled(enabled);
|
|
179 |
@Override |
|
180 |
public boolean isEmpty() {
|
|
181 |
if (StringUtils.isBlank(this.getText())) {
|
|
182 |
return true;
|
|
156 | 183 |
} |
184 |
try { |
|
185 |
Date date = this.df.parse(this.getText()); |
|
186 |
return false; |
|
187 |
} catch (ParseException ex) { |
|
188 |
return true; |
|
189 |
} |
|
190 |
} |
|
157 | 191 |
|
158 |
@Override |
|
159 |
public boolean isEnabled() { |
|
160 |
return this.btnDate.isEnabled(); |
|
192 |
@Override |
|
193 |
public Date get() { |
|
194 |
if (StringUtils.isBlank(this.getText())) { |
|
195 |
return null; |
|
161 | 196 |
} |
197 |
try { |
|
198 |
Date date = this.df.parse(this.getText()); |
|
199 |
return date; |
|
200 |
} catch (ParseException ex) { |
|
201 |
return null; |
|
202 |
} |
|
203 |
} |
|
162 | 204 |
|
163 |
private void doShowCalendar() { |
|
164 |
if( !this.isEditable() ) { |
|
165 |
return; |
|
166 |
} |
|
167 |
JPopupMenu menu = new JPopupMenu(); |
|
168 |
menu.add(getJCalendar()); |
|
169 |
Date v = this.get(); |
|
170 |
if (v != null) { |
|
171 |
getJCalendar().setDate(v); |
|
172 |
} |
|
173 |
menu.show(this.txtDate, 0, this.txtDate.getY() + this.txtDate.getPreferredSize().height); |
|
174 |
this.set(getJCalendar().getDate()); |
|
175 |
this.fireChangeEvent(); |
|
205 |
@Override |
|
206 |
public void set(Date date) { |
|
207 |
if( date == null ) { |
|
208 |
this.txtDate.setText(""); |
|
209 |
return; |
|
176 | 210 |
} |
211 |
this.txtDate.setText(this.df.format(date)); |
|
212 |
} |
|
177 | 213 |
|
178 |
protected JCalendar getJCalendar() { |
|
179 |
if (this.jcalendar == null) { |
|
180 |
this.jcalendar = new JCalendar(); |
|
181 |
this.jcalendar.addDateListener((DateEvent arg0) -> { |
|
182 |
set(getJCalendar().getDate()); |
|
183 |
fireChangeEvent(); |
|
184 |
}); |
|
185 |
} |
|
186 |
return (JCalendar) this.jcalendar; |
|
214 |
@Override |
|
215 |
public void setEnabled(boolean enabled) { |
|
216 |
this.btnDate.setEnabled(enabled); |
|
217 |
this.txtDate.setEnabled(enabled); |
|
218 |
} |
|
219 |
|
|
220 |
@Override |
|
221 |
public boolean isEnabled() { |
|
222 |
return this.btnDate.isEnabled(); |
|
223 |
} |
|
224 |
|
|
225 |
private void doShowCalendar() { |
|
226 |
if (!this.isEditable()) { |
|
227 |
return; |
|
187 | 228 |
} |
229 |
JPopupMenu menu = new JPopupMenu(); |
|
230 |
menu.add(getJCalendar()); |
|
231 |
Date v = this.get(); |
|
232 |
if (v != null) { |
|
233 |
getJCalendar().setDate(v); |
|
234 |
} |
|
235 |
menu.show(this.txtDate, 0, this.txtDate.getY() + this.txtDate.getPreferredSize().height); |
|
236 |
} |
|
188 | 237 |
|
189 |
@Override |
|
190 |
public void coerceAndSet(Object value) { |
|
191 |
this.set((Date) this.coerce(DataTypes.DATE, value, new Date())); |
|
238 |
protected JCalendar getJCalendar() { |
|
239 |
if (this.jcalendar == null) { |
|
240 |
this.jcalendar = new JCalendar(); |
|
241 |
this.jcalendar.addDateListener((DateEvent arg0) -> { |
|
242 |
set(getJCalendar().getDate()); |
|
243 |
fireChangeEvent(); |
|
244 |
}); |
|
192 | 245 |
} |
193 |
|
|
246 |
return (JCalendar) this.jcalendar; |
|
247 |
} |
|
248 |
|
|
249 |
@Override |
|
250 |
public void coerceAndSet(Object value) { |
|
251 |
this.set((Date) this.coerce(DataTypes.DATE, value, new Date())); |
|
252 |
} |
|
253 |
|
|
194 | 254 |
} |
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/pickercontroller/ColorPickerControllerImpl.java | ||
---|---|---|
11 | 11 |
import javax.swing.JButton; |
12 | 12 |
import javax.swing.JColorChooser; |
13 | 13 |
import javax.swing.JSlider; |
14 |
import javax.swing.JTextField; |
|
15 | 14 |
import javax.swing.SwingUtilities; |
16 | 15 |
import javax.swing.event.ChangeEvent; |
17 | 16 |
import javax.swing.event.ChangeListener; |
17 |
import javax.swing.text.JTextComponent; |
|
18 | 18 |
|
19 | 19 |
import org.gvsig.tools.ToolsLocator; |
20 | 20 |
import org.gvsig.tools.i18n.I18nManager; |
... | ... | |
31 | 31 |
implements ColorPickerController |
32 | 32 |
{ |
33 | 33 |
|
34 |
private final JTextField txtLabel;
|
|
34 |
private final JTextComponent txtLabel;
|
|
35 | 35 |
private final JButton btnShowDialog; |
36 | 36 |
private final JSlider sldAlpha; |
37 | 37 |
private Color color; |
... | ... | |
48 | 48 |
} |
49 | 49 |
} |
50 | 50 |
|
51 |
public ColorPickerControllerImpl(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
51 |
public ColorPickerControllerImpl(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
52 | 52 |
this.txtLabel = txtLabel; |
53 | 53 |
this.btnShowDialog = btnShowDialog; |
54 | 54 |
this.sldAlpha = sldAlpha; |
... | ... | |
67 | 67 |
sldAlpha.removeChangeListener(l); |
68 | 68 |
} |
69 | 69 |
} |
70 |
this.btnShowDialog.addActionListener(new ActionListener() { |
|
71 |
@Override |
|
72 |
public void actionPerformed(ActionEvent e) { |
|
73 |
doShowDialog(); |
|
74 |
} |
|
70 |
this.btnShowDialog.addActionListener((ActionEvent e) -> { |
|
71 |
doShowDialog(); |
|
75 | 72 |
}); |
76 | 73 |
if( this.sldAlpha != null ) { |
77 | 74 |
this.sldAlpha.setMinimum(0); |
78 | 75 |
this.sldAlpha.setMaximum(255); |
79 |
this.sldAlpha.addChangeListener(new ChangeListener() { |
|
80 |
@Override |
|
81 |
public void stateChanged(ChangeEvent e) { |
|
82 |
doAlphaChanged(); |
|
83 |
} |
|
76 |
this.sldAlpha.addChangeListener((ChangeEvent e) -> { |
|
77 |
doAlphaChanged(); |
|
84 | 78 |
}); |
85 | 79 |
} |
86 | 80 |
Font font = this.txtLabel.getFont(); |
... | ... | |
97 | 91 |
} |
98 | 92 |
} |
99 | 93 |
|
100 |
public ColorPickerControllerImpl(JTextField txtLabel, JButton btnShowDialog) {
|
|
94 |
public ColorPickerControllerImpl(JTextComponent txtLabel, JButton btnShowDialog) {
|
|
101 | 95 |
this(txtLabel, btnShowDialog, null, false); |
102 | 96 |
} |
103 | 97 |
|
104 |
public ColorPickerControllerImpl(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
98 |
public ColorPickerControllerImpl(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
105 | 99 |
this(txtLabel, btnShowDialog, sldAlpha, false); |
106 | 100 |
} |
107 | 101 |
|
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/pickercontroller/FilePickerControllerImpl.java | ||
---|---|---|
1 | 1 |
package org.gvsig.tools.swing.impl.pickercontroller; |
2 | 2 |
|
3 | 3 |
import java.awt.event.ActionEvent; |
4 |
import java.awt.event.ActionListener; |
|
5 | 4 |
import java.awt.event.KeyAdapter; |
6 | 5 |
import java.awt.event.KeyEvent; |
7 | 6 |
import java.io.File; |
... | ... | |
9 | 8 |
import javax.swing.ImageIcon; |
10 | 9 |
import javax.swing.JButton; |
11 | 10 |
import javax.swing.JFileChooser; |
12 |
import javax.swing.JTextField; |
|
13 | 11 |
import javax.swing.filechooser.FileFilter; |
12 |
import javax.swing.text.JTextComponent; |
|
14 | 13 |
import org.apache.commons.lang3.ArrayUtils; |
15 | 14 |
import org.gvsig.tools.ToolsLocator; |
16 | 15 |
import org.gvsig.tools.dataTypes.DataTypes; |
... | ... | |
33 | 32 |
implements FilePickerController { |
34 | 33 |
|
35 | 34 |
private final JButton btnFile; |
36 |
private final JTextField txtFile;
|
|
35 |
private final JTextComponent txtFile;
|
|
37 | 36 |
private final File initialPath; |
38 | 37 |
private final String fileChooserID; |
39 | 38 |
private final String dialogTitle; |
... | ... | |
57 | 56 |
} |
58 | 57 |
} |
59 | 58 |
|
60 |
public FilePickerControllerImpl(JTextField txtFile, JButton btnFile, String dialogTitle) {
|
|
59 |
public FilePickerControllerImpl(JTextComponent txtFile, JButton btnFile, String dialogTitle) {
|
|
61 | 60 |
this(txtFile, btnFile, dialogTitle, null, null, true); |
62 | 61 |
} |
63 | 62 |
|
64 |
public FilePickerControllerImpl(JTextField txtFile, JButton btnFile) {
|
|
63 |
public FilePickerControllerImpl(JTextComponent txtFile, JButton btnFile) {
|
|
65 | 64 |
this(txtFile, btnFile, null, null, null, true); |
66 | 65 |
} |
67 | 66 |
|
68 |
public FilePickerControllerImpl(JTextField txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
67 |
public FilePickerControllerImpl(JTextComponent txtFile, JButton btnFile, String dialogTitle, String fileChooserID, File initialPath, boolean seticon) {
|
|
69 | 68 |
this.value = null; |
70 | 69 |
this.txtFile = txtFile; |
71 | 70 |
this.btnFile = btnFile; |
... | ... | |
81 | 80 |
this.btnFile.setIcon(this.getIcon("picker-file")); |
82 | 81 |
this.btnFile.setText(""); |
83 | 82 |
} |
84 |
this.btnFile.addActionListener(new ActionListener() { |
|
85 |
@Override |
|
86 |
public void actionPerformed(ActionEvent e) { |
|
87 |
doSelectFile(); |
|
88 |
} |
|
83 |
this.btnFile.addActionListener((ActionEvent e) -> { |
|
84 |
doSelectFile(); |
|
89 | 85 |
}); |
90 | 86 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
91 | 87 |
toolsSwingManager.setDefaultPopupMenu(txtFile); |
92 |
toolsSwingManager.addClearButton(txtFile, new ActionListener() { |
|
93 |
@Override |
|
94 |
public void actionPerformed(ActionEvent e) { |
|
95 |
doClear(); |
|
96 |
} |
|
88 |
toolsSwingManager.addClearButton(txtFile, (ActionEvent e) -> { |
|
89 |
doClear(); |
|
97 | 90 |
}); |
98 | 91 |
//this.txtFile.setEditable(false); |
99 | 92 |
this.txtFile.addKeyListener(new KeyAdapter() { |
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/DefaultColorChooserController.java | ||
---|---|---|
9 | 9 |
import javax.swing.JButton; |
10 | 10 |
import javax.swing.JColorChooser; |
11 | 11 |
import javax.swing.JSlider; |
12 |
import javax.swing.JTextField; |
|
13 | 12 |
import javax.swing.SwingUtilities; |
14 | 13 |
import javax.swing.event.ChangeEvent; |
15 | 14 |
import javax.swing.event.ChangeListener; |
15 |
import javax.swing.text.JTextComponent; |
|
16 | 16 |
|
17 | 17 |
import org.gvsig.tools.ToolsLocator; |
18 | 18 |
import org.gvsig.tools.i18n.I18nManager; |
... | ... | |
22 | 22 |
|
23 | 23 |
public class DefaultColorChooserController implements ColorChooserController { |
24 | 24 |
|
25 |
private final JTextField txtLabel;
|
|
25 |
private final JTextComponent txtLabel;
|
|
26 | 26 |
private final JButton btnShowDialog; |
27 | 27 |
private final JSlider sldAlpha; |
28 | 28 |
private Color color; |
29 | 29 |
private boolean allowNull; |
30 | 30 |
private ChangeListener changeListener; |
31 | 31 |
|
32 |
public DefaultColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
32 |
public DefaultColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) {
|
|
33 | 33 |
this.txtLabel = txtLabel; |
34 | 34 |
this.btnShowDialog = btnShowDialog; |
35 | 35 |
this.sldAlpha = sldAlpha; |
... | ... | |
42 | 42 |
for( ChangeListener l : sldAlpha.getChangeListeners()) { |
43 | 43 |
sldAlpha.removeChangeListener(l); |
44 | 44 |
} |
45 |
this.btnShowDialog.addActionListener(new ActionListener() { |
|
46 |
@Override |
|
47 |
public void actionPerformed(ActionEvent e) { |
|
48 |
doShowDialog(); |
|
49 |
} |
|
45 |
this.btnShowDialog.addActionListener((ActionEvent e) -> { |
|
46 |
doShowDialog(); |
|
50 | 47 |
}); |
51 | 48 |
if( this.sldAlpha != null ) { |
52 | 49 |
this.sldAlpha.setMinimum(0); |
53 | 50 |
this.sldAlpha.setMaximum(255); |
54 |
this.sldAlpha.addChangeListener(new ChangeListener() { |
|
55 |
@Override |
|
56 |
public void stateChanged(ChangeEvent e) { |
|
57 |
doAlphaChanged(); |
|
58 |
} |
|
51 |
this.sldAlpha.addChangeListener((ChangeEvent e) -> { |
|
52 |
doAlphaChanged(); |
|
59 | 53 |
}); |
60 | 54 |
} |
61 | 55 |
Font font = this.txtLabel.getFont(); |
... | ... | |
72 | 66 |
} |
73 | 67 |
} |
74 | 68 |
|
75 |
public DefaultColorChooserController(JTextField txtLabel, JButton btnShowDialog) {
|
|
69 |
public DefaultColorChooserController(JTextComponent txtLabel, JButton btnShowDialog) {
|
|
76 | 70 |
this(txtLabel, btnShowDialog, null, false); |
77 | 71 |
} |
78 | 72 |
|
79 |
public DefaultColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
73 |
public DefaultColorChooserController(JTextComponent txtLabel, JButton btnShowDialog, JSlider sldAlpha) {
|
|
80 | 74 |
this(txtLabel, btnShowDialog, sldAlpha, false); |
81 | 75 |
} |
82 | 76 |
|
Also available in: Unified diff