Author: sbavencoff Date: 2013-11-22 17:49:26 +0100 (Fri, 22 Nov 2013) New Revision: 3717 Url: http://chorem.org/projects/lima/repository/revisions/3717 Log: [Entry Book] : move button into toolBar add shortcuts add icons Added: trunk/lima-swing/src/main/resources/icons/action-entryBook-edit.png trunk/lima-swing/src/main/resources/icons/action-entryBook-import.png trunk/lima-swing/src/main/resources/icons/action-entryBook-new.png trunk/lima-swing/src/main/resources/icons/action-entryBook-remove.png Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2013-11-22 16:48:35 UTC (rev 3716) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2013-11-22 16:49:26 UTC (rev 3717) @@ -49,7 +49,7 @@ <JLabel text="lima.ui.entrybook.code"/> </cell> <cell> - <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}" editable='{isAddState()}' /> + <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}" enabled='{isAddState()}' /> <Document javaBean="getEntryBookCodeField().getDocument()" onInsertUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())' onRemoveUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())'/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2013-11-22 16:48:35 UTC (rev 3716) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2013-11-22 16:49:26 UTC (rev 3717) @@ -41,7 +41,37 @@ ]]></script> <row> - <cell fill="both" weightx="1" weighty="1" rows='4'> + <cell fill="horizontal"> + <JToolBar floatable="false"> + + <JButton id="addButton" + toolTipText="{ _("lima.ui.entrybook.add") + " (Ctrl+N)"}" + actionIcon='entryBook-new' + onActionPerformed="handler.addEntryBook()"/> + + <JButton id="updateButton" + toolTipText="{ _("lima.ui.entrybook.update") + " (Ctrl+M)"}" + actionIcon='entryBook-edit' + onActionPerformed="handler.updateEntryBook()" + enabled="{isSelectedRow()}"/> + + <JButton id="removeButton" + toolTipText="{ _("lima.ui.entrybook.remove") + " (Del)"}" + actionIcon='entryBook-remove' + onActionPerformed="handler.deleteEntryBook()" + enabled="{isSelectedRow()}"/> + + <JButton id="importButton" + actionIcon='entryBook-import' + toolTipText="lima.ui.importexport.import" + onActionPerformed="handler.importEntryBooks()"/> + + </JToolBar> + </cell> + </row> + + <row> + <cell fill="both" weightx="1" weighty="1"> <JScrollPane> <EntryBookTable id="entryBooksTable" rowHeight="24" constructorParams="getHandler()" @@ -52,29 +82,5 @@ onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/> </JScrollPane> </cell> - <cell fill="horizontal"> - <JButton id="addButton" text="lima.ui.entrybook.add" - onActionPerformed="getHandler().addEntryBook()"/> - </cell> </row> - <row> - <cell fill="horizontal"> - <JButton id="updateButton" text="lima.ui.entrybook.update" - enabled="{isSelectedRow()}" - onActionPerformed="getHandler().updateEntryBook()"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JButton id="removeButton" text="lima.ui.entrybook.remove" - enabled="{isSelectedRow()}" - onActionPerformed="getHandler().deleteEntryBook()"/> - </cell> - </row> - <row> - <cell fill="horizontal" anchor="north" weighty="1"> - <JButton id="importButton" text="lima.ui.importexport.import" - onActionPerformed="getHandler().importEntryBooks()"/> - </cell> - </row> </Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-11-22 16:48:35 UTC (rev 3716) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-11-22 16:49:26 UTC (rev 3717) @@ -25,12 +25,6 @@ package org.chorem.lima.ui.entrybook; -import static org.nuiton.i18n.I18n._; - -import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.ServiceListener; @@ -44,6 +38,15 @@ import org.chorem.lima.ui.importexport.ImportExport; import org.jdesktop.swingx.JXTable; +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Handler for entry book view. * @@ -68,6 +71,51 @@ } public void init() { + + InputMap inputMap = view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = view.getActionMap(); + + // add action on Ctrl + N + String binding = "new-entryBook"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + addEntryBook(); + } + }); + + // add action on Delete + binding = "remove-entryBook"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + deleteEntryBook(); + } + }); + + // add action on Ctrl + M + binding = "modify-entryBook"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + updateEntryBook(); + } + }); + + EntryBookTable table = view.getEntryBooksTable(); + + table.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 ) { + updateEntryBook(); + } + } + }); + loadAllEntryBooks(); } @@ -92,7 +140,19 @@ public void addEntryBook() { EntryBook newEntryBook = new EntryBookImpl(); - EntryBookForm entryBookForm = new EntryBookForm(view); + final EntryBookForm entryBookForm = new EntryBookForm(view); + + InputMap inputMap = entryBookForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = entryBookForm.getRootPane().getActionMap(); + String binding = "dispose"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + entryBookForm.performCancel(); + } + }); + entryBookForm.setEntryBook(newEntryBook); entryBookForm.setLocationRelativeTo(view); entryBookForm.setVisible(true); @@ -121,7 +181,19 @@ int selectedRow = entryBookTable.getSelectedRow(); EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow); - EntryBookForm entryBookForm = new EntryBookForm(view); + final EntryBookForm entryBookForm = new EntryBookForm(view); + + InputMap inputMap = entryBookForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = entryBookForm.getRootPane().getActionMap(); + String binding = "dispose"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + entryBookForm.performCancel(); + } + }); + entryBookForm.setAddState(false); entryBookForm.setEntryBook(selectedEntryBook); entryBookForm.setLocationRelativeTo(view); @@ -169,7 +241,19 @@ */ public void importEntryBooks() { - EntryBookImportForm form = new EntryBookImportForm(view); + final EntryBookImportForm form = new EntryBookImportForm(view); + + InputMap inputMap = form.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = form.getRootPane().getActionMap(); + String binding = "dispose"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + form.performCancel(); + } + }); + form.setLocationRelativeTo(view); form.setVisible(true); Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-edit.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-edit.png) =================================================================== (Binary files differ) Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-import.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-import.png) =================================================================== (Binary files differ) Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-new.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-new.png) =================================================================== (Binary files differ) Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-remove.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-remove.png) =================================================================== (Binary files differ)