branch feature/ReplaceComboByList created (now 486367e)
This is an automated email from the git hooks/post-receive script. New change to branch feature/ReplaceComboByList in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git at 486367e Handle onEnter on the client combo This branch includes the following new commits: new 486367e Handle onEnter on the client combo The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 486367e90716d4798ffbb491b3c0b26af3864d63 Author: Julien Ruchaud <julien.ruchaud@debux.org> Date: Wed Jun 8 12:31:29 2016 +0200 Handle onEnter on the client combo -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/ReplaceComboByList in repository faxtomail. See https://gitlab.nuiton.org/codelutin/faxtomail.git commit 486367e90716d4798ffbb491b3c0b26af3864d63 Author: Julien Ruchaud <julien.ruchaud@debux.org> Date: Wed Jun 8 12:31:29 2016 +0200 Handle onEnter on the client combo --- .../ui/swing/actions/ShowDemandeAction.java | 6 -- .../ui/swing/content/demande/DemandeUIHandler.java | 68 +++++++++++++++++++++- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java index ba1abf9..da6a752 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/ShowDemandeAction.java @@ -22,7 +22,6 @@ package com.franciaflex.faxtomail.ui.swing.actions; * #L% */ -import com.franciaflex.faxtomail.persistence.entities.Client; import com.franciaflex.faxtomail.persistence.entities.Email; import com.franciaflex.faxtomail.persistence.entities.FaxToMailUser; import com.franciaflex.faxtomail.persistence.entities.MailFolder; @@ -46,7 +45,6 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -180,10 +178,6 @@ public class ShowDemandeAction extends AbstractMainUIFaxToMailAction { currentEmail.setEditable(false); } } - - MailFolder folder = currentEmail.getMailFolder(); - List<Client> allowedClients = serviceContext.getClientService().getClientsForFolder(folder); - currentEmail.setAllowedClients(allowedClients); } @Override diff --git a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java index 0ee690f..4e24bf1 100644 --- a/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java +++ b/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java @@ -69,10 +69,16 @@ import javax.swing.event.ListSelectionListener; import javax.swing.table.TableCellEditor; import java.awt.*; import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.InputMethodEvent; +import java.awt.event.InputMethodListener; +import java.awt.event.ItemListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.text.AttributedCharacterIterator; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -82,6 +88,8 @@ import java.util.Date; import java.util.List; import java.util.Map; import java.util.Set; +import javax.swing.text.JTextComponent; +import jaxx.runtime.swing.model.JaxxFilterableComboBoxModel; import static org.nuiton.i18n.I18n.t; @@ -97,6 +105,8 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, private static final Log log = LogFactory.getLog(DemandeUIHandler.class); protected BeanMonitor monitor; + + protected String clientSearch; protected PropertyChangeListener rangeRowListener = new PropertyChangeListener() { @Override @@ -434,10 +444,62 @@ public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, } } - BeanFilterableComboBox<Client> clientComboBox = ui.getClientComboBox(); - clientComboBox.getComboBoxModel().setWildcardCharacter(null); - initBeanFilterableComboBox(clientComboBox, model.getAllowedClients(), model.getClient()); + // Handle combo search + final BeanFilterableComboBox<Client> clientComboBox = ui.getClientComboBox(); + initBeanFilterableComboBox(clientComboBox, null, model.getClient()); + + final JComboBox comboBox = clientComboBox.getCombobox(); + final JTextComponent editorComponent = (JTextComponent) comboBox.getEditor().getEditorComponent(); + editorComponent.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + int keyCode = e.getKeyCode(); + if (keyCode == KeyEvent.VK_ENTER) { + clientSearch = editorComponent.getText(); + } else { + clientSearch = null; + } + } + + @Override + public void keyReleased(KeyEvent e) { + int keyCode = e.getKeyCode(); + if (keyCode == KeyEvent.VK_ENTER) { + FaxToMailServiceContext serviceContext = getContext().newServiceContext(); + MailFolder folder = getModel().getMailFolder(); + List<Client> allowedClients = serviceContext.getClientService().getClientsForFolder(folder); + + getModel().setAllowedClients(allowedClients); + clientComboBox.setData(allowedClients); + + editorComponent.setText(clientSearch); + } + } + }); + + clientComboBox.addPropertyChangeListener(BeanFilterableComboBox.PROPERTY_SELECTED_ITEM, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (clientSearch != null) { + JaxxFilterableComboBoxModel model = (JaxxFilterableComboBoxModel) comboBox.getModel(); + model.setFilterText(clientSearch); + editorComponent.setText(clientSearch); + } + } + }); + + editorComponent.addFocusListener(new FocusListener() { + @Override + public void focusGained(FocusEvent e) { + comboBox.showPopup(); + } + + @Override + public void focusLost(FocusEvent e) { + } + }); + listModelIsModify(model); } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm