r2966 - in trunk: . lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/utils lima-swing/src/main/filters lima-swing/src/main/java/org/chorem/lima lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/entrybook lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart lima-swing/src/main/j
Author: jpepin Date: 2010-07-12 12:37:10 +0200 (Mon, 12 Jul 2010) New Revision: 2966 Url: http://chorem.org/repositories/revision/lima/2966 Log: Modification de l'UI : page d'accueil, icones, menus d'import / export. Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java trunk/lima-swing/src/main/filters/action-leave-fullscreen.png trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx trunk/lima-swing/src/main/resources/icons/action-charts-accounts.png trunk/lima-swing/src/main/resources/icons/action-charts-entrybooks.png trunk/lima-swing/src/main/resources/icons/action-charts-financialperiod.png trunk/lima-swing/src/main/resources/icons/action-charts-financialstatements.png trunk/lima-swing/src/main/resources/icons/action-charts-fiscalperiod.png trunk/lima-swing/src/main/resources/icons/action-entries-balanced.png trunk/lima-swing/src/main/resources/icons/action-entries-search.png trunk/lima-swing/src/main/resources/icons/action-entries-unbalanced.png trunk/lima-swing/src/main/resources/icons/action-reports-account.png trunk/lima-swing/src/main/resources/icons/action-reports-balance.png trunk/lima-swing/src/main/resources/icons/action-reports-entrybook.png trunk/lima-swing/src/main/resources/icons/action-reports-financialstatement.png trunk/lima-swing/src/main/resources/icons/action-reports-ledger.png trunk/lima-swing/src/main/resources/images/accounts.png trunk/lima-swing/src/main/resources/images/entries.png trunk/lima-swing/src/main/resources/images/entrybooks.png trunk/lima-swing/src/main/resources/images/fiscalperiods.png Removed: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java trunk/lima-swing/src/main/resources/icons/action-account.png trunk/lima-swing/src/main/resources/icons/action-closure-timespan.png trunk/lima-swing/src/main/resources/icons/action-closure.png trunk/lima-swing/src/main/resources/icons/action-journal.png trunk/lima-swing/src/main/resources/icons/action-rapport.png trunk/lima-swing/src/main/resources/icons/action-search.png trunk/lima-swing/src/main/resources/icons/action-transaction.png trunk/lima-swing/src/main/resources/icons/action-view.png trunk/lima-swing/src/main/resources/icons/unused/ Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties trunk/lima-swing/src/main/resources/icons/action-about.png trunk/lima-swing/src/main/resources/icons/action-closeTab.png trunk/lima-swing/src/main/resources/icons/action-lettering.png trunk/lima-swing/src/main/resources/icons/action-translate.png trunk/pom.xml Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ExportService.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -59,5 +59,15 @@ */ public String exportAccountsChartAsCSV() throws LimaException; + /** + * export entries as EBP + */ + public String exportEntriesAsEBP() throws LimaException; + + /** + * export accounts as EBP + */ + public String exportAccountsAsEBP() throws LimaException; + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -24,12 +24,15 @@ import java.text.SimpleDateFormat; import java.util.List; import javax.ejb.Stateless; + +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.ExportService; import org.chorem.lima.business.ExportServiceLocal; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.utils.ImportExportEntityEnum; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.ClosedPeriodicEntryBook; @@ -48,6 +51,8 @@ import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; +import org.omg.CORBA.portable.ValueOutputStream; + import au.com.bytecode.opencsv.CSVWriter; /** @@ -66,7 +71,7 @@ private TopiaContext rootContext; - private final SimpleDateFormat sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss"); + private static final SimpleDateFormat SDateFormat = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss"); public ExportServiceImpl() { LimaConfig config = LimaConfig.getInstance(); @@ -79,6 +84,140 @@ } } + //############## EXPORT EBP + /** + * Export entries to EBP + * Struturce example : 1,010101,VE,411ART,, "Ventes d’ordinateur ", "123 ",12548.95,D,010301, + * Can't use opencsv for create export because don't support "" for just some columns + */ + @Override + public String exportEntriesAsEBP() throws LimaException { + TopiaContext topiaContext = null; + SimpleDateFormat epbDateFormat = new SimpleDateFormat("ddMMyyyy"); + String result = ""; + int num = 0; + + try { + topiaContext = beginTransaction(); + //export entries + FinancialTransactionDAO financialTransactionDAO = + LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext); + List<FinancialTransaction> listFinancialTransaction = + financialTransactionDAO.findAll(); + // For all financialTransaction + for (FinancialTransaction financialTransaction : listFinancialTransaction) { + String date = epbDateFormat.format(financialTransaction.getTransactionDate()); + String entrybookCode = ""; + EntryBook entryBook = financialTransaction.getEntryBook(); + + if (entryBook != null){ + entrybookCode = entryBook.getCode(); + } + + String[] nextLine = new String[11]; + for (Entry entry : financialTransaction.getEntry()) { + num++; + Account account = entry.getAccount(); + + String accountNumber = ""; + if (account != null){ + accountNumber = entry.getAccount().getAccountNumber(); + } + + String debitcredit = ""; + if (entry.getDebit()){ + debitcredit = "D"; + } + else { + debitcredit = "C"; + } + + nextLine[0] = String.valueOf(num); + nextLine[1] = date; + nextLine[2] = entrybookCode; + nextLine[3] = accountNumber; + nextLine[5] = '"'+entry.getDescription()+'"'; + nextLine[6] = '"'+entry.getVoucher()+'"'; + nextLine[7] = new Double(entry.getAmount()).toString(); + nextLine[8] = debitcredit; + + // Ajoute la ligne au fichier + for (int i=0; i<9; i++){ + String string = ""; + String nextln = nextLine[i]; + if (nextln != null){ + string = nextln; + } + if (i==8){ + result+=string+"\r\n"; + } + else { + result+=string+","; + } + } + } + } + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + /*catch (IOException eeeIO) { + log.debug("Can't create new CSV Writer",eeeIO); + }*/ + finally { + doFinally(topiaContext, log); + } + return result; + } + + /** + * Export accounts chart to EBP + * Structure ebp - example : + * 411DUPOND,DUPOND,,21 rue du bois, 78120, Rambouillet, France,,0135698475,0135698475 + * + */ + @Override + public String exportAccountsAsEBP() throws LimaException { + TopiaContext topiaContext = null; + StringWriter out = new StringWriter(); + CSVWriter csvWriter; + + + try { + topiaContext = beginTransaction(); + csvWriter = new CSVWriter(out, CSVWriter.DEFAULT_SEPARATOR, CSVWriter.NO_QUOTE_CHARACTER); + //export accounts + String[] nextLine = new String[10]; + // Récupère tous les comptes + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(topiaContext); + List<Account> listAccount = accountDAO.findAll(); + // Pour tous les comptes + for (Account account : listAccount) { + nextLine[0] = account.getAccountNumber(); + nextLine[1] = StringUtils.remove(account.getLabel(), ","); + // Ajoute la ligne au fichier + csvWriter.writeNext(nextLine); + } + // Write cache in string + csvWriter.flush(); + csvWriter.close(); + } + catch (TopiaException eeeTE){ + doCatch(topiaContext, eeeTE, log); + } + catch (IOException eeeIO) { + log.debug("Can't create new CSV Writer",eeeIO); + } + finally { + doFinally(topiaContext, log); + } + return out.getBuffer().toString(); + } + + + + //############## EXPORT CSV /** * Export integrality of database in CSV @@ -162,7 +301,7 @@ financialStatementDAO.findAll(); // For all Financialstatements for (FinancialStatement financialStatement : listFinancialStatements) { - nextLine[0] = "FNST"; + nextLine[0] = ImportExportEntityEnum.FINANCIALSTATEMENT.getLabel(); nextLine[1] = financialStatement.getLabel(); nextLine[2] = new Boolean( financialStatement.getHeader()).toString(); @@ -236,7 +375,7 @@ List<EntryBook> listEntryBook = entryBookDAO.findAll(); // For all EntryBook for (EntryBook entryBook : listEntryBook) { - nextLine[0] = "ENBK"; + nextLine[0] = ImportExportEntityEnum.ENTRYBOOK.getLabel(); nextLine[1] = entryBook.getCode(); nextLine[2] = entryBook.getLabel(); nextLine[3] = entryBook.getType(); @@ -293,7 +432,7 @@ List<Account> listAccount = accountDAO.findAll(); // Pour tous les comptes for (Account account : listAccount) { - nextLine[0] = "ACCN"; + nextLine[0] = ImportExportEntityEnum.ACCOUNT.getLabel(); nextLine[1] = account.getAccountNumber(); nextLine[2] = account.getLabel(); nextLine[3] = account.getThirdParty(); @@ -336,19 +475,19 @@ // For all financialTransaction for (FinancialTransaction financialTransaction : listFinancialTransaction) { String[] nextLine = new String[8]; - nextLine[0] = "FTRC"; + nextLine[0] = ImportExportEntityEnum.FINANCIALTRANSACTION.getLabel(); nextLine[1] = String.valueOf(numTransaction); nextLine[2] = - sdf.format(financialTransaction.getTransactionDate()); + SDateFormat.format(financialTransaction.getTransactionDate()); nextLine[3] = new Double( financialTransaction.getAmountDebit()).toString(); nextLine[4] = new Double( financialTransaction.getAmountCredit()).toString(); nextLine[5] = - sdf.format(financialTransaction.getFinancialPeriod(). + SDateFormat.format(financialTransaction.getFinancialPeriod(). getBeginDate()); nextLine[6] = - sdf.format(financialTransaction.getFinancialPeriod(). + SDateFormat.format(financialTransaction.getFinancialPeriod(). getEndDate()); EntryBook entryBook = financialTransaction.getEntryBook(); if (entryBook != null){ @@ -359,7 +498,7 @@ nextLine = new String[10]; for (Entry entry : financialTransaction.getEntry()) { - nextLine[0] = "NTRY"; + nextLine[0] = ImportExportEntityEnum.ENTRY.getLabel(); nextLine[1] = String.valueOf(numTransaction); nextLine[2] = entry.getDescription(); nextLine[3] = new Double(entry.getAmount()).toString(); @@ -395,9 +534,9 @@ fiscalPeriodDAO.findAll(); // For all Entry for (FiscalPeriod fiscalPeriod : listFiscalPeriod) { - nextLine[0] = "FSCP"; - nextLine[1] = sdf.format(fiscalPeriod.getBeginDate()); - nextLine[2] = sdf.format(fiscalPeriod.getEndDate()); + nextLine[0] = ImportExportEntityEnum.FISCALPERIOD.getLabel(); + nextLine[1] = SDateFormat.format(fiscalPeriod.getBeginDate()); + nextLine[2] = SDateFormat.format(fiscalPeriod.getEndDate()); nextLine[3] = new Boolean(fiscalPeriod.getLocked()).toString(); // Ajoute la ligne au fichier csvWriter.writeNext(nextLine); @@ -423,14 +562,14 @@ closedPeriodicEntryBookDAO.findAll(); // For all Entry for (ClosedPeriodicEntryBook closedPeriodicEntryBook : listClosedPeriodicEntryBook) { - nextLine[0] = "CPEB"; + nextLine[0] = ImportExportEntityEnum.CLOSEDPERIODICENTRYBOOK.getLabel(); nextLine[1] = new Boolean( closedPeriodicEntryBook.getLocked()).toString(); nextLine[2] = - sdf.format(closedPeriodicEntryBook.getFinancialPeriod(). + SDateFormat.format(closedPeriodicEntryBook.getFinancialPeriod(). getBeginDate()); nextLine[3] = - sdf.format(closedPeriodicEntryBook.getFinancialPeriod(). + SDateFormat.format(closedPeriodicEntryBook.getFinancialPeriod(). getEndDate()); nextLine[4] = closedPeriodicEntryBook.getEntryBook().getCode(); // Ajoute la ligne au fichier Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -19,7 +19,6 @@ package org.chorem.lima.business.ejb; -import java.util.Collections; import java.util.List; import javax.ejb.Stateless; import org.apache.commons.logging.Log; @@ -29,7 +28,6 @@ import org.chorem.lima.business.FinancialPeriodServiceLocal; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.utils.FinancialPeriodComparator; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.ClosedPeriodicEntryBookDAO; import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; @@ -151,8 +149,12 @@ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper. getFinancialPeriodDAO(transaction); - result = financialPeriodDAO.findAllByLocked(false); - Collections.sort(result, new FinancialPeriodComparator()); + + TopiaQuery query = financialPeriodDAO.createQuery() + .addEquals(FinancialPeriod.LOCKED, Boolean.FALSE) + .addOrder(FinancialPeriod.BEGIN_DATE); + + result = financialPeriodDAO.findAllByQuery(query); } catch (TopiaException ex) { doCatch(transaction, ex, log); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -412,6 +412,8 @@ entryOld.setAccount(entry.getAccount()); entryOld.setAmount(entryAmount); entryOld.setDebit(entryAmountBool); + entryOld.setDescription(entry.getDescription()); + entryOld.setVoucher(entry.getVoucher()); entryOld.setFinancialTransaction(entry.getFinancialTransaction()); entryOld.setPosition(entry.getPosition()); entryOld.setLettering(entry.getLettering()); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -56,6 +56,7 @@ import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.utils.FiscalPeriodComparator; +import org.chorem.lima.business.utils.ImportExportEntityEnum; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.AccountImpl; @@ -122,7 +123,7 @@ EntryBookServiceLocal entryBookService; - private final SimpleDateFormat sdf = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss"); + private static final SimpleDateFormat SDateFormat = new SimpleDateFormat("dd,MM,yyyy HH:mm:ss"); public ImportServiceImpl() { @@ -187,28 +188,31 @@ while ((nextLine = csvReader.readNext()) != null) { - String indice = nextLine[0]; - if (indice.equals("ACCN")){ + ImportExportEntityEnum importExportEntityEnum = ImportExportEntityEnum.valueOfLabel(nextLine[0]); + + switch (importExportEntityEnum) { + case ACCOUNT: result += importAccountsChartsCSV(nextLine, accounts, topiaContext); - } - else if (indice.equals("ENBK")){ + break; + case ENTRYBOOK: result += importEntryBooksChartCSV(nextLine, topiaContext); - } - else if (indice.equals("FNST")){ + break; + case FINANCIALSTATEMENT: result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext); - } - else if (indice.equals("FSCP")){ + break; + case FISCALPERIOD: result += importFiscalPeriodCSV(nextLine, fiscalPeriods, topiaContext); - } - else if (indice.equals("CPEB")){ + break; + case CLOSEDPERIODICENTRYBOOK: importClosedPeriodicEntryBookCSV(nextLine, closedPeriodicEntryBooks, topiaContext); - } - else if (indice.equals("FTRC")){ + break; + case FINANCIALTRANSACTION: importFinancialTransactionsCSV(nextLine, financialTransactions, topiaContext); - } - else if (indice.equals("NTRY")){ + break; + case ENTRY: importEntriesCSV(nextLine, entries, topiaContext); - } + break; + } } //create accounts @@ -254,8 +258,7 @@ CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); while ((nextLine = csvReader.readNext()) != null) { - String indice = nextLine[0]; - if (indice.equals("ENBK")){ + if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.ENTRYBOOK){ result += importEntryBooksChartCSV(nextLine, topiaContext); } } @@ -292,8 +295,7 @@ CSVReader csvReader = new CSVReader(new StringReader(datas), ';'); while ((nextLine = csvReader.readNext()) != null) { - String indice = nextLine[0]; - if (indice.equals("FNST")){ + if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.FINANCIALSTATEMENT){ result += importFinancialsStatementChartCSV(nextLine, financialStatements, topiaContext); } } @@ -334,8 +336,7 @@ while ((nextLine = csvReader.readNext()) != null) { - String indice = nextLine[0]; - if (indice.equals("ACCN")){ + if (ImportExportEntityEnum.valueOfLabel(nextLine[0]) == ImportExportEntityEnum.ACCOUNT){ result += importAccountsChartsCSV(nextLine, accounts, topiaContext); } } @@ -410,9 +411,9 @@ LimaCallaoDAOHelper.getFiscalPeriodDAO(topiaContext); FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); - Date beginDate = sdf.parse(nextLine[1]); + Date beginDate = SDateFormat.parse(nextLine[1]); fiscalPeriod.setBeginDate(beginDate); - Date endDate = sdf.parse(nextLine[2]); + Date endDate = SDateFormat.parse(nextLine[2]); fiscalPeriod.setEndDate(endDate); fiscalPeriod.setLocked(new Boolean(nextLine[3])); @@ -742,9 +743,9 @@ for (ClosedPeriodicEntryBookImport closedPeriodicEntryBookImport : closedPeriodicEntryBooks) { //update closedPeriodicEntryBook Date beginDateFinancialPeriod = - sdf.parse(closedPeriodicEntryBookImport.getBeginDateFinancialPeriod()); + SDateFormat.parse(closedPeriodicEntryBookImport.getBeginDateFinancialPeriod()); Date endDateFinancialPeriod = - sdf.parse(closedPeriodicEntryBookImport.getEndDateFinancialPeriod()); + SDateFormat.parse(closedPeriodicEntryBookImport.getEndDateFinancialPeriod()); FinancialPeriod financialPeriod = financialPeriodDAO.findByNaturalId(beginDateFinancialPeriod, endDateFinancialPeriod); String codeEntryBook = closedPeriodicEntryBookImport.getCodeEntryBook(); @@ -784,7 +785,7 @@ for (int num : financialTransactions.keySet()) { FinancialTransactionImport financialTransactionImport = financialTransactions.get(num); FinancialTransaction financialTransaction = new FinancialTransactionImpl(); - Date dateFinancialTransaction = sdf.parse(financialTransactionImport.getDate()); + Date dateFinancialTransaction = SDateFormat.parse(financialTransactionImport.getDate()); financialTransaction.setTransactionDate(dateFinancialTransaction); financialTransaction.setAmountDebit(new Double(financialTransactionImport.getAmountDebit())); financialTransaction.setAmountCredit(new Double(financialTransactionImport.getAmountCredit())); Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -1,35 +0,0 @@ -/* *##% Lima Business - * 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.business.utils; - -import java.util.Comparator; -import org.chorem.lima.entity.FinancialPeriod; - -public class FinancialPeriodComparator implements Comparator<FinancialPeriod>{ - - /** - * sort by financial begin date - */ - @Override - public int compare(FinancialPeriod o1, FinancialPeriod o2) { - return o1.getBeginDate().compareTo(o2.getBeginDate()); - } - -} Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java (rev 0) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ImportExportEntityEnum.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -0,0 +1,29 @@ +package org.chorem.lima.business.utils; + +public enum ImportExportEntityEnum { + + ACCOUNT("ACCN"), ENTRYBOOK("ENBK"), FINANCIALSTATEMENT("FNST"), FISCALPERIOD("FSCP"), CLOSEDPERIODICENTRYBOOK("CPEB"), FINANCIALTRANSACTION("FTRC"), ENTRY("NTRY"); + private final String label; + + private ImportExportEntityEnum(String label) { + this.label = label; + } + + public String getLabel() { + return this.label; + } + + public static ImportExportEntityEnum valueOfLabel(String label){ + ImportExportEntityEnum value = null; + + for (ImportExportEntityEnum importExportEntityEnum : ImportExportEntityEnum.values()) { + if (label.equals(importExportEntityEnum.label)){ + value = importExportEntityEnum; + break; + } + } + return value; + } +} + + Added: trunk/lima-swing/src/main/filters/action-leave-fullscreen.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/filters/action-leave-fullscreen.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -19,18 +19,16 @@ package org.chorem.lima; import static org.nuiton.i18n.I18n._; - import java.beans.PropertyChangeListener; import java.util.Locale; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.actions.MiscAction; import org.nuiton.util.ApplicationConfig; import org.nuiton.util.ArgumentsParserException; -import org.nuiton.util.ConverterUtil; import org.nuiton.util.Version; import org.nuiton.util.VersionUtil; +import org.nuiton.util.converter.ConverterUtil; /** * La configuration de l'application. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -37,8 +37,8 @@ import org.chorem.lima.ui.MainViewHandler; import org.chorem.lima.util.ErrorHelper; import org.nuiton.i18n.I18n; -import org.nuiton.util.ConverterUtil; import org.nuiton.util.StringUtil; +import org.nuiton.util.converter.ConverterUtil; /** * Lima main. Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx 2010-07-12 10:37:10 UTC (rev 2966) @@ -1,50 +0,0 @@ -<!-- ##% 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. - ##% --> - -<JDialog modal="true"> - - <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> - <Boolean id="addState" javaBean='true'/> - - <script> - <![CDATA[ - protected void performCancel() { - getRadioButtons().setSelectedValue(null); - dispose(); - } - ]]> - </script> - - <Table> - <row> - <cell> - <JRadioButton text='lima.importexport.export' value='export' buttonGroup="{getRadioButtons()}" - selected='true'/> - </cell> - <cell> - <JRadioButton text='lima.importexport.import' value='import' buttonGroup="{getRadioButtons()}" - selected='true'/> - </cell> - <cell fill="none"> - <JButton text="lima.common.ok" onActionPerformed="dispose()"/> - </cell> - <cell fill="none"> - <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> - </cell> - </row> - </Table> -</JDialog> \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportHandler.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -1,63 +0,0 @@ -package org.chorem.lima.ui; - -import static org.nuiton.i18n.I18n._; -import javax.swing.JFileChooser; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.util.DialogHelper; -import org.chorem.lima.util.FileChooseView; -import org.chorem.lima.util.ImportExport; - -public class ImportExportHandler { - - /** log. */ - private static final Log log = LogFactory.getLog(ImportExportHandler.class); - - protected MainView view; - - ImportExportHandler(MainView mainView){ - this.view=mainView; - } - - public void importexportDialog(){ - - ImportExportForm importExportForm = new ImportExportForm(view); - importExportForm.setLocationRelativeTo(view); - importExportForm.setVisible(true); - - Object value = importExportForm.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - String mode = (String) value; - FileChooseView fileChooseView = new FileChooseView(view); - - JFileChooser chooser = fileChooseView.getChooser(); - ImportExport importExport = ImportExport.getInstance(); - - try { - if (mode.equals("import")){ - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - String message = importExport.importFromCsvFile(filePath, ""); - DialogHelper.showReportDialog(message, _("lima.importexport.import"), view); - } - } - else { - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - importExport.exportToCsvFile(filePath, ""); - } - } - } catch (LimaException eee) { - if (log.isErrorEnabled()){ - log.error("Can't "+ mode +" this file", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } - -} 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-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-07-12 10:37:10 UTC (rev 2966) @@ -23,6 +23,7 @@ <script><![CDATA[ import java.util.Locale; import org.chorem.lima.LimaConfig; +import org.chorem.lima.ui.importexport.ImportExportEnum; public LimaConfig getConfig() { return getContextValue(LimaConfig.class); @@ -77,20 +78,32 @@ </script> <JMenuBar> + <JMenu text="lima.menu.file"> - <JMenuItem text="lima.common.importexport" onActionPerformed='getHandler().showImportExportView(this)'/> - <!-- <JMenu text="lima.import" actionIcon='import-element'> - <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='getHandler().showExportView("all")'/> - <JMenuItem text="lima.export.all.csv" onActionPerformed='getHandler().showExportView("all_csv")'/> - <JMenuItem text="lima.export.account" onActionPerformed='getHandler().showExportView("account")'/> - </JMenu> --> + <JMenu text="lima.importexport.lima"> + <JMenu text="lima.importexport.import" actionIcon='import-element'> + <JMenuItem text="lima.importexport.all" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ALL_IMPORT)'/> + <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ACCOUNTCHARTS_IMPORT)'/> + <JMenuItem text="lima.importexport.entrybooks" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ENTRYBOOKS_IMPORT)'/> + <JMenuItem text="lima.importexport.financialstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_FINANCIALSTATEMENTS_IMPORT)'/> + </JMenu> + <JMenu text="lima.importexport.export" actionIcon='export-element'> + <JMenuItem text="lima.importexport.all" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ALL_EXPORT)'/> + <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ACCOUNTCHARTS_EXPORT)'/> + <JMenuItem text="lima.importexport.entrybooks" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_ENTRYBOOKS_EXPORT)'/> + <JMenuItem text="lima.importexport.financialstatements" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.LIMA_FINANCIALSTATEMENTS_EXPORT)'/> + </JMenu> + </JMenu> + <JMenu text="lima.importexport.ebp"> + <JMenu text="lima.importexport.import" actionIcon='import-element'> + <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT)'/> + <JMenuItem text="lima.importexport.entries" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ENTRIES_IMPORT)'/> + </JMenu> + <JMenu text="lima.importexport.export" actionIcon='export-element'> + <JMenuItem text="lima.importexport.accountcharts" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ACCOUNTCHARTS_EXPORT)'/> + <JMenuItem text="lima.importexport.entries" onActionPerformed='getHandler().showImportExportView(this, ImportExportEnum.EBP_ENTRIES_EXPORT)'/> + </JMenu> + </JMenu> <JSeparator/> <JMenuItem text="lima.common.print" actionIcon='print'/> <JSeparator/> @@ -118,19 +131,22 @@ <JMenu text="lima.structure"> <JMenuItem text="lima.charts.account" onActionPerformed='getHandler().showAccountView(this)' - actionIcon='account'/> + actionIcon='charts-accounts'/> <JMenuItem text="lima.charts.entrybook" onActionPerformed='getHandler().showEntryBookView(this)' - actionIcon='journal'/> - <JMenuItem text="lima.charts.fiscalyear" onActionPerformed='getHandler().showFiscalPeriodView(this)'/> - <JMenuItem text="lima.charts.financialperiod" onActionPerformed='getHandler().showFinancialPeriodView(this)'/> - <JMenuItem text="lima.charts.financialstatement" onActionPerformed='getHandler().showFinancialStatementView(this)'/> + actionIcon='charts-entrybooks'/> + <JMenuItem text="lima.charts.fiscalyear" onActionPerformed='getHandler().showFiscalPeriodView(this)' + actionIcon='charts-fiscalperiod'/> + <JMenuItem text="lima.charts.financialperiod" onActionPerformed='getHandler().showFinancialPeriodView(this)' + actionIcon='charts-financialperiod'/> + <JMenuItem text="lima.charts.financialstatement" onActionPerformed='getHandler().showFinancialStatementView(this)' + actionIcon='charts-financialstatements'/> </JMenu> <JMenu text="lima.entries"> <JMenuItem text="lima.entries.addtransaction" onActionPerformed='getHandler().showTransactionView(this)' - actionIcon='transaction'/> + actionIcon='entries-balanced'/> <JMenuItem text="lima.entries.searchunbalancedtransaction" onActionPerformed='getHandler().showTransactionUnbalancedView(this)' - actionIcon='search'/> + actionIcon='entries-unbalanced'/> <JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)' actionIcon='lettering'/> </JMenu> @@ -142,11 +158,16 @@ </JMenu> --> <JMenu text="lima.reports"> - <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)'/> - <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/> - <JMenuItem text="lima.reports.balance" onActionPerformed='getHandler().showBalanceView(this)'/> - <JMenuItem text="lima.reports.ledger" onActionPerformed='getHandler().showLedgerView(this)'/> - <JMenuItem text="lima.reports.financialstatement" onActionPerformed='getHandler().showFinancialStatementReportsView(this)' actionIcon='rapport'/> + <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)' + actionIcon='reports-account'/> + <JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)' + actionIcon='reports-entrybook'/> + <JMenuItem text="lima.reports.balance" onActionPerformed='getHandler().showBalanceView(this)' + actionIcon='reports-balance'/> + <JMenuItem text="lima.reports.ledger" onActionPerformed='getHandler().showLedgerView(this)' + actionIcon='reports-ledger'/> + <JMenuItem text="lima.reports.financialstatement" onActionPerformed='getHandler().showFinancialStatementReportsView(this)' + actionIcon='reports-financialstatement'/> </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-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -44,6 +44,8 @@ import org.chorem.lima.ui.financialtransaction.LetteringView; import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedView; import org.chorem.lima.ui.home.HomeView; +import org.chorem.lima.ui.importexport.ImportExport; +import org.chorem.lima.ui.importexport.ImportExportEnum; import org.chorem.lima.ui.ledger.LedgerView; import org.chorem.lima.util.ErrorHelper; @@ -383,10 +385,10 @@ mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView); } - public void showImportExportView(JAXXContext rootContext) { + public void showImportExportView(JAXXContext rootContext, ImportExportEnum type) { MainView mainView = getUI(rootContext); - ImportExportHandler importExportHandler = new ImportExportHandler(mainView); - importExportHandler.importexportDialog(); + ImportExport importExport = ImportExport.getInstance(mainView); + importExport.importExport(type); } public void showExportView(String type) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -19,7 +19,6 @@ package org.chorem.lima.ui.account; import static org.nuiton.i18n.I18n._; -import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; @@ -30,14 +29,14 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.ImportExportForm; import org.chorem.lima.ui.account.AccountForm; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.account.SubLedgerForm; +import org.chorem.lima.ui.importexport.ImportExport; +import org.chorem.lima.ui.importexport.ImportExportEnum; +import org.chorem.lima.ui.importexport.ImportExportForm; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; -import org.chorem.lima.util.FileChooseView; -import org.chorem.lima.util.ImportExport; import org.jdesktop.swingx.JXTreeTable; /** @@ -261,31 +260,19 @@ // if action confirmed if (value != null){ String mode = (String) value; - FileChooseView fileChooseView = new FileChooseView(view); + ImportExport importExport = ImportExport.getInstance(view); - JFileChooser chooser = fileChooseView.getChooser(); - ImportExport importExport = ImportExport.getInstance(); - try { if (mode.equals("import")){ - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - String message = importExport.importFromCsvFile(filePath, "importAccountsChart"); + importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_IMPORT); accountsTreeTableModel.refreshTree(); - DialogHelper.showReportDialog(message, _("lima.importexport.import"), view); - } } else { - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - importExport.exportToCsvFile(filePath, "exportAccountsChart"); - } + importExport.importExport(ImportExportEnum.LIMA_ACCOUNTCHARTS_EXPORT); } } catch (LimaException eee) { if (log.isErrorEnabled()){ - log.error("Can't "+ mode +" this file", eee); + log.error("Can't refresh tree", eee); } DialogHelper.showMessageDialog(eee.getMessage()); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -19,17 +19,16 @@ package org.chorem.lima.ui.entrybook; import static org.nuiton.i18n.I18n._; -import javax.swing.JFileChooser; import javax.swing.JOptionPane; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; -import org.chorem.lima.ui.ImportExportForm; +import org.chorem.lima.ui.importexport.ImportExport; +import org.chorem.lima.ui.importexport.ImportExportEnum; +import org.chorem.lima.ui.importexport.ImportExportForm; import org.chorem.lima.util.DialogHelper; -import org.chorem.lima.util.FileChooseView; -import org.chorem.lima.util.ImportExport; import org.jdesktop.swingx.JXTable; /** @@ -153,35 +152,16 @@ Object value = importExportForm.getRadioButtons().getSelectedValue(); // if action confirmed if (value != null){ - String mode = (String) value; - FileChooseView fileChooseView = new FileChooseView(view); + String mode = (String) value; + ImportExport importExport = ImportExport.getInstance(view); - JFileChooser chooser = fileChooseView.getChooser(); - ImportExport importExport = ImportExport.getInstance(); - - try { - if (mode.equals("import")){ - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - String message = importExport.importFromCsvFile(filePath, "importEntryBookChart"); - entryBookTableModel.refreshTable(); - DialogHelper.showReportDialog(message, _("lima.importexport.import"), view); - } - } - else { - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - importExport.exportToCsvFile(filePath, "exportEntryBookChart"); - } - } - } catch (LimaException eee) { - if (log.isErrorEnabled()){ - log.error("Can't "+ mode +" this file", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } - } + if (mode.equals("import")){ + importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_IMPORT); + entryBookTableModel.refreshTable(); + } + else { + importExport.importExport(ImportExportEnum.LIMA_ENTRYBOOKS_EXPORT); + } + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -28,13 +28,14 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FinancialStatement; import org.chorem.lima.entity.FinancialStatementImpl; -import org.chorem.lima.ui.ImportExportForm; import org.chorem.lima.ui.financialstatementchart.FinancialStatementHeaderForm; import org.chorem.lima.ui.financialstatementchart.FinancialStatementMovementForm; +import org.chorem.lima.ui.importexport.ImportExport; +import org.chorem.lima.ui.importexport.ImportExportEnum; +import org.chorem.lima.ui.importexport.ImportExportForm; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import org.chorem.lima.util.FileChooseView; -import org.chorem.lima.util.ImportExport; import org.jdesktop.swingx.JXTreeTable; /** @@ -249,11 +250,7 @@ } public void importexportFinancialStatement(){ - - JXTreeTable treeTable = view.getTreeTable(); - FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); - + ImportExportForm importExportForm = new ImportExportForm(view); importExportForm.setLocationRelativeTo(view); importExportForm.setVisible(true); @@ -262,34 +259,13 @@ // if action confirmed if (value != null){ String mode = (String) value; - FileChooseView fileChooseView = new FileChooseView(view); - - JFileChooser chooser = fileChooseView.getChooser(); - ImportExport importExport = ImportExport.getInstance(); - - try { - if (mode.equals("import")){ - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - String message = importExport.importFromCsvFile(filePath, "importFinancialStatementsChart"); - treeTableModel.refreshTree(); - DialogHelper.showReportDialog(message, _("lima.importexport.import"), view); - } - } - else { - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - if (chooser.showOpenDialog(view) == JFileChooser.APPROVE_OPTION) { - String filePath = chooser.getSelectedFile().getAbsolutePath(); - importExport.exportToCsvFile(filePath, "exportFinancialStatementsChart"); - } - } - } catch (LimaException eee) { - if (log.isErrorEnabled()){ - log.error("Can't "+ mode +" this file", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } + ImportExport importExport = ImportExport.getInstance(view); + if (mode.equals("import")){ + importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_IMPORT); + } + else { + importExport.importExport(ImportExportEnum.LIMA_FINANCIALSTATEMENTS_EXPORT); + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2010-07-12 10:37:10 UTC (rev 2966) @@ -1,68 +1,104 @@ <Table> <HomeViewHandler id="handler" javaBean='new HomeViewHandler(this)' /> - <Dimension id="fixedSize" javaBean='new Dimension(600,150)' /> + <Dimension id="fixedSize" javaBean='new Dimension(500,200)' /> + <Dimension id="miniSize" javaBean='new Dimension(300,150)' /> + <Color id="green" javaBean='new Color(0xee, 0xff, 0xee)'/> + + <script> <![CDATA[ import static org.nuiton.i18n.I18n._; + import java.awt.Color; + import java.awt.Font; void $afterCompleteSetup() { getHandler().refresh(); } ]]> </script> - <row weightx="1" weighty="1" anchor="west"> - <cell> - <JLabel font='{new Font("Arial", 0, 16)}' text="LIMA"/> - </cell> - </row> - <row weightx="1" weighty="1"> - <cell> + <row> + <cell anchor="southeast"> <JPanel id="limaHomeChartAccount" - border='{BorderFactory.createTitledBorder(_("lima.charts.account"))}' - minimumSize='{getFixedSize()}' + border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}' + minimumSize='{getMiniSize()}' preferredSize='{getFixedSize()}' layout='{new BoxLayout(limaHomeChartAccount,BoxLayout.X_AXIS)}'> - <JEditorPane id="textHomeAccount"/> + <Table> + <row> + <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/accounts.png"))}'/></cell> + <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.charts.account'/></cell> + </row> + <row fill="both"> + <cell columns="2" weightx="1" weighty="0.9"> + <JEditorPane id="textHomeAccount" + opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/> + </cell> + </row> + </Table> </JPanel> </cell> - </row> - <row> - <cell> + <cell anchor="southwest"> <JPanel id="limaHomeEntryBook" - border='{BorderFactory.createTitledBorder(_("lima.charts.entrybook"))}' - minimumSize='{getFixedSize()}' + border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}' + minimumSize='{getMiniSize()}' preferredSize='{getFixedSize()}' layout='{new BoxLayout(limaHomeEntryBook,BoxLayout.X_AXIS)}'> - <JEditorPane id="textHomeEntryBook"/> + <Table> + <row> + <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/entrybooks.png"))}'/></cell> + <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.charts.entrybook'/></cell> + </row> + <row fill="both"> + <cell columns="2" weightx="1" weighty="0.9"> + <JEditorPane id="textHomeEntryBook" + opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/> + </cell> + </row> + </Table> </JPanel> </cell> </row> <row> - <cell> + <cell anchor="northeast"> <JPanel id="limaHomeFiscalYear" - border='{BorderFactory.createTitledBorder(_("lima.charts.fiscalyear"))}' - minimumSize='{getFixedSize()}' + border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}' + minimumSize='{getMiniSize()}' preferredSize='{getFixedSize()}' layout='{new BoxLayout(limaHomeFiscalYear,BoxLayout.X_AXIS)}'> - <JEditorPane id="textHomeFiscalYear"/> + <Table> + <row> + <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/fiscalperiods.png"))}'/></cell> + <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.charts.fiscalyear'/></cell> + </row> + <row fill="both"> + <cell columns="2" weightx="1" weighty="0.9"> + <JEditorPane id="textHomeFiscalYear" + opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/> + </cell> + </row> + </Table> </JPanel> </cell> - </row> - <row> - <cell> + <cell anchor="northwest"> <JPanel id="limaHomeDaily" - border='{BorderFactory.createTitledBorder(_("lima.daily"))}' - minimumSize='{getFixedSize()}' + border='{BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)}' + minimumSize='{getMiniSize()}' preferredSize='{getFixedSize()}' layout='{new BoxLayout(limaHomeDaily,BoxLayout.X_AXIS)}'> - <JEditorPane id="textHomeDaily"/> + <Table> + <row> + <cell weightx="0" weighty="0.1" anchor="northwest"><JLabel icon='{new ImageIcon(getClass().getResource("/images/entries.png"))}'/></cell> + <cell weightx="1" weighty="0.1" anchor="center"><JLabel foreground='{Color.DARK_GRAY}' font='{new Font("sans-serif", Font.BOLD, 16)}' text='lima.daily'/></cell> + </row> + <row fill="both"> + <cell columns="2" weightx="1" weighty="0.9"> + <JEditorPane id="textHomeDaily" + opaque="true" contentType="text/html" editable="false" UI="{new javax.swing.plaf.basic.BasicEditorPaneUI()}" background="{getGreen()}"/> + </cell> + </row> + </Table> </JPanel> </cell> </row> - <row weightx="1" weighty="1" anchor="west"> - <cell> - <JLabel icon='{new ImageIcon(getClass().getResource("/images/logo-codelutin.png"))}'/> - </cell> - </row> </Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -2,10 +2,17 @@ import static org.nuiton.i18n.I18n._; import java.awt.Color; +import java.awt.Font; import java.util.List; +import javax.swing.BorderFactory; import javax.swing.JEditorPane; +import javax.swing.JPanel; +import javax.swing.border.Border; +import javax.swing.border.EtchedBorder; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; +import javax.swing.plaf.basic.BasicEditorPaneUI; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; @@ -21,6 +28,8 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; +import com.sun.codemodel.internal.JLabel; + public class HomeViewHandler implements HyperlinkListener { private static final Log log = LogFactory.getLog(HomeViewHandler.class); @@ -38,10 +47,8 @@ protected HyperlinkListener accountsListener; protected HyperlinkListener entrybookListener; - - private Color greenBackground; - private Color redBackground; + private static Color redBackground = new Color(0xff, 0xee, 0xee); protected HomeViewHandler(HomeView view) { @@ -57,11 +64,7 @@ LimaServiceFactory.getInstance().getTransactionService(); fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService(); - - greenBackground = new Color(153, 255, 153); - redBackground = new Color(255, 102, 102); - } @@ -98,52 +101,76 @@ public void refresh(){ - + //Get all editorpanes + JEditorPane accountPane = view.getTextHomeAccount(); + JEditorPane entryBookPane = view.getTextHomeEntryBook(); + JEditorPane fiscalYearPane = view.getTextHomeFiscalYear(); + JEditorPane dailyPane = view.getTextHomeDaily(); + + //add hyperlink listener + accountPane.addHyperlinkListener(this); + entryBookPane.addHyperlinkListener(this); + fiscalYearPane.addHyperlinkListener(this); + dailyPane.addHyperlinkListener(this); + String htmlBegin = "<font face='sans-serif' size=3><p style=vertical-align:'bottom', horizontal-align:'center'>"; + String htmlEnd = "</p></font>"; + try { - //ACCOUNT + + //ACCOUNTS CHART List<Account> accounts = accountService.getAllAccounts(); - JEditorPane accountPane = view.getTextHomeAccount(); - accountPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - accountPane.setOpaque(true); - accountPane.setContentType("text/html"); - accountPane.setEditable(false); - accountPane.addHyperlinkListener(this); if (accounts.size()>0){ - String accountsString = _("limahome.chartaccounts1") + " " + - accounts.size() + " " + _("limahome.chartaccounts2"); - accountPane.setBackground(greenBackground); - accountPane.setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#accountschart'>"+accountsString+"</a></p>"); + String accountsString = _("limahome.chartaccounts.state1_2") + " " + + accounts.size() + " " + _("limahome.chartaccounts.state2_2") + + "<br/><br/><a href='#accountschart'>" + + _("limahome.chartaccounts.modify") + "</a>"; + //set Text + accountPane.setText(htmlBegin + accountsString + htmlEnd); } else { accountPane.setBackground(redBackground); - String accountsString = "<p style=vertical-align:'bottom', horizontal-align:'center'>"+_("limahome.fiscalperiodnoopen") + - "<br/><a href='#accountschart'>"+_("limahome.createchartaccounts")+"</a>"; - accountPane.setText(accountsString+"</p>"); + String accountsString = _("limahome.chartaccounts.nothing") + + "<br/><br/><a href='#accountschart'>" + + _("limahome.chartaccounts.create") + "</a>"; + //set Text + accountPane.setText(htmlBegin + accountsString + htmlEnd); } - //ENTRYBOOK + + //ENTRYBOOKS List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); - JEditorPane entryBookPane = view.getTextHomeEntryBook(); - entryBookPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - entryBookPane.setOpaque(true); - entryBookPane.setContentType("text/html"); - entryBookPane.setEditable(false); - entryBookPane.addHyperlinkListener(this); - - if (entryBooks.size()>0){ - entryBookPane.setBackground(greenBackground); - String entryBooksString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#entrybookschart'>"+_("limahome.entrybooks1") + - " " + entryBooks.size() + " " + _("limahome.entrybooks2") + - "</a><br/><ul>"; - for (EntryBook entryBook : entryBooks) { - entryBooksString += "<li>"+entryBook.getCode() + - " - "+entryBook.getLabel()+"</li>"; + int ebSize = entryBooks.size(); + if (ebSize>0){ + String entryBooksString=""; + if (ebSize == 1){ + entryBooksString = _("limahome.entrybooks.state.single") + + "<br/>" + entryBooks.get(0) + + "<br/><br/><a href='#entrybookschart'>" + + _("limahome.entrybooks.modify") + "</a>"; + } - entryBookPane.setText(entryBooksString+"</ul>"+"</p>"); + else { + entryBooksString = _("limahome.entrybooks.state1_2.plural") + + " " + entryBooks.size() + " " + + _("limahome.entrybooks.state2_2.plural") + "<ul>"; + for (EntryBook entryBook : entryBooks) { + entryBooksString += "<li>"+entryBook.getCode() + + " - "+entryBook.getLabel()+"</li>"; + } + entryBooksString += "</ul></p><p horizontal-align:'center'>" + + "<a href='#entrybookschart'>" + + _("limahome.entrybooks.modify") + "</a>"; + } + //set Text + entryBookPane.setText(htmlBegin + entryBooksString + htmlEnd); } else { entryBookPane.setBackground(redBackground); - entryBookPane.setText("<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#entrybookschart'>"+_("limahome.entrybooknoopen")+"</a></p>"); + //set Text + entryBookPane.setText(htmlBegin + + _("limahome.entrybooks.nothing") + + "<br/><br/><a href='#entrybookschart'>" + + _("limahome.entrybooks.create") +"</a>" + htmlEnd); } //FISCAL PERIOD @@ -151,58 +178,49 @@ fiscalPeriodService.getAllFiscalPeriods(); List<FiscalPeriod> unblockedFiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); - - JEditorPane fiscalYearPane = view.getTextHomeFiscalYear(); - fiscalYearPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - fiscalYearPane.setOpaque(true); - fiscalYearPane.setContentType("text/html"); - fiscalYearPane.setEditable(false); - fiscalYearPane.addHyperlinkListener(this); - - JEditorPane dailyPane = view.getTextHomeDaily(); - dailyPane.setUI(new javax.swing.plaf.basic.BasicEditorPaneUI()); - dailyPane.setOpaque(true); - dailyPane.setContentType("text/html"); - dailyPane.setEditable(false); - dailyPane.addHyperlinkListener(this); - if (unblockedFiscalPeriods.size()>0){ - fiscalYearPane.setBackground(greenBackground); - String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#fiscalperiodschart'>" - + unblockedFiscalPeriods.size() + - " " + _("limahome.fiscalperiodopened")+"<br/>" + - (fiscalPeriods.size()-unblockedFiscalPeriods.size()) + - " " + _("limahome.fiscalperiodclosed"); - fiscalYearPane.setText(fiscalString+"</a></p>"); + String fiscalString = unblockedFiscalPeriods.size() + " " + + _("limahome.fiscalperiod.opened") + "<br/>" + + (fiscalPeriods.size()-unblockedFiscalPeriods.size()) + + " " + _("limahome.fiscalperiod.closed") + + "<br/><br/><a href='#fiscalperiodschart'>" + + _("limahome.fiscalperiod.modify") + "</a>"; + //set Text + fiscalYearPane.setText(htmlBegin + fiscalString + htmlEnd); - //FINACIAL TRANSACTION + //FINANCIAL TRANSACTION List<FinancialTransaction> financialTransactions = financialTransactionService. getAllFinancialTransactionsUnbalanced(fiscalPeriods.get(0)); if (financialTransactions.size()>0){ dailyPane.setBackground(redBackground); - String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#financialtransactionunbalanced'>" - + financialTransactions.size() + - _("limahome.transactionunbalanced")+"</a></p>"; - dailyPane.setText(transactionsString); + String transactionsString = financialTransactions.size() + + " " + _("limahome.transaction.unbalanced") + + "<br/><br/><a href='#financialtransactionunbalanced'>" + + _("limahome.transaction.modifiy") + "</a>"; + //set Text + dailyPane.setText(htmlBegin + transactionsString + htmlEnd); } else { - dailyPane.setBackground(greenBackground); - String transactionsString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#financialtransactionbalanced'>" - + _("limahome.transactionbalanced"); - dailyPane.setText(transactionsString+"</a></p>"); + String transactionsString = _("limahome.transaction.balanced") + + "<br/><br/><a href='#financialtransactionbalanced'>" + + _("limahome.transaction.create") + "</a>"; + //set Text + dailyPane.setText(htmlBegin + transactionsString + htmlEnd); } - } else { fiscalYearPane.setBackground(redBackground); dailyPane.setBackground(redBackground); - String fiscalString = "<p style=vertical-align:'bottom', horizontal-align:'center'><a href='#fiscalperiodschart'>" + _("limahome.fiscalperiodnoopen"); + String fiscalString = _("limahome.fiscalperiod.noopen"); if (fiscalPeriods.size()>0){ - fiscalString += fiscalPeriods.size() + - _("limahome.fiscalperiodclosed"); + fiscalString += "<br/>" + fiscalPeriods.size() + " " + + _("limahome.fiscalperiod.closed"); } - fiscalYearPane.setText(fiscalString+"</a></p>"); + fiscalString += "<br/><br/><a href='#fiscalperiodschart'>" + + _("limahome.fiscalperiod.create") + "</a>"; + //set Text + fiscalYearPane.setText(htmlBegin + fiscalString + htmlEnd); } } catch (LimaException eee) { Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java (from rev 2964, trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -0,0 +1,223 @@ +/* *##% 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.importexport; + +import static org.nuiton.i18n.I18n._; +import java.awt.Component; +import java.io.BufferedInputStream; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import javax.swing.JFileChooser; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.ExportService; +import org.chorem.lima.business.ImportService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.account.AccountViewHandler; +import org.chorem.lima.util.DialogHelper; +import org.chorem.lima.util.FileChooseView; + +public class ImportExport { + + private static ImportExport exchanger; + + private static final Log log = LogFactory.getLog(AccountViewHandler.class); + + protected static Component viewComponent; + + protected ImportService importService; + + protected ExportService exportService; + + public ImportExport(Component view) { + viewComponent=view; + importService = LimaServiceFactory.getInstance().getImportService(); + exportService = LimaServiceFactory.getInstance().getExportService(); + } + + + public void importExport(ImportExportEnum importExportMethode){ + String result = ""; + String datas = ""; + String filePath = ""; + String charset = "UTF-8"; + try { + switch (importExportMethode) { + case LIMA_ALL_EXPORT: + filePath = chooseFile(false); + datas = exportService.exportAsCSV(); + createFile(filePath, charset, datas); + break; + case LIMA_ACCOUNTCHARTS_EXPORT: + filePath = chooseFile(false); + datas = exportService.exportAccountsChartAsCSV(); + createFile(filePath, charset, datas); + break; + case LIMA_ENTRYBOOKS_EXPORT: + filePath = chooseFile(false); + datas = exportService.exportEntryBookChartAsCSV(); + createFile(filePath, charset, datas); + break; + case LIMA_FINANCIALSTATEMENTS_EXPORT: + filePath = chooseFile(false); + datas = exportService.exportFinancialStatementChartAsCSV(); + createFile(filePath, charset, datas); + break; + case EBP_ACCOUNTCHARTS_EXPORT: + //For windows ebp + filePath = chooseFile(false); + charset = "ISO-8859-1"; + datas = exportService.exportAccountsAsEBP(); + createFile(filePath, charset, datas); + break; + case EBP_ENTRIES_EXPORT: + //For windows ebp + charset = "ISO-8859-1"; + filePath = chooseFile(false); + datas = exportService.exportEntriesAsEBP(); + createFile(filePath, charset, datas); + break; + case LIMA_ALL_IMPORT: + filePath = chooseFile(true); + datas = extractFile(filePath); + result = importService.importCSV(datas); + break; + case LIMA_ACCOUNTCHARTS_IMPORT: + filePath = chooseFile(true); + datas = extractFile(filePath); + result = importService.importAccountsChartAsCSV(datas); + break; + case LIMA_ENTRYBOOKS_IMPORT: + filePath = chooseFile(true); + datas = extractFile(filePath); + result = importService.importEntryBooksChartAsCSV(datas); + break; + case LIMA_FINANCIALSTATEMENTS_IMPORT: + filePath = chooseFile(true); + datas = extractFile(filePath); + result = importService.importFinancialStatementsChartAsCSV(datas); + break; + case EBP_ACCOUNTCHARTS_IMPORT: + filePath = chooseFile(true); + datas = extractFile(filePath); + break; + case EBP_ENTRIES_IMPORT: + filePath = chooseFile(true); + datas = extractFile(filePath); + break; + } + if (!result.equals("")){ + DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent); + } + else { + DialogHelper.showMessageDialog(_("lima.importexport.import.terminated")); + } + } + catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't call export import service ", eee); + } + } + + + } + + + + public String chooseFile(Boolean importMode){ + String filePath = ""; + FileChooseView fileChooseView = new FileChooseView(); + JFileChooser chooser = fileChooseView.getChooser(); + + if (importMode){ + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) { + filePath = chooser.getSelectedFile().getAbsolutePath(); + } + } + else { + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) { + filePath = chooser.getSelectedFile().getAbsolutePath(); + } + } + return filePath; + } + + + + /** + * Get csv datas in string and write file + * + */ + public void createFile(String filePath, String charset, String datas){ + try { + File file = new File(filePath); + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); + out.write(datas); + out.flush(); + out.close(); + } + catch (IOException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't write file " + filePath, eee); + } + } + } + + + + /** + * Open csv file and get his datas on a string + * + */ + public String extractFile(String path){ + byte[] buffer = new byte[(int) new File(path).length()]; + try { + BufferedInputStream f = new BufferedInputStream(new FileInputStream(path)); + f.read(buffer); + f.close(); + } + catch (IOException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't read file "+path, eee); + } + } + return new String(buffer); + } + + + + public static ImportExport getInstance(Component view) { + if (exchanger == null) { + exchanger = new ImportExport(view); + } + else { + viewComponent=view; + } + return exchanger; + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportEnum.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -0,0 +1,9 @@ +package org.chorem.lima.ui.importexport; + +public enum ImportExportEnum { + LIMA_ALL_EXPORT, LIMA_ALL_IMPORT, + LIMA_ACCOUNTCHARTS_EXPORT, LIMA_ENTRYBOOKS_EXPORT, LIMA_FINANCIALSTATEMENTS_EXPORT, + LIMA_ACCOUNTCHARTS_IMPORT, LIMA_ENTRYBOOKS_IMPORT, LIMA_FINANCIALSTATEMENTS_IMPORT, + EBP_ACCOUNTCHARTS_EXPORT, EBP_ENTRIES_EXPORT, + EBP_ACCOUNTCHARTS_IMPORT, EBP_ENTRIES_IMPORT; +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx (from rev 2959, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportExportForm.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportForm.jaxx 2010-07-12 10:37:10 UTC (rev 2966) @@ -0,0 +1,50 @@ +<!-- ##% 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. + ##% --> + +<JDialog modal="true"> + + <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> + <Boolean id="addState" javaBean='true'/> + + <script> + <![CDATA[ + protected void performCancel() { + getRadioButtons().setSelectedValue(null); + dispose(); + } + ]]> + </script> + + <Table> + <row> + <cell> + <JRadioButton text='lima.importexport.export' value='export' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + <cell> + <JRadioButton text='lima.importexport.import' value='import' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + <cell fill="none"> + <JButton text="lima.common.ok" onActionPerformed="dispose()"/> + </cell> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ImportExport.java 2010-07-12 10:37:10 UTC (rev 2966) @@ -1,134 +0,0 @@ -/* *##% 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.util; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.ExportService; -import org.chorem.lima.business.ImportService; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.account.AccountViewHandler; - -public class ImportExport { - - private static ImportExport exchanger; - - private static final Log log = LogFactory.getLog(AccountViewHandler.class); - - protected ImportService importService; - - protected ExportService exportService; - - public ImportExport() { - importService = LimaServiceFactory.getInstance().getImportService(); - exportService = LimaServiceFactory.getInstance().getExportService(); - } - - /** - * Call export methode in business - * Get csv datas in string and write file - * @param path - * @param exportMethode - * @throws LimaException - */ - public void exportToCsvFile(String path, String exportMethode) throws LimaException { - String result = ""; - try { - FileWriter f = new FileWriter(new File(path)); - if (exportMethode.equals("exportEntryBookChart")){ - result = exportService.exportEntryBookChartAsCSV(); - } - else if (exportMethode.equals("exportAccountsChart")){ - result = exportService.exportAccountsChartAsCSV(); - - } - else if (exportMethode.equals("exportFinancialStatementsChart")){ - result = exportService.exportFinancialStatementChartAsCSV(); - } - else { - result = exportService.exportAsCSV(); - } - f.write(result); - f.flush(); - f.close(); - } - catch (IOException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't write file "+path, eee); - } - } - } - - - /** - * Open scv file and get his datas on a string - * Call import methode in business - * - * @param path - * @param importMethode - * @return - * @throws LimaException - */ - public String importFromCsvFile(String path, String importMethode) throws LimaException { - String result = ""; - byte[] buffer = new byte[(int) new File(path).length()]; - try { - BufferedInputStream f = new BufferedInputStream(new FileInputStream(path)); - f.read(buffer); - - if (importMethode.equals("importEntryBookChart")){ - result = importService.importEntryBooksChartAsCSV(new String(buffer)); - } - else if (importMethode.equals("importAccountsChart")){ - result = importService.importAccountsChartAsCSV(new String(buffer)); - } - else if (importMethode.equals("importFinancialStatementsChart")){ - result = importService.importFinancialStatementsChartAsCSV(new String(buffer)); - } - else { - result = importService.importCSV(new String(buffer)); - } - f.close(); - } - catch (IOException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't read file "+path, eee); - } - } - - return result; - } - - public static ImportExport getInstance() { - if (exchanger == null) { - exchanger = new ImportExport(); - } - return exchanger; - } - -} 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-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-07-12 10:37:10 UTC (rev 2966) @@ -94,8 +94,16 @@ lima.import.all.csv=Import all datas (CSV) lima.import.all.csv.ebp=Import all datas (EBP) lima.import.journal=Import journal +lima.importexport.accountcharts= +lima.importexport.all= +lima.importexport.ebp= +lima.importexport.entries= +lima.importexport.entrybooks= lima.importexport.export=Export +lima.importexport.financialstatements= lima.importexport.import=Import +lima.importexport.import.terminated= +lima.importexport.lima= lima.init.closed=Lima closed at %1$s lima.init.errorclosing= lima.lettering.add= 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-07-07 10:58:46 UTC (rev 2965) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-07-12 10:37:10 UTC (rev 2966) @@ -94,8 +94,16 @@ lima.import.all.csv=Importer une nouvelle base (CSV) lima.import.all.csv.ebp=Importer des donn\u00E9es de EBP lima.import.journal=Importer le journal +lima.importexport.accountcharts=Plan des comptes +lima.importexport.all=Tout +lima.importexport.ebp=Import/Export EBP +lima.importexport.entries=\u00C9critures +lima.importexport.entrybooks=Journaux lima.importexport.export=Export +lima.importexport.financialstatements=Plan BCR lima.importexport.import=Import +lima.importexport.import.terminated=Import +lima.importexport.lima=Import/Export Lima lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s lima.init.errorclosing= lima.lettering.add=Ajouter une lettre @@ -176,16 +184,24 @@ lima.transaction.period=P\u00E9riode lima.voucher=Document lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9 -limahome.accountsnoopen=Aucun compte \! -limahome.chartaccounts1=Le plan comptable possede -limahome.chartaccounts2=comptes -limahome.createchartaccounts=Cr\u00E9er le plan comptable -limahome.entrybooknoopen=Aucun journal ouvert \! -limahome.entrybooks1=Les -limahome.entrybooks2=journaux sont \: -limahome.fiscalperiodclosed=exercices clotur\u00E9s -limahome.fiscalperiodnoopen=Aucun exercice ouvert \! -limahome.fiscalperiodopened=exercices ouverts -limahome.transactionbalanced=Toutes les entr\u00E9es sont \u00E9quilibr\u00E9es -limahome.transactionunbalanced=ne sont pas \u00E9quilibr\u00E9e \! +limahome.chartaccounts.nothing=Aucun compte \! +limahome.chartaccounts.state1_2=Le plan comptable possede +limahome.chartaccounts.state2_2=comptes +limahome.chartaccounts.create=Cr\u00E9er le plan des comptes +limahome.chartaccounts.modify=Modifier le plan des comptes +limahome.entrybooks.nothing=Aucun journal ouvert \! +limahome.entrybooks.modify=Modifier les journaux +limahome.entrybooks.create=Cr\u00E9er les journaux +limahome.entrybooks.state1_2.plural=Les +limahome.entrybooks.state2_2.plural=journaux sont \: +limahome.entrybooks.state.single=Le journal est \: +limahome.fiscalperiod.closed=exercices clotur\u00E9s +limahome.fiscalperiod.opened=exercices ouverts +limahome.fiscalperiod.noopen=Aucun exercice ouvert \! +limahome.fiscalperiod.create=Cr\u00E9er un exercice +limahome.fiscalperiod.modify=Modifier les exercices +limahome.transaction.balanced=Toutes les \u00E9critures sont \u00E9quilibr\u00E9es +limahome.transaction.unbalanced=\u00E9critures ne sont pas \u00E9quilibr\u00E9es \! +limahome.transaction.modifiy=Modifier les \u00E9critures non \u00E9quilibr\u00E9es +limahome.transaction.create=Modifier les \u00E9critures update= Modified: trunk/lima-swing/src/main/resources/icons/action-about.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/icons/action-account.png =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/resources/icons/action-charts-accounts.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-accounts.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-charts-entrybooks.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-entrybooks.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-charts-financialperiod.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-financialperiod.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-charts-financialstatements.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-financialstatements.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-charts-fiscalperiod.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-charts-fiscalperiod.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/lima-swing/src/main/resources/icons/action-closeTab.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/icons/action-closure-timespan.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/icons/action-closure.png =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/resources/icons/action-entries-balanced.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-entries-balanced.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-entries-search.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-entries-search.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-entries-unbalanced.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-entries-unbalanced.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/lima-swing/src/main/resources/icons/action-journal.png =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/resources/icons/action-lettering.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/icons/action-rapport.png =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/resources/icons/action-reports-account.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-account.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-reports-balance.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-balance.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-reports-entrybook.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-entrybook.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-reports-financialstatement.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-financialstatement.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-reports-ledger.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-reports-ledger.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: trunk/lima-swing/src/main/resources/icons/action-search.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/icons/action-transaction.png =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/resources/icons/action-translate.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/icons/action-view.png =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/resources/images/accounts.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/images/accounts.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/images/entries.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/images/entries.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/images/entrybooks.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/images/entrybooks.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/images/fiscalperiods.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/images/fiscalperiods.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-07-07 10:58:46 UTC (rev 2965) +++ trunk/pom.xml 2010-07-12 10:37:10 UTC (rev 2966) @@ -254,7 +254,7 @@ <eugene.version>2.1-SNAPSHOT</eugene.version> <topia.version>2.3.5-SNAPSHOT</topia.version> <jaxx.version>2.0.2</jaxx.version> - <i18n.version>1.2.3-SNAPSHOT</i18n.version> + <i18n.version>1.2.2</i18n.version> <!--axis.version>1.4.1</axis.version--> <!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
participants (1)
-
jpepin@users.chorem.org