Revision 2297 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
DefaultToolsSwingManager.java | ||
---|---|---|
3 | 3 |
import org.gvsig.tools.swing.api.FilteredListModel; |
4 | 4 |
import java.awt.BorderLayout; |
5 | 5 |
import java.awt.Color; |
6 |
import java.awt.Component; |
|
6 | 7 |
import java.awt.Cursor; |
7 | 8 |
import java.awt.Dimension; |
8 | 9 |
import java.awt.event.ActionEvent; |
... | ... | |
81 | 82 |
import org.gvsig.tools.swing.impl.pickercontroller.DataTypePickerControllerImpl; |
82 | 83 |
|
83 | 84 |
public class DefaultToolsSwingManager implements ToolsSwingManager { |
85 |
private static final String CLEAR_BUTTON_NAME = "ClearButton"; |
|
86 |
|
|
84 | 87 |
|
85 | 88 |
private Dimension maxPhysicalSizeOfBufferedImage; |
86 | 89 |
private JWebBrowserFactory webBrowserfactory; |
... | ... | |
485 | 488 |
// Si no puede a?adir el boton no hace nada. |
486 | 489 |
} |
487 | 490 |
} |
491 |
public boolean hasClearButton(final JComboBox combo) { |
|
492 |
try { |
|
493 |
JTextComponent text = (JTextComponent) combo.getEditor().getEditorComponent(); |
|
494 |
return this.hasClearButton(text); |
|
495 |
} catch (Throwable th) { |
|
496 |
return false; |
|
497 |
} |
|
498 |
} |
|
488 | 499 |
|
500 |
public void removeClearButton(final JComboBox combo) { |
|
501 |
try { |
|
502 |
JTextComponent text = (JTextComponent) combo.getEditor().getEditorComponent(); |
|
503 |
this.removeClearButton(text); |
|
504 |
} catch (Throwable th) { |
|
505 |
// Si no puede a?adir el boton no hace nada. |
|
506 |
} |
|
507 |
} |
|
508 |
|
|
509 |
public boolean hasClearButton(final JTextComponent text) { |
|
510 |
for (Component component : text.getComponents()) { |
|
511 |
if( component instanceof JButton && |
|
512 |
StringUtils.equalsIgnoreCase(CLEAR_BUTTON_NAME, component.getName()) ) { |
|
513 |
return true; |
|
514 |
} |
|
515 |
} |
|
516 |
return false; |
|
517 |
} |
|
518 |
|
|
519 |
public void removeClearButton(final JTextComponent text) { |
|
520 |
for (Component component : text.getComponents()) { |
|
521 |
if( component instanceof JButton && |
|
522 |
StringUtils.equalsIgnoreCase(CLEAR_BUTTON_NAME, component.getName()) ) { |
|
523 |
text.remove(component); |
|
524 |
return; |
|
525 |
} |
|
526 |
} |
|
527 |
} |
|
528 |
|
|
489 | 529 |
@Override |
490 | 530 |
public void addClearButton(final JTextComponent text, final ActionListener action) { |
491 | 531 |
final JButton btnClear = new JButton(getIcon("picker-cleartext")); |
... | ... | |
494 | 534 |
btnClear.setContentAreaFilled(false); |
495 | 535 |
btnClear.setOpaque(false); |
496 | 536 |
btnClear.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
537 |
btnClear.setName(CLEAR_BUTTON_NAME); |
|
497 | 538 |
if (action == null) { |
498 | 539 |
btnClear.addActionListener((ActionEvent e) -> { |
499 | 540 |
text.setText(""); |
Also available in: Unified diff