Author: sbavencoff Date: 2013-11-22 16:35:03 +0100 (Fri, 22 Nov 2013) New Revision: 3714 Url: http://chorem.org/projects/lima/repository/revisions/3714 Log: [Account Plan] : move button into toolBar add shortcuts add icons Added: trunk/lima-swing/src/main/resources/icons/action-account-edit.png trunk/lima-swing/src/main/resources/icons/action-account-import.png trunk/lima-swing/src/main/resources/icons/action-account-new.png trunk/lima-swing/src/main/resources/icons/action-account-remove.png Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2013-11-22 15:33:11 UTC (rev 3713) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2013-11-22 15:35:03 UTC (rev 3714) @@ -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.account.addaccount") + " (Ctrl+N)"}" + actionIcon='account-new' + onActionPerformed="handler.addAccount()"/> + + <JButton id="updateButton" + toolTipText="{ _("lima.ui.common.update") + " (Ctrl+M)"}" + actionIcon='account-edit' + onActionPerformed="handler.updateAccount()" + enabled="{isSelectedRow()}"/> + + <JButton id="removeButton" + toolTipText="{ _("lima.ui.common.remove") + " (Del)"}" + actionIcon='account-remove' + onActionPerformed="handler.removeAccount()" + enabled="{isSelectedRow()}"/> + + <JButton id="importButton" + actionIcon='account-import' + toolTipText="lima.ui.importexport.import" + onActionPerformed="handler.importAccountsChart()"/> + + </JToolBar> + </cell> + </row> + + <row> + <cell fill="both" weightx="1" weighty="1"> <JScrollPane> <JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" @@ -51,29 +81,5 @@ onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/> </JScrollPane> </cell> - <cell fill="horizontal"> - <JButton id="addButton" text="lima.ui.account.addaccount" - onActionPerformed="handler.addAccount()"/> - </cell> </row> - <row> - <cell fill="horizontal"> - <JButton id="updateButton" text="lima.ui.common.update" - onActionPerformed="handler.updateAccount()" - enabled="{isSelectedRow()}"/> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JButton id="removeButton" text="lima.ui.common.remove" - onActionPerformed="handler.removeAccount()" - enabled="{isSelectedRow()}"/> - </cell> - </row> - <row> - <cell fill="horizontal" anchor="north" weighty="1"> - <JButton id="importButton" text="lima.ui.importexport.import" - onActionPerformed="handler.importAccountsChart()"/> - </cell> - </row> </Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2013-11-22 15:33:11 UTC (rev 3713) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2013-11-22 15:35:03 UTC (rev 3714) @@ -25,25 +25,6 @@ package org.chorem.lima.ui.account; -import static org.nuiton.i18n.I18n._; - -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.SortedMap; -import java.util.TreeMap; - -import javax.swing.JOptionPane; -import javax.swing.tree.TreePath; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.ServiceListener; @@ -60,6 +41,25 @@ import org.jdesktop.swingx.treetable.MutableTreeTableNode; import org.jdesktop.swingx.treetable.TreeTableNode; +import javax.swing.*; +import javax.swing.tree.TreePath; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + +import static org.nuiton.i18n.I18n._; + /** * Handler associated with account view. * @@ -119,22 +119,42 @@ */ public void init() { JXTreeTable table = view.getAccountsTreeTable(); - table.addKeyListener(new KeyAdapter() { - /** - * for each action combination key are think - * for extend keyboard and laptop keyboard - */ + + //To block reaction of the dual key 'ctrl+a' (Selection of all lines) + InputMap inputMap = view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = view.getActionMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none"); + + // add action on Ctrl + N + String binding = "new-account"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { @Override - public void keyPressed(KeyEvent e) { - JXTreeTable source = (JXTreeTable) e.getSource(); - // clear row selection with the key: escape - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!source.isEditing()) { - source.clearSelection(); - } - } + public void actionPerformed(ActionEvent e) { + addAccount(); } }); + + // add action on Delete + binding = "remove-account"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + removeAccount(); + } + }); + + // add action on Ctrl + M + binding = "modify-account"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + updateAccount(); + } + }); + table.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { @@ -143,6 +163,13 @@ source.clearSelection(); } } + + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 2 ) { + updateAccount(); + } + } }); loadAllAccounts(); @@ -193,7 +220,19 @@ * Display add account view */ public void addAccount() { - AccountForm accountForm = new AccountForm(view); + final AccountForm accountForm = new AccountForm(view); + + InputMap inputMap = accountForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = accountForm.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) { + accountForm.dispose(); + } + }); + accountForm.setLocationRelativeTo(view); accountForm.setVisible(true); } @@ -288,7 +327,20 @@ Account selectedAccount = (Account)lastPathComponent.getUserObject(); // display edit form - UpdateAccountForm accountForm = new UpdateAccountForm(view); + final UpdateAccountForm accountForm = new UpdateAccountForm(view); + + InputMap inputMap = accountForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = accountForm.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) { + accountForm.dispose(); + } + }); + + accountForm.setAccount(selectedAccount); accountForm.setLocationRelativeTo(view); accountForm.setVisible(true); @@ -355,7 +407,19 @@ public void importAccountsChart() { - AccountImportForm form = new AccountImportForm(view); + final AccountImportForm form = new AccountImportForm(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); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2013-11-22 15:33:11 UTC (rev 3713) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2013-11-22 15:35:03 UTC (rev 3714) @@ -48,7 +48,8 @@ <JLabel text="lima.ui.account.number" labelFor='{numberTextField}'/> </cell> <cell fill="horizontal"> - <JTextField id="numberTextField" editable='{false}' + <JTextField id="numberTextField" + enabled="false" text="{getAccount().getAccountNumber()}"/> </cell> </row> Added: trunk/lima-swing/src/main/resources/icons/action-account-edit.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-edit.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-account-import.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-import.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-account-new.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-new.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-account-remove.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-remove.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream