Author: mallon Date: 2012-06-21 13:45:00 +0200 (Thu, 21 Jun 2012) New Revision: 3465 Url: http://chorem.org/repositories/revision/lima/3465 Log: D?\195?\169sormais, au sein du panneau de saisie des ?\195?\169critures, si aucun journal n'est ouvert, il est impossible d'ajouter une transaction; et un message indique ?\195?\160 l'utilisateur qu'il doit d'abord cr?\195?\169er un journal. De plus, lorsqu'au moins un journal est ouvert, celui-ci est s?\195?\169lectionn?\195?\169 par d?\195?\169faut au sein de la liste d?\195?\169roulante. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java 2012-06-20 15:14:10 UTC (rev 3464) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java 2012-06-21 11:45:00 UTC (rev 3465) @@ -37,4 +37,16 @@ /** serialVersionUID. */ private static final long serialVersionUID = 6991293987668268456L; + + /*By default, selection of the first entryBook (Because a + * transaction without an entrybook is forbidden) + */ + @Override + public Object getElementAt(int index) { + if (selectedObject == null){ + setSelectedItem(objects.get(0)); + return objects.get(0); + } + return objects.get(index); + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java 2012-06-20 15:14:10 UTC (rev 3464) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java 2012-06-21 11:45:00 UTC (rev 3465) @@ -45,7 +45,8 @@ private static final long serialVersionUID = 4778917695588663498L; protected List<E> objects; - + protected Object selectedObject = super.getSelectedItem(); + @Override public int getSize() { int result = 0; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2012-06-20 15:14:10 UTC (rev 3464) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2012-06-21 11:45:00 UTC (rev 3465) @@ -34,6 +34,7 @@ <FinancialTransactionViewHandler id="handler" constructorParams="this"/> <Boolean id="selectedRow" javaBean="false"/> + <Boolean id="noEntryBooks" javaBean="false"/> <script> <![CDATA[ @@ -51,7 +52,8 @@ <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}" renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}" - onItemStateChanged="handler.fiscalPeriodSelected(event)"/> + onItemStateChanged="handler.fiscalPeriodSelected(event)" + enabled="{isNoEntryBooks()}"/> </cell> <cell anchor="east"> <JLabel text="lima.ui.financialtransaction.financialperiod" labelFor='{financialPeriodComboBox}'/> @@ -62,11 +64,14 @@ <JComboBox id="financialPeriodComboBox" model="{financialPeriodComboBoxModel}" renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}" - onItemStateChanged="handler.financialPeriodSelected(event)"/> + onItemStateChanged="handler.financialPeriodSelected(event)" + enabled="{isNoEntryBooks()}"/> <JButton id="back" text="lima.ui.financialtransaction.buttonback" - onActionPerformed="handler.back(financialPeriodComboBox)"/> + onActionPerformed="handler.back(financialPeriodComboBox)" + enabled="{isNoEntryBooks()}"/> <JButton id="next" text="lima.ui.financialtransaction.buttonnext" - onActionPerformed="handler.next(financialPeriodComboBox)"/> + onActionPerformed="handler.next(financialPeriodComboBox)" + enabled="{isNoEntryBooks()}"/> </JPanel> </cell> <cell anchor="east"> @@ -76,7 +81,8 @@ <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookComboBoxModel"/> <JComboBox id="entryBookComboBox" model="{entryBookComboBoxModel}" renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}" - onItemStateChanged="handler.entryBookSelected(event)"/> + onItemStateChanged="handler.entryBookSelected(event)" + enabled="{isNoEntryBooks()}"/> </cell> </row> <row> @@ -88,7 +94,8 @@ <JButton text="lima.common.paste" enabled="{isSelectedRow()}" onActionPerformed="handler.pasteRow(financialTransactionTable.getSelectedRow())"/> <JButton text="lima.entries.addTransaction" - onActionPerformed="handler.addFinancialTransaction()"/> + onActionPerformed="handler.addFinancialTransaction()" + enabled="{isNoEntryBooks()}"/> <JButton text="lima.entries.addEntry" enabled="{isSelectedRow()}" onActionPerformed="handler.addEntry()"/> <JButton text="lima.common.remove" enabled="{isSelectedRow()}" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-06-20 15:14:10 UTC (rev 3464) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-06-21 11:45:00 UTC (rev 3465) @@ -94,27 +94,47 @@ LimaServiceFactory.addServiceListener(ImportService.class, this); } + //impossible to add transaction without entrybook + public boolean controlEntryBook(){ + boolean result = true; + + if (entryBookService.getAllEntryBooks().isEmpty()){ + JOptionPane.showMessageDialog(view, _("lima.ui.financialtransaction.messagenoentrybooks"), + _("lima.ui.financialtransaction.titlenoentrybooks"), JOptionPane.ERROR_MESSAGE); + result = false; + }else{ + result=true; + } + + view.setNoEntryBooks(result); + return result; + } + /** * Init all combo box in view. */ public void init() { - // fiscal periods - List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); - view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d fiscal periods", fiscalPeriods.size())); + if (controlEntryBook()){ + + // fiscal periods + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d fiscal periods", fiscalPeriods.size())); + } + if (!fiscalPeriods.isEmpty()) { + view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(0)); + } + + // entry books + List<EntryBook> allEntryBooks = entryBookService.getAllEntryBooks(); + view.getEntryBookComboBoxModel().setObjects(allEntryBooks); + + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d entry books", allEntryBooks.size())); + } } - if (!fiscalPeriods.isEmpty()) { - view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(0)); - } - - // entry books - List<EntryBook> allEntryBooks = entryBookService.getAllEntryBooks(); - view.getEntryBookComboBoxModel().setObjects(allEntryBooks); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d entry books", allEntryBooks.size())); - } } /** @@ -266,8 +286,7 @@ public void addFinancialTransaction() { FinancialTransactionTable table = view.getFinancialTransactionTable(); ListSelectionModel selectionModel = table.getSelectionModel(); - - addFinancialTransaction2(); + addFinancialTransactionAfterService(); //select the new line int numberRow = table.getRowCount(); selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); @@ -279,7 +298,7 @@ /** * Add new transaction after calling service. */ - public void addFinancialTransaction2() { + public void addFinancialTransactionAfterService() { FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem(); EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem(); Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-20 15:14:10 UTC (rev 3464) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-21 11:45:00 UTC (rev 3465) @@ -250,8 +250,10 @@ lima.ui.financialtransaction.financialperiod= lima.ui.financialtransaction.fiscalyear= lima.ui.financialtransaction.letter= +lima.ui.financialtransaction.messagenoentrybooks=At least one entry books must to be opened to create the corresponding transactions lima.ui.financialtransaction.messageremoveentry= lima.ui.financialtransaction.messageremovetransaction= +lima.ui.financialtransaction.titlenoentrybooks=No entry books opened lima.ui.financialtransaction.titleremoveentry= lima.ui.financialtransaction.titleremovetransaction= lima.ui.financialtransaction.voucher= Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-20 15:14:10 UTC (rev 3464) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-21 11:45:00 UTC (rev 3465) @@ -250,8 +250,10 @@ lima.ui.financialtransaction.financialperiod=Périodes comptables lima.ui.financialtransaction.fiscalyear=Exercices lima.ui.financialtransaction.letter=Lettre +lima.ui.financialtransaction.messagenoentrybooks=Au moins un journal doit être ouvert pour créer les transactions correspondantes lima.ui.financialtransaction.messageremoveentry=Voulez-vous supprimer cette ligne de transaction? lima.ui.financialtransaction.messageremovetransaction=Voulez-vous supprimer cette transaction? +lima.ui.financialtransaction.titlenoentrybooks=Aucun journal ouvert lima.ui.financialtransaction.titleremoveentry=Suppression lima.ui.financialtransaction.titleremovetransaction=Suppression lima.ui.financialtransaction.voucher=Pièce comptable