This is an automated email from the git hooks/post-receive script. New commit to branch feature/8429 in repository observe. See https://gitlab.nuiton.org/codelutin/observe.git commit 1365c73bb628fa222e3c18b73271960b0464d300 Author: Tony CHEMIT <chemit@codelutin.com> Date: Tue Nov 8 12:20:37 2016 +0100 Ajout raccourci clavier sur les listes déroulantes --- .../swing/ui/content/ContentUIInitializer.java | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ContentUIInitializer.java b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ContentUIInitializer.java index 6cd093c..c2cee31 100644 --- a/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ContentUIInitializer.java +++ b/application-swing/src/main/java/fr/ird/observe/application/swing/ui/content/ContentUIInitializer.java @@ -69,7 +69,9 @@ import org.nuiton.jaxx.widgets.gis.absolute.CoordinatesEditor; import org.nuiton.jaxx.widgets.select.FilterableDoubleList; import org.nuiton.util.DateUtil; +import javax.swing.AbstractAction; import javax.swing.AbstractButton; +import javax.swing.Action; import javax.swing.ActionMap; import javax.swing.JCheckBox; import javax.swing.JComboBox; @@ -82,6 +84,7 @@ import javax.swing.JSpinner; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.KeyStroke; import javax.swing.ListCellRenderer; import javax.swing.SwingUtilities; import javax.swing.border.LineBorder; @@ -89,6 +92,7 @@ import javax.swing.table.TableCellEditor; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.event.ActionEvent; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.ItemEvent; @@ -361,6 +365,43 @@ public class ContentUIInitializer<E extends IdDto, UI extends ObserveContentUI<E } beanComboBox.setI18nPrefix("observe.common."); beanComboBox.setMinimumSize(new Dimension(0, 24)); + beanComboBox.getResetButton().setToolTipText(beanComboBox.getResetButton().getToolTipText() + " (ctrl + D)"); + beanComboBox.getChangeDecorator().setToolTipText(beanComboBox.getChangeDecorator().getToolTipText() + " (ctrl + F)"); + JComponent editorComponent = (JComponent) beanComboBox.getCombobox().getEditor().getEditorComponent(); + + Action resetAction = new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + beanComboBox.doActionPerformed__on__resetButton(null); + SwingUtilities.invokeLater(beanComboBox::grabFocus); + } + }; + + editorComponent.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl pressed D"), "resetAction"); + editorComponent.getActionMap().put("resetAction", resetAction); + + Action showPopupAction = new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + if (!beanComboBox.getCombobox().isPopupVisible()) { + beanComboBox.getCombobox().showPopup(); + } else { + beanComboBox.setSelectedItem(beanComboBox.getCombobox().getEditor().getItem()); + beanComboBox.getCombobox().hidePopup(); + } + } + }; + editorComponent.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), "showPopupAction"); + editorComponent.getActionMap().put("showPopupAction", showPopupAction); + + Action showDecoratorPopupAction = new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + beanComboBox.getPopup().show(beanComboBox, 0, 0); + } + }; + editorComponent.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ctrl pressed F"), "showDecoratorPopupAction"); + editorComponent.getActionMap().put("showDecoratorPopupAction", showDecoratorPopupAction); Class dtoClass = getDtoClass(beanComboBox); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.