r2950 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/fiscalperiod java/org/chorem/lima/ui/home java/org/chorem/lima/util resources/i18n
Author: jpepin Date: 2010-06-28 13:03:51 +0200 (Mon, 28 Jun 2010) New Revision: 2950 Url: http://chorem.org/repositories/revision/lima/2950 Log: Ajout de lien hypertext d'acc?\195?\168s aux diff?\195?\169rentes fonctions dans l'onglet d'accueil. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 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 2010-06-27 06:36:49 UTC (rev 2949) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-28 11:03:51 UTC (rev 2950) @@ -19,20 +19,16 @@ package org.chorem.lima.ui.fiscalperiod; import static org.nuiton.i18n.I18n._; - import javax.swing.JOptionPane; - import org.jdesktop.swingx.JXTable; import org.nuiton.util.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; - import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.ui.fiscalperiod.AddPeriod; import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; import org.chorem.lima.util.DialogHelper; -import org.chorem.lima.util.ErrorHelper; /** * TODO add comment here. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2010-06-27 06:36:49 UTC (rev 2949) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2010-06-28 11:03:51 UTC (rev 2950) @@ -5,7 +5,7 @@ <script> <![CDATA[ import static org.nuiton.i18n.I18n._; - + void $afterCompleteSetup() { getHandler().refresh(); } @@ -23,7 +23,7 @@ minimumSize='{getFixedSize()}' preferredSize='{getFixedSize()}' layout='{new BoxLayout(limaHomeChartAccount,BoxLayout.X_AXIS)}'> - <JEditorPane id="textHomeAccount" /> + <JEditorPane id="textHomeAccount"/> </JPanel> </cell> </row> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-06-27 06:36:49 UTC (rev 2949) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-06-28 11:03:51 UTC (rev 2950) @@ -2,10 +2,17 @@ import static org.nuiton.i18n.I18n._; import java.awt.Color; -import java.awt.Component; +import java.io.IOException; import java.util.List; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.text.html.HTMLDocument; +import javax.swing.text.html.HTMLFrameHyperlinkEvent; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaContext; import org.chorem.lima.business.AccountService; import org.chorem.lima.business.EntryBookService; import org.chorem.lima.business.FinancialTransactionService; @@ -16,8 +23,10 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.MainView; +import org.chorem.lima.util.DialogHelper; -public class HomeViewHandler { +public class HomeViewHandler implements HyperlinkListener { private static final Log log = LogFactory.getLog(HomeViewHandler.class); @@ -30,13 +39,21 @@ protected FinancialTransactionService financialTransactionService; protected FiscalPeriodService fiscalPeriodService; + + protected HyperlinkListener accountsListener; + + protected HyperlinkListener entrybookListener; private Color greenBackground; private Color redBackground; protected HomeViewHandler(HomeView view) { + + this.view=view; + + accountService = LimaServiceFactory.getInstance().getAccountService(); entryBookService = @@ -48,54 +65,90 @@ greenBackground = new Color(153, 255, 153); redBackground = new Color(255, 102, 102); + + } - public void goToAccountChart(){ - - } + public void hyperlinkUpdate(HyperlinkEvent e) { + + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + + log.debug(e.getDescription()); + + if (e.getDescription().equals("#accountschart")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showAccountView(ui); + } + else if (e.getDescription().equals("#entrybookschart")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showEntryBookView(ui); + } + else if (e.getDescription().equals("#fiscalperiodschart")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showFiscalPeriodView(ui); + } + else if (e.getDescription().equals("#financialtransactionunbalanced")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showTransactionUnbalancedView(ui); + } + else if (e.getDescription().equals("#financialtransactionbalanced")) { + MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); + ui.getHandler().showTransactionView(ui); + } + } + + } + + + public void refresh(){ try { //ACCOUNT List<Account> accounts = accountService.getAllAccounts(); - view.getTextHomeAccount().setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - view.getTextHomeAccount().setOpaque(true); - view.getTextHomeAccount().setContentType("text/html"); - view.getTextHomeAccount().setEditable(false); + JEditorPane accountPane = view.getTextHomeAccount(); + accountPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); + accountPane.setOpaque(true); + accountPane.setContentType("text/html"); + accountPane.setEditable(false); + accountPane.addHyperlinkListener(this); if (accounts.size()>0){ String accountsString = _("limahome.chartaccounts1") + " " + accounts.size() + " " + _("limahome.chartaccounts2"); - view.getTextHomeAccount().setBackground(greenBackground); - view.getTextHomeAccount().setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://accountcharts'>"+accountsString+"</a></p>"); + accountPane.setBackground(greenBackground); + accountPane.setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#accountschart'>"+accountsString+"</a></p>"); } else { - view.getTextHomeAccount().setBackground(redBackground); + accountPane.setBackground(redBackground); String accountsString = "<p style=vertical-align:'bottom', horizontal-align:'center'>"+_("limahome.fiscalperiodnoopen") + - "<br/><a href='lima://accountcharts'>"+_("limahome.createchartaccounts")+"</a>"; - view.getTextHomeAccount().setText(accountsString+"</p>"); + "<br/><a href='#accountschart'>"+_("limahome.createchartaccounts")+"</a>"; + accountPane.setText(accountsString+"</p>"); } //ENTRYBOOK List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); - view.getTextHomeEntryBook().setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - view.getTextHomeEntryBook().setOpaque(true); - view.getTextHomeEntryBook().setContentType("text/html"); - view.getTextHomeEntryBook().setEditable(false); + JEditorPane entryBookPane = view.getTextHomeEntryBook(); + entryBookPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); + entryBookPane.setOpaque(true); + entryBookPane.setContentType("text/html"); + entryBookPane.setEditable(false); + entryBookPane.addHyperlinkListener(this); + if (entryBooks.size()>0){ - view.getTextHomeEntryBook().setBackground(greenBackground); - String entryBooksString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://entrybookcharts'>"+_("limahome.entrybooks1") + + entryBookPane.setBackground(greenBackground); + String entryBooksString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#entrybookschart'>"+_("limahome.entrybooks1") + " " + entryBooks.size() + " " + _("limahome.entrybooks2") + "</a><br/><ul>"; for (EntryBook entryBook : entryBooks) { entryBooksString += "<li>"+entryBook.getCode() + " - "+entryBook.getLabel()+"</li>"; } - view.getTextHomeEntryBook().setText(entryBooksString+"</ul>"+"</p>"); + entryBookPane.setText(entryBooksString+"</ul>"+"</p>"); } else { - view.getTextHomeEntryBook().setBackground(redBackground); - view.getTextHomeEntryBook().setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://entrybookcharts'>"+_("limahome.entrybooknoopen")+"</a></p>"); + entryBookPane.setBackground(redBackground); + entryBookPane.setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#entrybookschart'>"+_("limahome.entrybooknoopen")+"</a></p>"); } //FISCAL PERIOD @@ -104,52 +157,57 @@ List<FiscalPeriod> unblockedFiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); - view.getTextHomeFiscalYear().setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - view.getTextHomeFiscalYear().setOpaque(true); - view.getTextHomeFiscalYear().setContentType("text/html"); - view.getTextHomeFiscalYear().setEditable(false); - view.getTextHomeDaily().setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - view.getTextHomeDaily().setOpaque(true); - view.getTextHomeDaily().setContentType("text/html"); - view.getTextHomeDaily().setEditable(false); + JEditorPane fiscalYearPane = view.getTextHomeFiscalYear(); + fiscalYearPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); + fiscalYearPane.setOpaque(true); + fiscalYearPane.setContentType("text/html"); + fiscalYearPane.setEditable(false); + fiscalYearPane.addHyperlinkListener(this); + JEditorPane dailyPane = view.getTextHomeDaily(); + dailyPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); + dailyPane.setOpaque(true); + dailyPane.setContentType("text/html"); + dailyPane.setEditable(false); + dailyPane.addHyperlinkListener(this); + if (unblockedFiscalPeriods.size()>0){ - view.getTextHomeFiscalYear().setBackground(greenBackground); - String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://fiscalcharts'>" + fiscalYearPane.setBackground(greenBackground); + String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#fiscalperiodschart'>" + unblockedFiscalPeriods.size() + " " + _("limahome.fiscalperiodopened")+"<br/>" + (fiscalPeriods.size()-unblockedFiscalPeriods.size()) + " " + _("limahome.fiscalperiodclosed"); - view.getTextHomeFiscalYear().setText(fiscalString+"</a></p>"); + fiscalYearPane.setText(fiscalString+"</a></p>"); //FINACIAL TRANSACTION List<FinancialTransaction> financialTransactions = financialTransactionService. getAllFinancialTransactionsUnbalanced(fiscalPeriods.get(0)); if (financialTransactions.size()>0){ - view.getTextHomeDaily().setBackground(redBackground); - String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://financialtransactionunbalanced'>" + dailyPane.setBackground(redBackground); + String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#financialtransactionunbalanced'>" + financialTransactions.size() + _("limahome.transactionunbalanced")+"</a></p>"; - view.getTextHomeDaily().setText(transactionsString); + dailyPane.setText(transactionsString); } else { - view.getTextHomeDaily().setBackground(greenBackground); - String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://financialtransactionbalanced'>" + dailyPane.setBackground(greenBackground); + String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#financialtransactionbalanced'>" + _("limahome.transactionbalanced"); - view.getTextHomeDaily().setText(transactionsString+"</a></p>"); + dailyPane.setText(transactionsString+"</a></p>"); } } else { - view.getTextHomeFiscalYear().setBackground(redBackground); - view.getTextHomeDaily().setBackground(redBackground); - String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='lima://fiscalcharts'>" + _("limahome.fiscalperiodnoopen"); + fiscalYearPane.setBackground(redBackground); + dailyPane.setBackground(redBackground); + String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#fiscalperiodschart'>" + _("limahome.fiscalperiodnoopen"); if (fiscalPeriods.size()>0){ fiscalString += fiscalPeriods.size() + _("limahome.fiscalperiodclosed"); } - view.getTextHomeFiscalYear().setText(fiscalString+"</a></p>"); + fiscalYearPane.setText(fiscalString+"</a></p>"); } } catch (LimaException eee) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-06-27 06:36:49 UTC (rev 2949) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-06-28 11:03:51 UTC (rev 2950) @@ -1,21 +1,20 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. + * GNU General Public License for more details. * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ package org.chorem.lima.util; 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 2010-06-27 06:36:49 UTC (rev 2949) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-28 11:03:51 UTC (rev 2950) @@ -174,6 +174,7 @@ limahome.createchartaccounts= limahome.createchartaccounts1= limahome.createchartaccounts2= +limahome.entrybooknoopen= limahome.entrybooks1= limahome.entrybooks2= limahome.fiscalperiodclosed=
participants (1)
-
jpepin@users.chorem.org