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(); - } - -}