r3158 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod
Author: vsalaun Date: 2011-06-07 10:53:23 +0200 (Tue, 07 Jun 2011) New Revision: 3158 Url: http://chorem.org/repositories/revision/lima/3158 Log: #345 adding Date selector Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-06-06 09:59:07 UTC (rev 3157) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-06-07 08:53:23 UTC (rev 3158) @@ -29,6 +29,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; +import java.util.Date; import java.util.List; @@ -251,7 +252,7 @@ * @param entryBook * @throws LimaException */ - public void addRetainedEarnings(int selectedRow, EntryBook entryBook) throws LimaException { + public void addRetainedEarnings(int selectedRow, EntryBook entryBook, Date date) throws LimaException { FiscalPeriod fiscalPeriod = getFiscalPeriodAtRow(selectedRow); //check if the current fiscal period isn't block @@ -268,7 +269,7 @@ throw new LimaBusinessException("The previous fiscal period isn't blocked"); } - financialTransactionService.addRetainedEarnings(previousFiscalPeriod, fiscalPeriod, entryBook); + financialTransactionService.addRetainedEarnings(previousFiscalPeriod, fiscalPeriod, entryBook, date); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-06-06 09:59:07 UTC (rev 3157) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-06-07 08:53:23 UTC (rev 3158) @@ -27,6 +27,8 @@ import static org.nuiton.i18n.I18n._; +import java.util.Date; + import javax.swing.JOptionPane; import org.jdesktop.swingx.JXTable; import org.nuiton.util.DateUtil; @@ -130,7 +132,7 @@ /** * Checks confirmation from user - * Sets EntryBook to use + * Sets EntryBook and Date to use */ public void addRetainedEarnings() { JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); @@ -142,6 +144,7 @@ _("lima.common.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { + //Sets EntryBook EntryBook newEntryBook = new EntryBookImpl(); RetainedEarningsEntryBookForm entryBookForm = new RetainedEarningsEntryBookForm(view); entryBookForm.setEntryBook(newEntryBook); @@ -151,7 +154,16 @@ // null == cancel action EntryBook entryBook = entryBookForm.getEntryBook(); if (entryBook != null) { - model.addRetainedEarnings(selectedRow, entryBook); + //Sets Date + RetainedEarningsDateForm dateForm = new RetainedEarningsDateForm(view); + // jaxx constructor don't call super() ? + dateForm.setLocationRelativeTo(view); + dateForm.setVisible(true); + // null == cancel action + Date date = dateForm.getBeginDatePicker().getDate(); + if (date != null) { + model.addRetainedEarnings(selectedRow, entryBook, date); + } } } } catch (LimaException eee) { Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsDateForm.jaxx 2011-06-07 08:53:23 UTC (rev 3158) @@ -0,0 +1,47 @@ +<JDialog modal="true" + defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" + onWindowClosing="performCancel();"> + + <script> + <![CDATA[ + + getRootPane().setDefaultButton(okButton); + + import org.apache.commons.lang.time.DateUtils; + + // set begin date picker + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.DATE); + getBeginDatePicker().setDate(beginDate); + + /** + * Sets null to Date and closes JDialog + */ + protected void performCancel() { + getBeginDatePicker().setDate(null); + dispose(); + } + ]]> + </script> + + <Table> + <row> + <cell anchor="center"> + <JLabel text="lima.table.date"/> + </cell> + <cell anchor="west"> + <org.jdesktop.swingx.JXDatePicker id="beginDatePicker"/> + </cell> + </row> + <row> + <cell anchor="center"> + <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + <cell anchor="center"> + <JButton id="okButton" text="lima.common.ok" onActionPerformed="dispose()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file
participants (1)
-
vsalaun@users.chorem.org