This is an automated email from the git hooks/post-receive script. New commit to branch feature/1187 in repository lima. See http://git.chorem.org/lima.git commit e27ec71ef6a2a600f8a1ea2eadb01c46ad6d43de Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Fri Mar 27 08:52:22 2015 +0100 refs #1187 : fiscal period popups --- .../org/chorem/lima/ui/fiscalperiod/AddPeriod.css | 6 +- .../org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx | 28 +++---- .../ui/fiscalperiod/FiscalPeriodViewHandler.java | 70 +++++++++++------- .../fiscalperiod/RetainedEarningsEntryBookForm.css | 33 ++++----- .../RetainedEarningsEntryBookForm.jaxx | 85 +++++----------------- 5 files changed, 92 insertions(+), 130 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.css b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.css index b99c328..3aa092f 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.css @@ -37,10 +37,12 @@ labelFor : "{endDatePicker}"; } -#cancelButton { +#cancel { text : "lima.cancel"; + actionIcon : cancel; } -#okButton { +#ok { text : "lima.ok"; + actionIcon : ok; } \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx index 4af795a..06e4fc0 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx @@ -22,6 +22,7 @@ <JDialog id="periodFormDialog" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" + layout="{new BorderLayout()}" onWindowClosing="performCancel();"> <Boolean id="modifyPeriod" javaBean="false"/> @@ -30,7 +31,7 @@ <script> <![CDATA[ - getRootPane().setDefaultButton(okButton); + getRootPane().setDefaultButton(ok); protected void performOk() { setValidate(true); @@ -43,7 +44,7 @@ } ]]></script> - <Table fill="both"> + <Table constraints="BorderLayout.CENTER"> <row> <cell> <JLabel id="beginDateLabel"/> @@ -60,21 +61,12 @@ <org.jdesktop.swingx.JXDatePicker id="endDatePicker" /> </cell> </row> - <row> - <cell> - <Table fill="none" anchor="center" weighty="1"> - <row> - <cell> - <JButton id="cancelButton" - onActionPerformed="performCancel()"/> - </cell> - <cell> - <JButton id="okButton" - onActionPerformed="performOk()"/> - </cell> - </row> - </Table> - </cell> - </row> </Table> + <JPanel constraints="BorderLayout.SOUTH" + layout='{new GridLayout(1,0)}'> + <JButton id="cancel" + onActionPerformed="performCancel()"/> + <JButton id="ok" + onActionPerformed="performOk()"/> + </JPanel> </JDialog> diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java index 514f805..38d031a 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java @@ -45,7 +45,14 @@ import org.chorem.lima.business.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; import org.nuiton.util.DateUtil; -import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.DefaultListSelectionModel; +import javax.swing.InputMap; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.KeyStroke; +import javax.swing.SwingWorker; import javax.swing.event.ListSelectionEvent; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; @@ -374,46 +381,55 @@ public class FiscalPeriodViewHandler implements ServiceListener { if (answerRetainedEarnings == JOptionPane.YES_OPTION) { //Sets EntryBook - EntryBook newEntryBook = new EntryBookImpl(); RetainedEarningsEntryBookForm entryBookForm = new RetainedEarningsEntryBookForm(view); - entryBookForm.setEntryBook(newEntryBook); // jaxx constructor don't call super() ? entryBookForm.setLocationRelativeTo(view); entryBookForm.setVisible(true); - final EntryBook entryBook = entryBookForm.getEntryBook(); - if (entryBook != null && StringUtils.isNotBlank(entryBook.getCode())) { + if (entryBookForm.getValidate()) { + final EntryBook entryBook; - final RetainedEarningsWait retainedEarningsWait = new RetainedEarningsWait(view); - retainedEarningsWait.setLocationRelativeTo(view); + if (entryBookForm.getNewEntryBookCheckBox().isSelected()) { + entryBook = new EntryBookImpl(); + entryBook.setCode(entryBookForm.getCodeField().getText()); + entryBook.setLabel(entryBookForm.getLabelField().getText()); + } else { + entryBook = (EntryBook) entryBookForm.getEntryBookComboBox().getSelectedItem(); + } - new SwingWorker<FiscalPeriod, Void>() { - @Override - protected FiscalPeriod doInBackground() throws Exception { - FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, true); - tableModel.setValue(selectedRow, fiscalPeriodBlocked); + if (entryBook != null && StringUtils.isNotBlank(entryBook.getCode())) { - view.setBlockEnabled(false); - view.setDeleteEnabled(false); + final RetainedEarningsWait retainedEarningsWait = new RetainedEarningsWait(view); + retainedEarningsWait.setLocationRelativeTo(view); - return fiscalPeriodBlocked; - } + new SwingWorker<FiscalPeriod, Void>() { + @Override + protected FiscalPeriod doInBackground() throws Exception { + FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, true); + tableModel.setValue(selectedRow, fiscalPeriodBlocked); - @Override - protected void done() { - retainedEarningsWait.setVisible(false); - } - }.execute(); - retainedEarningsWait.setVisible(true); + view.setBlockEnabled(false); + view.setDeleteEnabled(false); - } else { + return fiscalPeriodBlocked; + } - JOptionPane.showMessageDialog(view, - t("lima.fiscalPeriod.block.cantBalanceNotBook"), - t("lima.fiscalPeriod.block.title"), - JOptionPane.ERROR_MESSAGE); + @Override + protected void done() { + retainedEarningsWait.setVisible(false); + } + }.execute(); + retainedEarningsWait.setVisible(true); + + } else { + + JOptionPane.showMessageDialog(view, + t("lima.fiscalPeriod.block.cantBalanceNotBook"), + t("lima.fiscalPeriod.block.title"), + JOptionPane.ERROR_MESSAGE); + } } } else { diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.css b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.css index 190ab4d..7412c17 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.css +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.css @@ -21,50 +21,47 @@ */ #retainedEarningsEntryBookFormDialog { title : "lima.fiscalPeriod.block.retainedEarnings"; + minimumSize : {new Dimension(250, 160)} } -#selectedEntryBook { - text : "lima.entryBook"; - selected : true; - buttonGroup : "EntryBookGroup"; - +#newEntryBookCheckBox { + text : "lima.fiscalPeriod.entryBooks.create"; + border : {BorderFactory.createEmptyBorder(6, 6, 6, 6)} } #entryBookSelectorLabel { text : "lima.entryBook"; + visible : {!newEntryBookCheckBox.isSelected()}; } #entryBookComboBox { - editable : "false"; -} - -#newEntryBook { - text : "lima.fiscalPeriod.entryBooks.create"; - selected : false; - buttonGroup : "EntryBookGroup"; + visible : {!newEntryBookCheckBox.isSelected()}; } #codeLabel { text : "lima.entryBook.code"; + visible : {newEntryBookCheckBox.isSelected()}; } #codeField { - text : "{getEntryBook().getCode()}"; + visible : {newEntryBookCheckBox.isSelected()}; } #labelLabel { text : "lima.label"; + visible : {newEntryBookCheckBox.isSelected()}; } -#LabelField { - editable : "{isAddState()}"; - text : "{getEntryBook().getLabel()}"; +#labelField { + visible : {newEntryBookCheckBox.isSelected()}; } -#cancelButton { +#cancel { text : "lima.cancel"; + actionIcon : cancel; } -#okButton { +#ok { text : "lima.ok"; + actionIcon : ok; } \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx index 2c50771..2754946 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx @@ -22,65 +22,37 @@ <JDialog id="retainedEarningsEntryBookFormDialog" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" - onWindowClosing="performCancel();"> + layout="{new BorderLayout()}" + onWindowClosing="dispose();"> <import> + java.awt.Dimension javax.swing.text.Document org.chorem.lima.entity.EntryBook org.chorem.lima.ui.common.EntryBookListRenderer </import> - <EntryBook id="entryBook" javaBean="null"/> - <Boolean id="addState" javaBean='true'/> + <Boolean id="validate" javaBean='false'/> <script> <![CDATA[ - getRootPane().setDefaultButton(okButton); + getRootPane().setDefaultButton(ok); /** * Sets null to EntryBook and closes JDialog */ - protected void performCancel() { - setEntryBook(null); + protected void performOk() { + setValidate(true); dispose(); } - - /** - * Sets the right EntryBook to use and its values - */ - protected void performNew() { - if (selectedEntryBook.isSelected()) { - entryBookComboBox.setEnabled(true); - labelField.setEditable(false); - codeField.setEditable(false); - if (getEntryBookComboBox().getSelectedItem() != null) { - getEntryBook().setCode(((EntryBook)getEntryBookComboBox().getSelectedItem()).getCode().trim()); - getEntryBook().setLabel(((EntryBook)getEntryBookComboBox().getSelectedItem()).getLabel().trim()); - } else { - setEntryBook(null); - } - } else { - entryBookComboBox.setEnabled(false); - labelField.setEditable(true); - codeField.setEditable(true); - getEntryBook().setCode(getCodeField().getText()); - getEntryBook().setLabel(getLabelField().getText()); - } - } - - void $afterCompleteSetup() { - performNew(); - } + ]]> </script> - <Table> - <row> - <cell anchor="west"> - <JRadioButton id="selectedEntryBook" - onActionPerformed="performNew()"/> - </cell> - </row> + <JCheckBox id="newEntryBookCheckBox" + constraints="BorderLayout.NORTH"/> + + <Table constraints="BorderLayout.CENTER"> <row> <cell> <JLabel id="entryBookSelectorLabel" /> @@ -89,14 +61,7 @@ <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBookComboBox"/> <JComboBox id="entryBookComboBox" model="{getModelEntryBookComboBox()}" - renderer="{new EntryBookListRenderer()}" - onItemStateChanged="getEntryBook().setCode(((EntryBook)getEntryBookComboBox().getSelectedItem()).getCode()); getEntryBook().setLabel(((EntryBook)getEntryBookComboBox().getSelectedItem()).getLabel())"/> - </cell> - </row> - <row> - <cell anchor="west"> - <JRadioButton id="newEntryBook" - onActionPerformed="performNew()"/> + renderer="{new EntryBookListRenderer()}"/> </cell> </row> <row> @@ -105,9 +70,6 @@ </cell> <cell> <JTextField id="codeField"/> - <Document javaBean="getCodeField().getDocument()" - onInsertUpdate='getEntryBook().setCode(getCodeField().getText())' - onRemoveUpdate='getEntryBook().setCode(getCodeField().getText())'/> </cell> </row> <row> @@ -116,21 +78,14 @@ </cell> <cell> <JTextField id="labelField"/> - <Document javaBean="getLabelField().getDocument()" - onInsertUpdate='getEntryBook().setLabel(getLabelField().getText())' - onRemoveUpdate='getEntryBook().setLabel(getLabelField().getText())'/> - </cell> - </row> - <row> - <cell> - <JButton id="cancelButton" - onActionPerformed="performCancel()"/> </cell> - <cell> - <JButton id="okButton" - onActionPerformed="dispose()"/> - </cell> - </row> </Table> + <JPanel constraints="BorderLayout.SOUTH" + layout='{new GridLayout(1,0)}'> + <JButton id="cancel" + onActionPerformed="dispose()"/> + <JButton id="ok" + onActionPerformed="performOk()"/> + </JPanel> </JDialog> -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.