Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 1853 discussions
Author: echatellier
Date: 2010-04-09 18:18:10 +0200 (Fri, 09 Apr 2010)
New Revision: 2848
Log:
Reformat log4j.properties
Modified:
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2010-04-09 16:17:30 UTC (rev 2847)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2010-04-09 16:18:10 UTC (rev 2848)
@@ -1,17 +1,16 @@
# Global logging configuration
log4j.rootLogger=ERROR, stdout, file
-# Console output...
+
+# Console output
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+#�File ouptut
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.file=lima.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-#log4j.appender.stdout.layout.ConversionPattern=%%c=%c %%C=%C %%d=%d %%F=%F %%l=%l %%L=%L %%m=%m %%M=%M %%p=%p %%r=%r %%t=%t %%x=%x %%X=%X
# package level
-log4j.logger.org.chorem.lima=DEBUG
-#log4j.logger.org.codelutin.jaxx.action=DEBUG
-#log4j.logger.org.codelutin.jaxx=DEBUG
-#log4j.logger.org.codelutin=INFO
+log4j.logger.org.chorem.lima=INFO
\ No newline at end of file
1
0
r2847 - trunk/lima-swing/src/main/java/org/chorem/lima/ui
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:17:30 +0200 (Fri, 09 Apr 2010)
New Revision: 2847
Log:
Modification of mainview (remove impl)
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-09 16:16:58 UTC (rev 2846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-09 16:17:30 UTC (rev 2847)
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##% -->
-<JFrame abstract='true' title="lima.title" onWindowClosing="getHandler().close(this)"
+<JFrame title="lima.title" onWindowClosing="getHandler().close(this)"
defaultCloseOperation="do_nothing_on_close"
undecorated='{getConfig().isFullScreen()}'
resizable="true" width="800" height="600"
@@ -36,42 +36,62 @@
return l != null && l.toString().equals(expected);
}
-protected abstract void onChangeView();
-protected abstract void showHomeView();
-protected abstract void showAccountView();
-protected abstract void showAddPeriod();
-protected abstract void showBalanceView();
-protected abstract void showBilanView();
-protected abstract void showClosurePeriodView();
-protected abstract void showClosureTimeSpanView();
-protected abstract void showClosureView();
-protected abstract void showExportView(String type);
-protected abstract void showImportView(String type);
-protected abstract void showJournalView();
-protected abstract void showLetteringView();
-protected abstract void showReportsView();
-protected abstract void showResultView();
-protected abstract void showSearchView();
-protected abstract void showTransactionView();
- ]]>
+/**
+ * Show a new closable tab.
+ *
+ * @param name name of tab to show
+ * @param container the tab container
+ * @param canClose {@code false} if tab can't be closed
+ */
+protected void showTab(String name, Component container, boolean canClose) {
+ // if contentTabbedPane doesnot yet contains tab
+ if (contentTabbedPane.indexOfTab(name) == -1) {
+ ClosableTabHeader closableHeader = new ClosableTabHeader();
+ closableHeader.setTitle(name);
+ closableHeader.setCanClose(canClose);
+ contentTabbedPane.addTab(name, container);
+ contentTabbedPane.setSelectedComponent(container);
+ contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader);
+ closableHeader.getCloseTab().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JButton button = (JButton) e.getSource();
+ ClosableTabHeader closableTab = (ClosableTabHeader) button.getParent();
+ String name = closableTab.getTitle();
+ contentTabbedPane.remove(contentTabbedPane.indexOfTab(name));
+ }
+ });
+ }
+}
+
+/**
+ * Show a new closable tab.
+ *
+ * @param name name of tab to show
+ * @param container the tab container
+ */
+protected void showTab(String name, Component container) {
+ showTab(name, container, true);
+}
+ ]]>
</script>
<JMenuBar>
<JMenu text="lima.menu.file">
<JMenu text="lima.import" actionIcon='import-element'>
- <JMenuItem text="lima.import.all" onActionPerformed='showImportView("all")'/>
- <JMenuItem text="lima.import.all.csv" onActionPerformed='showImportView("all_csv")'/>
- <JMenuItem text="lima.import.all.csv.ebp" onActionPerformed='showImportView("all_csv_ebp")'/>
- <JMenuItem text="lima.import.account" onActionPerformed='showImportView("account")'/>
- <JMenuItem text="lima.import.journal" onActionPerformed='showImportView("journal")'/>
+ <JMenuItem text="lima.import.all" onActionPerformed='getHandler().showImportView("all")'/>
+ <JMenuItem text="lima.import.all.csv" onActionPerformed='getHandler().showImportView("all_csv")'/>
+ <JMenuItem text="lima.import.all.csv.ebp" onActionPerformed='getHandler().showImportView("all_csv_ebp")'/>
+ <JMenuItem text="lima.import.account" onActionPerformed='getHandler().showImportView("account")'/>
+ <JMenuItem text="lima.import.journal" onActionPerformed='getHandler().showImportView("journal")'/>
</JMenu>
<JMenu text="lima.export" actionIcon='export-element'>
- <JMenuItem text="lima.export.all" onActionPerformed='showExportView("all")'/>
- <JMenuItem text="lima.export.all.csv" onActionPerformed='showExportView("all_csv")'/>
- <JMenuItem text="lima.export.account" onActionPerformed='showExportView("account")'/>
+ <JMenuItem text="lima.export.all" onActionPerformed='getHandler().showExportView("all")'/>
+ <JMenuItem text="lima.export.all.csv" onActionPerformed='getHandler().showExportView("all_csv")'/>
+ <JMenuItem text="lima.export.account" onActionPerformed='getHandler().showExportView("account")'/>
</JMenu>
<JSeparator/>
- <JMenuItem text="lima.print" actionIcon='print'/>
+ <JMenuItem text="lima.common.print" actionIcon='print'/>
<JSeparator/>
<JMenuItem id='menuFileFullscreen'
text="lima.action.fullscreen"
@@ -92,44 +112,45 @@
<JSeparator/>
<JMenuItem mnemonic="{'Q'}"
actionIcon='quit'
- text="lima.quit" onActionPerformed='getHandler().close(this)'/>
+ text="lima.common.quit" onActionPerformed='getHandler().close(this)'/>
</JMenu>
<JMenu text="lima.chartofaccounts">
- <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='showAccountView()'
+ <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='getHandler().showAccountView(this)'
actionIcon='account'/>
- <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='showJournalView()'
+ <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='getHandler().showJournalView(this)'
actionIcon='journal'/>
</JMenu>
<JMenu text="lima.fiscalyear">
- <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='showAddPeriod()'/>
- <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='showClosureTimeSpanView()'
+ <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='getHandler().showAddPeriod(this)'/>
+ <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='getHandler().showClosureTimeSpanView(this)'
actionIcon='closure-timespan'/>
- <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='showClosurePeriodView()'/>
- <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='showClosureView()'
+ <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='getHandler().showClosurePeriodView(this)'/>
+ <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='getHandler().showFiscalPeriodView(this)'
actionIcon='closure'/>
</JMenu>
<JMenu text="lima.entries">
- <JMenuItem text="lima.entries.addtransaction" onActionPerformed='showTransactionView()'
+ <JMenuItem text="lima.entries.addtransaction" onActionPerformed='getHandler().showTransactionView(this)'
actionIcon='transaction'/>
- <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='showSearchView()'
+ <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='getHandler().showSearchView(this)'
actionIcon='search'/>
- <JMenuItem text="lima.entries.lettering" onActionPerformed='showLetteringView()'
+ <JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)'
actionIcon='lettering'/>
</JMenu>
<JMenu text="lima.view">
- <JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten" onItemStateChanged='onChangeView()'
- selected="false" actionIcon='view'/>
+ <JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten"
+ onItemStateChanged='getHandler().onChangeView(this)'
+ selected="false" actionIcon='view'/>
</JMenu>
<JMenu text="lima.reports">
- <JMenuItem text="lima.reports" onActionPerformed='showReportsView()' actionIcon='rapport'/>
- <JMenuItem text="lima.balance" onActionPerformed='showBalanceView()'/>
- <JMenuItem text="lima.bilan" onActionPerformed='showBilanView()'/>
- <JMenuItem text="lima.result" onActionPerformed='showResultView()'/>
+ <JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/>
+ <JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
+ <JMenuItem text="lima.bilan" onActionPerformed='getHandler().showBilanView(this)'/>
+ <JMenuItem text="lima.result" onActionPerformed='getHandler().showResultView(this)'/>
</JMenu>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-09 16:16:58 UTC (rev 2846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-09 16:17:30 UTC (rev 2847)
@@ -1,4 +1,4 @@
-/* *##% Lima Main
+/* *##% Lima Swing
* Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software; you can redistribute it and/or
@@ -36,11 +36,28 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
+import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.ui.entrybook.EntryBookView;
+import org.chorem.lima.ui.period.FiscalPeriodView;
+import org.chorem.lima.ui.report.BalanceView;
+import org.chorem.lima.ui.report.BilanView;
+import org.chorem.lima.ui.report.ReportsView;
+import org.chorem.lima.ui.report.ResultView;
+import org.chorem.lima.ui.transaction.LetteringView;
+import org.chorem.lima.ui.transaction.TransactionView;
+import org.chorem.lima.util.ErrorHelper;
/**
- * User: chemit
+ * Handler for main view.
+ *
* Date: 8 nov. 2009
* Time: 09:59:54
+ *
+ * @author chemit
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
*/
public class MainViewHandler {
@@ -59,12 +76,10 @@
public MainView initUI(LimaContext rootContext, boolean fullscreen) {
// show main ui
- MainView ui = new MainViewImpl(rootContext);
+ MainView ui = new MainView(rootContext);
LimaContext.MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
- //ErrorDialogUI.init(ui);
-
// set fullscreen propery on main ui
ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
@@ -90,7 +105,9 @@
* @param ui l'ui principale de l'application
*/
public void close(MainView ui) {
- log.info("Vradi quitting...");
+ if (log.isInfoEnabled()) {
+ log.info("Lima quitting...");
+ }
boolean canContinue = ensureModification(ui);
if (!canContinue) {
return;
@@ -101,7 +118,9 @@
Runtime.getRuntime().halt(0);
} catch (Exception ex) {
- log.error("error while closing " + ex.getMessage(), ex);
+ if (log.isErrorEnabled()) {
+ log.error("error while closing " + ex.getMessage(), ex);
+ }
Runtime.getRuntime().halt(1);
}
}
@@ -169,25 +188,27 @@
try {
Desktop.getDesktop().browse(siteURL.toURI());
} catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- ErrorDialogUI.showError(ex);
+ if (log.isDebugEnabled()) {
+ log.error("Can't open lima website", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't open lima website", ex);
}
}
}
public void showAbout(MainView ui) {
- AboutPanel about = new AboutPanel() {
+ AboutPanel about = new AboutPanel()/* {
@Override
public void buildTopPanel() {
setIconPath("/icons/lima.png");
super.buildTopPanel();
}
- };
+ }*/;
about.setTitle(_("lima.title.about"));
about.setAboutText(_("lima.about.message"));
about.setBottomText(ui.getConfig().getCopyrightText());
-// about.setIconPath("/icons/lima.png");
+ about.setIconPath("/icons/lima.png");
about.setLicenseFile("META-INF/lima-main-LICENSE.txt");
about.setThirdpartyFile("META-INF/lima-main-THIRD-PARTY.txt");
about.init();
@@ -209,9 +230,6 @@
MainView ui = getUI(rootContext);
if (ui != null) {
-
- //ErrorDialogUI.init(null);
-
LimaContext.MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
ui.dispose();
@@ -245,7 +263,7 @@
return true;
}
- MainView getUI(JAXXContext context) {
+ protected MainView getUI(JAXXContext context) {
if (context instanceof MainView) {
return (MainView) context;
}
@@ -253,4 +271,134 @@
return ui;
}
+ public void showHomeView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ HomeView homeView = new HomeView(mainView);
+ mainView.showTab(_("lima.tab.home"), homeView, false);
+ }
+
+ public void showBilanView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ BilanView bilanView = new BilanView(mainView);
+ mainView.showTab(_("lima.tab.bilan"), bilanView);
+ }
+
+ public void showBalanceView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ BalanceView balanceView = new BalanceView(mainView);
+ mainView.showTab(_("lima.tab.balance"), balanceView);
+ }
+
+ public void showFiscalPeriodView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView);
+ mainView.showTab(_("lima.tab.period"), fiscalPeriodView);
+ }
+
+ public void showClosurePeriodView(JAXXContext rootContext) {
+
+ }
+
+ public void showClosureTimeSpanView(JAXXContext rootContext) {
+ //getClosureView().initBlockForm();
+ }
+
+ public void showAddPeriod(JAXXContext rootContext) {
+ //getClosureView().initAddPeriod();
+ }
+
+ public void showImportView(String type) {
+ /*if (!getImportView(type).isEnabled()) {
+ getImportView(type).setEnabled(true);
+ }*/
+ }
+
+ public void showExportView(String type) {
+ /*if (!getExportView(type).isEnabled()) {
+ getExportView(type).setEnabled(true);
+ }*/
+ }
+
+ public void showLetteringView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ LetteringView letteringView = new LetteringView(mainView);
+ mainView.showTab(_("lima.tab.lettering"), letteringView);
+ }
+
+ public void showSearchResultView(JAXXContext rootContext) {
+ /*MainView mainView = getUI(rootContext);
+ SearchResultView searchResultView = new SearchResultView(mainView);
+ mainView.showTab(_("lima.tab.search.result"), searchResultView);*/
+ }
+
+ public void showAccountView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ AccountView accountView = new AccountView(mainView);
+ mainView.showTab(_("lima.tab.account"), accountView);
+ }
+
+ public void showTransactionView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ TransactionView transactionView = new TransactionView(mainView);
+ mainView.showTab(_("lima.tab.transaction"), transactionView);
+ }
+
+ public void showJournalView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ EntryBookView entryBookView = new EntryBookView(mainView);
+ mainView.showTab(_("lima.tab.journal"), entryBookView);
+ }
+
+ public void showSearchView(JAXXContext rootContext) {
+ /*if (!getSearchView().isEnabled()) {
+ getSearchView().setEnabled(true);
+ }
+ getSearchView().setVisible(true);*/
+ }
+
+ public void showReportsView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ ReportsView reportsView = new ReportsView(mainView);
+ mainView.showTab(_("lima.tab.reports"), reportsView);
+ }
+
+ public void showResultView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ ResultView resultView = new ResultView(mainView);
+ mainView.showTab(_("lima.tab.result"), resultView);
+ }
+
+ /**
+ * Called by menuitem "Vue a plat".
+ *
+ * Mais le fonctionnement est a revoir, car un peu trop de code...
+ *
+ * @param rootContext
+ */
+ protected void onChangeView(JAXXContext rootContext) {
+ /*if (log.isDebugEnabled()) {
+ log.debug("onChangeView : ");
+ }
+ transactionView = getTransactionView();
+ searchResultView = getSearchResultView();
+ if (viewFlatten.getState()) {
+ // View not flatten
+ if (log.isDebugEnabled()) {
+ log.debug("onChangeView : setModel : getSortedModel");
+ }
+ transactionView.getTransactionTable().setModel(transactionView.getSortedModel());
+ searchResultView.getTransactionTable().setModel(searchResultView.getSortedModel());
+ } else {
+ // View Flatten
+ if (log.isDebugEnabled()) {
+ log.debug("onChangeView : setModel : getFlattenModel");
+ }
+ transactionView.getTransactionTable().setModel(transactionView.getFlattenModel());
+ searchResultView.getTransactionTable().setModel(searchResultView.getFlattenModel());
+ }
+ // Pack all columns
+ transactionView.getTransactionTable().packAll();
+ searchResultView.getTransactionTable().packAll();*/
+ }
+
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-09 16:16:58 UTC (rev 2846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-09 16:17:30 UTC (rev 2847)
@@ -1,417 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * 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 Public License for more details.
- *
- * 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.ui;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JTabbedPane;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import jaxx.runtime.JAXXContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.table.TransactionJXTable;
-import org.chorem.lima.table.model.TransactionFlattenTableModel;
-import org.chorem.lima.ui.account.AccountView;
-import org.chorem.lima.ui.entrybook.EntryBookView;
-import org.chorem.lima.ui.period.AddPeriod;
-import org.chorem.lima.ui.period.ClosureTimeSpanForm;
-import org.chorem.lima.ui.period.FiscalPeriodView;
-import org.chorem.lima.ui.report.BalanceViewImpl;
-import org.chorem.lima.ui.report.BilanViewImpl;
-import org.chorem.lima.ui.report.ReportsView;
-import org.chorem.lima.ui.report.ReportsViewImpl;
-import org.chorem.lima.ui.report.ResultViewImpl;
-import org.chorem.lima.ui.transaction.LetteringViewImpl;
-import org.chorem.lima.ui.transaction.SearchTransactionViewImpl;
-import org.chorem.lima.ui.transaction.TransactionViewImpl;
-
-/**
- * @author ore
- */
-public class MainViewImpl extends MainView {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 5339665516073792117L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(MainViewImpl.class);
-
- private HomeViewImpl homeView;
-
- private FiscalPeriodView closureView;
-
- private TransactionViewImpl transactionView;
-
- private TransactionViewImpl searchResultView;
-
- private EntryBookView journalView;
-
- private AccountView accountView;
-
- private SearchTransactionViewImpl searchView;
-
- private ReportsViewImpl reportsView;
-
- private ResultViewImpl resultView;
-
- private LetteringViewImpl letteringView;
-
- private ClosureTimeSpanForm closureTimeSpanForm;
-
- private BilanViewImpl bilanView;
-
- private BalanceViewImpl balanceView;
-
- private AddPeriod addPeriod;
-
- public MainViewImpl(JAXXContext c) {
- super(c);
-
- showHomeView();
-
- // Register a change listener
- contentTabbedPane.addChangeListener(new ChangeListener() {
- // This method is called whenever the selected tab changes
-
- @Override
- public void stateChanged(ChangeEvent evt) {
- JTabbedPane pane = (JTabbedPane) evt.getSource();
-
- // Get current tab
- int sel = pane.getSelectedIndex();
- if (sel != -1) {
- Component component = pane.getComponentAt(sel);
- // if TransactionViewImpl
- if (component instanceof TransactionViewImpl) {
- TransactionJXTable table = ((TransactionViewImpl) component).getTransactionTable();
- // if model is TransactionFlattenTableModel
- if (table.getModel() instanceof TransactionFlattenTableModel) {
- ((TransactionFlattenTableModel) table.getModel()).initFlattenModel();
- table.addColorEmptyLine();
- }
- }
- }
- }
- });
- }
-
- public HomeViewImpl getHomeView() {
- if (homeView == null) {
- homeView = new HomeViewImpl(this);
- }
- return homeView;
- }
-
- public AccountView getAccountView() {
- if (accountView == null) {
- accountView = new AccountView(this);
- }
- return accountView;
- }
-
- public AddPeriod getAddPeriod() {
- if (addPeriod == null) {
- addPeriod = new AddPeriod(this);
- }
- return addPeriod;
- }
-
- public BalanceViewImpl getBalanceView() {
- if (balanceView == null) {
- balanceView = new BalanceViewImpl(this);
- }
- return balanceView;
- }
-
- public BilanViewImpl getBilanView() {
- if (bilanView == null) {
- bilanView = new BilanViewImpl(this);
- }
- return bilanView;
- }
-
- public ClosureTimeSpanForm getClosureTimeSpanForm() {
- if (closureTimeSpanForm == null) {
- closureTimeSpanForm = new ClosureTimeSpanForm(this);
- }
- return closureTimeSpanForm;
- }
-
- public FiscalPeriodView getClosureView() {
- if (closureView == null) {
- closureView = new FiscalPeriodView(this);
- }
- return closureView;
- }
-
- /*public ExportViewImpl getExportView(String type) {
- ExportViewImpl exportView = new ExportViewImpl(type);
- return exportView;
- }
-
- public ImportViewImpl getImportView(String type) {
- ImportViewImpl importView = new ImportViewImpl(this, type);
- return importView;
- }*/
-
- public EntryBookView getEntryBookView() {
- if (journalView == null) {
- journalView = new EntryBookView(this);
- }
- return journalView;
- }
-
- public LetteringViewImpl getLetteringView() {
- if (letteringView == null) {
- letteringView = new LetteringViewImpl(this);
- }
- return letteringView;
- }
-
- public ReportsView getReportsView() {
- if (reportsView == null) {
- reportsView = new ReportsViewImpl(this);
- }
- return reportsView;
- }
-
- public ResultViewImpl getResultView() {
- if (resultView == null) {
- resultView = new ResultViewImpl(this);
- }
- return resultView;
- }
-
- public SearchTransactionViewImpl getSearchView() {
- if (searchView == null) {
- searchView = new SearchTransactionViewImpl(this);
- }
- return searchView;
- }
-
- public TransactionViewImpl getSearchResultView() {
- if (searchResultView == null) {
- searchResultView = new TransactionViewImpl(this);
- }
- return searchResultView;
- }
-
- public TransactionViewImpl getTransactionView() {
- if (transactionView == null) {
- transactionView = new TransactionViewImpl(this);
- }
- return transactionView;
- }
-
- /**
- * Show a new closable tab.
- *
- * @param name name of tab to show
- * @param container the tab container
- * @param canClose {@code false} if tab can't be closed
- */
- protected void showTab(String name, Component container, boolean canClose) {
- // if contentTabbedPane doesnot yet contains tab
- if (contentTabbedPane.indexOfTab(name) == -1) {
- ClosableTabHeader closableHeader = new ClosableTabHeader();
- closableHeader.setTitle(name);
- closableHeader.setCanClose(canClose);
- contentTabbedPane.addTab(name, container);
- contentTabbedPane.setSelectedComponent(container);
- contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader);
- closableHeader.getCloseTab().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JButton button = (JButton) e.getSource();
- ClosableTabHeader closableTab = (ClosableTabHeader) button.getParent();
- String name = closableTab.getTitle();
- contentTabbedPane.remove(contentTabbedPane.indexOfTab(name));
- }
- });
- }
- }
-
- /**
- * Show a new closable tab.
- *
- * @param name name of tab to show
- * @param container the tab container
- */
- protected void showTab(String name, Component container) {
- showTab(name, container, true);
- }
-
- @Override
- protected void showHomeView() {
- showTab(_("lima.tab.home"), getHomeView(), false);
- }
-
- @Override
- protected void showBilanView() {
- showTab(_("lima.tab.bilan"), getBilanView());
- }
-
- @Override
- protected void showBalanceView() {
- showTab(_("lima.tab.balance"), getBalanceView());
- }
-
- @Override
- protected void showClosureView() {
- showTab(_("lima.tab.period"), getClosureView());
- }
-
- /*
- * @see org.chorem.lima.ui.MainView#showClosurePeriodView()
- */
- @Override
- protected void showClosurePeriodView() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void showClosureTimeSpanView() {
- //getClosureView().initBlockForm();
- }
-
- @Override
- protected void showAddPeriod() {
- //getClosureView().initAddPeriod();
- }
-
- @Override
- protected void showImportView(String type) {
- /*if (!getImportView(type).isEnabled()) {
- getImportView(type).setEnabled(true);
- }*/
- }
-
- @Override
- protected void showExportView(String type) {
- /*if (!getExportView(type).isEnabled()) {
- getExportView(type).setEnabled(true);
- }*/
- }
-
- @Override
- protected void showLetteringView() {
- showTab(_("lima.tab.lettering"), getLetteringView());
- }
-
- /**
- *
- */
- protected void showSearchResultView() {
- log.debug("showSearchResultView : ");
- showTab(_("lima.tab.search.result"), getSearchResultView());
- }
-
- @Override
- protected void showAccountView() {
- showTab(_("lima.tab.account"), getAccountView());
- }
-
- @Override
- protected void showTransactionView() {
- showTab(_("lima.tab.transaction"), getTransactionView());
- }
-
- @Override
- protected void showJournalView() {
- showTab(_("lima.tab.journal"), getEntryBookView());
- }
-
- @Override
- protected void showSearchView() {
- if (!getSearchView().isEnabled()) {
- getSearchView().setEnabled(true);
- }
- getSearchView().setVisible(true);
- }
-
- @Override
- protected void showReportsView() {
- showTab(_("lima.tab.reports"), getReportsView());
- }
-
- @Override
- protected void showResultView() {
- showTab(_("lima.tab.result"), getResultView());
- }
-
- @Override
- public void dispose() {
- // Disposing other windows before main view
- //disposeWindow(searchView);
- //disposeWindow(journalForm);
- //disposeWindow(accountForm);
- //disposeWindow(closureTimeSpanForm);
- super.dispose();
- }
-
- /**
- * @param window the windows to dispose
- */
- public void disposeWindow(JFrame window) {
- if (window != null) {
- if (window.isVisible()) {
- window.setVisible(false);
- window.dispose();
- }
- }
- }
-
- @Override
- protected void onChangeView() {
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : ");
- }
- transactionView = getTransactionView();
- searchResultView = getSearchResultView();
- if (viewFlatten.getState()) {
- // View not flatten
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : setModel : getSortedModel");
- }
- transactionView.getTransactionTable().setModel(transactionView.getSortedModel());
- searchResultView.getTransactionTable().setModel(searchResultView.getSortedModel());
- } else {
- // View Flatten
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : setModel : getFlattenModel");
- }
- transactionView.getTransactionTable().setModel(transactionView.getFlattenModel());
- searchResultView.getTransactionTable().setModel(searchResultView.getFlattenModel());
- }
- // Pack all columns
- transactionView.getTransactionTable().packAll();
- searchResultView.getTransactionTable().packAll();
- }
-
-}
1
0
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:16:58 +0200 (Fri, 09 Apr 2010)
New Revision: 2846
Log:
Update i18n files
Modified:
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/resources/i18n/lima-swing-en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-09 16:15:11 UTC (rev 2845)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-09 16:16:58 UTC (rev 2846)
@@ -4,6 +4,7 @@
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
Exercice=
Global\ lima\ exception=
+Loading\ accounting...=
lima.about.message=
lima.account=Account
lima.account.label=
@@ -49,8 +50,11 @@
lima.closure.period.begin=Period from
lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
lima.common.add=
+lima.common.all=
lima.common.cancel=
lima.common.ok=
+lima.common.print=
+lima.common.quit=
lima.common.remove=
lima.common.update=
lima.config.category.directories=
@@ -152,6 +156,15 @@
lima.journal=Journal
lima.lettered=Lettered
lima.lettering=Lettering
+lima.lettering.add=
+lima.lettering.entries=
+lima.lettering.from=
+lima.lettering.lettered=
+lima.lettering.letteredall=
+lima.lettering.not.lettered=
+lima.lettering.notlettered=
+lima.lettering.remove=
+lima.lettering.to=
lima.loading=Loading
lima.menu.file=File
lima.menu.help=Help
@@ -189,6 +202,7 @@
lima.not.lettered=Not lettered
lima.number=Number
lima.ok=OK
+lima.openejb.remotemode.description=
lima.passif=Liability
lima.period=Period
lima.period.addFiscalPeriod=
@@ -259,6 +273,17 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=About Lima...
lima.to=To
+lima.transaction.column.account=
+lima.transaction.column.balance=
+lima.transaction.column.credit=
+lima.transaction.column.date=
+lima.transaction.column.debit=
+lima.transaction.column.description=
+lima.transaction.column.document=
+lima.transaction.column.entrybook=
+lima.transaction.column.period=
+lima.transaction.column.status=
+lima.transaction.confirmdelete=
lima.transaction.entrybook=
lima.transaction.period=
lima.ui.add.account=Add account
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 2010-04-09 16:15:11 UTC (rev 2845)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-09 16:16:58 UTC (rev 2846)
@@ -4,6 +4,7 @@
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
Exercice=
Global\ lima\ exception=
+Loading\ accounting...=
lima.about.message=\u00C0 propos de Lima
lima.account=Compte
lima.account.label=Libell\u00E9
@@ -17,7 +18,6 @@
lima.action.fullscreen.tip=Passer en mode plein \u00E9cran
lima.action.normalscreen=Ecran normal
lima.action.normalscreen.tip=Revenir en \u00E9cran normal
-lima.add=
lima.add.entry=Ajouter une entr\u00E9e
lima.add.lettering=
lima.add.transaction=
@@ -41,7 +41,6 @@
lima.bilan.passif=Passif
lima.bilan.total=Total
lima.block=Bloquer
-lima.cancel=
lima.charge=Charge
lima.chartofaccounts=Plan des comptes
lima.chartofaccounts.journal=Journal
@@ -51,8 +50,11 @@
lima.common.add=Ajout
lima.common.cancel=Annuler
lima.common.ok=OK
+lima.common.print=
+lima.common.quit=Quitter
lima.common.remove=Supprimer
lima.common.update=Modifier
+lima.comon.print=Imprimer
lima.config.category.directories=R\u00E9pertoires
lima.config.category.directories.description=R\u00E9pertoires utilis\u00E9s par Lima
lima.config.category.other=Autre
@@ -81,7 +83,7 @@
lima.description=Description
lima.edit=Editer
lima.edit.transaction=Editer une transaction
-lima.entries=Op\u00E9ration de Saisie
+lima.entries=
lima.entries.addtransaction=Ajouter une transaction
lima.entries.lettering=Ajouter une lettre
lima.entries.searchtransaction=Recherche les transactions
@@ -152,10 +154,18 @@
lima.journal=Journal
lima.lettered=Lettr\u00E9
lima.lettering=Lettrage
+lima.lettering.add=Ajouter une lettre
+lima.lettering.entries=Op\u00E9ration de saisie
+lima.lettering.from=De
+lima.lettering.lettered=Lettr\u00E9e
+lima.lettering.letteredall=Toutes
+lima.lettering.notlettered=Non lettr\u00E9e
+lima.lettering.remove=Supprimer
+lima.lettering.to=\u00C0
lima.loading=Chargement
lima.menu.file=Fichier
lima.menu.help=Aide
-lima.menu.help.about=A Propos
+lima.menu.help.about=\u00C0 Propos
lima.menu.help.help=Afficher l'aide
lima.menu.help.i18n=Langue
lima.menu.help.i18n.fr=Fran\u00E7ais
@@ -184,7 +194,7 @@
lima.non.valids.transactions=Ecritures non valides
lima.not.lettered=Non lettr\u00E9
lima.number=Num\u00E9ro
-lima.ok=
+lima.openejb.remotemode.description=
lima.passif=Passif
lima.period=P\u00E9riode
lima.period.addFiscalPeriod=Nouvel exercice
@@ -193,12 +203,11 @@
lima.period.close=Ferm\u00E9
lima.period.enddate=Fin de l'exercice \:
lima.period.filter=Filtre
-lima.period.menu=Exercice
+lima.period.menu=
lima.period.open=Ouvert
-lima.period.periodFilterLabel=Exercice
+lima.period.periodFilterLabel=
lima.preferences=Pr\u00E9f\u00E9rences
lima.prefix=Pr\u00E9fixe
-lima.print=Imprimer
lima.produit=Produit
lima.progressBar.export.etape1=Cr\u00E9ation base du fichier
lima.progressBar.export.etape2=Cr\u00E9ation informations
@@ -219,7 +228,6 @@
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
-lima.quit=Quitter
lima.remove=
lima.remove.lettering=Supprimer la lettre
lima.remove.transaction=Supprimer une transaction
@@ -247,7 +255,7 @@
lima.tab.home=Accueil
lima.tab.journal=Journal
lima.tab.lettering=Lettrage
-lima.tab.period=Exercice
+lima.tab.period=
lima.tab.reports=Rapports
lima.tab.result=Compte de r\u00E9sultat
lima.tab.search.result=Recherche
@@ -255,6 +263,17 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
lima.to=A
+lima.transaction.column.account=
+lima.transaction.column.balance=
+lima.transaction.column.credit=
+lima.transaction.column.date=
+lima.transaction.column.debit=
+lima.transaction.column.description=
+lima.transaction.column.document=
+lima.transaction.column.entrybook=
+lima.transaction.column.period=
+lima.transaction.column.status=
+lima.transaction.confirmdelete=
lima.transaction.entrybook=Journal
lima.transaction.period=
lima.ui.add.account=Ajouter un compte
1
0
r2845 - in trunk/lima-swing/src/main/java/org/chorem/lima: . combobox widgets
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:15:11 +0200 (Fri, 09 Apr 2010)
New Revision: 2845
Log:
Move wide combo box into widgets package
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/widgets/
trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-04-09 16:14:25 UTC (rev 2844)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-04-09 16:15:11 UTC (rev 2845)
@@ -1,114 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 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 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.
- *
- * 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>. ##%*
- */
-
-package org.chorem.lima.combobox;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.BasicComboPopup;
-import javax.swing.plaf.basic.ComboPopup;
-import javax.swing.plaf.metal.MetalComboBoxUI;
-import java.awt.*;
-import java.util.Vector;
-
-/**
- * Cette combo box surcharge quelques methodes de l'UI par defaut
- * pour que le composant popup soit plus grand que la combobox
- * elle même.
- *
- * @author ore
- */
-public class JWideComboBox extends JComboBox {
-
- private boolean layingOut = false;
-
- /**
- *
- */
- public JWideComboBox() {
- setUI(new ScrollMetalComboUI());
- }
-
- /**
- * @param items
- */
- public JWideComboBox(final Object items[]) {
- super(items);
- }
-
- /**
- * @param items
- */
- public JWideComboBox(Vector items) {
- super(items);
- }
-
- /**
- * @param aModel
- */
- public JWideComboBox(ComboBoxModel aModel) {
- super(aModel);
- }
-
- /**
- *
- */
- @Override
- public void doLayout() {
- try {
- layingOut = true;
- super.doLayout();
- } finally {
- layingOut = false;
- }
- }
-
- /**
- * @return
- */
- @Override
- public Dimension getSize() {
- Dimension dim = super.getSize();
- if (!layingOut) {
- int max = Math.max(dim.width, getPreferredSize().width);
- dim.width = max > 600 ? 600 : max;
- }
- return dim;
- }
-}
-
-class ScrollMetalComboUI extends MetalComboBoxUI {
-
- @Override
- protected ComboPopup createPopup() {
- return new ScrollBasicComboPopup(comboBox);
- }
-}
-
-class ScrollBasicComboPopup extends BasicComboPopup {
-
- public ScrollBasicComboPopup(JComboBox combo) {
- super(combo);
- }
-
- @Override
- protected JScrollPane createScroller() {
- return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java (from rev 2836, trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2010-04-09 16:15:11 UTC (rev 2845)
@@ -0,0 +1,100 @@
+/* *##% 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 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.
+ *
+ * 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>. ##%*
+ */
+
+package org.chorem.lima.widgets;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboPopup;
+import javax.swing.plaf.basic.ComboPopup;
+import javax.swing.plaf.metal.MetalComboBoxUI;
+import java.awt.*;
+import java.util.Vector;
+
+// put it at begin, otherwise jaxx complains again !!!
+class ScrollMetalComboUI extends MetalComboBoxUI {
+
+ @Override
+ protected ComboPopup createPopup() {
+ return new ScrollBasicComboPopup(comboBox);
+ }
+}
+
+//put it at begin, otherwise jaxx complains again !!!
+class ScrollBasicComboPopup extends BasicComboPopup {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 2353523521723292218L;
+
+ public ScrollBasicComboPopup(JComboBox combo) {
+ super(combo);
+ }
+
+ @Override
+ protected JScrollPane createScroller() {
+ return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ }
+}
+
+/**
+ * Cette combo box surcharge quelques methodes de l'UI par defaut
+ * pour que le composant popup soit plus grand que la combobox
+ * elle même.
+ *
+ * @author ore
+ */
+public class JWideComboBox extends JComboBox {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6715271536163434385L;
+
+ private boolean layingOut = false;
+
+ public JWideComboBox() {
+ super();
+ setUI(new ScrollMetalComboUI());
+ }
+
+ public JWideComboBox(final Object items[]) {
+ super(items);
+ }
+
+ public JWideComboBox(ComboBoxModel aModel) {
+ super(aModel);
+ }
+
+ @Override
+ public void doLayout() {
+ try {
+ layingOut = true;
+ super.doLayout();
+ } finally {
+ layingOut = false;
+ }
+ }
+
+ @Override
+ public Dimension getSize() {
+ Dimension dim = super.getSize();
+ if (!layingOut) {
+ int max = Math.max(dim.width, getPreferredSize().width);
+ dim.width = max > 600 ? 600 : max;
+ }
+ return dim;
+ }
+}
1
0
r2844 - trunk/lima-swing/src/main/java/org/chorem/lima/util
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:14:25 +0200 (Fri, 09 Apr 2010)
New Revision: 2844
Log:
Remove DTO specific code
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-04-09 16:13:25 UTC (rev 2843)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-04-09 16:14:25 UTC (rev 2844)
@@ -19,19 +19,23 @@
package org.chorem.lima.util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.item.PeriodItem;
import static org.nuiton.i18n.I18n._;
-import org.nuiton.util.Resource;
-import javax.swing.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.Resource;
+
/**
* @author ore
* @author Rémi Chapelet
@@ -88,34 +92,6 @@
}
/**
- * @param period
- * @return
- */
- public static List<PeriodItem> createMonthItems(PeriodDTO period) {
- if (period != null) {
- List<PeriodItem> list = new LinkedList<PeriodItem>();
- Calendar cal = new GregorianCalendar();
- cal.setTime(period.getBegin());
- for (int i = 0; i < 12; i++) {
- Date begin = cal.getTime();
-
- int last_day_month = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
- cal.set(Calendar.DAY_OF_MONTH, last_day_month);
- Date end = cal.getTime();
-
- PeriodItem item = new PeriodItem(period, begin, end, true);
- list.add(item);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.add(Calendar.MONTH, 1);
- }
-
- return list;
- } else {
- throw new NullPointerException();
- }
- }
-
- /**
* Adds all of the elements in the second collection to the first collection if they're not already present.
*
* @param c1 collection who receives elements
1
0
r2843 - trunk/lima-swing/src/main/java/org/chorem/lima/util
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:13:25 +0200 (Fri, 09 Apr 2010)
New Revision: 2843
Log:
Remove swingx auto complete class (just use code when needed)
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java 2010-04-09 16:12:37 UTC (rev 2842)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java 2010-04-09 16:13:25 UTC (rev 2843)
@@ -1,48 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 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 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.
- *
- * 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>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-/**
- * @author ore
- */
-public class AccountToStringConverter extends ObjectToStringConverter {
-
- private static AccountToStringConverter converter;
-
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return DTOHelper.EMPTY_STRING;
- }
- AccountDTO account = (AccountDTO) item;
- return account.getIdNumber() + " : " + account.getDescription();
- }
-
- public static AccountToStringConverter getInstance() {
- if (converter == null) {
- converter = new AccountToStringConverter();
- }
- return converter;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java 2010-04-09 16:12:37 UTC (rev 2842)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java 2010-04-09 16:13:25 UTC (rev 2843)
@@ -1,50 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 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 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.
- *
- * 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>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-/**
- * Converts a journal to string for AutoCompleteDecorator
- *
- * @author ore
- */
-public class JournalToStringConverter extends ObjectToStringConverter {
-
- private static JournalToStringConverter converter;
-
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return DTOHelper.EMPTY_STRING;
- }
- JournalDTO journal = (JournalDTO) item;
- return journal.getIdName() + " : " + journal.getDescription();
- }
-
- public static JournalToStringConverter getInstance() {
- if (converter == null) {
- converter = new JournalToStringConverter();
- }
- return converter;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java 2010-04-09 16:12:37 UTC (rev 2842)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java 2010-04-09 16:13:25 UTC (rev 2843)
@@ -1,49 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 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 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.
- *
- * 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>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-/**
- * @author ore
- */
-public class PeriodToStringConverter extends ObjectToStringConverter {
-
- private static PeriodToStringConverter converter;
-
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return DTOHelper.EMPTY_STRING;
- }
- PeriodDTO period = (PeriodDTO) item;
- return period.getIdName();
- }
-
-
- public static PeriodToStringConverter getInstance() {
- if (converter == null) {
- converter = new PeriodToStringConverter();
- }
- return converter;
- }
-}
1
0
r2842 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction: model table
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:12:37 +0200 (Fri, 09 Apr 2010)
New Revision: 2842
Log:
Migration of transaction and lettering UI.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java (from rev 2836, trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -0,0 +1,52 @@
+/* *##% 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 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 Public License for more details.
+ *
+ * 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.ui.transaction.model;
+
+import javax.swing.DefaultComboBoxModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Account combo box model.
+ *
+ * Used in:
+ * - lettering view
+ *
+ * @author ore
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountComboBoxModel extends DefaultComboBoxModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6914345613508897515L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountComboBoxModel.class);
+
+ /**
+ * @param items
+ */
+ public AccountComboBoxModel() {
+ super();
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -36,11 +36,11 @@
*/
public class EntryBookComboBoxModel implements ComboBoxModel {
- protected Object selectedMonth;
+ protected Object selectedEntryBook;
protected EntryBookService entryBookService;
- public EntryBookComboBoxModel(Object selectedMonth) {
+ public EntryBookComboBoxModel() {
entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
}
@@ -99,7 +99,7 @@
*/
@Override
public void setSelectedItem(Object anItem) {
- selectedMonth = anItem;
+ selectedEntryBook = anItem;
}
/*
@@ -107,6 +107,6 @@
*/
@Override
public Object getSelectedItem() {
- return selectedMonth;
+ return selectedEntryBook;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -24,7 +24,6 @@
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.service.LimaServiceFactory;
-import org.nuiton.util.MonthEnum;
/**
* Opened financial period combo box model.
@@ -37,11 +36,11 @@
*/
public class FinancialPeriodComboBoxModel implements ComboBoxModel {
- protected Object selectedMonth;
+ protected Object selectedFinancialPeriod;
protected FinancialPeriodService financialPeriodService;
- public FinancialPeriodComboBoxModel(Object selectedMonth) {
+ public FinancialPeriodComboBoxModel() {
financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
}
@@ -100,7 +99,7 @@
*/
@Override
public void setSelectedItem(Object anItem) {
- selectedMonth = anItem;
+ selectedFinancialPeriod = anItem;
}
/*
@@ -108,6 +107,6 @@
*/
@Override
public Object getSelectedItem() {
- return selectedMonth;
+ return selectedFinancialPeriod;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -1,127 +1,98 @@
-/*
- * *##% Lima Main
+/* *##% 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.ui.transaction.table;
import java.awt.Color;
import java.awt.Component;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.Date;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.TableColumnModel;
-import javax.swing.table.TableModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.entity.Transaction;
import org.chorem.lima.listener.EmptyLineSelectionListener;
-import org.chorem.lima.listener.TransactionHeaderListener;
-import org.chorem.lima.listener.TransactionKeyListener;
-import org.chorem.lima.table.editor.AccountTableCellEditor;
import org.chorem.lima.table.editor.DateTableCellEditor;
-import org.chorem.lima.table.editor.JournalTableCellEditor;
-import org.chorem.lima.table.editor.NumberTableCellEditor;
-import org.chorem.lima.table.editor.PeriodTableCellEditor;
-import org.chorem.lima.table.editor.TextTableCellEditor;
-import org.chorem.lima.table.model.TransactionFlattenTableModel;
import org.chorem.lima.table.model.TransactionSortedTableColumnModel;
import org.chorem.lima.table.model.TransactionTableModel;
-import org.chorem.lima.table.renderer.AccountTableCellRenderer;
-import org.chorem.lima.table.renderer.AmountTableCellRenderer;
-import org.chorem.lima.table.renderer.DateTableCellRenderer;
-import org.chorem.lima.table.renderer.JournalTableCellRenderer;
-import org.chorem.lima.table.renderer.PeriodTableCellRenderer;
-import org.chorem.lima.table.renderer.StatusTableCellRenderer;
-import org.chorem.lima.table.renderer.TextTableCellRenderer;
-import org.chorem.lima.table.renderer.TransactionHeaderRenderer;
+import org.chorem.lima.ui.transaction.TransactionHelper;
+import org.chorem.lima.ui.transaction.TransactionViewHandler;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
* @author ore
* @author Rémi Chapelet
*/
-public class TransactionTable extends JXTable {
+public class TransactionTable extends JXTable implements KeyListener {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
-
+
/** log. */
private static final Log log = LogFactory.getLog(TransactionTable.class);
+ protected TransactionViewHandler handler;
+
private ColorHighlighter colorEmptyLine;
-
+
private ColorHighlighter colorTransaction;
-
+
private ColorHighlighter colorBalance;
-
+
private EmptyLineSelectionListener emptyLineSelectionListener;
-
- private TransactionKeyListener keyListener;
/**
- * @param model
- * @param columnModel
*/
- public TransactionTable(TransactionTableModel model, TransactionSortedTableColumnModel columnModel) {
- super(model, columnModel);
- createDefaultColumnsFromModel();
-
- //setSelectionBackground(new Color(250,250,250));
- //setSelectionForeground(new Color(0,0,0));
-
- setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250)));
- setColumnControlVisible(true);
- getColumnExt(TransactionEnum.LETTERING.ordinal()).setVisible(false);
- /**
+ public TransactionTable(TransactionViewHandler handler/*,
+ TransactionTableModel model,
+ TransactionSortedTableColumnModel columnModel*/) {
+ //super(model, columnModel);
+
+ this.handler = handler;
+
+ /*
* New Table Header
*/
- getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
- getTableHeader().addMouseListener(new TransactionHeaderListener(this));
+ // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
- /**
+ /*
* Mod : il est possible d'activer cette option.
* Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
* automatiquement une nouvelle ligne (une entrée comptable)
*/
- //addMouseListener(getEmptyLineSelectionListener());
- /**
- * Fin mod
- */
+ addMouseListener(getEmptyLineSelectionListener());
- /**
+ /*
* Mod : il est possible d'activer cette option.
* Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
* programme insère une ligne comptable.
*/
- addKeyListener(getKeyListener());
+ addKeyListener(this);
-
- /**
- * Editing true
- */
- setTransactionEditable(true);
-
// cell rendering
- TableColumnModel tcm = getColumnModel();
+ /*TableColumnModel tcm = getColumnModel();
tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
@@ -141,37 +112,23 @@
tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());
- packAll();
- /**
- * Color transactions
- */
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
+
+ setDefaultEditor(Date.class, new DateTableCellEditor());
+
+
+ // Color transactions
addColorTransaction();
- addColorBalance();
+ addColorNonBalancedTransaction();
}
/**
- * @param editable
- */
- public void setTransactionEditable(boolean editable) {
- if (editable) {
- addMouseListener(emptyLineSelectionListener);
- addKeyListener(keyListener);
- } else {
- removeMouseListener(emptyLineSelectionListener);
- removeKeyListener(keyListener);
- }
- TransactionTableModel model = (TransactionTableModel) getModel();
- model.setEditable(editable);
- }
-
- /**
*
*/
public void addColorEmptyLine() {
- /*
- * Renvoie une couleur jaune pour chaque nouvelle ligne créée
- removeColorEmptyLine();
+
+ // Renvoie une couleur jaune pour chaque nouvelle ligne créée
+ /*removeColorEmptyLine();
if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
HighlightPredicate predicate = new HighlightPredicate() {
@@ -199,59 +156,50 @@
* Cette méthode permet de colorer toutes les transactions dans le tableau
* afin de bien distinguer les transactions et entrées comptables.
*/
- public void addColorTransaction() {
+ protected void addColorTransaction() {
if (colorTransaction != null) {
removeHighlighter(colorTransaction);
}
HighlightPredicate predicate = new HighlightPredicate() {
-
@Override
- public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
- return DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) ? true : false;
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return getModel().getElementAt(adapter.row) instanceof Transaction;
}
};
- colorTransaction = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null);
+ colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
+ 222), null, null, null);
addHighlighter(colorTransaction);
}
-
/**
* Permet de surligner une transaction dans le tableau lorsque cette dernière
* n'est pas équilibrée.
*/
- public void addColorBalance() {
+ protected void addColorNonBalancedTransaction() {
if (colorBalance != null) {
removeHighlighter(colorBalance);
}
HighlightPredicate predicate = new HighlightPredicate() {
-
@Override
- public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
boolean isHighlighted = false;
- // Si c'est une transaction
- if ( DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) )
- {
- if ( !DTOHelper.isBalanced((TransactionDTO) getModel().getElementAt(adapter.row)) )
- {
+ Object value = getModel().getElementAt(adapter.row);
+ if (value instanceof Transaction) {
+ Transaction currentTransaction = (Transaction) value;
+ if (!TransactionHelper.isBalanced(currentTransaction)) {
isHighlighted = true;
}
}
return isHighlighted;
}
};
- colorTransaction = new ColorHighlighter(predicate, new Color(255,198,209),null,null,null);
+ colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
+ 209), null, null, null);
addHighlighter(colorTransaction);
}
- /**
- *
- */
- public void removeColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- }
-
@Override
public TransactionTableModel getModel() {
return (TransactionTableModel) this.dataModel;
@@ -269,27 +217,165 @@
return emptyLineSelectionListener;
}
- /**
- * @return
- */
- public TransactionKeyListener getKeyListener() {
- if (keyListener == null) {
- return new TransactionKeyListener();
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ // VK_DELETE suppression de la transaction en cours
+ // ou de l'entree
+ if (e.getKeyCode() == KeyEvent.VK_DELETE) {
+ handler.deleteSelectedRow();
}
- return keyListener;
+
+ // Touche : insert ou ctrl+I
+ // Ajoute une transaction
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT)
+ || (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+
+ // TODO EC 20100408 String result = table.getModel().addEmptyTransaction();
+ }
+
+ // Touche '+' OU 'ctrl+Entr'
+ // Ajoute une entrée comptable ou transaction
+ if (e.getKeyCode() == KeyEvent.VK_PLUS
+ || (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ /*int max_y = table.getRowCount();
+ addLine(table);
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y, max_y);*/
+ }
+
+ /**
+ * Touche tab
+ * Ajoute une entrée comptable ou transaction seulement si tab est sur
+ * la dernière cellule.
+ */
+ if (e.getKeyChar() == KeyEvent.VK_TAB) {
+ // Vérifie si la cellule sélectionnée est la dernière
+ /*int x = table.getSelectedColumn();
+ int y = table.getSelectedRow();
+ int max_x = table.getColumnCount() - 1;
+ int max_y = table.getRowCount() - 1;
+ if (x == max_x && y == max_y) {
+ boolean result = addLine(table);
+ // positionne la sélection sur la nouvelle ligne créée
+ if (result) {
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
+ }*/
+ }
+
}
- /**
- * @param model
- * @return
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
*/
- public boolean isFlattenModel(TableModel model) {
- return TransactionFlattenTableModel.isFlattenModel(model);
+ @Override
+ public void keyTyped(KeyEvent e) {
+
}
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
@Override
- public void setModel(TableModel arg0) {
- super.setModel(arg0);
- removeColorEmptyLine();
+ public void keyReleased(KeyEvent e) {
+
}
+
+ /**
+ * Permet d'ajouter une nouvelle ligne : transaction ou entrée
+ * @param table la table
+ * @return
+ */
+ /*private boolean addLine(TransactionJXTable table) {
+ if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) {
+ // Vérifie si le tableau est vide, alors ajout d'une transaction
+ if (table.getRowCount() == 0) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table
+ .getModel();
+ int selectedRow = 0;
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ selectedRow = table.getRowCount() - 1;
+ } else {
+ // Line selected
+ selectedRow = table.getSelectedRow();
+ }
+ // Récupère la position de la transaction rattachée
+ int parentIndex = flattenModel.getParentIndex(selectedRow);
+
+ // Is transaction editable ?
+ Object o = flattenModel.getElementAt(parentIndex);
+ if (DTOHelper.isTransaction(o)) {
+ // Transaction n'est pas éditable
+ if (!ServiceHelper.isEditable((TransactionDTO) o)) {
+ return false;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ return false;
+ }
+ }
+
+ // Vérifie si la transaction est équilibrée ou non (et qu'elle posséde des entrées)
+ TransactionDTO transaction = (TransactionDTO) flattenModel
+ .getElementAt(parentIndex);
+ if (DTOHelper.isBalanced(transaction)
+ && !transaction.getEntries().isEmpty()) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = selectedRow + 1;
+ flattenModel.createEmptyLine();
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ } else {
+ // Line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = flattenModel
+ .emptyLineNextPosition(selectedRow);
+
+ // Once traitement for transaction
+ if (flattenModel.isEmptyLineEmpty()) {
+ flattenModel.createEmptyLine();
+ } else {
+ flattenModel.removeEmptyLine();
+ selectedRow = table.getSelectedRow();
+ parentIndex = flattenModel.getParentIndex(selectedRow);
+ posNext = flattenModel
+ .emptyLineNextPosition(selectedRow);
+ flattenModel.createEmptyLine();
+ }
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ }
+ return true;
+ }
+ return false;
+ }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -1,51 +1,57 @@
-/*
- * *##% Lima Main
+/* *##% 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.ui.transaction.table;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import static org.nuiton.i18n.I18n._;
+
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
import javax.swing.table.AbstractTableModel;
-import javax.xml.rpc.ServiceFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.RecordService;
import org.chorem.lima.business.TransactionService;
-import org.chorem.lima.comparator.JournalComparator;
-import org.chorem.lima.comparator.PeriodComparator;
-import org.chorem.lima.comparator.StatusComparator;
-import org.chorem.lima.enumeration.FilterEnum;
-import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.Transaction;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.ServiceHelper;
+import org.chorem.lima.ui.transaction.TransactionHelper;
+import org.chorem.lima.util.ErrorHelper;
/**
* Basic transaction table model.
*
+ * Le modele est filtré sur {@link #selectedEntryBook} et
+ * {@link #selectedFinancialPeriod} (montée en charge !).
+ *
+ * TODO EC20100408 revoir le modele, avoir des transactions et des entries
+ * c'est pas gérables.
+ * Le mieux serait d'avoir un "mega component transaction par ligne" et
+ * que ce composant puisse editer les entries.
+ * Ou autre chose.
+ *
* @author ore
* @author chatellier
* @version $Revision$
@@ -57,16 +63,20 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3914954536809622358L;
-
+
/** log. */
- private static final Log log = LogFactory.getLog(TransactionTableModel.class);
+ private static final Log log = LogFactory
+ .getLog(TransactionTableModel.class);
- /**
- * Services
- */
+ /** Transaction service. */
+ protected final TransactionService transactionService;
+ /** Record service. */
protected final RecordService recordService;
- protected final TransactionService transactionService;
+ protected EntryBook selectedEntryBook;
+
+ protected FinancialPeriod selectedFinancialPeriod;
+
/**
* Model constructor.
*
@@ -75,130 +85,336 @@
public TransactionTableModel() {
/* Services */
recordService = LimaServiceFactory.getInstance().getRecordService();
- transactionService = LimaServiceFactory.getInstance().getTransactionService();
+ transactionService = LimaServiceFactory.getInstance()
+ .getTransactionService();
}
- @Override
- public int getRowCount() {
- return model.getRowCount();
+ /**
+ * Le model est une combinaison de Transaction/Entries.
+ *
+ * TODO EC20100408 c'est pas evident a manipuler via une table
+ *
+ * @return
+ */
+ protected List<Object> getDataList() {
+
+ List<Object> results = new ArrayList<Object>();
+ try {
+ List<Transaction> transactions =
+ transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
+
+ for (Transaction transaction : transactions) {
+ results.add(transaction);
+ // TODO EC20100408 warn about lazy exception here
+ // TODO EC20100408 warn about non ordonned transaction.getEntry()
+ results.addAll(transaction.getEntry());
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+
+ return results;
}
@Override
public int getColumnCount() {
- return model.getColumnCount();
+ return 10;
}
@Override
- public Object getValueAt(int row, int column) {
- return model.getValueAt(getSortedRow(row), column);
- }
+ public Class<?> getColumnClass(int column) {
- @Override
- public Object getElementAt(int row) {
- return model.getElementAt(getSortedRow(row));
- }
+ Class<?> result = null;
- @Override
- public boolean isEditable() {
- return model.isEditable();
- }
+ switch (column) {
+ case 0:
+ result = Date.class;
+ break;
+ case 1:
+ result = Account.class;
+ break;
+ case 2:
+ result = EntryBook.class;
+ break;
+ case 3:
+ result = FinancialPeriod.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = Double.class;
+ break;
+ case 6:
+ result = Double.class;
+ break;
+ case 7:
+ result = String.class;
+ break;
+ case 8:
+ result = String.class;
+ break;
+ case 9:
+ result = String.class;
+ break;
+ }
- @Override
- public Class<?> getColumnClass(int column) {
- return model.getColumnClass(column);
+ return result;
}
@Override
public String getColumnName(int column) {
- return model.getColumnName(column);
+ String result = "n/a";
+
+ switch (column) {
+ case 0:
+ result = _("lima.transaction.column.date");
+ break;
+ case 1:
+ result = _("lima.transaction.column.account");
+ break;
+ case 2:
+ result = _("lima.transaction.column.entrybook");
+ break;
+ case 3:
+ result = _("lima.transaction.column.period");
+ break;
+ case 4:
+ result = _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = _("lima.transaction.column.debit");
+ break;
+ case 6:
+ result = _("lima.transaction.column.credit");
+ break;
+ case 7:
+ result = _("lima.transaction.column.balance");
+ break;
+ case 8:
+ result = _("lima.transaction.column.description");
+ break;
+ case 9:
+ result = _("lima.transaction.column.document");
+ break;
+ }
+
+ return result;
}
@Override
- public boolean isCellEditable(int row, int column) {
- return model.isCellEditable(getSortedRow(row), column);
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ List<Object> datas = getDataList();
+ result = datas.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
}
@Override
- public void setValueAt(Object value, int row, int col) {
- row = getSortedRow(row);
- String response;
- /**
- * TransactionDTO
- */
- TransactionDTO trans = (TransactionDTO) getElementAt(row);
- TransactionDTO cloneTrans = DTOHelper.cloneTransaction(trans);
- switch (TransactionEnum.values()[col]) {
- case PERIOD:
- cloneTrans.setPeriod((PeriodDTO) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setPeriod(cloneTrans.getPeriod());
- trans.setStatus(cloneTrans.getStatus());
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ result = datas.get(row);
+
+ if (result instanceof Transaction) {
+ Transaction currentRow = (Transaction)result;
+ switch (column) {
+ case 0:
+ result = currentRow.getTransactionDate();
+ break;
+ case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = TransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = TransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
+ break;
+ case 8:
+ result = currentRow.getDescription();
+ break;
+ case 9:
+ result = currentRow.getVoucherRef();
+ break;
}
- break;
- case JOURNAL:
- cloneTrans.setJournal((JournalDTO) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setJournal(cloneTrans.getJournal());
- trans.setStatus(cloneTrans.getStatus());
+ }
+ else if (result instanceof Entry) {
+ Entry currentEntry = (Entry)result;
+ switch (column) {
+ case 0:
+ result = null; // date
+ break;
+ case 1:
+ result = currentEntry.getAccount(); // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ break;
+ case 6:
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ break;
+ case 7:
+ result = null;
+ break;
+ case 8:
+ result = currentEntry.getDescription();
+ break;
+ case 9:
+ result = null;
+ break;
}
- break;
- case DATE:
- cloneTrans.setEntryDate((Date) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setEntryDate(cloneTrans.getEntryDate());
- trans.setStatus(cloneTrans.getStatus());
- }
- break;
- case DOCUMENT:
- cloneTrans.setVoucherRef((String) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setVoucherRef(cloneTrans.getVoucherRef());
- trans.setStatus(cloneTrans.getStatus());
- }
- break;
- case DESCRIPTION:
- cloneTrans.setDescription((String) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setDescription(cloneTrans.getDescription());
- trans.setStatus(cloneTrans.getStatus());
- }
- break;
+ }
}
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
}
- /**
- *
- */
@Override
- public String addEmptyTransaction() {
- return model.addEmptyTransaction();
- }
+ public void setValueAt(Object value, int row, int column) {
- /**
- * @param trans
- */
- @Override
- public String removeTransaction(TransactionDTO trans) {
- return model.removeTransaction(trans);
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+
+ if (currentRow instanceof Transaction) {
+ Transaction currentTransaction = (Transaction)currentRow;
+ switch (column) {
+ case 0:
+ currentTransaction.setTransactionDate((Date)value);
+ break;
+ /*case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = TransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = TransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
+ break;*/
+ case 8:
+ currentTransaction.setDescription((String)value);
+ break;
+ case 9:
+ currentTransaction.setVoucherRef((String)value);
+ break;
+ }
+
+ // notify service for modification
+ try {
+ transactionService.updateTransaction(currentTransaction);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //fireTableRowsUpdated(row, row); // to update what ???
+
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ switch (column) {
+ /*case 0:
+ result = null; // date
+ break;*/
+ case 1:
+ currentEntry.setAccount((Account)value); // account ?
+ break;
+ /*case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;*/
+ case 5:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(true);
+ break;
+ case 6:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(false);
+ break;
+ /*case 7:
+ result = null;
+ break;*/
+ case 8:
+ currentEntry.setDescription((String)value);
+ break;
+ /*case 9:
+ result = null;
+ break;*/
+ }
+
+ //transactionService.updateEntry(currentEntry);
+ // fire modification of all transaction
+ // see here, table is not adapted :)
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
}
}
1
0
r2841 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:12:23 +0200 (Fri, 09 Apr 2010)
New Revision: 2841
Log:
Migration of transaction and lettering UI.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-09 16:10:45 UTC (rev 2840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-09 16:12:23 UTC (rev 2841)
@@ -23,13 +23,13 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaContext;
import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
import org.chorem.lima.dto.AccountDTO;
import org.chorem.lima.item.Item;
import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
+import org.chorem.lima.ui.transaction.autocomplete.AccountToStringConverter;
+import org.chorem.lima.ui.transaction.model.AccountComboBoxModel;
+import org.chorem.lima.widgets.JWideComboBox;
import org.jdesktop.swingx.JXDatePicker;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-04-09 16:10:45 UTC (rev 2840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-04-09 16:12:23 UTC (rev 2841)
@@ -15,95 +15,86 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##% -->
-<Table insets='0,0,0,0' fill="both">
+<Table fill="both">
<script>
- protected void addLettering() {};
- protected void removeLettering() {};
- protected void precedentAccount() {};
- protected void nextAccount() {};
+ <![CDATA[
+ import org.chorem.lima.entity.Account;
+ import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+ import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
+
+ // Swingx auto complete (for account) :
+ AutoCompleteDecorator.decorate(accountComboBox, new ObjectToStringConverter() {
+ @Override
+ public String getPreferredStringForItem(Object item) {
+ if (item == null) {
+ return "";
+ }
+ Account account = (Account) item;
+ return account.getAccountNumber() + " : " + account.getLabel();
+ }
+ });
+
+ protected void addLettering() {
+ // never been implemented :(
+ };
+ protected void removeLettering() {
+ // never been implemented :(
+ };
+ ]]>
</script>
- <row weightx="1" weighty="0">
+ <row>
<cell>
- <!-- account -->
- <Table insets='0,0,0,0'>
- <row weightx="0" weighty="0">
- <cell anchor='center' weightx="0" weighty="0">
- <!-- precedent -->
- <JButton id="precedentButton"
- preferredSize='{new Dimension(24,24)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- onActionPerformed='precedentAccount()'
- />
- </cell>
- <cell anchor='center' weightx="0" weighty="0">
- <!-- next -->
- <JButton id="nextButton"
- preferredSize='{new Dimension(24,24)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- onActionPerformed='nextAccount()'
- />
- </cell>
- </row>
+ <Table>
<!-- account -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <row fill="horizontal" weightx="1" anchor="center">
<cell anchor="east">
<JLabel text="lima.account"/>
</cell>
- <cell weightx="0" weighty="0">
- <JPanel id="accountPanel"/>
+ <cell>
+ <org.chorem.lima.widgets.JWideComboBox id="accountComboBox"
+ model="{new org.chorem.lima.ui.transaction.model.AccountComboBoxModel()}" />
</cell>
</row>
- <!-- since -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <!-- from -->
+ <row fill="horizontal" weightx="1" anchor="center">
<cell anchor="east">
- <JLabel text="lima.since"/>
+ <JLabel text="lima.lettering.from"/>
</cell>
<cell>
- <JPanel id="sincePanel"/>
+ <org.chorem.lima.widgets.JWideComboBox id="fromPeriodComoboBox" />
</cell>
</row>
<!-- to -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <row fill="horizontal" weightx="1" anchor="center">
<cell anchor="east">
- <JLabel text="lima.to"/>
+ <JLabel text="lima.lettering.to"/>
</cell>
<cell>
- <JPanel id="toPanel"/>
+ <org.chorem.lima.widgets.JWideComboBox id="toPeriodComoboBox" />
</cell>
</row>
</Table>
</cell>
<cell>
<!-- entries -->
- <Table insets='0,0,0,0' fill="both">
+ <Table fill="both">
<row columns="3">
<cell>
- <JLabel text="lima.entries"/>
+ <JLabel text="lima.lettering.entries"/>
</cell>
</row>
<row>
<cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettered' value='{_("lima.lettered")}'
- selected='true'/>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettering.lettered'
+ value='{_("lima.lettering.lettered")}' selected='true'/>
</cell>
<cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.not.lettered'
- value='{_("lima.not.lettered")}'/>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettering.notlettered'
+ value='{_("lima.lettering.notlettered")}'/>
</cell>
<cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.all' value='{_("lima.all")}'/>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettering.letteredall'
+ value='{_("lima.lettering.letteredall")}'/>
</cell>
</row>
</Table>
@@ -111,18 +102,21 @@
</row>
<row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
<cell>
- <!-- table -->
- <JScrollPane id="tablePanel"/>
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="letteringTable" />
+ </JScrollPane>
</cell>
</row>
<row>
<cell>
<!-- add lettering -->
- <JButton id="addButton" text="lima.add.lettering" onActionPerformed="addLettering()"/>
+ <JButton id="addButton" text="lima.lettering.add"
+ onActionPerformed="addLettering()"/>
</cell>
<cell>
<!-- remove lettering -->
- <JButton id="removeButton" text="lima.remove.lettering" onActionPerformed="removeLettering()"/>
+ <JButton id="removeButton" text="lima.lettering.remove"
+ onActionPerformed="removeLettering()"/>
</cell>
</row>
</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java 2010-04-09 16:10:45 UTC (rev 2840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java 2010-04-09 16:12:23 UTC (rev 2841)
@@ -1,127 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 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 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.
- *
- * 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>. ##%*
- */
-
-package org.chorem.lima.ui.transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
-import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
-import org.nuiton.util.Resource;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.List;
-import java.util.Vector;
-
-import jaxx.runtime.JAXXContext;
-
-/**
- * @author ore
- */
-public class LetteringViewImpl extends LetteringView {
-
-
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(LetteringViewImpl.class);
- private final JWideComboBox accountComboBox;
-
- /**
- * @param parentContext
- */
- public LetteringViewImpl(JAXXContext parentContext) {
- super(parentContext);
-
- /** Calling services */
- List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
- LimaContext.getContext().getDataManager().getAccountModel().getData());
- /** Creating accounting model */
- Vector<AccountDTO> v1 = new Vector<AccountDTO>(accounts);
- AccountComboBoxModel model = new AccountComboBoxModel(v1);
- accountComboBox = new JWideComboBox();
- accountComboBox.setPreferredSize(new Dimension(200, 25));
- accountComboBox.setModel(model);
- LimaContext.getContext().getDataManager().getAccountModel().addPropertyChangeListener(model);
- accountComboBox.setRenderer(AccountComboBoxRenderer.getInstance());
- accountPanel.add(accountComboBox);
-
- /** AutoCompletion */
- AutoCompleteDecorator.decorate(accountComboBox, AccountToStringConverter.getInstance());
-
- Icon forwardIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Forward24.gif");
- Icon backIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Back24.gif");
- nextButton.setIcon(forwardIcon);
- precedentButton.setIcon(backIcon);
-
- /** Creating period model */
- List<PeriodDTO> periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
- LimaContext.getContext().getNeogiaFactory().getStatusService().getAllStatus()
- );
- Vector<PeriodDTO> v2 = new Vector<PeriodDTO>();
- for (PeriodDTO period : periodes) {
- v2.addElement(period);
- v2.addAll(period.getChildren());
- }
- JWideComboBox sinceComboBox = new JWideComboBox(v2);
- sinceComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
- sinceComboBox.setPreferredSize(new Dimension(200, 25));
- sincePanel.add(sinceComboBox);
-
- JWideComboBox toComboBox = new JWideComboBox(v2);
- toComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
- toComboBox.setPreferredSize(new Dimension(200, 25));
- toPanel.add(toComboBox);
-
- JXTable table = new JXTable();
- tablePanel.setViewportView(table);
- }
-
- /**
- *
- */
- @Override
- protected void nextAccount() {
- if (!(accountComboBox.getSelectedIndex() == accountComboBox.getModel().getSize() - 1)) {
- accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() + 1);
- }
-
- }
-
- /**
- *
- */
- @Override
- protected void precedentAccount() {
- if (!(accountComboBox.getSelectedIndex() == 0)) {
- accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() - 1);
- }
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx 2010-04-09 16:10:45 UTC (rev 2840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx 2010-04-09 16:12:23 UTC (rev 2841)
@@ -28,7 +28,7 @@
<Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
<row>
<cell>
- <JButton id="addButton" text="lima.add" width="100" onActionPerformed="addCriteriaWidget()"/>
+ <JButton id="addButton" text="lima.common.add" width="100" onActionPerformed="addCriteriaWidget()"/>
</cell>
<cell>
<JLabel text="lima.search.items.where" width="200"/>
@@ -49,10 +49,10 @@
</row>
<row>
<cell>
- <JButton id="okButton" onActionPerformed="doSearch()" text="lima.ok"/>
+ <JButton id="okButton" onActionPerformed="doSearch()" text="lima.common.ok"/>
</cell>
<cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="windowClosing()"/>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="windowClosing()"/>
</cell>
</row>
</Table>
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java 2010-04-09 16:12:23 UTC (rev 2841)
@@ -0,0 +1,79 @@
+/* *##% Lima Main
+ * 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 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.
+ *
+ * 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>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.Transaction;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TransactionHelper {
+
+ /**
+ * Get total credit for a transaction.
+ *
+ * @param transaction transaction to get credit
+ * @return total credit
+ */
+ public static double getCredit(Transaction transaction) {
+ double credit = 0;
+ for (Entry entry : transaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (!entry.getDebit()) {
+ credit += entry.getAmount();
+ }
+ }
+ return credit;
+ }
+
+ /**
+ * Get total debit for a transaction.
+ *
+ * @param transaction transaction to get debit
+ * @return total debit
+ */
+ public static double getDebit(Transaction transaction) {
+ double debit = 0;
+ for (Entry entry : transaction.getEntry()) {
+ // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
+ if (entry.getDebit()) {
+ debit += entry.getAmount();
+ }
+ }
+ return debit;
+ }
+
+ /**
+ * Return true if transaction is balanced (credit == debit).
+ *
+ * @param transaction transaction to test
+ * @return {@code true} if transaction is balanced
+ */
+ public static boolean isBalanced(Transaction transaction) {
+ boolean balanced = getDebit(transaction) == getCredit(transaction);
+ return balanced;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-09 16:10:45 UTC (rev 2840)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-09 16:12:23 UTC (rev 2841)
@@ -16,11 +16,15 @@
##% -->
<Table>
+ <TransactionViewHandler id="handler" javaBean="new TransactionViewHandler(this)" />
+ <Boolean id="selectedRow" javaBean="false" />
+
<script>
<![CDATA[
]]>
</script>
+
<!-- <JPopupMenu id="MenuRightPanel">
<JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
<JMenuItem text="lima.print"/>
@@ -29,7 +33,7 @@
<JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
<JMenuItem text="lima.print"/>
</JPopupMenu> -->
- <row fill="horizontal" weightx="0.75" weighty="0" anchor="center">
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
<cell>
<JLabel id="entryBookLabel" text="lima.transaction.entrybook"/>
</cell>
@@ -46,26 +50,34 @@
</cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='3' columns='4'>
+ <cell fill="both" weightx="1" weighty="1" rows="3" columns="4">
<JScrollPane>
+ <org.chorem.lima.ui.transaction.table.TransactionTableModel
+ id="transactionTableModel" />
<org.chorem.lima.ui.transaction.table.TransactionTable
- id="transactionsTable" sortable="false" rowHeight="22"
+ id="transactionTable" sortable="false" rowHeight="22"
+ constructorParams="getHandler()" model="{getTransactionTableModel()}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- highlighters="{HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
+ <javax.swing.ListSelectionModel javaBean="getTransactionTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(transactionTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
<cell>
- <JButton id="addButton" text="lima.add.transaction" onActionPerformed="addEmptyTransaction()" width="150"/>
+ <JButton text="lima.add.transaction"
+ onActionPerformed="getHandler().addEmptyTransaction()"/>
</cell>
</row>
<row>
<cell>
- <JButton id="removeButton" text="lima.remove.transaction" onActionPerformed="removeTransaction()" width="150"/>
+ <JButton text="lima.remove.transaction"
+ onActionPerformed="getHandler().removeTransaction()"
+ enabled="{isSelectedRow()}"/>
</cell>
</row>
<row>
<cell>
- <JButton text="lima.add.entry" onActionPerformed="addEmptyEntry()" width="150"/>
+ <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/>
</cell>
</row>
</Table>
\ No newline at end of file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java 2010-04-09 16:12:23 UTC (rev 2841)
@@ -0,0 +1,112 @@
+/* *##% 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 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 Public License for more details.
+ *
+ * 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.ui.transaction;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.Transaction;
+import org.chorem.lima.table.model.TransactionTableModel;
+import org.chorem.lima.ui.transaction.table.TransactionTable;
+
+/**
+ * Handler associated with account view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TransactionViewHandler {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(TransactionViewHandler.class);
+
+ protected TransactionView view;
+
+ protected TransactionViewHandler(TransactionView view) {
+ this.view = view;
+ }
+
+ public void addEmptyTransaction() {
+
+ }
+
+ public void removeTransaction() {
+
+ }
+
+ public void addEmptyEntry() {
+
+ }
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ */
+ public void deleteSelectedRow() {
+
+ TransactionTable table = (TransactionTable)view.getTransactionTable();
+ TransactionTableModel model = table.getModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+
+ Object selectedValue = model.getElementAt(indexSelectedRow);
+
+ String message = null;
+ if (selectedValue instanceof Transaction) {
+ message = _("lima.question.remove.transaction");
+ }
+ else {
+ message = _("lima.question.remove.entry");
+ }
+
+ int response = JOptionPane.showConfirmDialog(view, message,
+ _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_OPTION);
+
+ if (response == JOptionPane.YES_OPTION) {
+
+ if (selectedValue instanceof Transaction) {
+ // TODO EC-20100409 implements this
+ if (log.isWarnEnabled()) {
+ log.warn("TODO implement Transaction deletion");
+ }
+ }
+ else if (selectedValue instanceof Entry) {
+ // TODO EC-20100409 implements this
+ if (log.isWarnEnabled()) {
+ log.warn("TODO implement Entry deletion");
+ }
+ }
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call delete selected row without selection");
+ }
+ }
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r2840 - in trunk/lima-business/src/main/java/org/chorem/lima/business: . ejb
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:10:45 +0200 (Fri, 09 Apr 2010)
New Revision: 2840
Log:
Update report service signatures
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-04-09 10:13:09 UTC (rev 2839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-04-09 16:10:45 UTC (rev 2840)
@@ -19,6 +19,11 @@
package org.chorem.lima.business;
+import org.chorem.lima.beans.BalanceSheet;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
+
/**
* Service de generation des rapports.
*
@@ -36,15 +41,22 @@
*/
public interface ReportService {
-
/**
* Generation du bilan.
*
- * @param period
- * @return
+ * @param fiscalPeriod exercice
+ * @return le bilan
* @throws LimaException
*/
- String generateBalanceSheet(String period) throws LimaException;
+ BalanceSheet generateBalanceSheet(FiscalPeriod fiscalPeriod) throws LimaException;
+ /**
+ * Generation de la balance.
+ *
+ * @param financialPeriod la periode
+ * @return la balance
+ * @throws LimaException
+ */
+ BalanceTrial generateBalanceTrial(FinancialPeriod financialPeriod) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-04-09 10:13:09 UTC (rev 2839)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-04-09 16:10:45 UTC (rev 2840)
@@ -21,7 +21,12 @@
import javax.ejb.Stateless;
+import org.chorem.lima.beans.BalanceSheet;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportService;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
@Stateless
public class ReportServiceImpl implements ReportService {
@@ -30,14 +35,16 @@
return null;
}
- public String generateBalanceTrial(String period) {
- return null;
- }
-
- public String generateBalanceSheet(String period) {
+ public BalanceSheet generateBalanceSheet(FiscalPeriod fiscalPeriod) throws LimaException {
+ // bilan
return null;
}
+ public BalanceTrial generateBalanceTrial(FinancialPeriod financialPeriod) throws LimaException {
+ // balance
+ return null;
+ }
+
public String generateCashFlowStatement(String period) {
return null;
}
@@ -53,5 +60,4 @@
public String generateJournal(String type, String period) {
return null;
}
-
}
1
0
r2839 - trunk/lima-swing/src/main/java/org/chorem/lima/service
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 12:13:09 +0200 (Fri, 09 Apr 2010)
New Revision: 2839
Log:
Jndi properties are based on application config options.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-09 08:56:49 UTC (rev 2838)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-09 10:13:09 UTC (rev 2839)
@@ -30,13 +30,13 @@
import org.apache.openejb.assembler.classic.AppInfo;
import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.loader.SystemInstance;
+import org.chorem.lima.LimaMain;
import org.chorem.lima.business.AccountService;
import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.RecordService;
import org.chorem.lima.business.TransactionService;
-import org.chorem.lima.business.ejb.EntryBookServiceImpl;
/**
* Is class is a service factory based on embedded openejb container.
@@ -53,6 +53,24 @@
* Mais il vaudrait mieux essayer en distant pour verifier si
* la factorisation est similaire.
*
+ * Attention, en mode distant, les jar "javaee-api" et "openejbclient"
+ * doivent etre les mêmes (avec une snapshot ca fesait une NPE)
+ *
+ *
+ * <h3>Lookup EJB methods</h3>
+ *
+ * <ul>
+ * <li>first way is :
+ * <pre>FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");</pre></li>
+ * <li>second way is (spec compliant)
+ * <pre>Object obj = ctx.lookup("my/bean/Foo");
+ * FooHome ejbHome = (FooHome)
+ * PortableRemoteObject.narrow(obj, FooHome.class);</pre><li>
+ *
+ * <h3>TODO</h3>
+ *
+ * <p>All services are hardcoded in local mode for now</p>
+ *
* @author chatellier
* @version $Revision$
*
@@ -64,27 +82,35 @@
/** Log. */
private static Log log = LogFactory.getLog(LimaServiceFactory.class);
+ /** Single instance. */
protected static LimaServiceFactory instance;
+ /** JNDI context used to look for EJB. */
protected InitialContext ctx;
/**
* Init openejb jndi context.
*/
protected LimaServiceFactory() {
-
- // embedded server
- // TODO put this in configuration
- Properties properties = new Properties();
- properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
+ // TODO EC-20100407 maybe put all options in LimaConfig and allow user to configure it (remove getFlatOptions use)
+ Properties props = LimaMain.config.getFlatOptions();
+
+ // Context.INITIAL_CONTEXT_FACTORY is a mandatory option
+ // containsKey() does'nt work :(
+ if (!props.containsKey(Context.INITIAL_CONTEXT_FACTORY)) {
+ throw new RuntimeException("Application configuration is missing mandatory property "
+ + Context.INITIAL_CONTEXT_FACTORY);
+ }
+
try {
- ctx = new InitialContext(properties);
+ ctx = new InitialContext(props);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't initialize initial context", eee);
}
}
+
}
/**
@@ -108,15 +134,8 @@
*/
public AccountService getAccountService() {
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
String lookupName = "AccountServiceImplLocal";
AccountService ejbHome = null;
try {
@@ -130,49 +149,14 @@
}
/**
- * Get Journal service.
- *
- * @return account service proxy
- */
- public EntryBookServiceImpl getJournalService() {
-
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
- String lookupName = "JournalServiceImplLocal";
- EntryBookServiceImpl ejbHome = null;
- try {
- ejbHome = (EntryBookServiceImpl)ctx.lookup(lookupName);
- } catch (NamingException eee) {
- if (log.isErrorEnabled()) {
- log.error("Can't lookup for service : " + lookupName, eee);
- }
- }
- return ejbHome;
- }
-
- /**
* Get FiscalPeriod service.
*
* @return fiscalPeriod service proxy
*/
public FiscalPeriodService getFiscalPeriodService() {
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
String lookupName = "FiscalPeriodServiceImplLocal";
FiscalPeriodService ejbHome = null;
try {
@@ -188,19 +172,12 @@
/**
* Get FinancialPeriod service.
*
- * @return fiscalPeriod service proxy
+ * @return Financial Period service proxy
*/
public FinancialPeriodService getFinancialPeriodService() {
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
String lookupName = "FinancialPeriodServiceImplLocal";
FinancialPeriodService ejbHome = null;
try {
@@ -220,15 +197,8 @@
*/
public TransactionService getTransactionService() {
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
String lookupName = "TransactionServiceImplLocal";
TransactionService ejbHome = null;
try {
@@ -248,15 +218,8 @@
*/
public EntryBookService getEntryBookService() {
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
String lookupName = "EntryBookServiceImplLocal";
EntryBookService ejbHome = null;
try {
@@ -276,15 +239,8 @@
*/
public RecordService getRecordService() {
- // first way is
- // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
-
- // second way is (spec compliant)
- // Object obj = ctx.lookup("my/bean/Foo");
- // FooHome ejbHome = (FooHome)
- // PortableRemoteObject.narrow(obj, FooHome.class);
-
- // TODO put lookup name in configuration
+ // TODO EC-20100410 put lookup name in configuration
+ // name should be fully configurable due to custom implementation used
String lookupName = "RecordServiceImplLocal";
RecordService ejbHome = null;
try {
@@ -306,6 +262,8 @@
* @throws Exception when trying to destroy a non existent application
*/
public void destroy() throws Exception {
+
+ // destroy code (only in embedded mode)
Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
for (AppInfo appInfo : assembler.getDeployedApplications()) {
assembler.destroyApplication(appInfo.jarPath);
1
0