Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 1853 discussions
Author: echatellier
Date: 2010-04-09 10:56:49 +0200 (Fri, 09 Apr 2010)
New Revision: 2838
Log:
Add documentation
Modified:
trunk/lima-callao/src/main/xmi/accounting.zargo
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
1
0
r2837 - in trunk/lima-business/src/main/java/org/chorem/lima/business: . ejb
by echatellier@users.chorem.org 08 Apr '10
by echatellier@users.chorem.org 08 Apr '10
08 Apr '10
Author: echatellier
Date: 2010-04-08 15:26:27 +0200 (Thu, 08 Apr 2010)
New Revision: 2837
Log:
Add transaction service methods
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-08 12:29:15 UTC (rev 2836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-08 13:26:27 UTC (rev 2837)
@@ -21,6 +21,8 @@
import java.util.List;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.Transaction;
/**
@@ -34,11 +36,36 @@
*/
public interface TransactionService {
- //List<Transaction> getAllTransactions() throws LimaException;
+ /**
+ * Find all transaction (use carefully, can return a lot of results).
+ *
+ * @return all transaction
+ * @throws LimaException
+ */
+ List<Transaction> getAllTransactions() throws LimaException;
- //void createTransaction(Transaction transaction) throws LimaException;
+ /**
+ * Find all transaction for an entry book.
+ *
+ * @param entryBook entry book
+ * @return all transaction for entry book
+ * @throws LimaException
+ */
+ List<Transaction> getAllTransactionsForEntryBook(EntryBook entryBook) throws LimaException;
+
+ /**
+ * Find all transaction for an entry book and a financial period.
+ *
+ * @param entryBook entry book
+ * @param period financial period
+ * @return all transaction for entry book and period
+ * @throws LimaException
+ */
+ List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException;
+
+ void createTransaction(Transaction transaction) throws LimaException;
- //void updateTransaction(Transaction transaction) throws LimaException;
+ void updateTransaction(Transaction transaction) throws LimaException;
- //void removeTransaction(Transaction transaction) throws LimaException;
+ void removeTransaction(Transaction transaction) throws LimaException;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-08 12:29:15 UTC (rev 2836)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-08 13:26:27 UTC (rev 2837)
@@ -19,13 +19,17 @@
package org.chorem.lima.business.ejb;
+import java.util.List;
+
import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.TransactionService;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.Transaction;
import org.chorem.lima.entity.TransactionDAO;
@@ -45,7 +49,7 @@
* @author Rémi Chapelet
*/
@Stateless
-public class TransactionServiceImpl implements TransactionService {
+public class TransactionServiceImpl extends AbstractLimaService implements TransactionService {
private static final Log log = LogFactory.getLog(TransactionServiceImpl.class);
@@ -78,6 +82,7 @@
* @param journal
* @return
*/
+ @Override
public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef,
String description, TimeSpan timeSpan, Journal journal*/) {
/*String result = ServiceHelper.RESPOND_ERROR;
@@ -227,153 +232,77 @@
return result;
}*/
- /*
- * Permet de modifier une transaction à partir d'une transaction DTO.
- * Elle va rechercher le journal et le timespan correspondants.
- * @param transactionDTO
- * @return
- *
- public String modifyTransaction(TransactionDTO transactionDTO) {
- // Recherche du journal
- JournalServiceImpl journalServiceImpl = new JournalServiceImpl();
- Journal journal = journalServiceImpl
- .searchJournalWithLabel(transactionDTO.getJournalDTO()
- .getLabel());
- // Recherche du timeSpan
- TimeSpan timeSpan = timeSpanServiceImpl
- .searchTimeSpanByDate(transactionDTO.getTimeSpanDTO()
- .getBeginTimeSpan());
- // Appel pour la modification
- String result = modifyTransaction(transactionDTO.getId(),
- transactionDTO.getEntryDate(), transactionDTO.getVoucherRef(),
- transactionDTO.getDescription(), timeSpan, journal);
- return result;
- }*/
+ /**
+ * Permet de retrouver la premiere transaction associée au journal.
+ *
+ * Utilisé par entrybook service pour savoir si un journal a des transactions
+ * associées et empecher la suppression.
+ *
+ * @param topiaTransaction context à utiliser
+ * @param entryBook journal
+ * @throws TopiaException
+ */
+ protected Transaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
- /*
- * Recherche une transaction unique avec son identifiant TopiaId.
- * @param topiaId
- * @return
- *
- public Transaction searchTransactionWithTopiaId(String topiaId) {
- Transaction transaction = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- transaction = transactionDAO.findByTopiaId(topiaId);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return transaction;
- }*/
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- /*
- * Recherche une transaction unique à partir d'une transaction DTO.
- * @param transactionDTO
- * @return
- *
- public Transaction searchTransactionWithTopiaId(
- TransactionDTO transactionDTO) {
- Transaction transaction = searchTransactionWithTopiaId(transactionDTO
- .getId());
- return transaction;
- }*/
+ TopiaQuery query = transactionDAO.createQuery();
+ // entryBook is not visible, but column "entryBook"
+ // exist in transaction table
+ query.add("entryBook", entryBook);
- /*
- * Recherche une transaction dans la base de données, et renvoie celle-ci
- * sous format DTO. Nous ne pouvons pas appeler la méthode searchTransactionWithTopiaId
- * du fait que lors de la convertion, nous avons besoin du journal et du
- * timeSpan. Or il ne faut donc pas de fermeture de connexion à la base de
- * données pour celà.
- * @param topiaId
- * @return
- *
- public TransactionDTO searchTransactionDTO(String topiaId) {
- TransactionDTO transactionDTO = null;
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- return transactionDTO;
- }*/
+ Transaction result = transactionDAO.findByQuery(query);
+
+ return result;
+ }
- /*
- * Recherche toutes les transactions qui correspondent à un timespan.
- * @param timeSpan
- * @return
- *
- public List<Transaction> searchListTransactionWithTimeSpan(TimeSpan timeSpan) {
- List<Transaction> listTransaction = null;
- if (timeSpan != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- listTransaction = transactionDAO.findAllByTimeSpan(timeSpan);
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
- }
- }
- return listTransaction;
- }*/
+ @Override
+ public List<Transaction> getAllTransactions() throws LimaException {
+
+ // find all with null entry book filter
+
+ return getAllTransactionsForEntryBook(null);
+ }
+
+ @Override
+ public List<Transaction> getAllTransactionsForEntryBook(EntryBook entryBook) throws LimaException {
+
+ // find all with null period filter
- /*
- * Recherche les transactions DTO d'un timeSpan
- * @param timeSpan
- * @return
- *
- public List<TransactionDTO> searchListTransactionDTOWithTimeSpan(
- TimeSpan timeSpan) {
- List<TransactionDTO> listTransactionDTO = new ArrayList<TransactionDTO>();
- if (timeSpan != null) {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche
- List<Transaction> listTransaction = transactionDAO
- .findAllByTimeSpan(timeSpan);
- // Converti la transaction en DTO
- convertTransaction.setTransaction(rootContext);
- for (Transaction transaction : listTransaction) {
- TransactionDTO transactionDTO = convertTransaction
- .transactionEntityToDto(transaction);
- listTransactionDTO.add(transactionDTO);
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
+ return getAllTransactionsForEntryBookAndFinancialPeriod(entryBook, null);
+ }
+
+ @Override
+ public List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException {
+
+ List<Transaction> transactions = null;
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+
+ // filter with topia query
+ TopiaQuery query = transactionDAO.createQuery();
+
+ if (entryBook != null) {
+ query.add("entryBook", entryBook);
}
+
+ if (financialPeriod != null) {
+ query.add("financialPeriod", financialPeriod);
+ }
+
+ transactions = transactionDAO.findAllByQuery(query);
}
- return listTransactionDTO;
- }*/
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ return transactions;
+ }
/*
* Recherche toutes les transactions appartenant à un même journal donné
@@ -466,66 +395,46 @@
return result;
}*/
- /*
- * Permet d'effacer une transaction dans la base de données.
- * ATTENTION : Elle supprime également toutes les entées comptables
- * associées. Une transaction appartenant à un timeSpan bloqué ne peut être
- * supprimée.
- * @return
- *
- public String removeTransaction(String topiaId) {
- String result = ServiceHelper.RESPOND_ERROR;
+ @Override
+ public void updateTransaction(Transaction transaction) throws LimaException {
+
+ // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+
+ TopiaContext topiaTransaction = null;
try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- TransactionDAO transactionDAO = LimaCallaoDAOHelper
- .getTransactionDAO(topiaContext);
- // Recherche de l'entry
- Transaction transaction = transactionDAO.findByTopiaId(topiaId);
- // Transaction doit exister
- if (transaction != null) {
- // Vérifie si la transaction est non bloquée.
- if (!isTransactionBlocked(transaction)) {
- // Supprime tous les entrys de la transactions
- List<Entry> listEntry = entryServiceImpl
- .searchEntryWithTransaction(transaction);
- for (Entry entry : listEntry) {
- result = removeEntry(entry.getTopiaId());
- }
- // Supprime la transaction
- transactionDAO.delete(transaction);
- // Création BDD
- topiaContext.commitTransaction();
- if (log.isInfoEnabled()) {
- log.info("La transaction a été supprimée avec succès.");
- }
- result = ServiceHelper.RESPOND_SUCCESS;
- } else {
- // Transaction bloquée
- result = ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED;
- }
- } else {
- result = ServiceHelper.TRANSACTION_NOT_EXIST;
- }
- // Fermeture BDD
- topiaContext.closeContext();
- } catch (TopiaException e) {
- log.error(e);
+ topiaTransaction = rootContext.beginTransaction();
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+ transactionDAO.update(transaction);
}
- return result;
- }*/
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
- /*
- * Supprime une transaction au format DTO.
- * @param transactionDTO
- * @return
- *
- public String removeTransaction(TransactionDTO transactionDTO) {
- String result = removeTransaction(transactionDTO.getId());
- return result;
- }*/
+ }
+ @Override
+ public void removeTransaction(Transaction transaction) throws LimaException {
+
+ // TODO EC-20100408 add some checks ? (balance, status, etc... ? )
+
+ TopiaContext topiaTransaction = null;
+ try {
+ topiaTransaction = rootContext.beginTransaction();
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+ transactionDAO.delete(transaction);
+ }
+ catch (TopiaException ex) {
+ doCatch(topiaTransaction, ex, log);
+ }
+ finally {
+ doFinally(topiaTransaction, log);
+ }
+
+ }
+
/*
* Permet d'ajouter une entrée comptable pour une transaction donnée.
* ATTENTION : la transaction doit être NON bloquée.
@@ -734,26 +643,4 @@
boolean isTransactionBalanced = debit == credit;
return isTransactionBalanced;
}*/
-
- /**
- * Permet de retrouver la premiere transaction associée au journal.
- *
- * @param topiaTransaction context à utiliser
- * @param entryBook journal
- * @throws TopiaException
- */
- protected Transaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
-
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
-
- TopiaQuery query = transactionDAO.createQuery();
- // entryBook is not visible, but column "entryBook"
- // exist in transaction table
- query.add("entryBook", entryBook);
-
- Transaction result = transactionDAO.findByQuery(query);
-
- return result;
- }
-
}
\ No newline at end of file
1
0
Author: echatellier
Date: 2010-04-08 14:29:15 +0200 (Thu, 08 Apr 2010)
New Revision: 2836
Log:
Fix openejb dependencies and scope
Modified:
trunk/lima-business/pom.xml
trunk/pom.xml
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2010-04-08 10:09:15 UTC (rev 2835)
+++ trunk/lima-business/pom.xml 2010-04-08 12:29:15 UTC (rev 2836)
@@ -35,6 +35,7 @@
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-08 10:09:15 UTC (rev 2835)
+++ trunk/pom.xml 2010-04-08 12:29:15 UTC (rev 2836)
@@ -128,6 +128,14 @@
<version>3.1.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
+
+ <!-- Mandatory for remote mode (embedded need only core) -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-client</artifactId>
+ <version>3.1.3-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
<!-- autres libraires -->
<dependency>
@@ -232,9 +240,9 @@
<projectId>lima</projectId>
<!-- customized libs version -->
- <nuiton-utils.version>1.2.1-SNAPSHOT</nuiton-utils.version>
+ <nuiton-utils.version>1.2.2-SNAPSHOT</nuiton-utils.version>
<eugene.version>2.0.1-SNAPSHOT</eugene.version>
- <topia.version>2.3.2-SNAPSHOT</topia.version>
+ <topia.version>2.3.3-SNAPSHOT</topia.version>
<jaxx.version>2.0</jaxx.version>
<i18n.version>1.2.1</i18n.version>
1
0
Author: echatellier
Date: 2010-04-08 12:09:15 +0200 (Thu, 08 Apr 2010)
New Revision: 2835
Log:
Ajout d'un packaging jar-with-deps pour le deploiement en mode distant
Modified:
trunk/lima-business/pom.xml
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2010-04-08 10:08:49 UTC (rev 2834)
+++ trunk/lima-business/pom.xml 2010-04-08 10:09:15 UTC (rev 2835)
@@ -61,23 +61,30 @@
<!-- XML/CSV import export don't compile for now -->
<excludes>
- <exclude>**/*Import*.java</exclude>
- <exclude>**/*Export*.java</exclude>
+ <exclude>**/*CSV*.java</exclude>
+ <exclude>**/*XML*.java</exclude>
</excludes>
</configuration>
</plugin>
+
+ <!--
+ TODO EC-20100408 pour l'intant c'est une archive
+ jar-with-dependencies qui sert a deploiement dans
+ le conteneur d'EJB (openejb) mais un ear correct serait
+ préférable (mais en packaging ear, il manque le projet courant)
+ -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ <attach>false</attach>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
- <!-- <resources>
- <resource>
- <directory>${maven.src.dir}/main/resources/</directory>
- <includes>
- <include>*.properties</include>
- </includes>
- </resource>
- </resources> -->
</build>
-
</project>
1
0
08 Apr '10
Author: echatellier
Date: 2010-04-08 12:08:49 +0200 (Thu, 08 Apr 2010)
New Revision: 2834
Log:
Fix doc format
Modified:
trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
Modified: trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2010-04-08 09:22:46 UTC (rev 2833)
+++ trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2010-04-08 10:08:49 UTC (rev 2834)
@@ -1,3 +1,5 @@
-<!-- Empty configuration file based on
- http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html -->
+<!--
+ Empty configuration file based on
+ http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html
+-->
<ejb-jar/>
1
0
Author: echatellier
Date: 2010-04-08 11:22:46 +0200 (Thu, 08 Apr 2010)
New Revision: 2833
Log:
Passage des attributs "montant" en double (etait en String ?)
Modified:
trunk/lima-callao/src/main/xmi/accounting.zargo
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
1
0
Author: echatellier
Date: 2010-04-08 11:22:15 +0200 (Thu, 08 Apr 2010)
New Revision: 2832
Log:
Fix eugene plugin classpath
Modified:
trunk/lima-callao/pom.xml
Modified: trunk/lima-callao/pom.xml
===================================================================
--- trunk/lima-callao/pom.xml 2010-04-06 17:04:18 UTC (rev 2831)
+++ trunk/lima-callao/pom.xml 2010-04-08 09:22:15 UTC (rev 2832)
@@ -70,6 +70,13 @@
</goals>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${topia.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
1
0
Author: echatellier
Date: 2010-04-06 19:04:18 +0200 (Tue, 06 Apr 2010)
New Revision: 2831
Log:
Petite doc sur openejb embarqu?\195?\169 et client/serveur
Added:
trunk/src/site/rst/devel/openejb.rst
Added: trunk/src/site/rst/devel/openejb.rst
===================================================================
--- trunk/src/site/rst/devel/openejb.rst (rev 0)
+++ trunk/src/site/rst/devel/openejb.rst 2010-04-06 17:04:18 UTC (rev 2831)
@@ -0,0 +1,94 @@
+OpenEJB
+=======
+
+Définition des EJB
+------------------
+
+Les implementations des services sont marqués avec l'annotation
+@Stateless.
+
+Point à verifier pour les annotations @Webservice et @Local, @Remote
+sur les interfaces.
+
+Embedded mode
+-------------
+
+Intantanciation et recherche dans un ``InitialContext`` local :
+
+::
+
+ Properties properties = new Properties();
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
+
+ InitialContext ctx = new InitialContext(properties);
+
+ AccountService ejbHome = (AccountService)ctx.lookup("AccountServiceImplLocal");
+
+Le nom "AccountServiceImplLocal" est ici une convention de nommage.
+
+TODO reference ? (EC : impossible à retrouver)
+
+
+Server mode
+-----------
+
+Tomcat
+~~~~~~
+
+Details : http://openejb.apache.org/tomcat.html
+
+
+OpenEJB server
+~~~~~~~~~~~~~~
+
+Details : http://openejb.apache.org/remote-server.html
+Testé avec : https://repository.apache.org/content/groups/snapshots/org/apache/openejb/o…
+
+Procedure:
+ - bin/openejb start &
+ - bin/openejb deploy lima-business-0.4.0-SNAPSHOT-jar-with-dependencies.jar
+
+Si le déploiment a réussi, openejb devrait afficher :
+
+::
+
+ Ejb(ejb-name=ReportServiceImpl, id=ReportServiceImpl)
+ Jndi(name=ReportServiceImplRemote)
+
+ Ejb(ejb-name=RecordServiceImpl, id=RecordServiceImpl)
+ Jndi(name=RecordServiceImplRemote)
+
+ Ejb(ejb-name=FinancialPeriodServiceImpl, id=FinancialPeriodServiceImpl)
+ Jndi(name=FinancialPeriodServiceImplRemote)
+
+ Ejb(ejb-name=FiscalPeriodServiceImpl, id=FiscalPeriodServiceImpl)
+ Jndi(name=FiscalPeriodServiceImplRemote)
+
+ Ejb(ejb-name=EntryBookServiceImpl, id=EntryBookServiceImpl)
+ Jndi(name=EntryBookServiceImplRemote)
+
+ Ejb(ejb-name=TransactionServiceImpl, id=TransactionServiceImpl)
+ Jndi(name=TransactionServiceImplRemote)
+
+ Ejb(ejb-name=AccountServiceImpl, id=AccountServiceImpl)
+ Jndi(name=AccountServiceImplRemote)
+
+Client
+~~~~~~
+
+ Properties properties = new Properties();
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ properties.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
+ properties.put("java.naming.security.principal", "jonathan");
+ properties.put("java.naming.security.credentials", "secret");
+
+ InitialContext ctx = new InitialContext(properties);
+
+ AccountService ejbHome = (AccountService)ctx.lookup("AccountServiceImplRemote");
+
+Les identifiants "jonathan/secret" sont ceux par defaut définit dans le fishier
+OPENEJB_HOME/conf/users.properties
+
+Les jar "javaee-api-5.0-3-SNAPSHOT.jar" et "openejb-client-3.1.3-SNAPSHOT.jar"
+doivent être EXACTEMENT les mêmes entre le serveur et le client (sinon
+une NPE exception survient tout le temps).
\ No newline at end of file
1
0
Author: tchemit
Date: 2010-04-03 12:39:26 +0200 (Sat, 03 Apr 2010)
New Revision: 2830
Log:
Evolution #137: update to nuiton-i18n 1.2.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-02 17:04:31 UTC (rev 2829)
+++ trunk/pom.xml 2010-04-03 10:39:26 UTC (rev 2830)
@@ -236,7 +236,7 @@
<eugene.version>2.0.1-SNAPSHOT</eugene.version>
<topia.version>2.3.2-SNAPSHOT</topia.version>
<jaxx.version>2.0</jaxx.version>
- <i18n.version>1.2</i18n.version>
+ <i18n.version>1.2.1</i18n.version>
<!--axis.version>1.4.1</axis.version-->
<!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
1
0
r2829 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: . account account/model entrybook entrybook/model export period period/model report transaction transaction/model transaction/table
by echatellier@users.chorem.org 02 Apr '10
by echatellier@users.chorem.org 02 Apr '10
02 Apr '10
Author: echatellier
Date: 2010-04-02 19:04:31 +0200 (Fri, 02 Apr 2010)
New Revision: 2829
Log:
Resctructuration des ui (package par function).
Mise ?\195?\160 jour des ui, periods, account, transaction, entrybook...
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/css/
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx
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/MainViewImpl.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,43 +0,0 @@
-<JFrame locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
- <style source="css/lima.css"/>
- <Table insets='5,5,5,5'>
- <row>
- <cell>
- <JLabel text="lima.number"/>
- </cell>
- <cell>
- <JTextField id="numberTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.description"/>
- </cell>
- <cell>
- <JTextField id="descriptionTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.account.type"/>
- </cell>
- <cell>
- <JAXXComboBox id="typeComboBox">
- <item value='{null}' label=' ' selected="true"/>
- <item value='{_("lima.actif")}'/>
- <item value='{_("lima.passif")}'/>
- <item value='{_("lima.produit")}'/>
- <item value='{_("lima.charge")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,26 +0,0 @@
-
-<Table insets='0,0,0,0'>
- <script>
- protected void initAddAccount() {};
- protected void initUpdateAccount() {};
- protected void removeAccount() {};
- </script>
- <row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
- <JScrollPane id="accountScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.add" onActionPerformed="initAddAccount()" width="150"/>
- </cell>
- </row>
- <row>
- <cell >
- <JButton id="updateButton" text="lima.update" onActionPerformed="initUpdateAccount()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeAccount()" width="150"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,236 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.tree.model.AccountTreeTableModel;
-import org.jdesktop.swingx.JXTreeTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-import javax.swing.*;
-import javax.swing.tree.TreePath;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.LinkedList;
-import java.awt.Color;
-
-/**
- * @author ore
- */
-public class AccountViewImpl extends AccountView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(AccountViewImpl.class);
- private final JXTreeTable table;
- private final AccountTreeTableModel model;
- private final AccountForm form;
- private boolean isAddForm;
-
- /**
- * Constructor
- */
- public AccountViewImpl() {
- // TreeTable
- model = LimaContext.getContext().getDataManager().getAccountModel();
- table = new JXTreeTable(model);
- table.setColumnControlVisible(true);
- table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- accountScrollPane.setViewportView(table);
- form = LimaContext.getContext().getMainUI().getAccountForm();
- form.getOkButton().addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(
- ActionEvent e) {
- if (isAddForm) {
- addAccount();
- } else {
- updateAccount();
- }
- }
- });
-
- // Default button OK
- form.getRootPane().setDefaultButton(form.getOkButton());
- // Coloration
- table.setBackground(Color.WHITE);
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- //,new Color(250,250,250) createAlternateStriping(Color.GRAY,Color.WHITE)
- }
-
- /**
- * Initialize account form
- */
- private void initForm() {
- form.getTypeComboBox().setSelectedIndex(0);
- }
-
- /**
- * Initialize form account to add accounts
- */
- @Override
- protected void initAddAccount() {
- initForm();
- isAddForm = true;
- form.setTitle(_("lima.ui.add.account"));
- form.getNumberTextField().setText(DTOHelper.EMPTY_STRING);
- form.getNumberTextField().setEditable(true);
- form.getDescriptionTextField().setText(DTOHelper.EMPTY_STRING);
- form.getTypeComboBox().setSelectedIndex(0);
- form.setVisible(true);
-
- }
-
- /**
- * Initialize form account to update accounts
- */
- @Override
- protected void initUpdateAccount() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- initForm();
- isAddForm = false;
- // Show journal data selected in the form
- int selectedRow = table.getSelectedRow();
- TreePath treePath = table.getPathForRow(selectedRow);
- AccountDTO account = (AccountDTO) treePath.getLastPathComponent();
- form.setTitle(_("lima.ui.update.account"));
- form.getNumberTextField().setText(account.getIdNumber());
- form.getNumberTextField().setEditable(false);
- form.getDescriptionTextField().setText(account.getDescription());
- // Type of account
- if (account.getType() == null) {
- form.getTypeComboBox().setSelectedIndex(0);
- } else {
- for (int i = 1; i < form.getTypeComboBox().getItemCount(); i++) {
- if (((String) form.getTypeComboBox().getItemAt(i)).equalsIgnoreCase(account.getType())) {
- form.getTypeComboBox().setSelectedIndex(i);
- break;
- }
- }
- }
- form.setVisible(true);
- }
- }
-
- /**
- * On performed action, allows to add an account
- */
- private void addAccount() {
- if (log.isDebugEnabled()) {
- log.debug("addAccount : ");
- // Getting form data
- }
- String number = form.getNumberTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String type = (String) form.getTypeComboBox().getSelectedItem();
- if (log.isDebugEnabled()) {
- log.debug("type : " + type); // Contrainte sur le type ??
- }
- form.dispose();
- AccountDTO account;
- TreePath treePath;
- AccountDTO parent;
- // Not row selected
- if (table.getSelectedRow() == -1) {
- /**
- * Class account can't be created
- */
- parent = model.getData(); // Root
- treePath = new TreePath(parent);
- } else {
- /**
- * Add account child
- */ // Get Parent
- int selectedRow = table.getSelectedRow();
- treePath = table.getPathForRow(selectedRow);
- parent = (AccountDTO) treePath.getLastPathComponent();
- }
- account = new AccountDTO("0", number, description, type, new LinkedList<AccountDTO>(), parent);
- String result = model.addAccount(treePath, account);
- /** Affichage des erreurs */
- ErrorMessage.showMessage(result);
- }
-
- /**
- * On performed action, allows to update an account
- */
- private void updateAccount() {
- if (log.isDebugEnabled()) {
- log.debug("updateAccount : ");
- // Getting form data
- }
- String number = form.getNumberTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String type = (String) form.getTypeComboBox().getSelectedItem();
- form.dispose();
- // Setting new collected data
- int selectedRow = table.getSelectedRow();
- TreePath treePath = table.getPathForRow(selectedRow);
- AccountDTO account = (AccountDTO) treePath.getLastPathComponent();
- // Clone
- AccountDTO clone = DTOHelper.cloneAccount(account);
- clone.setIdNumber(number);
- clone.setDescription(description);
- clone.setType(type);
- String result = model.updateAccount(treePath, account, clone);
- /** Affichage des erreurs */
- ErrorMessage.showMessage(result);
- }
-
- /**
- * On performed action, allows to remove an account
- */
- @Override
- protected void removeAccount() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- int n = JOptionPane.showOptionDialog(this,
- _("lima.question.remove.account"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
- if (n == JOptionPane.YES_OPTION) {
- // update view of treetable
- int selectedRow = table.getSelectedRow();
- TreePath treePath = table.getPathForRow(selectedRow);
- AccountDTO account = (AccountDTO) treePath.getLastPathComponent();
- String result = model.removeAccount(treePath, account);
- /** Affichage des erreurs */
- ErrorMessage.showMessage(result);
- }
- }
- }
-
- public JXTreeTable getTable() {
- return table;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,8 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <row>
- <cell>
- <style source="css/lima.css" />
- <JLabel text="lima.home"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,36 +0,0 @@
-/**
- * *##% Lima-Callao AccueilViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-/**
- * @author Rémi Chapelet
- */
-public class AccueilViewImpl extends AccueilView {
-
-
- /**
- * Constructor
- */
- public AccueilViewImpl() {
-
-
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,35 +0,0 @@
-<JFrame width="300" height="150" locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
- <style source="css/lima.css" />
- <Table fill="both">
- <row>
- <cell>
- <JLabel text="lima.closure.period.begin"/>
- </cell>
- <cell>
- <JPanel id="beginMonthPeriodPanel"/>
- </cell>
- <cell>
- <JPanel id="beginYearPeriodPanel"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="endMonthPeriodPanel"/>
- </cell>
- <cell>
- <JPanel id="endYearPeriodPanel"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,32 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <script>
- protected void updateBalance() {};
- </script>
-
- <!-- Choix pour les périodes -->
- <row weightx="2" fill="both" insets="8,40,8,40">
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- <cell>
- <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="updateBalance()" />
- </cell>
- </row>
-
- <!-- Affichage de la balance -->
- <row columns="3" weightx="1" weighty="10" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tableBalance" />
- </cell>
- </row>
-
- <!-- Affichage du résultat -->
- <row columns="3" weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tableBalanceRes" />
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,192 +0,0 @@
-/**
- * *##% Lima-Callao
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.table.model.BalanceTableModel;
-import org.chorem.lima.table.renderer.BalanceTableCellRenderer;
-import static org.nuiton.i18n.I18n._;
-
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.table.DefaultTableModel;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * Cette classe permet l'affichage de la balance comptable.
- *
- * @author Rémi Chapelet
- */
-public class BalanceViewImpl extends BalanceView {
-
- private JComboBox comboBoxPeriod = new JComboBox();
- private JXTable table;
- private JXTable tableRes;
- private BalanceHelper balance = new BalanceHelper();
- private BalanceTableModel modelBalance;
- private DefaultTableModel model;
-
- /**
- * Constructor
- */
- public BalanceViewImpl() {
-
- //Initialise les périodes pour la combobox
- initComboBoxPeriod();
-
- /**
- * Création du model pour le tableau
- */
- // Création de la balance
- List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
- // Création de la table
- modelBalance = new BalanceTableModel(listBalance);
- table = new JXTable(modelBalance);
- /** Design de la table */
- table.setRowHeight(24);
- // Permet d'alterner les couleurs des lignes pour le tableau
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- table.setColumnControlVisible(true);
- // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
- for (int i = 0; i < table.getModel().getColumnCount(); i++) {
- table.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
- }
-
- // Affichage de la table
- tableBalance.setViewportView(table);
-
- /**
- * Calcul pour le total des soldes
- */
- model = new DefaultTableModel();
- String[] columnNames = {"1", "2", "3", "4", "5", "6"};
- model.setColumnIdentifiers(columnNames);
- tableRes = new JXTable(model);
- // On cache le header des colonnes
- tableRes.setColumnControlVisible(false);
- tableRes.getTableHeader().setVisible(false);
- // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
- for (int i = 0; i < tableRes.getModel().getColumnCount(); i++) {
- tableRes.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
- }
- // Initialise les valeurs pour le résultat total
- initTableBalanceRes(listBalance);
-
-
- /**
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Recherche la balance
- updateBalance();
- }
- });
- }
-
- /**
- * Permet de initialiser la table de résultat à chaque appel de cette
- * méthode.
- *
- * @param listBalance
- */
- private void initTableBalanceRes(List<BalanceDTO> listBalance) {
- // Déclaration des variables
- String TotalMoveDebit = "0";
- String TotalMoveCredit = "0";
- String TotalBalanceDebit = "0";
- String TotalBalanceCredit = "0";
- // Pour chaque ligne de la balance
- for (BalanceDTO balanceDTO : listBalance) {
- /** Calcul des mouvements */
- TotalMoveDebit = DTOHelper.AddNumbersString(TotalMoveDebit, balanceDTO.getDebit());
- TotalMoveCredit = DTOHelper.AddNumbersString(TotalMoveCredit, balanceDTO.getCredit());
- /** Calcul des soldes */
- if (balanceDTO.getType().equalsIgnoreCase("Actif") ||
- balanceDTO.getType().equalsIgnoreCase("Charge")) {
- String solde = DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit());
- TotalBalanceDebit = DTOHelper.AddNumbersString(solde, TotalBalanceDebit);
- } else {
- String solde = DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit());
- TotalBalanceCredit = DTOHelper.AddNumbersString(solde, TotalBalanceCredit);
- }
- }
- // Définition des données
- Object[] data =
- {"", _("lima.balance.total"), TotalMoveDebit, TotalMoveCredit, TotalBalanceDebit, TotalBalanceCredit};
- // Si il existe déja une ligne
- if (model.getRowCount() > 0) {
- model.removeRow(0);
- }
- // Ajout de la ligne
- model.addRow(data);
- tableRes.setModel(model);
- tableBalanceRes.setViewportView(tableRes);
- }
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initComboBoxPeriod() {
- // Recherche la liste de toutes les périodes
- List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
- // Model pour les périodes
- Vector<PeriodDTO> v = new Vector<PeriodDTO>();
- // On ajoute un élément null pour permettre d'afficher toutes les périodes
- v.addElement(null);
- // Pour chaque période (annuelle et NON mensuelle !)
- for (PeriodDTO period : periodes) {
- v.addElement(period);
- v.addAll(period.getChildren());
- }
- comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
- /**
- * Permet de recharger la balance. Elle appelle la méthode createBalance, qui
- * va parcourir de nouveau les entrées comptables pour la période, et calculer
- * la balance.
- */
- @Override
- protected void updateBalance() {
- // Récupère la liste de la balance
- List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
- modelBalance.setData(listBalance);
- modelBalance.fireTableDataChanged();
- initTableBalanceRes(listBalance);
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,29 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <script>
- protected void addLettering() {};
- protected void removeLettering() {};
- protected void precedentAccount() {};
- protected void nextAccount() {};
- </script>
-
- <!-- Choix pour les périodes -->
- <row>
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
-
- <!-- Affichage du bilan (actif et passif) -->
- <row weightx="1.0" weighty="1.0" anchor="center" fill="both">
- <cell weightx="0.5">
- <JScrollPane id="tabActif" />
- </cell>
- <cell weightx="0.5">
- <JScrollPane id="tabPassif" />
- </cell>
- </row>
-
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,480 +0,0 @@
-/**
- * *##% Lima-Callao BilanViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.bilan.Bilan;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.balance.Category;
-import org.chorem.lima.table.BilanActifJXTable;
-import org.chorem.lima.table.BilanPassifJXTable;
-import org.chorem.lima.table.model.BilanActifTableModel;
-import org.chorem.lima.table.model.BilanPassifTableModel;
-
-import java.awt.event.*;
-import javax.swing.*;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Vector;
-
-/**
- * Cette classe permet de calculer le bilan. Elle utilise la balance et
- * le compte de résultat.
- *
- * @author Rémi Chapelet
- */
-public class BilanViewImpl extends BilanView {
-
- private JComboBox comboBoxPeriod = new JComboBox();
- private BilanActifJXTable tableActif;
- private BilanPassifJXTable tablePassif;
- private BilanActifTableModel modelBilanActif;
- private BilanPassifTableModel modelBilanPassif;
- Hashtable<String, Bilan> actifTab = new Hashtable<String, Bilan>();
- Hashtable<String, Bilan> passifTab = new Hashtable<String, Bilan>();
- Hashtable<String, List<BalanceDTO>> provisionMap;
- private BalanceHelper balance = new BalanceHelper();
- private ProgressBarImpl progressBar;
-
- /**
- * Constructor
- */
- public BilanViewImpl() {
-
- // Initialise la combobox pour les périodes
- initComboBoxPeriod();
-
- // Création des modèles
- modelBilanActif = new BilanActifTableModel(new LinkedList<Bilan>());
- modelBilanPassif = new BilanPassifTableModel(new LinkedList<Bilan>());
-
-
- // Chargement du bilan
- //updateBilan();
-
- /** ACTIF */
- tableActif = new BilanActifJXTable(modelBilanActif);
- // Ajout du tableau
- tabActif.setViewportView(tableActif);
-
- /** PASSIF */
- tablePassif = new BilanPassifJXTable(modelBilanPassif);
- // Ajout du tableau
- tabPassif.setViewportView(tablePassif);
-
- /**
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- updateBilan();
- }
- });
-
- }
-
- /**
- * Cette partie consiste à créer les catégories du bilan
- */
- public void createCategory() {
- /** ACTIF */
-
- actifTab.put("ACTIF", new Bilan("TOTAL (1) + (2)", "total", null));
- actifTab.put("ACTIF_IMMOBILISE", new Bilan("ACTIF IMMOBILISE", "title", null));
- actifTab.put("ACTIF_IMMOBILISE_INCORPOREL", new Bilan("Immobilisé incorporel", "", null));
- actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
- actifTab.put("ACTIF_IMMOBILISE_CORPOREL", new Bilan("Immobilisé corporel", "", null));
- actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
- actifTab.put("ACTIF_IMMOBILISE_FINANCIER", new Bilan("Immobilisé financier", "", null));
- actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
- actifTab.put("ACTIF_CIRCULANT", new Bilan("ACTIF CIRCULANT", "title", null));
- actifTab.put("ACTIF_CIRCULANT_STOCK", new Bilan("stocks et en-cours", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
- actifTab.put("ACTIF_CIRCULANT_AVANCES", new Bilan("av. et ac. versés", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
- actifTab.put("ACTIF_CIRCULANT_CREANCES", new Bilan("Créances", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
- actifTab.put("ACTIF_CIRCULANT_VMP", new Bilan("VMP", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_VMP"));
- actifTab.put("ACTIF_CIRCULANT_DISPONIBILITE", new Bilan("Disponibilités", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
- actifTab.put("ACTIF_CIRCULANT_CCA", new Bilan("CCA", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CCA"));
- actifTab.get("ACTIF").add(actifTab.get("ACTIF_IMMOBILISE"));
- actifTab.get("ACTIF").add(actifTab.get("ACTIF_CIRCULANT"));
- /** PASSIF */
- passifTab.put("PASSIF", new Bilan("TOTAL (1) + (2) + (3)", "total", null));
- passifTab.put("PASSIF_CAPITAUX", new Bilan("CAPITAUX PROPRES", "title", null));
- passifTab.put("PASSIF_CP_CAPITAL", new Bilan("Capital", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_CAPITAL"));
- passifTab.put("PASSIF_CP_RESERVES", new Bilan("Réserves", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESERVES"));
- passifTab.put("PASSIF_CP_RAN", new Bilan("RAN", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RAN"));
- passifTab.put("PASSIF_CP_RESULTAT", new Bilan("Résultat", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESULTAT"));
- passifTab.put("PASSIF_CP_SUBVENTION", new Bilan("Subventions d'investissement", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_SUBVENTION"));
- passifTab.put("PASSIF_CP_PROVISION", new Bilan("Provisions réglementées", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_PROVISION"));
- passifTab.put("PASSIF_PR_PROVISIONS", new Bilan("PROVISIONS", "title", null));
- passifTab.put("PASSIF_PROVISIONS", new Bilan("Provisions", "", null));
- passifTab.get("PASSIF_PR_PROVISIONS").add(passifTab.get("PASSIF_PROVISIONS"));
- passifTab.put("PASSIF_DETTES", new Bilan("DETTES", "title", null));
- passifTab.put("PASSIF_DETTES_EMPRUNTS", new Bilan("Emprunts", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
- passifTab.put("PASSIF_DETTES_AVANCES", new Bilan("av. et ac. reçus", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AVANCES"));
- passifTab.put("PASSIF_DETTES_FOURNISSEURS", new Bilan("Fournisseurs", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
- passifTab.put("PASSIF_DETTES_FISCALES", new Bilan("Fiscales/sociales", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FISCALES"));
- passifTab.put("PASSIF_DETTES_IMMOBILISATIONS", new Bilan("Immobilisations", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
- passifTab.put("PASSIF_DETTES_AUTRES_DETTES", new Bilan("Autres dettes", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
- passifTab.put("PASSIF_DETTES_PCA", new Bilan("PCA", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_PCA"));
- passifTab.get("PASSIF").add(passifTab.get("PASSIF_CAPITAUX"));
- passifTab.get("PASSIF").add(passifTab.get("PASSIF_CP_PROVISION"));
- passifTab.get("PASSIF").add(passifTab.get("PASSIF_DETTES"));
- }
-
- /**
- * Permet de calculer le bilan
- */
- public void updateBilan() {
- log.debug("Update bilan :");
-
- MainViewImpl context = LimaContext.get().getMainUI();
- progressBar = new ProgressBarImpl(context, context);
- Runnable runnable = new Runnable() {
- public void run() {
- progressBar.setVisible(true);
- }
- };
- SwingUtilities.invokeLater(runnable);
-
- new Thread() {
- @Override
- public void run() {
-
- progressBar.setTitle("Chargement du bilan");
- progressBar.getProgressBar().setString("0% : Préparation des données");
- progressBar.getProgressBar().setValue(0);
-
- // Chargement de la balance
- List<BalanceDTO> ListbalanceDTO = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
-
-
- progressBar.getProgressBar().setString("10% : Balance chargée");
- progressBar.getProgressBar().setValue(10);
- /**
- * Vérifie chaque numéro de compte (balance) pour déterminer sa position
- * dans le bilan.
- * Chaque catégorie est un objet bilan, et possède à son tour des bilans
- * correspondants aux comptes.
- * Cette boucle ne prend pas en compte les amortissement et provisions.
- * Ces comptes sont mis dans une liste à part, pour être traités une seconde fois.
- */
-
- progressBar.getProgressBar().setString("15% : Création catégorie");
- progressBar.getProgressBar().setValue(15);
- createCategory();
- // Liste amort/prov à traiter apres
- provisionMap = new Hashtable<String, List<BalanceDTO>>();
-
- progressBar.getProgressBar().setString("20% : Chargement des comptes");
- progressBar.getProgressBar().setValue(20);
- // Récupère le nombre de balances
- float nbBalances = ListbalanceDTO.size();
- float incremente = 40 / nbBalances;
- float value = 20;
- // Pour chaque balance
- for (BalanceDTO balanceDTO : ListbalanceDTO) {
- /**
- * ACTIF
- */
- /** IMMOBILISATION */
- if (Category.accountNumberCategory("20", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("21", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("22", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("23", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("25", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("26", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("27", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- /** ACTIF CIRCULANT */
- if (Category.accountNumberCategory("31", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("32", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("33", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("34", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("35", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("36", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("37", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_STOCK").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("99", balanceDTO.getAccount().getIdNumber())) {
- // TODO
- //actifTab.get("ACTIF_CIRCULANT_AVANCES").add(balanceDTO,Util.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("41", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("50", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_VMP").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("51", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("52", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("53", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("54", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("486", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_CCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- /** AMORT. & PROV. */
- if (Category.accountNumberCategory("280", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_IMMOBILISE_INCORPOREL", listBalance);
- }
- provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO);
- }
- if (Category.accountNumberCategory("281", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_IMMOBILISE_CORPOREL", listBalance);
- }
- provisionMap.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO);
- }
- if (Category.accountNumberCategory("282", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_IMMOBILISE_FINANCIER", listBalance);
- }
- provisionMap.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO);
- }
- if (Category.accountNumberCategory("491", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_CIRCULANT_CREANCES", listBalance);
- }
- provisionMap.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO);
- }
- /**
- * PASSIF
- */
- /** CAPITAUX PROPRES */
- if (Category.accountNumberCategory("101", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("104", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("105", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("107", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("108", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("109", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_CAPITAL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("106", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_RESERVES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("11", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_RAN").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("12", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_RESULTAT").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("13", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_SUBVENTION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("14", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_PROVISION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- /** PROVISIONS */
- if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_PROVISIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- /** DETTES */
- if (Category.accountNumberCategory("16", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_EMPRUNTS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_AVANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("40", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_FOURNISSEURS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("43", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("44", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_FISCALES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("999", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_IMMOBILISATIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("9999", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_AUTRES_DETTES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("487", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_PCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- // Incrémente la barre de chargement
- value = value + incremente;
- progressBar.getProgressBar().setValue((int) value);
- progressBar.getProgressBar().setString((int) value + "% : Compte : " + balanceDTO.getName());
- }
-
- progressBar.getProgressBar().setString("60% : Mise en place des amortissements et provisions");
- progressBar.getProgressBar().setValue(60);
- /**
- * Mise en place des provisions et amortissements
- */
- if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
- if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_CORPOREL");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_IMMOBILISE_CORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
- if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_FINANCIER");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_IMMOBILISE_FINANCIER").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
- if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_CIRCULANT_CREANCES");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_CIRCULANT_CREANCES").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
-
- progressBar.getProgressBar().setString("70% : Calcul du résultat");
- progressBar.getProgressBar().setValue(70);
- /**
- * Appel de la méthode du calcul du compte de résultat pour avoir le
- * résultat
- */
- ResultViewImpl resultViewImpl = new ResultViewImpl();
- resultViewImpl.updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
- passifTab.get("PASSIF_CP_RESULTAT").add(new Bilan("Résultat", "", resultViewImpl.getResult(), "0"), resultViewImpl.getResult());
-
- progressBar.getProgressBar().setString("90% : Création des tableaux");
- progressBar.getProgressBar().setValue(90);
- /**
- * Ajout des données dans le model
- */
- /** ACTIF */
- List<Bilan> listActif = new LinkedList<Bilan>();
- listActif.add(actifTab.get("ACTIF_IMMOBILISE"));
- listActif.add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
- listActif.add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
- listActif.add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
- listActif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", actifTab.get("ACTIF_IMMOBILISE").getTotal(), actifTab.get("ACTIF_IMMOBILISE").getDepreciation()));
- listActif.add(actifTab.get("ACTIF_CIRCULANT"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_VMP"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_CCA"));
- listActif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", actifTab.get("ACTIF_CIRCULANT").getTotal(), actifTab.get("ACTIF_CIRCULANT").getDepreciation()));
- listActif.add(actifTab.get("ACTIF"));
-
- // Création du modèle à partir de la liste précédement créée
- modelBilanActif.setData(listActif);
- modelBilanActif.fireTableDataChanged();
-
- /** PASSIF */
- List<Bilan> listPassif = new LinkedList<Bilan>();
- listPassif.add(passifTab.get("PASSIF_CAPITAUX"));
- listPassif.add(passifTab.get("PASSIF_CP_CAPITAL"));
- listPassif.add(passifTab.get("PASSIF_CP_RESULTAT"));
- listPassif.add(passifTab.get("PASSIF_CP_RESERVES"));
- listPassif.add(passifTab.get("PASSIF_CP_RAN"));
- listPassif.add(passifTab.get("PASSIF_CP_SUBVENTION"));
- listPassif.add(passifTab.get("PASSIF_CP_PROVISION"));
- listPassif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", passifTab.get("PASSIF_CAPITAUX").getTotal(), "0"));
- listPassif.add(passifTab.get("PASSIF_PR_PROVISIONS"));
- listPassif.add(passifTab.get("PASSIF_PROVISIONS"));
- listPassif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", passifTab.get("PASSIF_PR_PROVISIONS").getTotal(), "0"));
- listPassif.add(passifTab.get("PASSIF_DETTES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
- listPassif.add(passifTab.get("PASSIF_DETTES_AVANCES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
- listPassif.add(passifTab.get("PASSIF_DETTES_FISCALES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
- listPassif.add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_PCA"));
- listPassif.add(new Bilan("SOUS-TOTAL (3)", "soustotal", passifTab.get("PASSIF_DETTES").getTotal(), "0"));
- listPassif.add(passifTab.get("PASSIF"));
-
- progressBar.getProgressBar().setString("90% : Opération terminée");
- progressBar.getProgressBar().setValue(90);
- // Création du modèle à partir de la liste précédement créée
- modelBilanPassif.setData(listPassif);
- progressBar.getProgressBar().setValue(95);
- modelBilanPassif.fireTableDataChanged();
- progressBar.getProgressBar().setValue(100);
- progressBar.dispose();
- }
- }.start();
-
- }
-
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initComboBoxPeriod() {
- // Recherche la liste de toutes les périodes
- List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
- // Model pour les périodes
- Vector<PeriodDTO> v = new Vector<PeriodDTO>();
- // On ajoute un élément null pour permettre d'afficher toutes les périodes
- v.addElement(null);
- // Pour chaque période (annuelle et NON mensuelle !)
- for (PeriodDTO period : periodes) {
- v.addElement(period);
- //v.addAll(period.getChildren());
- }
-
- comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
-
-}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,41 @@
+<!-- ##% 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.
+ ##% -->
+<Table insets='0,0,0,0' opaque='false'>
+
+ <String id="title" javaBean='null' />
+ <Boolean id="canClose" javaBean='true'/>
+
+ <row fill='both'>
+ <cell anchor='west' weightx="1" insets='0,0,0,0'>
+ <JLabel id='label' opaque='false' font-size='12'
+ verticalAlignment='center' verticalTextPosition='0'
+ text='{getTitle()}'/>
+ </cell>
+ <cell anchor='east' insets='2,15,0,0' weighty='0'>
+ <JButton id='closeTab' preferredSize='{new Dimension(16,16)}'
+ verticalAlignment='0'
+ verticalTextPosition='0'
+ opaque='true'
+ borderPainted='false'
+ focusPainted='false'
+ enabled='{isCanClose()}'
+ horizontalTextPosition='0'
+ actionIcon='closeTab'
+ />
+ </cell>
+ </row>
+</Table>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,4 +0,0 @@
-<JFrame title="lima.export" width="620" height="300"
-iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
-
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,41 +0,0 @@
-<JFrame width="500" height="240" id="ClosureTimeSpanView"
-defaultCloseOperation="dispose_on_close">
-
- <style source="css/lima.css" />
- <script>
- protected void windowClosing() {};
- </script>
- <Table insets='4,0,4,0'>
- <row>
- <cell>
- <JLabel text="lima.closure.period.begin"/>
- </cell>
- <cell>
- <JPanel id="beginPeriod"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="endPeriod"/>
- </cell>
- </row>
- <row>
- <cell columns="2">
- <JTextArea id="JTextAreaWarning" styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok" />
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-
-
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,28 +0,0 @@
-<Table insets='0,0,0,0'>
- <script>
- protected void initBlockForm() {};
- protected void initUnblockForm() {};
- </script>
- <row fill="horizontal" weightx="0.75" weighty="0" anchor="center" insets='5,5,5,5'>
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
- <row >
- <cell fill="both" weightx="1" weighty="1" rows='3' columns='4' >
- <JScrollPane id="closureScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.block" onActionPerformed="initBlockForm()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.unblock" onActionPerformed="initUnblockForm()" width="150"/>
- </cell>
- </row>
-
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,406 +0,0 @@
-/**
- * *##% Lima-Callao ClosureViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.swing.JComboBox;
-import javax.swing.ListSelectionModel;
-import javax.swing.RowFilter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.model.PeriodComboBoxModel;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.StatusDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.TriPeriodAsc;
-import org.chorem.lima.dto.util.TriPeriodDesc;
-import org.chorem.lima.table.model.ClosureTableModel;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-
-/**
- * Permet l'affichage du tableau avec les périodes mensuelles.
- *
- * @author Rémi Chapelet
- */
-public class ClosureViewImpl extends ClosureView {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8759564865633991757L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
-
- private final JXTable table;
- private JComboBox comboBoxPeriod = new JComboBox();
- private final ClosureTimeSpanForm form;
- private final AddPeriod addPeriodForm;
- private static boolean blockPeriod;
- private JComboBox comboBoxBeginPeriod = new JComboBox();
- private JComboBox comboBoxEndPeriod = new JComboBox();
- private JComboBox comboBeginYearPeriod = new JComboBox();
- private JComboBox comboBeginMonthPeriod = new JComboBox();
- private JComboBox comboEndYearPeriod = new JComboBox();
- private JComboBox comboEndMonthPeriod = new JComboBox();
-
-
- /**
- * Constructor
- */
- public ClosureViewImpl() {
-
- // Initialisation du choix pour les périodes
- initComboBoxPeriod();
-
- /* Set Period model */
- // Création du model pour le tableau
- table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
- table.setRowHeight(24);
- // Permet d'alterner les couleurs des lignes pour le tableau
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- // Definition de la selection possible sur les lignes
- table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- table.setColumnControlVisible(true);
-
- /*
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Récupère la période master
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
- //FilterPipeline filters = new FilterPipeline(filterArray);
-
- RowFilter<Object, Object> filter = null;
- if (periodMaster != null) {
- // 0 = check only in first column
- // filter :
- // period name containing selected periode
- // Final = ??? TODO
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(periodMaster.getBegin());
- filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0);
- if (log.isDebugEnabled()) {
- log.debug("Apply filter on " + calendar.get(Calendar.YEAR));
- }
- }
- table.setRowFilter(filter);
- }
- });
-
- // Ajout du tableau dans l'UI
- getClosureScrollPane().setViewportView(table);
-
- /*
- * Initialisation du formulaire pour bloquer ou débloquer une période.
- */
- form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
- form.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- updatePeriod();
- }
- });
-
- /**
- * Initialisation du formulaire pour ajouter un exercice
- */
- addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
-
- Calendar cal = Calendar.getInstance();
-
- //Init YEAR Periode Combobox
- // take care about previous year #120
- int todayYear = cal.get(Calendar.YEAR);
- for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) {
- comboBeginYearPeriod.addItem(currentYear);
- comboEndYearPeriod.addItem(currentYear);
- }
- comboBeginYearPeriod.setSelectedItem(todayYear);
- comboEndYearPeriod.setSelectedItem(todayYear);
-
-
- //Add BeginYear ComboBox to addPeriodForm
- addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
- addPeriodForm.getBeginYearPeriodPanel().validate();
-
- //Add EndYear ComboBox to addPeriodForm
- addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
- addPeriodForm.getEndYearPeriodPanel().validate();
-
- //Init MONTH Periode Combobox
- cal.set(Calendar.MONTH, Calendar.JANUARY);
- for (int j = 0; j <= 11; j++) {
- comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- cal.add(Calendar.MONTH, 1);
- }
-
- //Add BeginMonth ComboBox to addPeriodForm
- addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
- addPeriodForm.getBeginMonthPeriodPanel().validate();
-
- //Add EndMonth ComboBox to addPeriodForm
- addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
- addPeriodForm.getEndMonthPeriodPanel().validate();
-
- addPeriodForm.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addPeriod();
- addPeriodForm.dispose();
- }
- });
-
- }
-
-
- /**
- * Cette méthode permet de charger les périodes (annuelles) pour choisir
- * les périodes mensuelles à afficher dans le tableau.
- */
- public void initComboBoxPeriod() {
- /**
- * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxPeriod.setModel(periodModel);
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
-
- /**
- * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
- * plusieurs périodes.
- */
- @Override
- public void initBlockForm() {
- blockPeriod = true;
- form.setTitle(_("lima.ui.block.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise le formulaire pour débloquer des périodes mensuelles.
- */
- @Override
- public void initUnblockForm() {
- blockPeriod = false;
- form.setTitle(_("lima.ui.unblock.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
- * les deux combobox nécessaires pour début et fin de période.
- */
- public void initComboBoxForm() {
- /**
- * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxBeginPeriod.setModel(periodModel);
- comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Création Combobox fin période
- comboBoxEndPeriod.setModel(periodModel);
- comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- form.beginPeriod.add(comboBoxBeginPeriod);
- form.endPeriod.add(comboBoxEndPeriod);
-
- /**
- * Positionne, si les lignes sont sélectionnées, les comboBox sur
- * les bonnes périodes (période min et période max).
- */
- // Si une ou plusieurs lignes sont sélectionnées
- if (table.getSelectedRow() != -1) {
- // Récupère les périodes sélectionnées
- List<PeriodDTO> listPeriod = getSelectedPeriod();
- // Parcours du vecteur
- comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
- comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
- }
- }
-
-
- /**
- * Permet d'ajouter un nouvel exercice.
- */
- protected void addPeriod() {
- if (log.isDebugEnabled()) {
- log.debug("addPeriod : ");
- //Get form data
- }
- PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
-
- // get begin date
- Calendar beginCalendar = Calendar.getInstance();
- if (periodCurrent != null) {
- beginCalendar.setTime(periodCurrent.getBegin());
- }
- beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem());
- beginCalendar.set(Calendar.DAY_OF_MONTH, 1);
- // month is equals to list index
- beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
- Date beginDate = beginCalendar.getTime();
-
- // get end date
- Calendar endCalendar = Calendar.getInstance();
- endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem());
- endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
- int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- endCalendar.set(Calendar.DAY_OF_MONTH, maximum);
- Date endDate = endCalendar.getTime();
-
- if (log.isDebugEnabled()) {
- log.debug("Add new periode from " + beginDate + " to " + endDate);
- }
-
- String periodName = null;
- if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) {
- periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR));
- }
- else {
- periodName = Integer.toString(beginCalendar.get(Calendar.YEAR));
- }
-
- // TODO what is status.get(3) ???
- PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3));
-
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- closureModel.addPeriod(period, status);
- }
-
- /**
- * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
- * une ou plusieurs périodes, ou bien débloquer.
- * On récupère l'intervalle des périodes donné par le formulaire. On prend
- * les périodes aux extrémités.
- * Si on bloque les périodes, on va trier par ordre croissant sinon par
- * ordre décroissant. En effet, pour débloquer une période, il est important
- * que les périodes qui suivent soient bloquées ; par conséquent on doit
- * commencer par les dernières.
- */
- protected void updatePeriod() {
- // Liste des status
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
- // Liste des transactions
- List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
- // Chargement du model
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- /**
- * Récupère l'intervalle des périodes sélectionnées
- */
- PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
- PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
- // Exercice
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- // Si block période, on trie la liste en croissant ou bien décroissant
- List<PeriodDTO> listPeriod = periodMaster.getChildren();
- if (blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- } else {
- Collections.sort(listPeriod, new TriPeriodDesc());
- }
- // Pour toutes les périodes mensuelles
- for (PeriodDTO period : listPeriod) {
- if (((period.getBegin().after(periodBegin.getBegin()))
- && (period.getBegin().before(periodEnd.getBegin())))
- || (period.equals(periodBegin))
- || (period.equals(periodEnd))) {
- if (log.isDebugEnabled()) {
- log.debug("updatePeriod : " + period.getIdName() + " : "
- + blockPeriod);
- }
- /**
- * Détection des messages d'erreur
- */
- String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
- ErrorMessage.showMessage(message);
- }
- }
- // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
- // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
- // décroissant).
- if (!blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- }
- form.setVisible(false);
- form.dispose();
- }
-
- /**
- * Cette méthode permet de retourner une liste des périodes sélectionnées.
- *
- * @return liste des périodes sélectionnées
- */
- protected List<PeriodDTO> getSelectedPeriod() {
- // récupère les lignes sélectionnées
- int viewIndex[] = table.getSelectedRows();
- // chargement du model (tableau des périodes)
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
- // Pour chaque ligne sélectionnée
- for (int i : viewIndex) {
- int modelIndex = table.convertRowIndexToModel(i);
- listPeriod.add(closureModel.getRow(modelIndex));
- }
- return listPeriod;
- }
-
-
- public void initAddPeriod() {
- addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
- addPeriodForm.setVisible(true);
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,24 +0,0 @@
-<Table insets='5,5,5,5'>
- <script>
- protected void removeCriteriaWidget(){}
- </script>
- <row>
- <cell>
- <JAXXComboBox id="criteriaComboBox" width="200">
- <item value='date' label='{_("lima.date")}' selected="true"/>
- <item value='voucher' label='{_("lima.voucher")}'/>
- <item value='account' label='{_("lima.account")}'/>
- <item value='description' label='{_("lima.description")}'/>
- <item value='debit' label='{_("lima.debit")}'/>
- <item value='credit' label='{_("lima.credit")}'/>
- <item value='amount' label='{_("lima.amount")}'/>
- </JAXXComboBox>
- </cell>
- <cell weightx="0">
- <JPanel id="criteriaPanel"/>
- </cell>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeCriteriaWidget()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,213 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
-import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.item.Item;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
-import org.jdesktop.swingx.JXDatePicker;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Date;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author ore
- */
-public class CriteriaWidgetImpl extends CriteriaWidget {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(CriteriaWidgetImpl.class);
- private JTextField inputTextField;
- private JXDatePicker datePicker;
- private JComboBox comboBox;
- private JComboBox accountCombo;
-
- /**
- * Constructor
- */
- public CriteriaWidgetImpl() {
- // date input creation
- createDateInput();
-
- // item changed listener
- criteriaComboBox.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- String itemSelected = e.getItem().toString();
- if (itemSelected.equals("date")) {
- createDateInput();
- }
- if (itemSelected.equals("voucher") ||
- itemSelected.equals("description") ||
- itemSelected.equals("account")) {
- createTextInput();
- }
- if (itemSelected.equals("debit") ||
- itemSelected.equals("credit") ||
- itemSelected.equals("amount")) {
- createNumberInput();
- }
- if (itemSelected.equals("account")) {
- createAccountInput();
- }
- }
- }
- });
- }
-
- /**
- *
- */
- private void createNumberInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.greater.than")));
- getComboBox().addItem(new Item(2, _("lima.filter.less.than")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getInputTextField());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("numberinput : ");
- }
- }
-
- /**
- *
- */
- private void createTextInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.contains")));
- getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getInputTextField());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("textinput : ");
- }
- }
-
- /**
- *
- */
- private void createAccountInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.contains")));
- getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getAccountCombo());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("accountinput : ");
- }
- }
-
- /**
- *
- */
- private void createDateInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.before")));
- getComboBox().addItem(new Item(2, _("lima.filter.after")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getDatePicker());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("dateinput : ");
- }
- }
-
- @Override
- protected void removeCriteriaWidget() {
- LimaContext.getContext().getMainUI().getSearchView().removeCriteriaWidget(this);
- }
-
- /**
- * @return
- */
- public JComboBox getComboBox() {
- if (comboBox == null) {
- comboBox = new JComboBox();
- }
- return comboBox;
- }
-
- /**
- * @return
- */
- public JXDatePicker getDatePicker() {
- if (datePicker == null) {
- datePicker = new JXDatePicker(new Date(), LimaContext.getContext().getConfig().getLocale());
- }
- return datePicker;
- }
-
- /**
- * @return
- */
- public JTextField getInputTextField() {
- if (inputTextField == null) {
- inputTextField = new JTextField();
- inputTextField.setPreferredSize(new Dimension(150, 20));
- }
- return inputTextField;
- }
-
- public JComboBox getAccountCombo() {
- if (accountCombo == null) {
- List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
- LimaContext.getContext().getDataManager().getAccountModel().getData());
- Vector<AccountDTO> v = new Vector<AccountDTO>(accounts);
- AccountComboBoxModel model = new AccountComboBoxModel(v);
- accountCombo = new JWideComboBox(model);
- accountCombo.setRenderer(AccountComboBoxRenderer.getInstance());
- accountCombo.setPreferredSize(new Dimension(200, 25));
- // AutoCompletion
- AutoCompleteDecorator.decorate(accountCombo, AccountToStringConverter.getInstance());
- }
- return accountCombo;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,125 +0,0 @@
-/**
- * *##% Lima-Callao ErrorMessage
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-
-import org.chorem.lima.util.Util;
-import org.chorem.lima.service.util.ServiceHelper;
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Permet l'affichage des messages des erreurs possibles
- *
- * @author Rémi Chapelet
- */
-public class ErrorMessage {
-
-
- public static void showMessage(String msg)
- {
- if ( msg.equals(ServiceHelper.ACCOUNT_DOUBLE) )
- {
- Util.showMessageDialog( _("lima.error.account.double"));
- }
- if ( msg.equals(ServiceHelper.ACCOUNT_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.account.not.exist"));
- }
- if ( msg.equals(ServiceHelper.ACCOUNT_NOT_MASTER) )
- {
- Util.showMessageDialog( _("lima.error.account.not.master"));
- }
- if ( msg.equals(ServiceHelper.ACCOUNT_WITH_ENTRIES) )
- {
- Util.showMessageDialog( _("lima.error.account.with.entries"));
- }
- if ( msg.equals(ServiceHelper.ENTRY_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.entry.not.remove")+"\n\n"
- + _("lima.error.entry.not.exist"));
- }
- if ( msg.equals(ServiceHelper.JOURNAL_DOUBLE) )
- {
- Util.showMessageDialog( _("lima.error.journal.double"));
- }
- if ( msg.equals(ServiceHelper.JOURNAL_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.journal.not.exist"));
- }
- if ( msg.equals(ServiceHelper.JOURNAL_WITH_TRANSACTIONS) )
- {
- Util.showMessageDialog( _("lima.error.journal.with.transactions"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_ALL_TIMESPAN) )
- {
- Util.showMessageDialog( _("lima.error.period.all.timespan"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_CREATE_TIMESPANS) )
- {
- Util.showMessageDialog( _("lima.error.period.create.timespan"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_NEXT_NOT_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.next.not.blocked"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.period.not.exist"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_PREC_NOT_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.prec.not.blocked"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_TIMESPAN_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.timespan.block"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.timespan.not.blocked"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_BALANCED) )
- {
- Util.showMessageDialog( _("lima.error.transaction.exist.not.balanced"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.transaction.not.remove")+"\n\n"
- + _("lima.error.transaction.not.exist"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_JOURNAL) )
- {
- Util.showMessageDialog(_("lima.error.transaction.not.create")+"\n\n"
- + _("lima.error.transaction.not.journal"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_TIMESPAN) )
- {
- Util.showMessageDialog( _("lima.error.transaction.not.create")+"\n\n"
- + _("lima.error.transaction.not.period"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED) )
- {
- Util.showMessageDialog( _("lima.error.transaction.not.remove")+"\n\n"
- + _("lima.error.transaction.period.not.blocked"));
- }
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,102 +0,0 @@
-/**
- * *##% Lima-main ExportViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.export.CSVExport;
-import org.chorem.lima.export.XMLExport;
-import org.chorem.lima.util.Util;
-import org.chorem.lima.service.util.ServiceHelper;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.*;
-
-
-/**
- * Permet de gérer les fichiers à charger dans le programme.
- *
- * @author Rémi Chapelet
- */
-public class ExportViewImpl extends FileChooseView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(ExportViewImpl.class);
-
- private static XMLExport xmlExport = new XMLExport();
- private static CSVExport cvsExport;
-
- public ExportViewImpl(String type) {
- // chooser est le JFileChooser
- // Ouverture de la boite de dialogue
- chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
-
- if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
- // Récupère le nom du fichier
- String fichier = chooser.getSelectedFile().getName();
- // Récupère l'adresse du fichier
- String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
-
- if (log.isDebugEnabled()) {
- log.debug("Save file : " + fichier + " (" + cheminFichier + ")");
- }
- String result = "";
- /**
- * Action à appeler suivant le choix
- */
- if (type.equals("account")) {
- // Exporter les comptes au format Xml
- result = xmlExport.exportAccount(cheminFichier);
- } else {
- if (type.equals("all_csv")) {
- // Exporter toutes les données au format csv
- cvsExport = new CSVExport(cheminFichier);
- result = cvsExport.exportDatas();
- } else {
- // Exporter toutes les données au format xml
- result = xmlExport.exportFile(cheminFichier);
- }
- }
-
- /**
- * Message de sortie : succès ou erreur
- */
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
- } else {
- Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
- }
-
-
- if (log.isDebugEnabled()) {
- log.debug("File saved : " + fichier + " (" + cheminFichier + ")");
- }
- // Si il y a eu une erreur
-
- }
-
-
- }
-
-
-}
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,4 +1,3 @@
<JFrame title="lima.export">
- <style source="css/lima.css"/>
<JFileChooser id="chooser" width="620" height="400"/>
</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,7 @@
+<Table insets="0,0,0,0" fill="both">
+ <row>
+ <cell>
+ <JLabel text="lima.home"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,109 +0,0 @@
-/**
- * *##% Lima-main ImportViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.imports.CSVImport;
-import org.chorem.lima.imports.CSVImportEBP;
-import org.chorem.lima.imports.XMLImport;
-import org.chorem.lima.service.FileService;
-import org.chorem.lima.service.ServiceFactory;
-import org.chorem.lima.util.Util;
-import org.chorem.lima.service.util.ServiceHelper;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.*;
-
-/**
- * Permet de gérer les fichiers à charger dans le programme.
- *
- * @author Rémi Chapelet
- */
-public class ImportViewImpl extends FileChooseView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(ImportViewImpl.class);
-
- public ImportViewImpl(String type) {
- // chooser est le JFileChooser
- // Ouverture de la boite de dialogue
- chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
- if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
- String fichier = chooser.getSelectedFile().getName();
- String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
-
- if (log.isDebugEnabled()) {
- log.debug("Open file : " + fichier + " (" + cheminFichier + ")");
- }
- String result = "";
- /**
- * Action à appeler suivant le choix
- */
-
- XMLImport xmlImport = new XMLImport();
- if (type.equals("account")) {
- // Importer les comptes au format Xml
- result = xmlImport.importAccount(cheminFichier);
- } else {
- if (type.equals("journal")) {
- // Importer les journaux au format Xml
- result = xmlImport.importJournal(cheminFichier);
- } else {
- if (type.equals("all_csv")) {
- // Importer les données au format csv
- CSVImport cvsimport = new CSVImport(cheminFichier);
- result = cvsimport.importDatas();
- } else {
- if (type.equals("all_csv_ebp")) {
- // Importer les données au format csv
- CSVImportEBP cvsimport = new CSVImportEBP(cheminFichier);
- result = cvsimport.importDatas();
- } else {
- // Importer les données au format Xml
- FileService fileService = ServiceFactory.getServiceFactory().getFileService();
- result = fileService.importFile(cheminFichier);
- LimaContext.getContext().getDataManager().reset();
- }
- }
- }
- }
-
- /**
- * Message de sortie : succès ou erreur
- */
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
- } else {
- Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("File opened : " + fichier + " (" + cheminFichier + ")");
- }
- }
- }
-
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,38 +0,0 @@
-<JFrame locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
-
- <style source="css/lima.css" />
- <Table insets='5,5,5,5'>
- <row>
- <cell>
- <JLabel text="lima.name"/>
- </cell>
- <cell>
- <JTextField id="nameTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.description"/>
- </cell>
- <cell>
- <JTextField id="descriptionTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.prefix"/>
- </cell>
- <cell>
- <JTextField id="prefixTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,26 +0,0 @@
-
-<Table insets='0,0,0,0'>
- <script>
- protected void initAddForm() {};
- protected void initUpdateForm() {};
- protected void removeJournal() {};
- </script>
- <row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
- <JScrollPane id="journalScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.add" onActionPerformed="initAddForm()" width="150"/>
- </cell>
- </row>
- <row>
- <cell >
- <JButton id="updateButton" text="lima.update" onActionPerformed="initUpdateForm()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeJournal()" width="150"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,192 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.table.model.JournalTableModel;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-/**
- * @author ore
- */
-public class JournalViewImpl extends JournalView {
-
- /**
- * log *
- */
- private static final Log log = LogFactory.getLog(JournalViewImpl.class);
- private final JournalForm form;
- private final JXTable table;
- private boolean isAddForm;
-
- public JournalViewImpl() {
- /** Set Journal model */
- table = new JXTable(LimaContext.getContext().getDataManager().getJournalModel());
- table.setRowHeight(24);
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- table.setColumnControlVisible(true);
- getJournalScrollPane().setViewportView(table);
- form = LimaContext.getContext().getMainUI().getJournalForm();
- form.getOkButton().addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(
- ActionEvent e) {
- if (isAddForm) {
- addJournal();
- } else {
- updateJournal();
- }
- }
- });
-
- form.getRootPane().setDefaultButton(form.getOkButton());
- }
-
- /**
- *
- */
- @Override
- protected void initAddForm() {
- isAddForm = true;
- form.setTitle(_("lima.ui.add.journal"));
- form.getNameTextField().setText(DTOHelper.EMPTY_STRING);
- form.getNameTextField().setEditable(true);
- form.getDescriptionTextField().setText(DTOHelper.EMPTY_STRING);
- form.getPrefixTextField().setText(DTOHelper.EMPTY_STRING);
- form.setVisible(true);
- }
-
- /**
- *
- */
- @Override
- protected void initUpdateForm() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- isAddForm = false;
- // Show journal data selected in the form
- JournalDTO journal = getSelectedJournal();
- form.setTitle(_("lima.ui.update.journal"));
- form.getNameTextField().setText(journal.getIdName());
- form.getNameTextField().setEditable(false);
- form.getDescriptionTextField().setText(journal.getDescription());
- form.getPrefixTextField().setText(journal.getPrefix());
- form.setVisible(true);
- }
- }
-
- //TO FIX : champs vides
- /**
- *
- */
- protected void addJournal() {
- if (log.isDebugEnabled()) {
- log.debug("addJournal : ");
- //Get form data
- }
- String name = form.getNameTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String prefix = form.getPrefixTextField().getText();
- form.dispose();
- JournalDTO journal = new JournalDTO("0", name, description, prefix);
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- String result = journalModel.addJournal(journal);
- /**
- * Messages erreurs
- */
- ErrorMessage.showMessage(result);
- }
-
- /**
- *
- */
- protected void updateJournal() {
- if (log.isDebugEnabled()) {
- log.debug("updateJournal : ");
- }
- // Getting form data
- String name = form.getNameTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String prefix = form.getPrefixTextField().getText();
- // Setting new collected data
- JournalDTO journal = getSelectedJournal();
- // Clone
- JournalDTO clone = DTOHelper.cloneJournal(journal);
- clone.setIdName(name);
- clone.setDescription(description);
- clone.setPrefix(prefix);
- form.dispose();
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- String result = journalModel.updateJournal(journal, clone);
- /**
- * Messages erreurs
- */
- ErrorMessage.showMessage(result);
- }
-
- /**
- *
- */
- @Override
- protected void removeJournal() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- int n = JOptionPane.showOptionDialog(this,
- _("lima.question.remove.journal"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
- if (n == JOptionPane.YES_OPTION) {
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- String result = journalModel.removeJournal(getSelectedJournal());
- /**
- * Messages erreurs
- */
- ErrorMessage.showMessage(result);
- }
- }
- }
-
- /**
- * @return
- */
- protected JournalDTO getSelectedJournal() {
- int viewIndex = table.getSelectedRow();
- int modelIndex = table.convertRowIndexToModel(viewIndex);
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- return journalModel.getRow(modelIndex);
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,111 +0,0 @@
-<Table insets='0,0,0,0' fill="both">
- <script>
- protected void addLettering() {};
- protected void removeLettering() {};
- protected void precedentAccount() {};
- protected void nextAccount() {};
- </script>
- <row weightx="1" weighty="0">
- <cell>
- <!-- account -->
- <Table insets='0,0,0,0'>
- <row weightx="0" weighty="0">
- <cell anchor='center' weightx="0" weighty="0">
- <!-- precedent -->
- <JButton id="precedentButton"
- preferredSize='{new Dimension(24,24)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- onActionPerformed='precedentAccount()'
- />
- </cell>
- <cell anchor='center' weightx="0" weighty="0">
- <!-- next -->
- <JButton id="nextButton"
- preferredSize='{new Dimension(24,24)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- onActionPerformed='nextAccount()'
- />
- </cell>
- </row>
- <!-- account -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.account"/>
- </cell>
- <cell weightx="0" weighty="0">
- <JPanel id="accountPanel"/>
- </cell>
- </row>
- <!-- since -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.since"/>
- </cell>
- <cell>
- <JPanel id="sincePanel"/>
- </cell>
- </row>
- <!-- to -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="toPanel"/>
- </cell>
- </row>
- </Table>
- </cell>
- <cell>
- <!-- entries -->
- <Table insets='0,0,0,0' fill="both">
- <row columns="3">
- <cell>
- <JLabel text="lima.entries"/>
- </cell>
- </row>
- <row>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettered' value='{_("lima.lettered")}'
- selected='true'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.not.lettered'
- value='{_("lima.not.lettered")}'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.all' value='{_("lima.all")}'/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <!-- table -->
- <JScrollPane id="tablePanel"/>
- </cell>
- </row>
- <row>
- <cell>
- <!-- add lettering -->
- <JButton id="addButton" text="lima.add.lettering" onActionPerformed="addLettering()"/>
- </cell>
- <cell>
- <!-- remove lettering -->
- <JButton id="removeButton" text="lima.remove.lettering" onActionPerformed="removeLettering()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,118 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
-import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
-import org.nuiton.util.Resource;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author ore
- */
-public class LetteringViewImpl extends LetteringView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(LetteringViewImpl.class);
- private final JWideComboBox accountComboBox;
-
- public LetteringViewImpl() {
- /** Calling services */
- List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
- LimaContext.getContext().getDataManager().getAccountModel().getData());
- /** Creating accounting model */
- Vector<AccountDTO> v1 = new Vector<AccountDTO>(accounts);
- AccountComboBoxModel model = new AccountComboBoxModel(v1);
- accountComboBox = new JWideComboBox();
- accountComboBox.setPreferredSize(new Dimension(200, 25));
- accountComboBox.setModel(model);
- LimaContext.getContext().getDataManager().getAccountModel().addPropertyChangeListener(model);
- accountComboBox.setRenderer(AccountComboBoxRenderer.getInstance());
- accountPanel.add(accountComboBox);
-
- /** AutoCompletion */
- AutoCompleteDecorator.decorate(accountComboBox, AccountToStringConverter.getInstance());
-
- Icon forwardIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Forward24.gif");
- Icon backIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Back24.gif");
- nextButton.setIcon(forwardIcon);
- precedentButton.setIcon(backIcon);
-
- /** Creating period model */
- List<PeriodDTO> periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
- LimaContext.getContext().getNeogiaFactory().getStatusService().getAllStatus()
- );
- Vector<PeriodDTO> v2 = new Vector<PeriodDTO>();
- for (PeriodDTO period : periodes) {
- v2.addElement(period);
- v2.addAll(period.getChildren());
- }
- JWideComboBox sinceComboBox = new JWideComboBox(v2);
- sinceComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
- sinceComboBox.setPreferredSize(new Dimension(200, 25));
- sincePanel.add(sinceComboBox);
-
- JWideComboBox toComboBox = new JWideComboBox(v2);
- toComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
- toComboBox.setPreferredSize(new Dimension(200, 25));
- toPanel.add(toComboBox);
-
- JXTable table = new JXTable();
- tablePanel.setViewportView(table);
- }
-
- /**
- *
- */
- @Override
- protected void nextAccount() {
- if (!(accountComboBox.getSelectedIndex() == accountComboBox.getModel().getSize() - 1)) {
- accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() + 1);
- }
-
- }
-
- /**
- *
- */
- @Override
- protected void precedentAccount() {
- if (!(accountComboBox.getSelectedIndex() == 0)) {
- accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() - 1);
- }
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,9 +1,25 @@
-<JFrame title="lima.title" onWindowClosing="getHandler().close(this)"
+<!-- ##% 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.
+ ##% -->
+<JFrame abstract='true' title="lima.title" onWindowClosing="getHandler().close(this)"
defaultCloseOperation="do_nothing_on_close"
undecorated='{getConfig().isFullScreen()}'
resizable="true" width="800" height="600"
extendedState='{this.MAXIMIZED_BOTH}'>
- <style source="css/lima.css"/>
+
<script><![CDATA[
import java.util.Locale;
import org.chorem.lima.LimaConfig;
@@ -20,29 +36,28 @@
return l != null && l.toString().equals(expected);
}
-protected void onChangeView() {}
-protected void showAccountView() {}
-protected void showAccueilView() {}
-protected void showAddPeriod() {}
-protected void showBalanceView() {}
-protected void showBilanView() {}
-protected void showClosurePeriodView() {}
-protected void showClosureTimeSpanView() {}
-protected void showClosureView() {}
-protected void showExportView(String type) {}
-protected void showImportView(String type) {}
-protected void showJournalView() {}
-protected void showLetteringView() {}
-protected void showReportsView() {}
-protected void showResultView() {}
-protected void showSearchView() {}
-protected void showTransactionView() {}
+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();
]]>
</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")'/>
@@ -50,16 +65,13 @@
<JMenuItem text="lima.import.account" onActionPerformed='showImportView("account")'/>
<JMenuItem text="lima.import.journal" onActionPerformed='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")'/>
</JMenu>
<JSeparator/>
-
- <JMenuItem text="lima.print"
- actionIcon='print'/>
+ <JMenuItem text="lima.print" actionIcon='print'/>
<JSeparator/>
<JMenuItem id='menuFileFullscreen'
text="lima.action.fullscreen"
@@ -68,6 +80,8 @@
mnemonic="P"
visible="{!isUndecorated()}"
onActionPerformed="getHandler().changeScreen(this, true)"/>
+ <JMenuItem text="lima.preferences"
+ actionIcon="config" onActionPerformed="getHandler().showConfig(this)"/>
<JMenuItem id='menuFileNormalscreen'
text="lima.action.normalscreen"
toolTipText="lima.action.normalscreen.tip"
@@ -81,28 +95,34 @@
text="lima.quit" onActionPerformed='getHandler().close(this)'/>
</JMenu>
- <JMenu text="lima.edit">
- <JMenuItem text="lima.journal" onActionPerformed='showJournalView()'
+ <JMenu text="lima.chartofaccounts">
+ <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='showAccountView()'
+ actionIcon='account'/>
+ <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='showJournalView()'
actionIcon='journal'/>
- <JMenuItem text="lima.account" onActionPerformed='showAccountView()'
- actionIcon='account'/>
- <JMenuItem text="lima.find.transaction" onActionPerformed='showSearchView()'
- actionIcon='search'/>
- <JMenuItem text="lima.preferences"
- actionIcon="config" onActionPerformed="getHandler().showConfig(this)"/>
</JMenu>
- <JMenu text="lima.daily">
- <JMenuItem text="lima.edit.transaction" onActionPerformed='showTransactionView()'
+ <JMenu text="lima.fiscalyear">
+ <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='showAddPeriod()'/>
+ <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='showClosureTimeSpanView()'
+ actionIcon='closure-timespan'/>
+ <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='showClosurePeriodView()'/>
+ <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='showClosureView()'
+ actionIcon='closure'/>
+ </JMenu>
+
+ <JMenu text="lima.entries">
+ <JMenuItem text="lima.entries.addtransaction" onActionPerformed='showTransactionView()'
actionIcon='transaction'/>
- <JMenuItem text="lima.lettering" onActionPerformed='showLetteringView()'
+ <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='showSearchView()'
+ actionIcon='search'/>
+ <JMenuItem text="lima.entries.lettering" onActionPerformed='showLetteringView()'
actionIcon='lettering'/>
</JMenu>
<JMenu text="lima.view">
<JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten" onItemStateChanged='onChangeView()'
- selected="false"
- actionIcon='view'/>
+ selected="false" actionIcon='view'/>
</JMenu>
<JMenu text="lima.reports">
@@ -112,18 +132,7 @@
<JMenuItem text="lima.result" onActionPerformed='showResultView()'/>
</JMenu>
- <JMenu text="lima.menubar.closure">
-
- <JMenuItem text="lima.menubar.closure.addPeriod" onActionPerformed='showAddPeriod()'/>
-
- <JMenuItem text="lima.menubar.closure.timespan" onActionPerformed='showClosureTimeSpanView()'
- actionIcon='closure-timespan'/>
-
- <JMenuItem text="lima.menubar.closure.period" onActionPerformed='showClosurePeriodView()'/>
-
- <JMenuItem text="lima.menubar.closure.listperiod" onActionPerformed='showClosureView()'
- actionIcon='closure'/>
- </JMenu>
+
<JMenu text="lima.menu.help" mnemonic="{'H'}">
<JMenuItem id="help" text='lima.menu.help.help' actionIcon="help"
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-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,28 +1,48 @@
+/* *##% 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 static org.nuiton.i18n.I18n.n_;
+
+import java.awt.Desktop;
+import java.net.URL;
+import java.util.Locale;
+
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-import java.awt.*;
-import java.net.URL;
-import java.util.Locale;
-
/**
* User: chemit
* Date: 8 nov. 2009
* Time: 09:59:54
*/
-public class MainViewHandler { //implements JAXXHelp {
+public class MainViewHandler {
/**
* to use log facility, just put in your code: log.info(\"...\");
@@ -39,11 +59,11 @@
public MainView initUI(LimaContext rootContext, boolean fullscreen) {
// show main ui
- final MainView ui = new MainViewImpl(rootContext);
+ MainView ui = new MainViewImpl(rootContext);
LimaContext.MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
- ErrorDialogUI.init(ui);
+ //ErrorDialogUI.init(ui);
// set fullscreen propery on main ui
ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
@@ -130,37 +150,12 @@
ConfigUIBuilder.showConfigUI(configUI, ui, false);
}
- // @Override
public void showHelp(JAXXContext context, String helpId) {
-// MainView mainUI = getUI(context);
-//
-// ObserveHelpBroker helpBroker = context.getContextValue(ObserveHelpBroker.class);
-//
-// if (helpId == null) {
-// helpId = helpBroker.getDefaultID();
-// }
-// log.debug("show help " + helpId);
-// mainUI.getHelp().setCurrentID(helpId);
-//
-// mainUI.setContextValue(mainUI.getMode(), "oldMode");
-// mainUI.setMode(ObserveUIMode.HELP);
+
}
public void closeHelp(JAXXContext context) {
-// MainView mainUI = getUI(context);
-// ObserveUIMode oldMode = mainUI.getContextValue(ObserveUIMode.class, "oldMode");
-// if (oldMode == null) {
-// // on regarde si une base est chargee
-// ObserveDataContext dataContext = context.getContextValue(ObserveDataContext.class);
-// StorageService<?> mainStorage = dataContext.getStorage();
-//
-// if (mainStorage == null) {
-// oldMode = ObserveUIMode.NO_DB;
-// } else {
-// oldMode = ObserveUIMode.DB;
-// }
-// }
-// mainUI.setMode(oldMode);
+
}
public void gotoSite(JAXXContext rootContext) {
@@ -215,7 +210,7 @@
if (ui != null) {
- ErrorDialogUI.init(null);
+ //ErrorDialogUI.init(null);
LimaContext.MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
Modified: 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-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,212 +1,274 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
package org.chorem.lima.ui;
+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 static org.nuiton.i18n.I18n._;
+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;
-import javax.swing.*;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-
/**
* @author ore
*/
public class MainViewImpl extends MainView {
- /**
- * log
- */
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 5339665516073792117L;
+
+ /** log. */
private static final Log log = LogFactory.getLog(MainViewImpl.class);
- private AccueilViewImpl accueilView;
- private ClosureViewImpl closureView;
+
+ private HomeViewImpl homeView;
+
+ private FiscalPeriodView closureView;
+
private TransactionViewImpl transactionView;
+
private TransactionViewImpl searchResultView;
- private JournalViewImpl journalView;
- private AccountViewImpl accountView;
+
+ private EntryBookView journalView;
+
+ private AccountView accountView;
+
private SearchTransactionViewImpl searchView;
+
private ReportsViewImpl reportsView;
+
private ResultViewImpl resultView;
+
private LetteringViewImpl letteringView;
- private AccountForm accountForm;
- private JournalForm journalForm;
+
private ClosureTimeSpanForm closureTimeSpanForm;
+
private BilanViewImpl bilanView;
+
private BalanceViewImpl balanceView;
+
private AddPeriod addPeriod;
- public AccueilViewImpl getAccueilView() {
- if (accueilView == null) {
- accueilView = new AccueilViewImpl();
- }
- return accueilView;
+ 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 AccountForm getAccountForm() {
- if (accountForm == null) {
- accountForm = new AccountForm();
+ public HomeViewImpl getHomeView() {
+ if (homeView == null) {
+ homeView = new HomeViewImpl(this);
}
- return accountForm;
+ return homeView;
}
- public AccountViewImpl getAccountView() {
+ public AccountView getAccountView() {
if (accountView == null) {
- accountView = new AccountViewImpl();
+ accountView = new AccountView(this);
}
return accountView;
}
public AddPeriod getAddPeriod() {
if (addPeriod == null) {
- addPeriod = new AddPeriod();
+ addPeriod = new AddPeriod(this);
}
return addPeriod;
}
public BalanceViewImpl getBalanceView() {
if (balanceView == null) {
- balanceView = new BalanceViewImpl();
+ balanceView = new BalanceViewImpl(this);
}
return balanceView;
}
public BilanViewImpl getBilanView() {
if (bilanView == null) {
- bilanView = new BilanViewImpl();
+ bilanView = new BilanViewImpl(this);
}
return bilanView;
}
public ClosureTimeSpanForm getClosureTimeSpanForm() {
if (closureTimeSpanForm == null) {
- closureTimeSpanForm = new ClosureTimeSpanForm();
+ closureTimeSpanForm = new ClosureTimeSpanForm(this);
}
return closureTimeSpanForm;
}
- public ClosureViewImpl getClosureView() {
+ public FiscalPeriodView getClosureView() {
if (closureView == null) {
- closureView = new ClosureViewImpl();
+ closureView = new FiscalPeriodView(this);
}
return closureView;
}
- public ExportViewImpl getExportView(String type) {
+ /*public ExportViewImpl getExportView(String type) {
ExportViewImpl exportView = new ExportViewImpl(type);
return exportView;
}
public ImportViewImpl getImportView(String type) {
- ImportViewImpl importView = new ImportViewImpl(type);
+ ImportViewImpl importView = new ImportViewImpl(this, type);
return importView;
- }
+ }*/
- public JournalForm getJournalForm() {
- if (journalForm == null) {
- journalForm = new JournalForm();
- }
- return journalForm;
- }
-
- public JournalView getJournalView() {
+ public EntryBookView getEntryBookView() {
if (journalView == null) {
- journalView = new JournalViewImpl();
+ journalView = new EntryBookView(this);
}
return journalView;
}
public LetteringViewImpl getLetteringView() {
if (letteringView == null) {
- letteringView = new LetteringViewImpl();
+ letteringView = new LetteringViewImpl(this);
}
return letteringView;
}
public ReportsView getReportsView() {
if (reportsView == null) {
- reportsView = new ReportsViewImpl();
+ reportsView = new ReportsViewImpl(this);
}
return reportsView;
}
public ResultViewImpl getResultView() {
if (resultView == null) {
- resultView = new ResultViewImpl();
+ resultView = new ResultViewImpl(this);
}
return resultView;
}
public SearchTransactionViewImpl getSearchView() {
if (searchView == null) {
- searchView = new SearchTransactionViewImpl();
+ searchView = new SearchTransactionViewImpl(this);
}
return searchView;
}
public TransactionViewImpl getSearchResultView() {
if (searchResultView == null) {
- searchResultView = new TransactionViewImpl();
+ searchResultView = new TransactionViewImpl(this);
}
return searchResultView;
}
public TransactionViewImpl getTransactionView() {
if (transactionView == null) {
- transactionView = new TransactionViewImpl();
+ 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
*/
- private void showTab(String name, Component container) {
+ protected void showTab(String name, Component container, boolean canClose) {
// if contentTabbedPane doesnot yet contains tab
if (contentTabbedPane.indexOfTab(name) == -1) {
- MyTabHeader panel = new MyTabHeader();
- panel.getLabel().setText(name);
+ ClosableTabHeader closableHeader = new ClosableTabHeader();
+ closableHeader.setTitle(name);
+ closableHeader.setCanClose(canClose);
contentTabbedPane.addTab(name, container);
contentTabbedPane.setSelectedComponent(container);
- contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), panel);
- panel.getCloseTab().addMouseListener(new javax.swing.event.MouseInputAdapter() {
-
+ contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader);
+ closableHeader.getCloseTab().addActionListener(new ActionListener() {
@Override
- public void mouseClicked(MouseEvent e) {
+ public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
- MyTabHeader mytab = (MyTabHeader) button.getParent();
- String name = mytab.getLabel().getText();
+ 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 showAccueilView() {
- showTab(_("lima.tab.home"), getAccueilView());
+ protected void showHomeView() {
+ showTab(_("lima.tab.home"), getHomeView(), false);
}
@Override
@@ -221,31 +283,40 @@
@Override
protected void showClosureView() {
- showTab(_("lima.tab.closure"), getClosureView());
+ 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();
+ //getClosureView().initBlockForm();
}
@Override
protected void showAddPeriod() {
- getClosureView().initAddPeriod();
+ //getClosureView().initAddPeriod();
}
@Override
protected void showImportView(String type) {
- if (!getImportView(type).isEnabled()) {
+ /*if (!getImportView(type).isEnabled()) {
getImportView(type).setEnabled(true);
- }
+ }*/
}
@Override
protected void showExportView(String type) {
- if (!getExportView(type).isEnabled()) {
+ /*if (!getExportView(type).isEnabled()) {
getExportView(type).setEnabled(true);
- }
+ }*/
}
@Override
@@ -273,7 +344,7 @@
@Override
protected void showJournalView() {
- showTab(_("lima.tab.journal"), getJournalView());
+ showTab(_("lima.tab.journal"), getEntryBookView());
}
@Override
@@ -294,66 +365,13 @@
showTab(_("lima.tab.result"), getResultView());
}
-// @Override
-// protected void windowClosing() {
-// if (log.isDebugEnabled()) {
-// log.debug("Shutdown called");
-// }
-// //Main.getActionFactory().fireAction("quit", this);
-// try {
-// dispose();
-// Main.ShutdownHook.interrupted();
-// //Main.getContext().close();
-// Runtime.getRuntime().halt(0);
-// System.exit(0);
-// } catch (Exception ex) {
-// log.error("error while closing " + ex.getMessage(), ex);
-// Runtime.getRuntime().halt(1);
-// }
-// }
-
- public MainViewImpl(JAXXContext c) {
- super(c);
-
-// ContextProvider.checkContextInit();
-
- showAccueilView();
-
-
- // 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();
- }
- }
- }
- }
- });
- }
-
-
@Override
public void dispose() {
// Disposing other windows before main view
- disposeWindow(searchView);
- disposeWindow(journalForm);
- disposeWindow(accountForm);
- disposeWindow(closureTimeSpanForm);
+ //disposeWindow(searchView);
+ //disposeWindow(journalForm);
+ //disposeWindow(accountForm);
+ //disposeWindow(closureTimeSpanForm);
super.dispose();
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,20 +0,0 @@
-<Table insets='0,0,0,0' opaque='false'>
- <row fill='both'>
- <cell anchor='west' weightx="1" insets='0,0,0,0'>
- <JLabel id='label' opaque='false' font-size='12'
- verticalAlignment='center' verticalTextPosition='0'/>
- </cell>
- <cell anchor='east' insets='2,15,0,0' weighty='0'>
- <JButton id='closeTab' preferredSize='{new Dimension(16,16)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- actionIcon='closeTab'
- />
- </cell>
- </row>
-</Table>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,47 +0,0 @@
-
-<Table insets='0,0,0,0'>
- <row>
- <cell fill="horizontal">
- <JLabel text="lima.reports"/>
- </cell>
- <cell>
- <JAXXComboBox>
- <item value='{_("lima.balance")}'/>
- <item value='{_("lima.journal")}'/>
- <item value='{_("lima.grand.livre")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell columns="2">
- <JPanel id="reportsPanel"/>
- </cell>
- </row>
- <row>
- <cell fill="horizontal">
- <JLabel text="lima.period"/>
- </cell>
- <cell>
- <JAXXComboBox>
- <item value='{null}' label=' '/>
- <item value='Exercice 08'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.non.valids.transactions"/>
- </cell>
- <cell>
- <JCheckBox id="nonValidsTransactionsCheckBox"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton text="lima.export.PDF"/>
- </cell>
- <cell>
- <JButton text="lima.export.CSV"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,34 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-
-package org.chorem.lima.ui;
-
-/**
- * @author ore
- */
-public class ReportsViewImpl extends ReportsView {
-
- /**
- * Constructor
- */
- public ReportsViewImpl() {
- }
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,41 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <script>
- protected void update() {};
- </script>
-
- <!-- Choix pour les périodes -->
- <row weightx="2" fill="both" insets="8,40,8,40">
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
-
- <row columns="2" weightx="2" fill="both" insets="8,40,8,40">
- <cell>
- <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="update()" />
- </cell>
- </row>
-
- <!-- Affichage du compte de résultat -->
- <row weightx="1" weighty="6" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tabCharge" />
- </cell>
- <cell>
- <JScrollPane id="tabProduit" />
- </cell>
- </row>
-
- <!-- Affichage du résultat -->
- <row weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tabChargeRes" />
- </cell>
- <cell>
- <JScrollPane id="tabProduitRes" />
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,381 +0,0 @@
-/**
- * *##% Lima-Callao ResultViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.balance.Category;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.table.ResultChargesJXTable;
-import org.chorem.lima.table.ResultProduitsJXTable;
-import org.chorem.lima.table.model.ResultChargesTableModel;
-import org.chorem.lima.table.model.ResultProduitsTableModel;
-import org.chorem.lima.util.Util;
-import static org.nuiton.i18n.I18n._;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.table.DefaultTableModel;
-import javax.swing.*;
-
-import java.awt.event.*;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * Cette classe permet d'afficher le compte de résultat de l'entreprise.
- * Elle utilise quatre tableaux :
- * _ pour produit (identifié par tabProduit)
- * _ pour charge (identifié par tabCharge)
- * _ pour les totaux (identifié par tabChargeRes et tabProduitRes)
- * <p/>
- * Elle va dans un premier temps déterminer les deux tableaux charges et produits.
- * Ensuite, elle va calculer le résultat pour charges et produits.
- * Enfin elle détermine le résultat final suivant le bénéfice ou perte, il sera
- * placé dans les produits ou charges.
- *
- * @author Rémi Chapelet
- */
-public class ResultViewImpl extends ResultView {
-
- private static final Log log = LogFactory.getLog(ResultViewImpl.class);
- private JComboBox comboBoxPeriod = new JComboBox();
- private BalanceHelper balance = new BalanceHelper();
- private JXTable tableChargeRes;
- private JXTable tableProduitRes;
- private String resultat;
- private ResultChargesTableModel modelResultCharges;
- private ResultProduitsTableModel modelResultProduits;
- private DefaultTableModel modelChargeRes;
- private DefaultTableModel modelProduitRes;
-
- public ResultViewImpl() {
-
- // Initialise la combobox pour les périodes
- initComboBoxPeriod();
-
- // Création des modèles
- modelResultCharges = new ResultChargesTableModel(null);
- modelResultProduits = new ResultProduitsTableModel(null);
-
- /**
- * Initialise les tableaux pour afficher les résultats de produits
- * et charges
- */
- String[] columnNames = {"1", "2"};
- // Résultat charges
- modelChargeRes = new DefaultTableModel();
- modelChargeRes.setColumnIdentifiers(columnNames);
- tableChargeRes = new JXTable(modelChargeRes);
- // On cache le header des colonnes
- tableChargeRes.setColumnControlVisible(false);
- tableChargeRes.getTableHeader().setVisible(false);
- // Résultat produits
- modelProduitRes = new DefaultTableModel();
- modelProduitRes.setColumnIdentifiers(columnNames);
- tableProduitRes = new JXTable(modelProduitRes);
- // On cache le header des colonnes
- tableProduitRes.setColumnControlVisible(false);
- tableProduitRes.getTableHeader().setVisible(false);
-
-
- // Charge les produits et charges
- updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
-
- /**
- * CHARGES
- */
- // Création du tableau avec le modèle
- JXTable tableCharge = new ResultChargesJXTable(modelResultCharges);
- // Ajout du tableau
- tabCharge.setViewportView(tableCharge);
-
- /**
- * PRODUITS
- */
- // Création du tableau avec le modèle
- JXTable tableProduit = new ResultProduitsJXTable(modelResultProduits);
- // Ajout du tableau
- tabProduit.setViewportView(tableProduit);
-
- /**
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Actualise le compte de résultat
- updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
- }
- });
-
- }
-
- @Override
- public void update() {
- updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
- }
-
-
- /**
- * Permet d'initialiser le résultat des charges
- *
- * @param totalCharges
- */
- private void initTabChargeRes(String totalCharges) {
- // Définition des données
- Object[] data =
- {_("lima.result.total.charge"), totalCharges};
- // Si il existe déja une ligne
- if (modelChargeRes.getRowCount() > 0) {
- modelChargeRes.removeRow(0);
- }
- // Ajout de la ligne
- modelChargeRes.addRow(data);
- tableChargeRes.setModel(modelChargeRes);
- tabChargeRes.setViewportView(tableChargeRes);
- }
-
- /**
- * Permet d'initialiser le résultat des produits
- *
- * @param totalProduits
- */
- private void initTabProduitRes(String totalProduits) {
- // Définition des données
- Object[] data =
- {_("lima.result.total.produit"), totalProduits};
- // Si il existe déja une ligne
- if (modelProduitRes.getRowCount() > 0) {
- modelProduitRes.removeRow(0);
- }
- // Ajout de la ligne
- modelProduitRes.addRow(data);
- tableProduitRes.setModel(modelProduitRes);
- tabProduitRes.setViewportView(tableProduitRes);
- }
-
-
- /**
- * Permet d'actualiser le modèle produits et charges pour les données. De
- * même, il détermine de nouveau le résultat.
- * Il recherche la balance, puis trie pour prendre seulement les comptes 6
- * et 7. Ensuite il positionne chacun de ses comptes dans la bonne rubrique
- * (produits et charges, financier, exceptionnelles, etc).
- * Enfin, il associe les données aux modèles, et lance le calcul des
- * résultats.
- * @param period
- */
- protected void updateResult(PeriodDTO period) {
- // Chargement de la balance
- List<BalanceDTO> ListbalanceDTO = balance.createBalance(period);
- /**
- * Création tableau associatif pour produits et charges
- */
- // charges
- Hashtable<String, List<BalanceDTO>> chargeTab = new Hashtable<String, List<BalanceDTO>>();
- chargeTab.put("exploitation", new LinkedList<BalanceDTO>());
- chargeTab.put("financier", new LinkedList<BalanceDTO>());
- chargeTab.put("exceptionnel", new LinkedList<BalanceDTO>());
- chargeTab.put("autres", new LinkedList<BalanceDTO>());
- // Produits
- Hashtable<String, List<BalanceDTO>> produitTab = new Hashtable<String, List<BalanceDTO>>();
- produitTab.put("exploitation", new LinkedList<BalanceDTO>());
- produitTab.put("financier", new LinkedList<BalanceDTO>());
- produitTab.put("exceptionnel", new LinkedList<BalanceDTO>());
-
- /**
- * On filtre tous les comptes de balance pour ne prendre que les comptes
- * 6 (charges) et 7 (produits).
- * Ensuite on associe chaque compte à la catégorie dont il appartient dans
- * le compte de résultat.
- * Exemple : 641 rémunération du personnel
- * On recherche sur ce compte dans quelle catégorie il appartient. Ici,
- * catégorie 64, donc à mettre dans Charges-Exploitation
- */
- String totalCharges = "0";
- String totalProduits = "0";
- // Parcours tous les comptes de la balance pour rechercher les comptes 6 et 7
- for (BalanceDTO balanceDTO : ListbalanceDTO) {
- /**
- * CHARGES
- */
- // Exploitation
- if (Category.accountNumberCategory("60", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("61", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("62", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("63", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("64", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("65", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("681", balanceDTO.getAccount().getIdNumber())
- ) {
- chargeTab.get("exploitation").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- // Financières
- if (Category.accountNumberCategory("66", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("686", balanceDTO.getAccount().getIdNumber())) {
- chargeTab.get("financier").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- // Exceptionnelles
- if (Category.accountNumberCategory("67", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("687", balanceDTO.getAccount().getIdNumber())) {
- chargeTab.get("exceptionnel").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- // Autres
- if (Category.accountNumberCategory("691", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("695", balanceDTO.getAccount().getIdNumber())) {
- chargeTab.get("autres").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- /**
- * PRODUIT
- */
- // Exploitation
- if (Category.accountNumberCategory("70", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("71", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("72", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("73", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("74", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("75", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("781", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("791", balanceDTO.getAccount().getIdNumber())
- ) {
- produitTab.get("exploitation").add(balanceDTO);
- totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- // Financières
- if (Category.accountNumberCategory("76", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("786", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("796", balanceDTO.getAccount().getIdNumber())) {
- produitTab.get("financier").add(balanceDTO);
- totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- // Exceptionnelles
- if (Category.accountNumberCategory("77", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("787", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("797", balanceDTO.getAccount().getIdNumber())) {
- produitTab.get("exceptionnel").add(balanceDTO);
- totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
-
- /**
- * Création des tableaux Charges et Produits
- */
- // CHARGES
- List<BalanceDTO> listCharges = new LinkedList<BalanceDTO>();
- BalanceDTO titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
- listCharges.add(titleExploitation);
- listCharges.addAll(chargeTab.get("exploitation"));
- BalanceDTO titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
- listCharges.add(titleFinancier);
- listCharges.addAll(chargeTab.get("financier"));
- BalanceDTO titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
- listCharges.add(titleExceptionnel);
- listCharges.addAll(chargeTab.get("exceptionnel"));
- BalanceDTO titleAutre = new BalanceDTO("Autres", "title", "0", "0", "title", null);
- listCharges.add(titleAutre);
- listCharges.addAll(chargeTab.get("autres"));
- // Création du modèle à partir de la liste précédement créée
- modelResultCharges.setData(listCharges);
- modelResultCharges.fireTableDataChanged();
-
- // PRODUITS
- List<BalanceDTO> listProduits = new LinkedList<BalanceDTO>();
- titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
- listProduits.add(titleExploitation);
- listProduits.addAll(produitTab.get("exploitation"));
- titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
- listProduits.add(titleFinancier);
- listProduits.addAll(produitTab.get("financier"));
- titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
- listProduits.add(titleExceptionnel);
- listProduits.addAll(produitTab.get("exceptionnel"));
- // Création du modèle à partir de la liste précédement créée
- modelResultProduits.setData(listProduits);
- modelResultProduits.fireTableDataChanged();
-
- /**
- * Actualise les résultats
- */
- initTabChargeRes(totalCharges);
- initTabProduitRes(totalProduits);
-
- // Affiche le résultat en produit OU en charge suivant le bénéfice ou perte
- resultat = "0";
- // On efface les résultats (ligne bénéfice ou perte)
- if (modelChargeRes.getRowCount() > 1) {
- modelChargeRes.removeRow(0);
- }
- if (modelProduitRes.getRowCount() > 1) {
- modelProduitRes.removeRow(0);
- }
- // Si les charges sont plus grandes que les produits : pertes
- if (Util.compareTo(totalCharges, totalProduits) == 1) {
- resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
- Object[] data ={_("lima.result.loss"), resultat};
- modelChargeRes.addRow(data);
- modelChargeRes.fireTableDataChanged();
- } else {
- // Sinon profit
- resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
- Object[] data ={_("lima.result.profit"), resultat};
-
- modelProduitRes.addRow(data);
- modelProduitRes.fireTableDataChanged();
- }
- }
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initComboBoxPeriod() {
- // Recherche la liste de toutes les périodes
- List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
- // Model pour les périodes
- Vector<PeriodDTO> v = new Vector<PeriodDTO>();
- // On ajoute un élément null pour permettre d'afficher toutes les périodes
- v.addElement(null);
- // Pour chaque période (annuelle et NON mensuelle !)
- for (PeriodDTO period : periodes) {
- v.addElement(period);
- v.addAll(period.getChildren());
- }
- comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
- public String getResult() {
- return resultat;
- }
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,43 +0,0 @@
-<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
- onWindowClosing="windowClosing()"
- defaultCloseOperation="do_nothing_on_close"
- iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
- <script>
- protected void addCriteriaWidget() {};
- protected void doSearch() {};
- protected void windowClosing() {};
- </script>
- <JScrollPane>
- <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
- <row>
- <cell>
- <JButton id="addButton" text="lima.add" width="100" onActionPerformed="addCriteriaWidget()"/>
- </cell>
- <cell>
- <JLabel text="lima.search.items.where" width="200"/>
- </cell>
- <cell>
- <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
- <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
- <item value='any' label='{_("lima.any.criteria")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell columns="3">
- <VBox id="criteriaWidgetPanel"
- border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
- />
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" onActionPerformed="doSearch()" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="windowClosing()"/>
- </cell>
- </row>
- </Table>
- </JScrollPane>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,217 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.enumeration.FilterEnum;
-import org.chorem.lima.table.TransactionJXTable;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.*;
-
-/**
- * @author ore
- */
-public class SearchTransactionViewImpl extends SearchTransactionView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(SearchTransactionViewImpl.class);
- private final TransactionJXTable table;
-
- public SearchTransactionViewImpl() {
- // At Least one criteria
- CriteriaWidgetImpl widget = new CriteriaWidgetImpl();
- widget.getRemoveButton().setEnabled(false);
- criteriaWidgetPanel.add(widget);
- this.validate();
-
- TransactionViewImpl searchResult = LimaContext.getContext().getMainUI().getSearchResultView();
- searchResult.setFiltreEnabled(false);
- table = searchResult.getTransactionTable();
- getRootPane().setDefaultButton(okButton);
- }
-
- @Override
- protected void addCriteriaWidget() {
- criteriaWidgetPanel.add(new CriteriaWidgetImpl());
- this.validate();
- }
-
- public void removeCriteriaWidget(CriteriaWidget widget) {
- criteriaWidgetPanel.remove(widget);
- this.validate();
- }
-
- protected void showTransactionView() {
- LimaContext.getContext().getMainUI().showSearchResultView();
- }
-
- @Override
- protected void doSearch() {
- if (criteriaWidgetPanel.getComponentCount() > 0) {
- table.getModel().initData();
- table.addColorEmptyLine();
- /** Any or All */
- String allOrAny = (String) criteriaAllAnyComboBox.getSelectedItem();
- boolean all = allOrAny.equals("all");
- for (int i = 0; i < criteriaWidgetPanel.getComponentCount(); i++) {
- CriteriaWidgetImpl myWidget = (CriteriaWidgetImpl) criteriaWidgetPanel.getComponent(i);
- JComboBox comboCriteria = myWidget.getCriteriaComboBox();
- if (comboCriteria.getSelectedIndex() != -1) {
- String itemSelected = (String) comboCriteria.getSelectedItem();
- /**
- * Date item
- */
- if (itemSelected.equals("date")) {
- searchDate(myWidget, FilterEnum.Date, all);
- }
-
- /**
- * Voucher item
- */
- if (itemSelected.equals("voucher")) {
- searchText(myWidget, FilterEnum.Voucher, all);
- }
-
- /**
- * Account item
- */
- if (itemSelected.equals("account")) {
- searchText(myWidget, FilterEnum.Account, all);
- }
-
- /**
- * Description item
- */
- if (itemSelected.equals("description")) {
- searchText(myWidget, FilterEnum.Description, all);
- }
-
- /**
- * Debit item
- */
- if (itemSelected.equals("debit")) {
- searchNumber(myWidget, FilterEnum.Debit, all);
- }
-
- /**
- * Credit item
- */
- if (itemSelected.equals("credit")) {
- searchNumber(myWidget, FilterEnum.Credit, all);
- }
-
- /**
- * Amount item
- */
- if (itemSelected.equals("amount")) {
- searchNumber(myWidget, FilterEnum.Amount, all);
- }
-
- } else {
- throw new NullPointerException();
- }
- } // end for
- } else {
- throw new NullPointerException();
- }
- }
-
- /**
- * @param myWidget
- * @param type
- * @param all
- */
- protected void searchDate(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
- JXDatePicker datePicker = myWidget.getDatePicker();
- if (datePicker.getDate() != null) {
- if (log.isDebugEnabled()) {
- log.debug("search with date : " + datePicker.getDate());
- }
- JComboBox comboNextCriteria = myWidget.getComboBox();
- if (comboNextCriteria.getSelectedIndex() != -1) {
- table.getModel().filter(type, myWidget, all);
- showTransactionView();
- } else {
- throw new NullPointerException();
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- private void searchNumber(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
- JTextField text = myWidget.getInputTextField();
- if (text.getText() != null) {
- if (log.isDebugEnabled()) {
- log.debug("search with number : " + text.getText());
- }
- /**
- * Parse double
- */
- try {
- String value = text.getText();
- Double.parseDouble(value.equals(DTOHelper.EMPTY_STRING) ? "0" : value);
-
- JComboBox comboNextCriteria = myWidget.getComboBox();
- if (comboNextCriteria.getSelectedIndex() != -1) {
- table.getModel().filter(type, myWidget, all);
- showTransactionView();
- } else {
- throw new NullPointerException();
- }
- } catch (NumberFormatException e) {
- JOptionPane.showMessageDialog(this, _("lima.exception.number.format"));
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- private void searchText(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
- JTextField text = myWidget.getInputTextField();
- if (text.getText() != null) {
- if (log.isDebugEnabled()) {
- log.debug("search with text : " + text.getText());
- }
- JComboBox comboNextCriteria = myWidget.getComboBox();
- if (comboNextCriteria.getSelectedIndex() != -1) {
- table.getModel().filter(type, myWidget, all);
- showTransactionView();
- } else {
- throw new NullPointerException();
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- @Override
- protected void windowClosing() {
- this.setVisible(false);
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,48 +0,0 @@
-<Table insets='0,0,0,0'>
- <script>
- protected void addEmptyTransaction() {};
- protected void removeTransaction() {};
- protected void addEmptyEntry() {};
- </script>
- <JPopupMenu id="MenuRightPanel">
- <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
- <JMenuItem text="lima.print"/>
- </JPopupMenu>
- <JPopupMenu id="MenuRightTransaction">
- <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
- <JMenuItem text="lima.print"/>
- </JPopupMenu>
- <row fill="horizontal" weightx="0.75" weighty="0" anchor="center" insets='5,5,5,5'>
- <cell>
- <JLabel id="journalLabel" text="lima.journal"/>
- </cell>
- <cell>
- <JPanel id="journalPanel"/>
- </cell>
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
- <row >
- <cell fill="both" weightx="1" weighty="1" rows='3' columns='4' >
- <JScrollPane id="transactionScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.add.transaction" onActionPerformed="addEmptyTransaction()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.remove.transaction" onActionPerformed="removeTransaction()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton text="lima.add.entry" onActionPerformed="addEmptyEntry()" width="150"/>
- </cell>
- </row>
-
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,372 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import javax.swing.*;
-import java.awt.event.*;
-import java.util.Date;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.model.JournalComboBoxModel;
-import org.chorem.lima.combobox.model.PeriodComboBoxModel;
-import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.EntryDTO;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.enumeration.FilterEnum;
-import org.chorem.lima.listener.ClicRight;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.table.model.*;
-import org.chorem.lima.table.TransactionJXTable;
-import org.chorem.lima.util.Util;
-import static org.nuiton.i18n.I18n._;
-
-
-/**
- * @author ore
- * @author Rémi Chapelet
- */
-public class TransactionViewImpl extends TransactionView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(TransactionViewImpl.class);
- private JComboBox comboJournal;
- private JComboBox comboPeriod;
- private TransactionJXTable transactionTable;
- private TransactionDataTableModel model;
- private TransactionFilteredTableModel filterModel;
- private TransactionSortedTableModel sortedModel;
- private TransactionSortedTableColumnModel columnModel;
- private TransactionFlattenTableModel flattenModel;
-
- public TransactionDataTableModel getModel() {
- if (model == null) {
- model = LimaContext.getContext().getDataManager().getTransactionModel();
- }
- return model;
- }
-
- public TransactionFilteredTableModel getFilterModel() {
- if (filterModel == null) {
- filterModel = new TransactionFilteredTableModel(getModel());
- }
- return filterModel;
- }
-
- public TransactionSortedTableColumnModel getColumnModel() {
- if (columnModel == null) {
- columnModel = new TransactionSortedTableColumnModel(getSortedModel());
- }
- return columnModel;
- }
-
- public TransactionSortedTableModel getSortedModel() {
- if (sortedModel == null) {
- sortedModel = new TransactionSortedTableModel(getFilterModel());
- }
- return sortedModel;
- }
-
- public TransactionFlattenTableModel getFlattenModel() {
- if (flattenModel == null) {
- flattenModel = new TransactionFlattenTableModel(getSortedModel());
- }
- return flattenModel;
- }
-
- public TransactionJXTable getTransactionTable() {
- if (transactionTable == null) {
- transactionTable = new TransactionJXTable(getFlattenModel(), getColumnModel());
- transactionTable.setName("TransactionTable");
- }
- return transactionTable;
- }
-
- public JComboBox getComboJournal() {
- if (comboJournal == null) {
- comboJournal = new JComboBox();
- comboJournal.setName("Liste journal");
- }
- return comboJournal;
- }
-
- public JComboBox getComboPeriod() {
- if (comboPeriod == null) {
- comboPeriod = new JComboBox();
- comboPeriod.setName("Liste periode");
- }
- return comboPeriod;
- }
-
- /**
- * Constructor
- */
- public TransactionViewImpl() {
-
- initJournalComboBox();
- initPeriodComboBox();
-
- getTransactionTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- transactionScrollPane.setViewportView(getTransactionTable());
-
- /**
- * Property change listeners
- */
- getModel().addPropertyChangeListener(getFilterModel());
- getFilterModel().addPropertyChangeListener(getSortedModel());
- getSortedModel().addPropertyChangeListener(getFlattenModel());
-
- getComboJournal().addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- getTransactionTable().removeColorEmptyLine();
- getFlattenModel().initData();
-
- if (e.getStateChange() == ItemEvent.SELECTED) {
- JComboBox comboBox = (JComboBox) e.getSource();
- JournalDTO item = (JournalDTO) comboBox.getSelectedItem();
- getFlattenModel().filter(FilterEnum.Journal, item, true);
- LimaContext.getContext().getDataManager().setCurrentJournal(item);
- }
-
- if (!(getComboPeriod().getSelectedIndex() == -1 || getComboPeriod().getSelectedIndex() == 0)) {
- getFlattenModel().filter(FilterEnum.Period, getComboPeriod().getSelectedItem(), true);
- }
- }
- });
- getComboPeriod().addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- getTransactionTable().removeColorEmptyLine();
- getFlattenModel().initData();
- if (e.getStateChange() == ItemEvent.SELECTED) {
- JComboBox comboBox = (JComboBox) e.getSource();
- PeriodDTO item = (PeriodDTO) comboBox.getSelectedItem();
- getFlattenModel().filter(FilterEnum.Period, item, true);
- LimaContext.getContext().getDataManager().setCurrentPeriod(item);
- }
-
- if (!(getComboJournal().getSelectedIndex() == -1 || getComboJournal().getSelectedIndex() == 0)) {
- getFlattenModel().filter(FilterEnum.Journal, getComboJournal().getSelectedItem(), true);
- }
- }
- });
- /**
- * Permet de mettre la sélection du combobox par défaut sur le mois actuel lors
- * de l'ouverture de la page des transactions.
- */
- int index = 0;
- // Récupère la date actuelle
- Date d = new Date();
- String dateToday = ServiceHelper.dateToMonth(d) + " " + (d.getYear() + 1900);
- for (int i = 0; i <= getComboPeriod().getItemCount(); i++) {
- Object o = getComboPeriod().getItemAt(i);
- if (o != null) {
- if (dateToday.equals(((PeriodDTO) o).getIdName())) {
- index = i;
- }
- }
- }
- if (index != 0){
- getComboPeriod().setSelectedIndex(index);
-
- }
-
- /**
- * Implémente le clic droit
- */
- MouseListener popupListeneTransr = new ClicRight(MenuRightTransaction);
- getTransactionTable().addMouseListener(popupListeneTransr);
- }
-
-
- /**
- * Initialise la combobox contenant les journaux
- */
- private void initJournalComboBox() {
- /** Getting data from journal model **/
- List<JournalDTO> journals = LimaContext.getContext().getDataManager().getJournalModel().getData();
- /** Creating combobox model */
- Vector<JournalDTO> v = new Vector<JournalDTO>(journals.size());
- /** null item */
- v.add(null);
- v.addAll(journals);
- JournalComboBoxModel comboBoxModel = new JournalComboBoxModel(v);
- /** Property Change Listener */
- LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
- getComboJournal().setModel(comboBoxModel);
- getComboJournal().setRenderer(JournalComboBoxRenderer.getInstance());
- // AutoCompletion
- // AutoCompleteDecorator.decorate(comboJournal, JournalToStringConverter.getInstance());
- journalPanel.add(getComboJournal());
- journalPanel.validate();
- }
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initPeriodComboBox() {
- // Recherche la liste de toutes les périodes
-
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- getComboPeriod().setModel(periodModel);
- getComboPeriod().setRenderer(PeriodComboBoxRenderer.getInstance());
- // AutoCompletion
- // AutoCompleteDecorator.decorate(comboPeriod, PeriodToStringConverter.getInstance());
- periodPanel.add(getComboPeriod());
- periodPanel.validate();
- }
-
- /**
- * @param enabled new value
- */
- public void setFiltreEnabled(boolean enabled) {
- getComboPeriod().setEnabled(enabled);
- getComboJournal().setEnabled(enabled);
- }
-
- /**
- * ajout de transaction vide avec le bouton
- */
- @Override
- protected void addEmptyTransaction() {
- String result = transactionTable.getModel().addEmptyTransaction();
- /**
- * Si il n'y pas de message success, alors il existe une erreur.
- * Création de la boite de dialogue avec le message d'erreur correspondant
- */
- ErrorMessage.showMessage(result);
- }
-
- /**
- * suppression de transaction avec le bouton
- */
- @Override
- protected void removeTransaction() {
- // Any row selected
- Integer indexSelectedRow = transactionTable.getSelectedRow();
- if (indexSelectedRow != -1) {
- String message = DTOHelper.isTransaction(
- transactionTable.getModel().getElementAt(indexSelectedRow))
- ? _("lima.question.remove.transaction")
- : _("lima.question.remove.entry");
- int n = Util.showConfirmDialog(message);
- if (n == JOptionPane.YES_OPTION) {
- TransactionTableModel model = transactionTable.getModel();
- // Message de retour
- String result = "";
- if (TransactionFlattenTableModel.isFlattenModel(model)) {
- // Flatten
- TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) transactionTable.getModel();
- flattenModel.removeEmptyLine();
- /**
- * Supprime la ligne sélectionnée : transaction ou entry
- */
- if (DTOHelper.isTransaction(model.getElementAt(indexSelectedRow))) {
- // Transaction
- result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
- } else {
- // Entry
- result = flattenModel.removeEntry((EntryDTO) model.getElementAt(indexSelectedRow));
- }
- transactionTable.addColorEmptyLine();
- } else {
- // Not Flatten
- result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
- }
- /**
- * Messages erreurs
- */
- if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- ErrorMessage.showMessage(message);
- }
- }
- }
- }
-
- /**
- * Implémente le bouton ajout d'une entrée.
- * Permet d'ajouter une ligne comptable sur la transaction sélectionnée.
- */
- @Override
- protected void addEmptyEntry() {
- if (transactionTable.getSelectionModel().isSelectionEmpty()) {
- // Not line selected
- } else {
- // Line selected
- int selectedRow = transactionTable.getSelectedRow();
- int parentIndex = flattenModel.getParentIndex(selectedRow);
- /**
- * Is transaction editable ?
- */
- Object o = flattenModel.getElementAt(parentIndex);
- if (DTOHelper.isTransaction(o)) {
- // Transaction n'est pas éditable
- if (!ServiceHelper.isEditable((TransactionDTO) o)) {
- Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
- return;
- }
- } else {
- //Entry n'est pas éditable
- if (!ServiceHelper.isEditable((EntryDTO) o)) {
- Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
- return;
- }
- }
-
- // Click in not current transaction
- if (flattenModel.getCurrentParentIndex() != parentIndex) {
- int posNext = flattenModel.emptyLineNextPosition(selectedRow);
- /**
- * Once traitement for transaction
- */
- if (flattenModel.isEmptyLineEmpty()) {
- flattenModel.createEmptyLine();
- } else {
- flattenModel.removeEmptyLine();
- selectedRow = transactionTable.getSelectedRow();
- parentIndex = flattenModel.getParentIndex(selectedRow);
- posNext = flattenModel.emptyLineNextPosition(selectedRow);
- flattenModel.createEmptyLine();
- }
- flattenModel.addEmptyLine(posNext);
-
- // To end
- flattenModel.setCurrentParentIndex(parentIndex);
- }
- /**
- * New Line Color
- */
- transactionTable.addColorEmptyLine();
- }
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,74 @@
+<!-- ##% 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 defaultCloseOperation="dispose_on_close" modal="true">
+
+ <org.chorem.lima.entity.Account id="account" javaBean='null'/>
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ setAccount(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.number"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="numberTextField" editable='{isAddState()}' text="{getAccount().getAccountNumber()}"/>
+ <javax.swing.text.Document javaBean="getNumberTextField().getDocument()"
+ onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())'
+ onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.label"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/>
+ <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()"
+ onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())'
+ onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.type"/>
+ </cell>
+ <cell fill="horizontal">
+ <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}'
+ selectedItem="{getAccount().getType()}"
+ onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
+ </cell>
+ </row>
+ <row>
+ <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
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,55 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table>
+
+ <AccountViewHandler id="handler" javaBean="new AccountViewHandler(this)" />
+ <Boolean id="selectedRow" javaBean="false" />
+
+ <script>
+ <![CDATA[
+ //getHandler().init();
+ ]]>
+ </script>
+
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows='3'>
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
+ highlighters='{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}' />
+ <javax.swing.ListSelectionModel javaBean="getAccountsTreeTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal">
+ <JButton id="addButton" text="lima.common.add" onActionPerformed="getHandler().addAccount()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="updateButton" text="lima.common.update" onActionPerformed="getHandler().updateAccount()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="removeButton" text="lima.common.remove" onActionPerformed="getHandler().removeAccount()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,169 @@
+/* *##% 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.account;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+import javax.swing.tree.TreePath;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.ui.account.model.AccountTreeTableModel;
+import org.chorem.lima.ui.account.AccountForm;
+import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.JXTreeTable;
+
+/**
+ * Handler associated with account view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountViewHandler {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountViewHandler.class);
+
+ protected AccountView view;
+
+ protected AccountViewHandler(AccountView view) {
+ this.view = view;
+ }
+
+ /**
+ * Add new account with account form.
+ */
+ public void addAccount() {
+
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+
+ Account newAccount = new AccountImpl();
+ AccountForm accountForm = new AccountForm(view);
+ accountForm.setAccount(newAccount);
+ // jaxx constructor don't call super() ?
+ accountForm.setLocationRelativeTo(view);
+ accountForm.setVisible(true);
+
+ // null == cancel action
+ newAccount = accountForm.getAccount();
+ if (newAccount != null) {
+ // get current selection path
+ TreePath treePath = null;
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ if ( selectedRow != -1) {
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ } else {
+ treePath = new TreePath(accountsTreeTableModel.getRoot());
+ }
+
+ // add it
+ try {
+ accountsTreeTableModel.addAccount(treePath, newAccount);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add account", ex);
+ }
+ }
+ };
+
+ /**
+ * Open account form with selected account.
+ */
+ public void updateAccount() {
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+
+ // get selected account
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null
+ Account selectedAccount = (Account)treePath.getLastPathComponent();
+
+ AccountForm accountForm = new AccountForm(view);
+ accountForm.setAccount(selectedAccount);
+ // jaxx constructor don't call super() ?
+ accountForm.setLocationRelativeTo(view);
+ accountForm.setVisible(true);
+
+ // null == cancel action
+ selectedAccount = accountForm.getAccount();
+ if (selectedAccount != null) {
+ // get current selection path
+ if ( selectedRow != -1) {
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ } else {
+ treePath = new TreePath(accountsTreeTableModel.getRoot());
+ }
+
+ // update it
+ try {
+ accountsTreeTableModel.updateAccount(treePath, selectedAccount);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add account", ex);
+ }
+ }
+ };
+
+ /**
+ * Ask for user to remove for selected account, and remove it if confirmed.
+ */
+ public void removeAccount() {
+
+ // maybe this code can be factorised
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+
+ // Any row selected
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ if ( selectedRow != -1) {
+ int n = JOptionPane.showConfirmDialog(view,
+ _("lima.question.remove.account"),
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ if (n == JOptionPane.YES_OPTION) {
+ // update view of treetable
+ TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ Account account = (Account) treePath.getLastPathComponent();
+ try {
+ accountsTreeTableModel.removeAccount(treePath, account);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't delete account", ex);
+ }
+ }
+ }
+ };
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,240 @@
+/* *##% 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.account.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.swing.tree.TreePath;
+
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+
+/**
+ * Tree table model for account edition.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountTreeTableModel extends AbstractTreeTableModel {
+
+ /** Account service. */
+ protected final AccountService accountService;
+
+ /**
+ * Model constructor. Init account service used here.
+ */
+ public AccountTreeTableModel() {
+ // root
+ super(new AccountImpl());
+ // Gets factory service
+ accountService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ /**
+ * @deprecated can't be used
+ */
+ public Account getData() {
+ return (Account) root;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = null;
+ switch (column) {
+ case 0:
+ res = _("lima.account.number");
+ break;
+ case 1:
+ res = _("lima.account.label");
+ break;
+ }
+ return res;
+ }
+
+ @Override
+ public int getChildCount(Object node) {
+ int result = 0;
+ if (node instanceof Account) {
+ if (node == getRoot()) {
+ try {
+ result = accountService.getChildrenAccounts(null).size();
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ Account parentAccount = (Account) node;
+ try {
+ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.size();
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Object getChild(Object parent, int index) {
+ Object result = null;
+ if (parent == getRoot()) {
+ try {
+ List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ result = allAccounts.get(index);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ Account parentAccount = (Account) parent;
+
+ // FIXME sub account is a collection ?
+ try {
+ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.get(index);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ int result = 0;
+ Account parentAccount = (Account) parent;
+ Account childAccount = (Account) child;
+
+ if (parent == getRoot()) {
+ try {
+ List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ result = allAccounts.indexOf(child);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ // FIXME sub account is a collection ?
+ try {
+ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.indexOf(childAccount);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(Object node, int column) {
+ Object result = "n/a";
+ if (node instanceof Account) {
+ Account account = (Account) node;
+ switch (column) {
+ case 0:
+ result = account.getAccountNumber();
+ break;
+ case 1:
+ result = account.getLabel();
+ break;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isCellEditable(Object node, int column) {
+ return false;
+ }
+
+ @Override
+ public boolean isLeaf(Object node) {
+ return getChildCount(node) == 0;
+ }
+
+ /**
+ * Add account (path can be null).
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void addAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ Account parentAccount = (Account)path.getLastPathComponent();
+ if (parentAccount == getRoot()) {
+ parentAccount = null;
+ }
+
+ accountService.createAccount(parentAccount, account);
+ int index = getIndexOfChild(path.getLastPathComponent(), account);
+ modelSupport.fireChildAdded(path, index, account);
+ }
+
+ /**
+ * Update account.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void updateAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ accountService.updateAccount(account);
+ int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
+ // TODO maybe not working if order change
+ modelSupport.fireChildChanged(path.getParentPath(), index, account);
+ }
+
+ /**
+ * Remove account.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void removeAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
+ accountService.removeAccount(account);
+ modelSupport.fireChildRemoved(path.getParentPath(), index, account);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,79 @@
+/* *##% 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.account.model;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ * Combo box model with accounts types.
+ * (actif, passif, produit, charge).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountTypeListModel extends AbstractListModel implements ComboBoxModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6817328905036446359L;
+
+ protected Object selectedObject;
+
+ /** Data. TODO put string in another place, don't use hard coded string. */
+ protected Object[] data = new Object[]{ "actif", "passif", "produit", "charge" };
+
+ public AccountTypeListModel() {
+ super();
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedObject = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedObject;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return data.length;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return data[index];
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,75 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##% -->
+<JDialog modal="true">
+
+ <org.chorem.lima.entity.EntryBook id="entryBook" javaBean="null" />
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ setEntryBook(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell>
+ <JLabel text="lima.entrybook.label"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookLabelField" editable='{isAddState()}' text="{getEntryBook().getLabel()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookLabelField().getDocument()"
+ onInsertUpdate='getEntryBook().setLabel(getEntryBookLabelField().getText())'
+ onRemoveUpdate='getEntryBook().setLabel(getEntryBookLabelField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.entrybook.description"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookDescriptionField" text="{getEntryBook().getDescription()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookDescriptionField().getDocument()"
+ onInsertUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())'
+ onRemoveUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.entrybook.prefix"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookPrefixField" text="{getEntryBook().getPrefix()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookPrefixField().getDocument()"
+ onInsertUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())'
+ onRemoveUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" onActionPerformed="dispose()"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,58 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table>
+
+ <EntryBookViewHandler id="handler" javaBean="new EntryBookViewHandler(this)" />
+ <!-- Selected row bindings -->
+ <Boolean id="selectedRow" javaBean="false" />
+
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows='4'>
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="entryBooksTable" rowHeight="24"
+ model="{new org.chorem.lima.ui.entrybook.model.EntryBookTableModel()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ columnControlVisible="true"/>
+ <javax.swing.ListSelectionModel javaBean="getEntryBooksTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal">
+ <JButton id="addButton" text="lima.common.add"
+ onActionPerformed="getHandler().addEntryBook()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="updateButton" text="lima.common.update" enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().updateEntryBook()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="removeButton" text="lima.common.remove" enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().deleteEntryBook()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,131 @@
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.entrybook;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.JXTable;
+
+/**
+ * Handler for entry book view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookViewHandler {
+
+ private static final Log log = LogFactory.getLog(EntryBookViewHandler.class);
+
+ protected EntryBookView view;
+
+ public EntryBookViewHandler(EntryBookView view) {
+ this.view = view;
+ }
+
+ public void addEntryBook() {
+
+ JXTable entryBookTable = view.getEntryBooksTable();
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+
+ EntryBook newEntryBook = new EntryBookImpl();
+ EntryBookForm entryBookForm = new EntryBookForm(view);
+ entryBookForm.setEntryBook(newEntryBook);
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+
+ // null == cancel action
+ newEntryBook = entryBookForm.getEntryBook();
+ if (newEntryBook != null) {
+
+ // add it
+ try {
+ entryBookTableModel.addEntryBook(newEntryBook);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add entry book", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add entry book", ex);
+ }
+ }
+ }
+
+ public void updateEntryBook() {
+
+ JXTable entryBookTable = view.getEntryBooksTable();
+ int selectedRow = entryBookTable.getSelectedRow();
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+
+ // add it
+ try {
+ EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ EntryBookForm entryBookForm = new EntryBookForm(view);
+ entryBookForm.setEntryBook(selectedEntryBook);
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+
+ // null == cancel action
+ selectedEntryBook = entryBookForm.getEntryBook();
+ if (selectedEntryBook != null) {
+ entryBookTableModel.updateEntryBook(selectedEntryBook);
+ }
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add update book", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't update entry book", ex);
+ }
+ }
+
+ public void deleteEntryBook() {
+ JXTable entryBookTable = view.getEntryBooksTable();
+ int selectedRow = entryBookTable.getSelectedRow();
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+
+ // add it
+ try {
+ EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+
+ int response = JOptionPane.showConfirmDialog(view, _("Do you really want to delete entry book %s ?", selectedEntryBook.getLabel()),
+ _("Confirmation"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ entryBookTableModel.removeEntryBook(selectedEntryBook);
+ }
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete update book", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't delete entry book", ex);
+ }
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/table/model/JournalTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,214 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.entrybook.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(EntryBookTableModel.class);
+
+ /** Services. */
+ protected EntryBookService entryBookService;
+
+ /**
+ * Constructor.
+ */
+ public EntryBookTableModel() {
+ entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ }
+
+ /*
+ * @return
+ *
+ public List<JournalDTO> getData() {
+ return data;
+ }*/
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ try {
+ result = entryBookService.getAllEntryBooks().size();
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.entrybook.label");
+ break;
+ case 1:
+ res = _("lima.entrybook.description");
+ break;
+ case 2:
+ res = _("lima.entrybook.prefix");
+ break;
+ }
+ return res;
+ }
+
+ public EntryBook getEntryBookAtRow(int row) throws LimaException {
+ EntryBook entryBook = null;
+ entryBook = entryBookService.getAllEntryBooks().get(row);
+
+ return entryBook;
+ }
+
+ /*
+ * @param row
+ * @return
+ *
+ @Override
+ public Object getRow(int row) {
+ return data.get(row);
+ }*/
+
+ @Override
+ public Object getValueAt(int row, int column) {
+
+ Object result = null;
+ try {
+ EntryBook entryBook = getEntryBookAtRow(row);
+
+ switch (column) {
+ case 0:
+ result = entryBook.getLabel();
+ break;
+ case 1:
+ result = entryBook.getDescription();
+ break;
+ case 2:
+ result = entryBook.getPrefix();
+ break;
+ }
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ try {
+ EntryBook entryBook = getEntryBookAtRow(row);
+
+ switch (column) {
+ case 0:
+ entryBook.setLabel((String)value);
+ break;
+ case 1:
+ entryBook.setDescription((String)value);
+ break;
+ case 2:
+ entryBook.setPrefix((String)value);
+ break;
+ }
+
+ // update on remote service
+ entryBookService.updateEntryBook(entryBook);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // TODO why false ?
+ return false;
+ }
+
+ /**
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void addEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ entryBookService.createEntryBook(entryBook);
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ fireTableRowsInserted(row, row);
+ }
+
+ /**
+ *
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void updateEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ entryBookService.updateEntryBook(entryBook);
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ fireTableRowsUpdated(row, row);
+ }
+
+ /**
+ *
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ entryBookService.removeEntryBook(entryBook);
+ fireTableRowsDeleted(row, row);
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,102 @@
+/**
+ * *##% Lima-main ExportViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.export;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.csv.CSVExport;
+import org.chorem.lima.business.ejb.xml.XMLExport;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.*;
+
+
+/**
+ * Permet de gérer les fichiers à charger dans le programme.
+ *
+ * @author Rémi Chapelet
+ */
+public class ExportViewImpl extends FileChooseView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(ExportViewImpl.class);
+
+ private static XMLExport xmlExport = new XMLExport();
+ private static CSVExport cvsExport;
+
+ public ExportViewImpl(String type) {
+ // chooser est le JFileChooser
+ // Ouverture de la boite de dialogue
+ chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+
+ if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
+ // Récupère le nom du fichier
+ String fichier = chooser.getSelectedFile().getName();
+ // Récupère l'adresse du fichier
+ String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Save file : " + fichier + " (" + cheminFichier + ")");
+ }
+ String result = "";
+ /**
+ * Action à appeler suivant le choix
+ */
+ if (type.equals("account")) {
+ // Exporter les comptes au format Xml
+ result = xmlExport.exportAccount(cheminFichier);
+ } else {
+ if (type.equals("all_csv")) {
+ // Exporter toutes les données au format csv
+ cvsExport = new CSVExport(cheminFichier);
+ result = cvsExport.exportDatas();
+ } else {
+ // Exporter toutes les données au format xml
+ result = xmlExport.exportFile(cheminFichier);
+ }
+ }
+
+ /**
+ * Message de sortie : succès ou erreur
+ */
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
+ }
+
+
+ if (log.isDebugEnabled()) {
+ log.debug("File saved : " + fichier + " (" + cheminFichier + ")");
+ }
+ // Si il y a eu une erreur
+
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,109 @@
+/**
+ * *##% Lima-main ImportViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.export;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.ejb.csv.CSVImport;
+import org.chorem.lima.business.ejb.csv.CSVImportEBP;
+import org.chorem.lima.business.ejb.xml.XMLImport;
+import org.chorem.lima.service.FileService;
+import org.chorem.lima.service.ServiceFactory;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.*;
+
+/**
+ * Permet de gérer les fichiers à charger dans le programme.
+ *
+ * @author Rémi Chapelet
+ */
+public class ImportViewImpl extends FileChooseView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(ImportViewImpl.class);
+
+ public ImportViewImpl(String type) {
+ // chooser est le JFileChooser
+ // Ouverture de la boite de dialogue
+ chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+ if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
+ String fichier = chooser.getSelectedFile().getName();
+ String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Open file : " + fichier + " (" + cheminFichier + ")");
+ }
+ String result = "";
+ /**
+ * Action à appeler suivant le choix
+ */
+
+ XMLImport xmlImport = new XMLImport();
+ if (type.equals("account")) {
+ // Importer les comptes au format Xml
+ result = xmlImport.importAccount(cheminFichier);
+ } else {
+ if (type.equals("journal")) {
+ // Importer les journaux au format Xml
+ result = xmlImport.importJournal(cheminFichier);
+ } else {
+ if (type.equals("all_csv")) {
+ // Importer les données au format csv
+ CSVImport cvsimport = new CSVImport(cheminFichier);
+ result = cvsimport.importDatas();
+ } else {
+ if (type.equals("all_csv_ebp")) {
+ // Importer les données au format csv
+ CSVImportEBP cvsimport = new CSVImportEBP(cheminFichier);
+ result = cvsimport.importDatas();
+ } else {
+ // Importer les données au format Xml
+ FileService fileService = ServiceFactory.getServiceFactory().getFileService();
+ result = fileService.importFile(cheminFichier);
+ LimaContext.getContext().getDataManager().reset();
+ }
+ }
+ }
+ }
+
+ /**
+ * Message de sortie : succès ou erreur
+ */
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("File opened : " + fichier + " (" + cheminFichier + ")");
+ }
+ }
+ }
+
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,96 @@
+<!-- ##% 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">
+
+ <script>
+ <![CDATA[
+ import org.nuiton.util.MonthEnum;
+ import org.chorem.lima.entity.FiscalPeriodImpl;
+ import org.chorem.lima.ui.period.model.FiscalPeriodMonthComboBoxModel;
+ import org.chorem.lima.ui.period.model.FiscalPeriodSplinnerModel;
+ import java.util.Calendar;
+
+ protected void performOk() {
+ if (period == null) {
+ // FIXME never ever use IMPL !!!
+ setPeriod(new FiscalPeriodImpl());
+ }
+
+ // get begin date
+ Calendar calendarBegin = Calendar.getInstance();
+ calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal());
+ calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue());
+
+ // get end date
+ Calendar calendarEnd = Calendar.getInstance();
+ calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal());
+ calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue());
+
+ getPeriod().setBeginDate(calendarBegin.getTime());
+ getPeriod().setEndDate(calendarEnd.getTime());
+
+ dispose();
+ }
+
+ protected void performCancel() {
+ setPeriod(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <org.chorem.lima.entity.FiscalPeriod id="period" javaBean="null" />
+
+ <Table fill="both">
+ <row>
+ <cell>
+ <JLabel text="lima.period.begindate"/>
+ </cell>
+ <cell>
+ <JComboBox id="periodBeginMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.JANUARY)}"/>
+ </cell>
+ <cell>
+ <JSpinner id="periodBeginYear" model="{new FiscalPeriodSplinnerModel()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.period.enddate"/>
+ </cell>
+ <cell>
+ <JComboBox id="periodEndMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.DECEMBER)}"/>
+ </cell>
+ <cell>
+ <JSpinner id="periodEndYear" model="{new FiscalPeriodSplinnerModel()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <Table fill="none" anchor="center" weighty="1">
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,19 @@
+<!-- ##% 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.
+ ##% -->
+<JFrame title="lima.export" width="620" height="300" iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
+
+</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,56 @@
+<!-- ##% 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">
+ <style source="styles.css" />
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <Table>
+ <row>
+ <cell>
+ <JLabel text="lima.closure.period.begin"/>
+ </cell>
+ <cell>
+ <JPanel id="beginPeriod"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.to"/>
+ </cell>
+ <cell>
+ <JPanel id="endPeriod"/>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2">
+ <JTextArea styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" />
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="dispose()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,408 @@
+/* *##% 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.period;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.swing.JComboBox;
+import javax.swing.ListSelectionModel;
+import javax.swing.RowFilter;
+
+import jaxx.runtime.JAXXContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.model.PeriodComboBoxModel;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.StatusDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.TriPeriodAsc;
+import org.chorem.lima.dto.util.TriPeriodDesc;
+import org.chorem.lima.table.model.ClosureTableModel;
+import org.chorem.lima.ui.ErrorMessage;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+
+/**
+ * Permet l'affichage du tableau avec les périodes mensuelles.
+ *
+ * @author Rémi Chapelet
+ */
+public class ClosureViewImpl extends ClosureView {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8759564865633991757L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
+
+ private final JXTable table;
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private final ClosureTimeSpanForm form;
+ private final AddPeriod addPeriodForm;
+ private static boolean blockPeriod;
+ private JComboBox comboBoxBeginPeriod = new JComboBox();
+ private JComboBox comboBoxEndPeriod = new JComboBox();
+ private JComboBox comboBeginYearPeriod = new JComboBox();
+ private JComboBox comboBeginMonthPeriod = new JComboBox();
+ private JComboBox comboEndYearPeriod = new JComboBox();
+ private JComboBox comboEndMonthPeriod = new JComboBox();
+
+ /**
+ * @param parentContext
+ */
+ public ClosureViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // Initialisation du choix pour les périodes
+ initComboBoxPeriod();
+
+ /* Set Period model */
+ // Création du model pour le tableau
+ table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
+ table.setRowHeight(24);
+ // Permet d'alterner les couleurs des lignes pour le tableau
+ table.setHighlighters(HighlighterFactory.createAlternateStriping());
+ // Definition de la selection possible sur les lignes
+ table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ table.setColumnControlVisible(true);
+
+ /*
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Récupère la période master
+ PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
+ //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
+ //FilterPipeline filters = new FilterPipeline(filterArray);
+
+ RowFilter<Object, Object> filter = null;
+ if (periodMaster != null) {
+ // 0 = check only in first column
+ // filter :
+ // period name containing selected periode
+ // Final = ??? TODO
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(periodMaster.getBegin());
+ filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0);
+ if (log.isDebugEnabled()) {
+ log.debug("Apply filter on " + calendar.get(Calendar.YEAR));
+ }
+ }
+ table.setRowFilter(filter);
+ }
+ });
+
+ // Ajout du tableau dans l'UI
+ getClosureScrollPane().setViewportView(table);
+
+ /*
+ * Initialisation du formulaire pour bloquer ou débloquer une période.
+ */
+ form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
+ form.getOkButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updatePeriod();
+ }
+ });
+
+ /**
+ * Initialisation du formulaire pour ajouter un exercice
+ */
+ addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
+
+ Calendar cal = Calendar.getInstance();
+
+ //Init YEAR Periode Combobox
+ // take care about previous year #120
+ int todayYear = cal.get(Calendar.YEAR);
+ for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) {
+ comboBeginYearPeriod.addItem(currentYear);
+ comboEndYearPeriod.addItem(currentYear);
+ }
+ comboBeginYearPeriod.setSelectedItem(todayYear);
+ comboEndYearPeriod.setSelectedItem(todayYear);
+
+
+ //Add BeginYear ComboBox to addPeriodForm
+ addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
+ addPeriodForm.getBeginYearPeriodPanel().validate();
+
+ //Add EndYear ComboBox to addPeriodForm
+ addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
+ addPeriodForm.getEndYearPeriodPanel().validate();
+
+ //Init MONTH Periode Combobox
+ cal.set(Calendar.MONTH, Calendar.JANUARY);
+ for (int j = 0; j <= 11; j++) {
+ comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
+ comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
+ cal.add(Calendar.MONTH, 1);
+ }
+
+ //Add BeginMonth ComboBox to addPeriodForm
+ addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
+ addPeriodForm.getBeginMonthPeriodPanel().validate();
+
+ //Add EndMonth ComboBox to addPeriodForm
+ addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
+ addPeriodForm.getEndMonthPeriodPanel().validate();
+
+ addPeriodForm.getOkButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addPeriod();
+ addPeriodForm.dispose();
+ }
+ });
+
+ }
+
+
+ /**
+ * Cette méthode permet de charger les périodes (annuelles) pour choisir
+ * les périodes mensuelles à afficher dans le tableau.
+ */
+ public void initComboBoxPeriod() {
+ /**
+ * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
+ */
+ // Récupère les périodes
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ // Création Combobox debut période
+ comboBoxPeriod.setModel(periodModel);
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Ajout des combobox
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+
+ /**
+ * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
+ * plusieurs périodes.
+ */
+ @Override
+ public void initBlockForm() {
+ blockPeriod = true;
+ form.setTitle(_("lima.ui.block.timespan"));
+ initComboBoxForm();
+ form.setVisible(true);
+ }
+
+
+ /**
+ * Initialise le formulaire pour débloquer des périodes mensuelles.
+ */
+ @Override
+ public void initUnblockForm() {
+ blockPeriod = false;
+ form.setTitle(_("lima.ui.unblock.timespan"));
+ initComboBoxForm();
+ form.setVisible(true);
+ }
+
+
+ /**
+ * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
+ * les deux combobox nécessaires pour début et fin de période.
+ */
+ public void initComboBoxForm() {
+ /**
+ * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
+ */
+ // Récupère les périodes
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ // Création Combobox debut période
+ comboBoxBeginPeriod.setModel(periodModel);
+ comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Création Combobox fin période
+ comboBoxEndPeriod.setModel(periodModel);
+ comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Ajout des combobox
+ form.beginPeriod.add(comboBoxBeginPeriod);
+ form.endPeriod.add(comboBoxEndPeriod);
+
+ /**
+ * Positionne, si les lignes sont sélectionnées, les comboBox sur
+ * les bonnes périodes (période min et période max).
+ */
+ // Si une ou plusieurs lignes sont sélectionnées
+ if (table.getSelectedRow() != -1) {
+ // Récupère les périodes sélectionnées
+ List<PeriodDTO> listPeriod = getSelectedPeriod();
+ // Parcours du vecteur
+ comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
+ comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
+ }
+ }
+
+
+ /**
+ * Permet d'ajouter un nouvel exercice.
+ */
+ protected void addPeriod() {
+ if (log.isDebugEnabled()) {
+ log.debug("addPeriod : ");
+ //Get form data
+ }
+ PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
+ List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
+
+ // get begin date
+ Calendar beginCalendar = Calendar.getInstance();
+ if (periodCurrent != null) {
+ beginCalendar.setTime(periodCurrent.getBegin());
+ }
+ beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem());
+ beginCalendar.set(Calendar.DAY_OF_MONTH, 1);
+ // month is equals to list index
+ beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
+ Date beginDate = beginCalendar.getTime();
+
+ // get end date
+ Calendar endCalendar = Calendar.getInstance();
+ endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem());
+ endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
+ int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+ endCalendar.set(Calendar.DAY_OF_MONTH, maximum);
+ Date endDate = endCalendar.getTime();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Add new periode from " + beginDate + " to " + endDate);
+ }
+
+ String periodName = null;
+ if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) {
+ periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR));
+ }
+ else {
+ periodName = Integer.toString(beginCalendar.get(Calendar.YEAR));
+ }
+
+ // TODO what is status.get(3) ???
+ PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3));
+
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ closureModel.addPeriod(period, status);
+ }
+
+ /**
+ * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
+ * une ou plusieurs périodes, ou bien débloquer.
+ * On récupère l'intervalle des périodes donné par le formulaire. On prend
+ * les périodes aux extrémités.
+ * Si on bloque les périodes, on va trier par ordre croissant sinon par
+ * ordre décroissant. En effet, pour débloquer une période, il est important
+ * que les périodes qui suivent soient bloquées ; par conséquent on doit
+ * commencer par les dernières.
+ */
+ protected void updatePeriod() {
+ // Liste des status
+ List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
+ // Liste des transactions
+ List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
+ // Chargement du model
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ /**
+ * Récupère l'intervalle des périodes sélectionnées
+ */
+ PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
+ PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
+ // Exercice
+ PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
+ // Si block période, on trie la liste en croissant ou bien décroissant
+ List<PeriodDTO> listPeriod = periodMaster.getChildren();
+ if (blockPeriod) {
+ Collections.sort(listPeriod, new TriPeriodAsc());
+ } else {
+ Collections.sort(listPeriod, new TriPeriodDesc());
+ }
+ // Pour toutes les périodes mensuelles
+ for (PeriodDTO period : listPeriod) {
+ if (((period.getBegin().after(periodBegin.getBegin()))
+ && (period.getBegin().before(periodEnd.getBegin())))
+ || (period.equals(periodBegin))
+ || (period.equals(periodEnd))) {
+ if (log.isDebugEnabled()) {
+ log.debug("updatePeriod : " + period.getIdName() + " : "
+ + blockPeriod);
+ }
+ /**
+ * Détection des messages d'erreur
+ */
+ String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
+ ErrorMessage.showMessage(message);
+ }
+ }
+ // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
+ // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
+ // décroissant).
+ if (!blockPeriod) {
+ Collections.sort(listPeriod, new TriPeriodAsc());
+ }
+ form.setVisible(false);
+ form.dispose();
+ }
+
+ /**
+ * Cette méthode permet de retourner une liste des périodes sélectionnées.
+ *
+ * @return liste des périodes sélectionnées
+ */
+ protected List<PeriodDTO> getSelectedPeriod() {
+ // récupère les lignes sélectionnées
+ int viewIndex[] = table.getSelectedRows();
+ // chargement du model (tableau des périodes)
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
+ // Pour chaque ligne sélectionnée
+ for (int i : viewIndex) {
+ int modelIndex = table.convertRowIndexToModel(i);
+ listPeriod.add(closureModel.getRow(modelIndex));
+ }
+ return listPeriod;
+ }
+
+
+ public void initAddPeriod() {
+ addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
+ addPeriodForm.setVisible(true);
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,65 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table>
+
+ <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" />
+ <Boolean id="selectedPeriod" javaBean="false" />
+
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <row fill="horizontal" weightx="1" anchor="center" columns="2">
+ <cell>
+ <JPanel border='{BorderFactory.createTitledBorder(_("lima.period.filter"))}'>
+ <JLabel text="lima.period.periodFilterLabel"/>
+ <JComboBox id="periodFilterComboBox" />
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1">
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="fiscalPeriodTable"
+ model="{new org.chorem.lima.ui.period.model.FiscalPeriodTableModel()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ rowHeight="24"
+ selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
+ columnControlVisible="true" />
+ <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()"
+ onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal" weighty="1" anchor="north">
+ <Table>
+ <row>
+ <cell>
+ <JButton id="addButton" text="lima.period.addFiscalPeriod" onActionPerformed="getHandler().addFiscalPeriod()"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="blockButton" text="lima.period.block" enabled="{isSelectedPeriod()}"
+ onActionPerformed="getHandler().blockFiscalPeriod()" />
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+</Table>
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,103 @@
+/* *##% 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.period;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.period.model.FiscalPeriodTableModel;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodViewHandler {
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class);
+
+ protected FiscalPeriodView view;
+
+ protected FiscalPeriodViewHandler(FiscalPeriodView view) {
+ this.view = view;
+ }
+
+ public void addFiscalPeriod() {
+
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
+
+ AddPeriod addPeriodDialog = new AddPeriod(view);
+ // jaxx don't call super() ?
+ addPeriodDialog.setLocationRelativeTo(view);
+ addPeriodDialog.setVisible(true);
+
+ FiscalPeriod period = addPeriodDialog.getPeriod();
+ // null = cancel
+ if (period != null) {
+
+ Date beginDate = period.getBeginDate();
+ Date endDate = period.getEndDate();
+ // set both to 0:00.000
+ beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
+ endDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
+
+ // on cree pour l'instant des periodes de 1mois
+ Date loopDate = beginDate;
+ while (loopDate.compareTo(endDate) < 0) {
+ Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
+
+ Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ financialPeriod.setBeginDate(loopDate);
+ financialPeriod.setEndDate(periodEndDate);
+ period.addFinancialPeriod(financialPeriod);
+
+ loopDate = loopUpperDate;
+ }
+
+ try {
+ model.addFiscalPeriod(period);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add fiscal period", ex);
+ }
+ ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
+ }
+ }
+ }
+
+ public void blockFiscalPeriod() {
+ throw new NotImplementedException("To be continued...");
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,90 @@
+/* *##% 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.period.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.nuiton.util.MonthEnum;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodMonthComboBoxModel implements ComboBoxModel {
+
+ protected Object selectedMonth;
+
+ public FiscalPeriodMonthComboBoxModel(Object selectedMonth) {
+ this.selectedMonth = selectedMonth;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return MonthEnum.values().length;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return MonthEnum.values()[index].getLibelle();
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedMonth = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedMonth;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,56 @@
+/* *##% 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.period.model;
+
+import java.util.Calendar;
+
+import javax.swing.SpinnerNumberModel;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodSplinnerModel extends SpinnerNumberModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -3647031968061521832L;
+
+ /**
+ * Init modele with current year as initial value.
+ */
+ public FiscalPeriodSplinnerModel() {
+ super();
+
+ Calendar calendar = Calendar.getInstance();
+ int year = calendar.get(Calendar.YEAR);
+ setValue(year);
+
+ // minimum = next year ?
+ setMinimum(year - 1);
+
+ // maximum = ???
+ setMaximum(year + 10);
+ }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,168 @@
+/* *##% 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.period.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 77027335135838258L;
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class);
+
+ protected FiscalPeriodService fiscalPeriodService;
+
+ public FiscalPeriodTableModel() {
+ fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+
+ int result = 0;
+ try {
+ result = fiscalPeriodService.getAllFiscalPeriods().size();
+ }
+ catch (LimaException ex) {
+ // FIXME
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int columnIndex) {
+
+ String result = "n/a";
+
+ switch(columnIndex) {
+ case 0 :
+ result = _("Exercice");
+ break;
+ case 1:
+ result = _("Bloquée");
+ break;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnClass(int)
+ */
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ // both String
+ return String.class;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#isCellEditable(int, int)
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ Object result = "n/a";
+
+ // a refaire, c'est pas optimisé
+ List<FiscalPeriod> periods;
+ try {
+ periods = fiscalPeriodService.getAllFiscalPeriods();
+ FiscalPeriod fiscalPeriod = periods.get(rowIndex);
+
+ switch (columnIndex) {
+ case 0:
+ result = fiscalPeriod.getBeginDate() + " - " + fiscalPeriod.getEndDate();
+ break;
+ case 1:
+ result = fiscalPeriod.getLocked();
+ break;
+ }
+
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
+ */
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+
+ }
+
+ /**
+ * @param period
+ */
+ public void addFiscalPeriod(FiscalPeriod period) throws LimaException {
+
+ int currentRowCount = getRowCount();
+
+ // Calling fiscal period service
+ fiscalPeriodService.createFiscalPeriod(period);
+ fireTableRowsInserted(currentRowCount, currentRowCount);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,8 @@
+.warning {
+ foreground: red;
+ // JTextArea sur plusieurs lignes
+ lineWrap: true;
+ // Implique que les mots ne sont pas coupés
+ wrapStyleWord: true;
+ editable: false;
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,32 @@
+<Table insets="0,0,0,0" fill="both">
+ <script>
+ protected void updateBalance() {};
+ </script>
+
+ <!-- Choix pour les périodes -->
+ <row weightx="2" fill="both" insets="8,40,8,40">
+ <cell>
+ <JLabel id="periodLabel" text="lima.period"/>
+ </cell>
+ <cell>
+ <JPanel id="periodPanel"/>
+ </cell>
+ <cell>
+ <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="updateBalance()" />
+ </cell>
+ </row>
+
+ <!-- Affichage de la balance -->
+ <row columns="3" weightx="1" weighty="10" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tableBalance" />
+ </cell>
+ </row>
+
+ <!-- Affichage du résultat -->
+ <row columns="3" weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tableBalanceRes" />
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,195 @@
+/**
+ * *##% Lima-Callao
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.report;
+
+
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.balance.BalanceHelper;
+import org.chorem.lima.dto.BalanceDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.table.model.BalanceTableModel;
+import org.chorem.lima.table.renderer.BalanceTableCellRenderer;
+import static org.nuiton.i18n.I18n._;
+
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Cette classe permet l'affichage de la balance comptable.
+ *
+ * @author Rémi Chapelet
+ */
+public class BalanceViewImpl extends BalanceView {
+
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private JXTable table;
+ private JXTable tableRes;
+ private BalanceHelper balance = new BalanceHelper();
+ private BalanceTableModel modelBalance;
+ private DefaultTableModel model;
+
+ /**
+ * @param parentContext
+ */
+ public BalanceViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ //Initialise les périodes pour la combobox
+ initComboBoxPeriod();
+
+ /**
+ * Création du model pour le tableau
+ */
+ // Création de la balance
+ List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ // Création de la table
+ modelBalance = new BalanceTableModel(listBalance);
+ table = new JXTable(modelBalance);
+ /** Design de la table */
+ table.setRowHeight(24);
+ // Permet d'alterner les couleurs des lignes pour le tableau
+ table.setHighlighters(HighlighterFactory.createAlternateStriping());
+ table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ table.setColumnControlVisible(true);
+ // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
+ for (int i = 0; i < table.getModel().getColumnCount(); i++) {
+ table.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
+ }
+
+ // Affichage de la table
+ tableBalance.setViewportView(table);
+
+ /**
+ * Calcul pour le total des soldes
+ */
+ model = new DefaultTableModel();
+ String[] columnNames = {"1", "2", "3", "4", "5", "6"};
+ model.setColumnIdentifiers(columnNames);
+ tableRes = new JXTable(model);
+ // On cache le header des colonnes
+ tableRes.setColumnControlVisible(false);
+ tableRes.getTableHeader().setVisible(false);
+ // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
+ for (int i = 0; i < tableRes.getModel().getColumnCount(); i++) {
+ tableRes.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
+ }
+ // Initialise les valeurs pour le résultat total
+ initTableBalanceRes(listBalance);
+
+
+ /**
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Recherche la balance
+ updateBalance();
+ }
+ });
+ }
+
+ /**
+ * Permet de initialiser la table de résultat à chaque appel de cette
+ * méthode.
+ *
+ * @param listBalance
+ */
+ private void initTableBalanceRes(List<BalanceDTO> listBalance) {
+ // Déclaration des variables
+ String TotalMoveDebit = "0";
+ String TotalMoveCredit = "0";
+ String TotalBalanceDebit = "0";
+ String TotalBalanceCredit = "0";
+ // Pour chaque ligne de la balance
+ for (BalanceDTO balanceDTO : listBalance) {
+ /** Calcul des mouvements */
+ TotalMoveDebit = DTOHelper.AddNumbersString(TotalMoveDebit, balanceDTO.getDebit());
+ TotalMoveCredit = DTOHelper.AddNumbersString(TotalMoveCredit, balanceDTO.getCredit());
+ /** Calcul des soldes */
+ if (balanceDTO.getType().equalsIgnoreCase("Actif") ||
+ balanceDTO.getType().equalsIgnoreCase("Charge")) {
+ String solde = DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit());
+ TotalBalanceDebit = DTOHelper.AddNumbersString(solde, TotalBalanceDebit);
+ } else {
+ String solde = DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit());
+ TotalBalanceCredit = DTOHelper.AddNumbersString(solde, TotalBalanceCredit);
+ }
+ }
+ // Définition des données
+ Object[] data =
+ {"", _("lima.balance.total"), TotalMoveDebit, TotalMoveCredit, TotalBalanceDebit, TotalBalanceCredit};
+ // Si il existe déja une ligne
+ if (model.getRowCount() > 0) {
+ model.removeRow(0);
+ }
+ // Ajout de la ligne
+ model.addRow(data);
+ tableRes.setModel(model);
+ tableBalanceRes.setViewportView(tableRes);
+ }
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initComboBoxPeriod() {
+ // Recherche la liste de toutes les périodes
+ List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
+ // Model pour les périodes
+ Vector<PeriodDTO> v = new Vector<PeriodDTO>();
+ // On ajoute un élément null pour permettre d'afficher toutes les périodes
+ v.addElement(null);
+ // Pour chaque période (annuelle et NON mensuelle !)
+ for (PeriodDTO period : periodes) {
+ v.addElement(period);
+ v.addAll(period.getChildren());
+ }
+ comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+ /**
+ * Permet de recharger la balance. Elle appelle la méthode createBalance, qui
+ * va parcourir de nouveau les entrées comptables pour la période, et calculer
+ * la balance.
+ */
+ @Override
+ protected void updateBalance() {
+ // Récupère la liste de la balance
+ List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ modelBalance.setData(listBalance);
+ modelBalance.fireTableDataChanged();
+ initTableBalanceRes(listBalance);
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,29 @@
+<Table insets="0,0,0,0" fill="both">
+ <script>
+ protected void addLettering() {};
+ protected void removeLettering() {};
+ protected void precedentAccount() {};
+ protected void nextAccount() {};
+ </script>
+
+ <!-- Choix pour les périodes -->
+ <row>
+ <cell>
+ <JLabel id="periodLabel" text="lima.period"/>
+ </cell>
+ <cell>
+ <JPanel id="periodPanel"/>
+ </cell>
+ </row>
+
+ <!-- Affichage du bilan (actif et passif) -->
+ <row weightx="1.0" weighty="1.0" anchor="center" fill="both">
+ <cell weightx="0.5">
+ <JScrollPane id="tabActif" />
+ </cell>
+ <cell weightx="0.5">
+ <JScrollPane id="tabPassif" />
+ </cell>
+ </row>
+
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,485 @@
+/**
+ * *##% Lima-Callao BilanViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.report;
+
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.BalanceDTO;
+import org.chorem.lima.bilan.Bilan;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.balance.BalanceHelper;
+import org.chorem.lima.balance.Category;
+import org.chorem.lima.table.BilanActifJXTable;
+import org.chorem.lima.table.BilanPassifJXTable;
+import org.chorem.lima.table.model.BilanActifTableModel;
+import org.chorem.lima.table.model.BilanPassifTableModel;
+import org.chorem.lima.ui.MainViewImpl;
+import org.chorem.lima.ui.ProgressBarImpl;
+
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Cette classe permet de calculer le bilan. Elle utilise la balance et
+ * le compte de résultat.
+ *
+ * @author Rémi Chapelet
+ */
+public class BilanViewImpl extends BilanView {
+
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private BilanActifJXTable tableActif;
+ private BilanPassifJXTable tablePassif;
+ private BilanActifTableModel modelBilanActif;
+ private BilanPassifTableModel modelBilanPassif;
+ Hashtable<String, Bilan> actifTab = new Hashtable<String, Bilan>();
+ Hashtable<String, Bilan> passifTab = new Hashtable<String, Bilan>();
+ Hashtable<String, List<BalanceDTO>> provisionMap;
+ private BalanceHelper balance = new BalanceHelper();
+ private ProgressBarImpl progressBar;
+
+ /**
+ * @param parentContext
+ */
+ public BilanViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // Initialise la combobox pour les périodes
+ initComboBoxPeriod();
+
+ // Création des modèles
+ modelBilanActif = new BilanActifTableModel(new LinkedList<Bilan>());
+ modelBilanPassif = new BilanPassifTableModel(new LinkedList<Bilan>());
+
+
+ // Chargement du bilan
+ //updateBilan();
+
+ /** ACTIF */
+ tableActif = new BilanActifJXTable(modelBilanActif);
+ // Ajout du tableau
+ tabActif.setViewportView(tableActif);
+
+ /** PASSIF */
+ tablePassif = new BilanPassifJXTable(modelBilanPassif);
+ // Ajout du tableau
+ tabPassif.setViewportView(tablePassif);
+
+ /**
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ updateBilan();
+ }
+ });
+
+ }
+
+ /**
+ * Cette partie consiste à créer les catégories du bilan
+ */
+ public void createCategory() {
+ /** ACTIF */
+
+ actifTab.put("ACTIF", new Bilan("TOTAL (1) + (2)", "total", null));
+ actifTab.put("ACTIF_IMMOBILISE", new Bilan("ACTIF IMMOBILISE", "title", null));
+ actifTab.put("ACTIF_IMMOBILISE_INCORPOREL", new Bilan("Immobilisé incorporel", "", null));
+ actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
+ actifTab.put("ACTIF_IMMOBILISE_CORPOREL", new Bilan("Immobilisé corporel", "", null));
+ actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
+ actifTab.put("ACTIF_IMMOBILISE_FINANCIER", new Bilan("Immobilisé financier", "", null));
+ actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
+ actifTab.put("ACTIF_CIRCULANT", new Bilan("ACTIF CIRCULANT", "title", null));
+ actifTab.put("ACTIF_CIRCULANT_STOCK", new Bilan("stocks et en-cours", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
+ actifTab.put("ACTIF_CIRCULANT_AVANCES", new Bilan("av. et ac. versés", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
+ actifTab.put("ACTIF_CIRCULANT_CREANCES", new Bilan("Créances", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
+ actifTab.put("ACTIF_CIRCULANT_VMP", new Bilan("VMP", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_VMP"));
+ actifTab.put("ACTIF_CIRCULANT_DISPONIBILITE", new Bilan("Disponibilités", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
+ actifTab.put("ACTIF_CIRCULANT_CCA", new Bilan("CCA", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CCA"));
+ actifTab.get("ACTIF").add(actifTab.get("ACTIF_IMMOBILISE"));
+ actifTab.get("ACTIF").add(actifTab.get("ACTIF_CIRCULANT"));
+ /** PASSIF */
+ passifTab.put("PASSIF", new Bilan("TOTAL (1) + (2) + (3)", "total", null));
+ passifTab.put("PASSIF_CAPITAUX", new Bilan("CAPITAUX PROPRES", "title", null));
+ passifTab.put("PASSIF_CP_CAPITAL", new Bilan("Capital", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_CAPITAL"));
+ passifTab.put("PASSIF_CP_RESERVES", new Bilan("Réserves", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESERVES"));
+ passifTab.put("PASSIF_CP_RAN", new Bilan("RAN", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RAN"));
+ passifTab.put("PASSIF_CP_RESULTAT", new Bilan("Résultat", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESULTAT"));
+ passifTab.put("PASSIF_CP_SUBVENTION", new Bilan("Subventions d'investissement", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_SUBVENTION"));
+ passifTab.put("PASSIF_CP_PROVISION", new Bilan("Provisions réglementées", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_PROVISION"));
+ passifTab.put("PASSIF_PR_PROVISIONS", new Bilan("PROVISIONS", "title", null));
+ passifTab.put("PASSIF_PROVISIONS", new Bilan("Provisions", "", null));
+ passifTab.get("PASSIF_PR_PROVISIONS").add(passifTab.get("PASSIF_PROVISIONS"));
+ passifTab.put("PASSIF_DETTES", new Bilan("DETTES", "title", null));
+ passifTab.put("PASSIF_DETTES_EMPRUNTS", new Bilan("Emprunts", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
+ passifTab.put("PASSIF_DETTES_AVANCES", new Bilan("av. et ac. reçus", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AVANCES"));
+ passifTab.put("PASSIF_DETTES_FOURNISSEURS", new Bilan("Fournisseurs", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
+ passifTab.put("PASSIF_DETTES_FISCALES", new Bilan("Fiscales/sociales", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FISCALES"));
+ passifTab.put("PASSIF_DETTES_IMMOBILISATIONS", new Bilan("Immobilisations", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
+ passifTab.put("PASSIF_DETTES_AUTRES_DETTES", new Bilan("Autres dettes", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
+ passifTab.put("PASSIF_DETTES_PCA", new Bilan("PCA", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_PCA"));
+ passifTab.get("PASSIF").add(passifTab.get("PASSIF_CAPITAUX"));
+ passifTab.get("PASSIF").add(passifTab.get("PASSIF_CP_PROVISION"));
+ passifTab.get("PASSIF").add(passifTab.get("PASSIF_DETTES"));
+ }
+
+ /**
+ * Permet de calculer le bilan
+ */
+ public void updateBilan() {
+ log.debug("Update bilan :");
+
+ MainViewImpl context = LimaContext.get().getMainUI();
+ progressBar = new ProgressBarImpl(context, context);
+ Runnable runnable = new Runnable() {
+ public void run() {
+ progressBar.setVisible(true);
+ }
+ };
+ SwingUtilities.invokeLater(runnable);
+
+ new Thread() {
+ @Override
+ public void run() {
+
+ progressBar.setTitle("Chargement du bilan");
+ progressBar.getProgressBar().setString("0% : Préparation des données");
+ progressBar.getProgressBar().setValue(0);
+
+ // Chargement de la balance
+ List<BalanceDTO> ListbalanceDTO = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
+
+
+ progressBar.getProgressBar().setString("10% : Balance chargée");
+ progressBar.getProgressBar().setValue(10);
+ /**
+ * Vérifie chaque numéro de compte (balance) pour déterminer sa position
+ * dans le bilan.
+ * Chaque catégorie est un objet bilan, et possède à son tour des bilans
+ * correspondants aux comptes.
+ * Cette boucle ne prend pas en compte les amortissement et provisions.
+ * Ces comptes sont mis dans une liste à part, pour être traités une seconde fois.
+ */
+
+ progressBar.getProgressBar().setString("15% : Création catégorie");
+ progressBar.getProgressBar().setValue(15);
+ createCategory();
+ // Liste amort/prov à traiter apres
+ provisionMap = new Hashtable<String, List<BalanceDTO>>();
+
+ progressBar.getProgressBar().setString("20% : Chargement des comptes");
+ progressBar.getProgressBar().setValue(20);
+ // Récupère le nombre de balances
+ float nbBalances = ListbalanceDTO.size();
+ float incremente = 40 / nbBalances;
+ float value = 20;
+ // Pour chaque balance
+ for (BalanceDTO balanceDTO : ListbalanceDTO) {
+ /**
+ * ACTIF
+ */
+ /** IMMOBILISATION */
+ if (Category.accountNumberCategory("20", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("21", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("22", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("23", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("25", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("26", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("27", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ /** ACTIF CIRCULANT */
+ if (Category.accountNumberCategory("31", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("32", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("33", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("34", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("35", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("36", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("37", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_STOCK").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("99", balanceDTO.getAccount().getIdNumber())) {
+ // TODO
+ //actifTab.get("ACTIF_CIRCULANT_AVANCES").add(balanceDTO,Util.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("41", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("50", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_VMP").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("51", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("52", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("53", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("54", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("486", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_CCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ /** AMORT. & PROV. */
+ if (Category.accountNumberCategory("280", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_IMMOBILISE_INCORPOREL", listBalance);
+ }
+ provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO);
+ }
+ if (Category.accountNumberCategory("281", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_IMMOBILISE_CORPOREL", listBalance);
+ }
+ provisionMap.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO);
+ }
+ if (Category.accountNumberCategory("282", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_IMMOBILISE_FINANCIER", listBalance);
+ }
+ provisionMap.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO);
+ }
+ if (Category.accountNumberCategory("491", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_CIRCULANT_CREANCES", listBalance);
+ }
+ provisionMap.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO);
+ }
+ /**
+ * PASSIF
+ */
+ /** CAPITAUX PROPRES */
+ if (Category.accountNumberCategory("101", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("104", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("105", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("107", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("108", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("109", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_CAPITAL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("106", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_RESERVES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("11", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_RAN").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("12", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_RESULTAT").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("13", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_SUBVENTION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("14", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_PROVISION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ /** PROVISIONS */
+ if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_PROVISIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ /** DETTES */
+ if (Category.accountNumberCategory("16", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_EMPRUNTS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_AVANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("40", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_FOURNISSEURS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("43", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("44", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_FISCALES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("999", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_IMMOBILISATIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("9999", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_AUTRES_DETTES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("487", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_PCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ // Incrémente la barre de chargement
+ value = value + incremente;
+ progressBar.getProgressBar().setValue((int) value);
+ progressBar.getProgressBar().setString((int) value + "% : Compte : " + balanceDTO.getName());
+ }
+
+ progressBar.getProgressBar().setString("60% : Mise en place des amortissements et provisions");
+ progressBar.getProgressBar().setValue(60);
+ /**
+ * Mise en place des provisions et amortissements
+ */
+ if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+ if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_CORPOREL");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_IMMOBILISE_CORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+ if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_FINANCIER");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_IMMOBILISE_FINANCIER").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+ if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_CIRCULANT_CREANCES");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_CIRCULANT_CREANCES").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+
+ progressBar.getProgressBar().setString("70% : Calcul du résultat");
+ progressBar.getProgressBar().setValue(70);
+ /**
+ * Appel de la méthode du calcul du compte de résultat pour avoir le
+ * résultat
+ */
+ ResultViewImpl resultViewImpl = new ResultViewImpl();
+ resultViewImpl.updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ passifTab.get("PASSIF_CP_RESULTAT").add(new Bilan("Résultat", "", resultViewImpl.getResult(), "0"), resultViewImpl.getResult());
+
+ progressBar.getProgressBar().setString("90% : Création des tableaux");
+ progressBar.getProgressBar().setValue(90);
+ /**
+ * Ajout des données dans le model
+ */
+ /** ACTIF */
+ List<Bilan> listActif = new LinkedList<Bilan>();
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE"));
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
+ listActif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", actifTab.get("ACTIF_IMMOBILISE").getTotal(), actifTab.get("ACTIF_IMMOBILISE").getDepreciation()));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_VMP"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_CCA"));
+ listActif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", actifTab.get("ACTIF_CIRCULANT").getTotal(), actifTab.get("ACTIF_CIRCULANT").getDepreciation()));
+ listActif.add(actifTab.get("ACTIF"));
+
+ // Création du modèle à partir de la liste précédement créée
+ modelBilanActif.setData(listActif);
+ modelBilanActif.fireTableDataChanged();
+
+ /** PASSIF */
+ List<Bilan> listPassif = new LinkedList<Bilan>();
+ listPassif.add(passifTab.get("PASSIF_CAPITAUX"));
+ listPassif.add(passifTab.get("PASSIF_CP_CAPITAL"));
+ listPassif.add(passifTab.get("PASSIF_CP_RESULTAT"));
+ listPassif.add(passifTab.get("PASSIF_CP_RESERVES"));
+ listPassif.add(passifTab.get("PASSIF_CP_RAN"));
+ listPassif.add(passifTab.get("PASSIF_CP_SUBVENTION"));
+ listPassif.add(passifTab.get("PASSIF_CP_PROVISION"));
+ listPassif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", passifTab.get("PASSIF_CAPITAUX").getTotal(), "0"));
+ listPassif.add(passifTab.get("PASSIF_PR_PROVISIONS"));
+ listPassif.add(passifTab.get("PASSIF_PROVISIONS"));
+ listPassif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", passifTab.get("PASSIF_PR_PROVISIONS").getTotal(), "0"));
+ listPassif.add(passifTab.get("PASSIF_DETTES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_AVANCES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_FISCALES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_PCA"));
+ listPassif.add(new Bilan("SOUS-TOTAL (3)", "soustotal", passifTab.get("PASSIF_DETTES").getTotal(), "0"));
+ listPassif.add(passifTab.get("PASSIF"));
+
+ progressBar.getProgressBar().setString("90% : Opération terminée");
+ progressBar.getProgressBar().setValue(90);
+ // Création du modèle à partir de la liste précédement créée
+ modelBilanPassif.setData(listPassif);
+ progressBar.getProgressBar().setValue(95);
+ modelBilanPassif.fireTableDataChanged();
+ progressBar.getProgressBar().setValue(100);
+ progressBar.dispose();
+ }
+ }.start();
+
+ }
+
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initComboBoxPeriod() {
+ // Recherche la liste de toutes les périodes
+ List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
+ // Model pour les périodes
+ Vector<PeriodDTO> v = new Vector<PeriodDTO>();
+ // On ajoute un élément null pour permettre d'afficher toutes les périodes
+ v.addElement(null);
+ // Pour chaque période (annuelle et NON mensuelle !)
+ for (PeriodDTO period : periodes) {
+ v.addElement(period);
+ //v.addAll(period.getChildren());
+ }
+
+ comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,47 @@
+
+<Table insets='0,0,0,0'>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.reports"/>
+ </cell>
+ <cell>
+ <JAXXComboBox>
+ <item value='{_("lima.balance")}'/>
+ <item value='{_("lima.journal")}'/>
+ <item value='{_("lima.grand.livre")}'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2">
+ <JPanel id="reportsPanel"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.period"/>
+ </cell>
+ <cell>
+ <JAXXComboBox>
+ <item value='{null}' label=' '/>
+ <item value='Exercice 08'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.non.valids.transactions"/>
+ </cell>
+ <cell>
+ <JCheckBox id="nonValidsTransactionsCheckBox"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton text="lima.export.PDF"/>
+ </cell>
+ <cell>
+ <JButton text="lima.export.CSV"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,39 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+
+package org.chorem.lima.ui.report;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class ReportsViewImpl extends ReportsView {
+
+ /**
+ * @param parentContext
+ */
+ public ReportsViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+ }
+
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,41 @@
+<Table insets="0,0,0,0" fill="both">
+ <script>
+ protected void update() {};
+ </script>
+
+ <!-- Choix pour les périodes -->
+ <row weightx="2" fill="both" insets="8,40,8,40">
+ <cell>
+ <JLabel id="periodLabel" text="lima.period"/>
+ </cell>
+ <cell>
+ <JPanel id="periodPanel"/>
+ </cell>
+ </row>
+
+ <row columns="2" weightx="2" fill="both" insets="8,40,8,40">
+ <cell>
+ <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="update()" />
+ </cell>
+ </row>
+
+ <!-- Affichage du compte de résultat -->
+ <row weightx="1" weighty="6" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tabCharge" />
+ </cell>
+ <cell>
+ <JScrollPane id="tabProduit" />
+ </cell>
+ </row>
+
+ <!-- Affichage du résultat -->
+ <row weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tabChargeRes" />
+ </cell>
+ <cell>
+ <JScrollPane id="tabProduitRes" />
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,387 @@
+/**
+ * *##% Lima-Callao ResultViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.report;
+
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.balance.BalanceHelper;
+import org.chorem.lima.balance.Category;
+import org.chorem.lima.dto.BalanceDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.table.ResultChargesJXTable;
+import org.chorem.lima.table.ResultProduitsJXTable;
+import org.chorem.lima.table.model.ResultChargesTableModel;
+import org.chorem.lima.table.model.ResultProduitsTableModel;
+import org.chorem.lima.util.Util;
+import static org.nuiton.i18n.I18n._;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.table.DefaultTableModel;
+import javax.swing.*;
+
+import java.awt.event.*;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Cette classe permet d'afficher le compte de résultat de l'entreprise.
+ * Elle utilise quatre tableaux :
+ * _ pour produit (identifié par tabProduit)
+ * _ pour charge (identifié par tabCharge)
+ * _ pour les totaux (identifié par tabChargeRes et tabProduitRes)
+ * <p/>
+ * Elle va dans un premier temps déterminer les deux tableaux charges et produits.
+ * Ensuite, elle va calculer le résultat pour charges et produits.
+ * Enfin elle détermine le résultat final suivant le bénéfice ou perte, il sera
+ * placé dans les produits ou charges.
+ *
+ * @author Rémi Chapelet
+ */
+public class ResultViewImpl extends ResultView {
+
+ private static final Log log = LogFactory.getLog(ResultViewImpl.class);
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private BalanceHelper balance = new BalanceHelper();
+ private JXTable tableChargeRes;
+ private JXTable tableProduitRes;
+ private String resultat;
+ private ResultChargesTableModel modelResultCharges;
+ private ResultProduitsTableModel modelResultProduits;
+ private DefaultTableModel modelChargeRes;
+ private DefaultTableModel modelProduitRes;
+
+ /**
+ * @param parentContext
+ */
+ public ResultViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // Initialise la combobox pour les périodes
+ initComboBoxPeriod();
+
+ // Création des modèles
+ modelResultCharges = new ResultChargesTableModel(null);
+ modelResultProduits = new ResultProduitsTableModel(null);
+
+ /**
+ * Initialise les tableaux pour afficher les résultats de produits
+ * et charges
+ */
+ String[] columnNames = {"1", "2"};
+ // Résultat charges
+ modelChargeRes = new DefaultTableModel();
+ modelChargeRes.setColumnIdentifiers(columnNames);
+ tableChargeRes = new JXTable(modelChargeRes);
+ // On cache le header des colonnes
+ tableChargeRes.setColumnControlVisible(false);
+ tableChargeRes.getTableHeader().setVisible(false);
+ // Résultat produits
+ modelProduitRes = new DefaultTableModel();
+ modelProduitRes.setColumnIdentifiers(columnNames);
+ tableProduitRes = new JXTable(modelProduitRes);
+ // On cache le header des colonnes
+ tableProduitRes.setColumnControlVisible(false);
+ tableProduitRes.getTableHeader().setVisible(false);
+
+
+ // Charge les produits et charges
+ updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+
+ /**
+ * CHARGES
+ */
+ // Création du tableau avec le modèle
+ JXTable tableCharge = new ResultChargesJXTable(modelResultCharges);
+ // Ajout du tableau
+ tabCharge.setViewportView(tableCharge);
+
+ /**
+ * PRODUITS
+ */
+ // Création du tableau avec le modèle
+ JXTable tableProduit = new ResultProduitsJXTable(modelResultProduits);
+ // Ajout du tableau
+ tabProduit.setViewportView(tableProduit);
+
+ /**
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Actualise le compte de résultat
+ updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ }
+ });
+
+ }
+
+ @Override
+ public void update() {
+ updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ }
+
+
+ /**
+ * Permet d'initialiser le résultat des charges
+ *
+ * @param totalCharges
+ */
+ private void initTabChargeRes(String totalCharges) {
+ // Définition des données
+ Object[] data =
+ {_("lima.result.total.charge"), totalCharges};
+ // Si il existe déja une ligne
+ if (modelChargeRes.getRowCount() > 0) {
+ modelChargeRes.removeRow(0);
+ }
+ // Ajout de la ligne
+ modelChargeRes.addRow(data);
+ tableChargeRes.setModel(modelChargeRes);
+ tabChargeRes.setViewportView(tableChargeRes);
+ }
+
+ /**
+ * Permet d'initialiser le résultat des produits
+ *
+ * @param totalProduits
+ */
+ private void initTabProduitRes(String totalProduits) {
+ // Définition des données
+ Object[] data =
+ {_("lima.result.total.produit"), totalProduits};
+ // Si il existe déja une ligne
+ if (modelProduitRes.getRowCount() > 0) {
+ modelProduitRes.removeRow(0);
+ }
+ // Ajout de la ligne
+ modelProduitRes.addRow(data);
+ tableProduitRes.setModel(modelProduitRes);
+ tabProduitRes.setViewportView(tableProduitRes);
+ }
+
+
+ /**
+ * Permet d'actualiser le modèle produits et charges pour les données. De
+ * même, il détermine de nouveau le résultat.
+ * Il recherche la balance, puis trie pour prendre seulement les comptes 6
+ * et 7. Ensuite il positionne chacun de ses comptes dans la bonne rubrique
+ * (produits et charges, financier, exceptionnelles, etc).
+ * Enfin, il associe les données aux modèles, et lance le calcul des
+ * résultats.
+ * @param period
+ */
+ protected void updateResult(PeriodDTO period) {
+ // Chargement de la balance
+ List<BalanceDTO> ListbalanceDTO = balance.createBalance(period);
+ /**
+ * Création tableau associatif pour produits et charges
+ */
+ // charges
+ Hashtable<String, List<BalanceDTO>> chargeTab = new Hashtable<String, List<BalanceDTO>>();
+ chargeTab.put("exploitation", new LinkedList<BalanceDTO>());
+ chargeTab.put("financier", new LinkedList<BalanceDTO>());
+ chargeTab.put("exceptionnel", new LinkedList<BalanceDTO>());
+ chargeTab.put("autres", new LinkedList<BalanceDTO>());
+ // Produits
+ Hashtable<String, List<BalanceDTO>> produitTab = new Hashtable<String, List<BalanceDTO>>();
+ produitTab.put("exploitation", new LinkedList<BalanceDTO>());
+ produitTab.put("financier", new LinkedList<BalanceDTO>());
+ produitTab.put("exceptionnel", new LinkedList<BalanceDTO>());
+
+ /**
+ * On filtre tous les comptes de balance pour ne prendre que les comptes
+ * 6 (charges) et 7 (produits).
+ * Ensuite on associe chaque compte à la catégorie dont il appartient dans
+ * le compte de résultat.
+ * Exemple : 641 rémunération du personnel
+ * On recherche sur ce compte dans quelle catégorie il appartient. Ici,
+ * catégorie 64, donc à mettre dans Charges-Exploitation
+ */
+ String totalCharges = "0";
+ String totalProduits = "0";
+ // Parcours tous les comptes de la balance pour rechercher les comptes 6 et 7
+ for (BalanceDTO balanceDTO : ListbalanceDTO) {
+ /**
+ * CHARGES
+ */
+ // Exploitation
+ if (Category.accountNumberCategory("60", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("61", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("62", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("63", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("64", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("65", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("681", balanceDTO.getAccount().getIdNumber())
+ ) {
+ chargeTab.get("exploitation").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ // Financières
+ if (Category.accountNumberCategory("66", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("686", balanceDTO.getAccount().getIdNumber())) {
+ chargeTab.get("financier").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ // Exceptionnelles
+ if (Category.accountNumberCategory("67", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("687", balanceDTO.getAccount().getIdNumber())) {
+ chargeTab.get("exceptionnel").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ // Autres
+ if (Category.accountNumberCategory("691", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("695", balanceDTO.getAccount().getIdNumber())) {
+ chargeTab.get("autres").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ /**
+ * PRODUIT
+ */
+ // Exploitation
+ if (Category.accountNumberCategory("70", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("71", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("72", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("73", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("74", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("75", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("781", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("791", balanceDTO.getAccount().getIdNumber())
+ ) {
+ produitTab.get("exploitation").add(balanceDTO);
+ totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ // Financières
+ if (Category.accountNumberCategory("76", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("786", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("796", balanceDTO.getAccount().getIdNumber())) {
+ produitTab.get("financier").add(balanceDTO);
+ totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ // Exceptionnelles
+ if (Category.accountNumberCategory("77", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("787", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("797", balanceDTO.getAccount().getIdNumber())) {
+ produitTab.get("exceptionnel").add(balanceDTO);
+ totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+
+ /**
+ * Création des tableaux Charges et Produits
+ */
+ // CHARGES
+ List<BalanceDTO> listCharges = new LinkedList<BalanceDTO>();
+ BalanceDTO titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
+ listCharges.add(titleExploitation);
+ listCharges.addAll(chargeTab.get("exploitation"));
+ BalanceDTO titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
+ listCharges.add(titleFinancier);
+ listCharges.addAll(chargeTab.get("financier"));
+ BalanceDTO titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
+ listCharges.add(titleExceptionnel);
+ listCharges.addAll(chargeTab.get("exceptionnel"));
+ BalanceDTO titleAutre = new BalanceDTO("Autres", "title", "0", "0", "title", null);
+ listCharges.add(titleAutre);
+ listCharges.addAll(chargeTab.get("autres"));
+ // Création du modèle à partir de la liste précédement créée
+ modelResultCharges.setData(listCharges);
+ modelResultCharges.fireTableDataChanged();
+
+ // PRODUITS
+ List<BalanceDTO> listProduits = new LinkedList<BalanceDTO>();
+ titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
+ listProduits.add(titleExploitation);
+ listProduits.addAll(produitTab.get("exploitation"));
+ titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
+ listProduits.add(titleFinancier);
+ listProduits.addAll(produitTab.get("financier"));
+ titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
+ listProduits.add(titleExceptionnel);
+ listProduits.addAll(produitTab.get("exceptionnel"));
+ // Création du modèle à partir de la liste précédement créée
+ modelResultProduits.setData(listProduits);
+ modelResultProduits.fireTableDataChanged();
+
+ /**
+ * Actualise les résultats
+ */
+ initTabChargeRes(totalCharges);
+ initTabProduitRes(totalProduits);
+
+ // Affiche le résultat en produit OU en charge suivant le bénéfice ou perte
+ resultat = "0";
+ // On efface les résultats (ligne bénéfice ou perte)
+ if (modelChargeRes.getRowCount() > 1) {
+ modelChargeRes.removeRow(0);
+ }
+ if (modelProduitRes.getRowCount() > 1) {
+ modelProduitRes.removeRow(0);
+ }
+ // Si les charges sont plus grandes que les produits : pertes
+ if (Util.compareTo(totalCharges, totalProduits) == 1) {
+ resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
+ Object[] data ={_("lima.result.loss"), resultat};
+ modelChargeRes.addRow(data);
+ modelChargeRes.fireTableDataChanged();
+ } else {
+ // Sinon profit
+ resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
+ Object[] data ={_("lima.result.profit"), resultat};
+
+ modelProduitRes.addRow(data);
+ modelProduitRes.fireTableDataChanged();
+ }
+ }
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initComboBoxPeriod() {
+ // Recherche la liste de toutes les périodes
+ List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
+ // Model pour les périodes
+ Vector<PeriodDTO> v = new Vector<PeriodDTO>();
+ // On ajoute un élément null pour permettre d'afficher toutes les périodes
+ v.addElement(null);
+ // Pour chaque période (annuelle et NON mensuelle !)
+ for (PeriodDTO period : periodes) {
+ v.addElement(period);
+ v.addAll(period.getChildren());
+ }
+ comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+ public String getResult() {
+ return resultat;
+ }
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,41 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table insets='5,5,5,5'>
+ <script>
+ protected void removeCriteriaWidget(){}
+ </script>
+ <row>
+ <cell>
+ <JAXXComboBox id="criteriaComboBox" width="200">
+ <item value='date' label='{_("lima.date")}' selected="true"/>
+ <item value='voucher' label='{_("lima.voucher")}'/>
+ <item value='account' label='{_("lima.account")}'/>
+ <item value='description' label='{_("lima.description")}'/>
+ <item value='debit' label='{_("lima.debit")}'/>
+ <item value='credit' label='{_("lima.credit")}'/>
+ <item value='amount' label='{_("lima.amount")}'/>
+ </JAXXComboBox>
+ </cell>
+ <cell weightx="0">
+ <JPanel id="criteriaPanel"/>
+ </cell>
+ <cell>
+ <JButton id="removeButton" text="lima.remove" onActionPerformed="removeCriteriaWidget()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,217 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import static org.nuiton.i18n.I18n._;
+import org.chorem.lima.combobox.JWideComboBox;
+import org.chorem.lima.combobox.model.AccountComboBoxModel;
+import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.item.Item;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.util.AccountToStringConverter;
+import org.jdesktop.swingx.JXDatePicker;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class CriteriaWidgetImpl extends CriteriaWidget {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(CriteriaWidgetImpl.class);
+ private JTextField inputTextField;
+ private JXDatePicker datePicker;
+ private JComboBox comboBox;
+ private JComboBox accountCombo;
+
+ /**
+ * @param parentContext
+ */
+ public CriteriaWidgetImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // date input creation
+ createDateInput();
+
+ // item changed listener
+ criteriaComboBox.addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ String itemSelected = e.getItem().toString();
+ if (itemSelected.equals("date")) {
+ createDateInput();
+ }
+ if (itemSelected.equals("voucher") ||
+ itemSelected.equals("description") ||
+ itemSelected.equals("account")) {
+ createTextInput();
+ }
+ if (itemSelected.equals("debit") ||
+ itemSelected.equals("credit") ||
+ itemSelected.equals("amount")) {
+ createNumberInput();
+ }
+ if (itemSelected.equals("account")) {
+ createAccountInput();
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ private void createNumberInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.greater.than")));
+ getComboBox().addItem(new Item(2, _("lima.filter.less.than")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getInputTextField());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("numberinput : ");
+ }
+ }
+
+ /**
+ *
+ */
+ private void createTextInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.contains")));
+ getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getInputTextField());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("textinput : ");
+ }
+ }
+
+ /**
+ *
+ */
+ private void createAccountInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.contains")));
+ getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getAccountCombo());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("accountinput : ");
+ }
+ }
+
+ /**
+ *
+ */
+ private void createDateInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.before")));
+ getComboBox().addItem(new Item(2, _("lima.filter.after")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getDatePicker());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("dateinput : ");
+ }
+ }
+
+ @Override
+ protected void removeCriteriaWidget() {
+ LimaContext.getContext().getMainUI().getSearchView().removeCriteriaWidget(this);
+ }
+
+ /**
+ * @return
+ */
+ public JComboBox getComboBox() {
+ if (comboBox == null) {
+ comboBox = new JComboBox();
+ }
+ return comboBox;
+ }
+
+ /**
+ * @return
+ */
+ public JXDatePicker getDatePicker() {
+ if (datePicker == null) {
+ datePicker = new JXDatePicker(new Date(), LimaContext.getContext().getConfig().getLocale());
+ }
+ return datePicker;
+ }
+
+ /**
+ * @return
+ */
+ public JTextField getInputTextField() {
+ if (inputTextField == null) {
+ inputTextField = new JTextField();
+ inputTextField.setPreferredSize(new Dimension(150, 20));
+ }
+ return inputTextField;
+ }
+
+ public JComboBox getAccountCombo() {
+ if (accountCombo == null) {
+ List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
+ LimaContext.getContext().getDataManager().getAccountModel().getData());
+ Vector<AccountDTO> v = new Vector<AccountDTO>(accounts);
+ AccountComboBoxModel model = new AccountComboBoxModel(v);
+ accountCombo = new JWideComboBox(model);
+ accountCombo.setRenderer(AccountComboBoxRenderer.getInstance());
+ accountCombo.setPreferredSize(new Dimension(200, 25));
+ // AutoCompletion
+ AutoCompleteDecorator.decorate(accountCombo, AccountToStringConverter.getInstance());
+ }
+ return accountCombo;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,128 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table insets='0,0,0,0' fill="both">
+ <script>
+ protected void addLettering() {};
+ protected void removeLettering() {};
+ protected void precedentAccount() {};
+ protected void nextAccount() {};
+ </script>
+ <row weightx="1" weighty="0">
+ <cell>
+ <!-- account -->
+ <Table insets='0,0,0,0'>
+ <row weightx="0" weighty="0">
+ <cell anchor='center' weightx="0" weighty="0">
+ <!-- precedent -->
+ <JButton id="precedentButton"
+ preferredSize='{new Dimension(24,24)}'
+ verticalAlignment='0'
+ verticalTextPosition='0'
+ opaque='true'
+ borderPainted='false'
+ focusPainted='false'
+ enabled='true'
+ horizontalTextPosition='0'
+ onActionPerformed='precedentAccount()'
+ />
+ </cell>
+ <cell anchor='center' weightx="0" weighty="0">
+ <!-- next -->
+ <JButton id="nextButton"
+ preferredSize='{new Dimension(24,24)}'
+ verticalAlignment='0'
+ verticalTextPosition='0'
+ opaque='true'
+ borderPainted='false'
+ focusPainted='false'
+ enabled='true'
+ horizontalTextPosition='0'
+ onActionPerformed='nextAccount()'
+ />
+ </cell>
+ </row>
+ <!-- account -->
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.account"/>
+ </cell>
+ <cell weightx="0" weighty="0">
+ <JPanel id="accountPanel"/>
+ </cell>
+ </row>
+ <!-- since -->
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.since"/>
+ </cell>
+ <cell>
+ <JPanel id="sincePanel"/>
+ </cell>
+ </row>
+ <!-- to -->
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.to"/>
+ </cell>
+ <cell>
+ <JPanel id="toPanel"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ <cell>
+ <!-- entries -->
+ <Table insets='0,0,0,0' fill="both">
+ <row columns="3">
+ <cell>
+ <JLabel text="lima.entries"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettered' value='{_("lima.lettered")}'
+ selected='true'/>
+ </cell>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.not.lettered'
+ value='{_("lima.not.lettered")}'/>
+ </cell>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.all' value='{_("lima.all")}'/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <!-- table -->
+ <JScrollPane id="tablePanel"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <!-- add lettering -->
+ <JButton id="addButton" text="lima.add.lettering" onActionPerformed="addLettering()"/>
+ </cell>
+ <cell>
+ <!-- remove lettering -->
+ <JButton id="removeButton" text="lima.remove.lettering" onActionPerformed="removeLettering()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,127 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.JWideComboBox;
+import org.chorem.lima.combobox.model.AccountComboBoxModel;
+import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.util.AccountToStringConverter;
+import org.nuiton.util.Resource;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class LetteringViewImpl extends LetteringView {
+
+
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(LetteringViewImpl.class);
+ private final JWideComboBox accountComboBox;
+
+ /**
+ * @param parentContext
+ */
+ public LetteringViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ /** Calling services */
+ List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
+ LimaContext.getContext().getDataManager().getAccountModel().getData());
+ /** Creating accounting model */
+ Vector<AccountDTO> v1 = new Vector<AccountDTO>(accounts);
+ AccountComboBoxModel model = new AccountComboBoxModel(v1);
+ accountComboBox = new JWideComboBox();
+ accountComboBox.setPreferredSize(new Dimension(200, 25));
+ accountComboBox.setModel(model);
+ LimaContext.getContext().getDataManager().getAccountModel().addPropertyChangeListener(model);
+ accountComboBox.setRenderer(AccountComboBoxRenderer.getInstance());
+ accountPanel.add(accountComboBox);
+
+ /** AutoCompletion */
+ AutoCompleteDecorator.decorate(accountComboBox, AccountToStringConverter.getInstance());
+
+ Icon forwardIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Forward24.gif");
+ Icon backIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Back24.gif");
+ nextButton.setIcon(forwardIcon);
+ precedentButton.setIcon(backIcon);
+
+ /** Creating period model */
+ List<PeriodDTO> periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
+ LimaContext.getContext().getNeogiaFactory().getStatusService().getAllStatus()
+ );
+ Vector<PeriodDTO> v2 = new Vector<PeriodDTO>();
+ for (PeriodDTO period : periodes) {
+ v2.addElement(period);
+ v2.addAll(period.getChildren());
+ }
+ JWideComboBox sinceComboBox = new JWideComboBox(v2);
+ sinceComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
+ sinceComboBox.setPreferredSize(new Dimension(200, 25));
+ sincePanel.add(sinceComboBox);
+
+ JWideComboBox toComboBox = new JWideComboBox(v2);
+ toComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
+ toComboBox.setPreferredSize(new Dimension(200, 25));
+ toPanel.add(toComboBox);
+
+ JXTable table = new JXTable();
+ tablePanel.setViewportView(table);
+ }
+
+ /**
+ *
+ */
+ @Override
+ protected void nextAccount() {
+ if (!(accountComboBox.getSelectedIndex() == accountComboBox.getModel().getSize() - 1)) {
+ accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() + 1);
+ }
+
+ }
+
+ /**
+ *
+ */
+ @Override
+ protected void precedentAccount() {
+ if (!(accountComboBox.getSelectedIndex() == 0)) {
+ accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() - 1);
+ }
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,60 @@
+<!-- ##% 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.
+ ##% -->
+
+<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
+ onWindowClosing="windowClosing()"
+ defaultCloseOperation="do_nothing_on_close"
+ iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
+ <script>
+ protected void addCriteriaWidget() {};
+ protected void doSearch() {};
+ protected void windowClosing() {};
+ </script>
+ <JScrollPane>
+ <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
+ <row>
+ <cell>
+ <JButton id="addButton" text="lima.add" width="100" onActionPerformed="addCriteriaWidget()"/>
+ </cell>
+ <cell>
+ <JLabel text="lima.search.items.where" width="200"/>
+ </cell>
+ <cell>
+ <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
+ <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
+ <item value='any' label='{_("lima.any.criteria")}'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <VBox id="criteriaWidgetPanel"
+ border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" onActionPerformed="doSearch()" text="lima.ok"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.cancel" onActionPerformed="windowClosing()"/>
+ </cell>
+ </row>
+ </Table>
+ </JScrollPane>
+</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,224 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import static org.nuiton.i18n.I18n._;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.enumeration.FilterEnum;
+import org.chorem.lima.table.TransactionJXTable;
+import org.jdesktop.swingx.JXDatePicker;
+
+import javax.swing.*;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class SearchTransactionViewImpl extends SearchTransactionView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(SearchTransactionViewImpl.class);
+ private final TransactionJXTable table;
+
+ /**
+ * @param parentContext
+ */
+ public SearchTransactionViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // At Least one criteria
+ CriteriaWidgetImpl widget = new CriteriaWidgetImpl();
+ widget.getRemoveButton().setEnabled(false);
+ criteriaWidgetPanel.add(widget);
+ this.validate();
+
+ TransactionViewImpl searchResult = LimaContext.getContext().getMainUI().getSearchResultView();
+ searchResult.setFiltreEnabled(false);
+ table = searchResult.getTransactionTable();
+ getRootPane().setDefaultButton(okButton);
+ }
+
+ @Override
+ protected void addCriteriaWidget() {
+ criteriaWidgetPanel.add(new CriteriaWidgetImpl());
+ this.validate();
+ }
+
+ public void removeCriteriaWidget(CriteriaWidget widget) {
+ criteriaWidgetPanel.remove(widget);
+ this.validate();
+ }
+
+ protected void showTransactionView() {
+ LimaContext.getContext().getMainUI().showSearchResultView();
+ }
+
+ @Override
+ protected void doSearch() {
+ if (criteriaWidgetPanel.getComponentCount() > 0) {
+ table.getModel().initData();
+ table.addColorEmptyLine();
+ /** Any or All */
+ String allOrAny = (String) criteriaAllAnyComboBox.getSelectedItem();
+ boolean all = allOrAny.equals("all");
+ for (int i = 0; i < criteriaWidgetPanel.getComponentCount(); i++) {
+ CriteriaWidgetImpl myWidget = (CriteriaWidgetImpl) criteriaWidgetPanel.getComponent(i);
+ JComboBox comboCriteria = myWidget.getCriteriaComboBox();
+ if (comboCriteria.getSelectedIndex() != -1) {
+ String itemSelected = (String) comboCriteria.getSelectedItem();
+ /**
+ * Date item
+ */
+ if (itemSelected.equals("date")) {
+ searchDate(myWidget, FilterEnum.Date, all);
+ }
+
+ /**
+ * Voucher item
+ */
+ if (itemSelected.equals("voucher")) {
+ searchText(myWidget, FilterEnum.Voucher, all);
+ }
+
+ /**
+ * Account item
+ */
+ if (itemSelected.equals("account")) {
+ searchText(myWidget, FilterEnum.Account, all);
+ }
+
+ /**
+ * Description item
+ */
+ if (itemSelected.equals("description")) {
+ searchText(myWidget, FilterEnum.Description, all);
+ }
+
+ /**
+ * Debit item
+ */
+ if (itemSelected.equals("debit")) {
+ searchNumber(myWidget, FilterEnum.Debit, all);
+ }
+
+ /**
+ * Credit item
+ */
+ if (itemSelected.equals("credit")) {
+ searchNumber(myWidget, FilterEnum.Credit, all);
+ }
+
+ /**
+ * Amount item
+ */
+ if (itemSelected.equals("amount")) {
+ searchNumber(myWidget, FilterEnum.Amount, all);
+ }
+
+ } else {
+ throw new NullPointerException();
+ }
+ } // end for
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ /**
+ * @param myWidget
+ * @param type
+ * @param all
+ */
+ protected void searchDate(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
+ JXDatePicker datePicker = myWidget.getDatePicker();
+ if (datePicker.getDate() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("search with date : " + datePicker.getDate());
+ }
+ JComboBox comboNextCriteria = myWidget.getComboBox();
+ if (comboNextCriteria.getSelectedIndex() != -1) {
+ table.getModel().filter(type, myWidget, all);
+ showTransactionView();
+ } else {
+ throw new NullPointerException();
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ private void searchNumber(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
+ JTextField text = myWidget.getInputTextField();
+ if (text.getText() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("search with number : " + text.getText());
+ }
+ /**
+ * Parse double
+ */
+ try {
+ String value = text.getText();
+ Double.parseDouble(value.equals(DTOHelper.EMPTY_STRING) ? "0" : value);
+
+ JComboBox comboNextCriteria = myWidget.getComboBox();
+ if (comboNextCriteria.getSelectedIndex() != -1) {
+ table.getModel().filter(type, myWidget, all);
+ showTransactionView();
+ } else {
+ throw new NullPointerException();
+ }
+ } catch (NumberFormatException e) {
+ JOptionPane.showMessageDialog(this, _("lima.exception.number.format"));
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ private void searchText(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
+ JTextField text = myWidget.getInputTextField();
+ if (text.getText() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("search with text : " + text.getText());
+ }
+ JComboBox comboNextCriteria = myWidget.getComboBox();
+ if (comboNextCriteria.getSelectedIndex() != -1) {
+ table.getModel().filter(type, myWidget, all);
+ showTransactionView();
+ } else {
+ throw new NullPointerException();
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ @Override
+ protected void windowClosing() {
+ this.setVisible(false);
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,71 @@
+<!-- ##% 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.
+ ##% -->
+
+<Table>
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <!-- <JPopupMenu id="MenuRightPanel">
+ <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
+ <JMenuItem text="lima.print"/>
+ </JPopupMenu>
+ <JPopupMenu id="MenuRightTransaction">
+ <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
+ <JMenuItem text="lima.print"/>
+ </JPopupMenu> -->
+ <row fill="horizontal" weightx="0.75" weighty="0" anchor="center">
+ <cell>
+ <JLabel id="entryBookLabel" text="lima.transaction.entrybook"/>
+ </cell>
+ <cell>
+ <JComboBox id="entryBookComboBox"
+ model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" />
+ </cell>
+ <cell>
+ <JLabel id="periodLabel" text="lima.transaction.period"/>
+ </cell>
+ <cell>
+ <JComboBox id="financialPeriodPanel"
+ model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows='3' columns='4'>
+ <JScrollPane>
+ <org.chorem.lima.ui.transaction.table.TransactionTable
+ id="transactionsTable" sortable="false" rowHeight="22"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ highlighters="{HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
+ </JScrollPane>
+ </cell>
+ <cell>
+ <JButton id="addButton" text="lima.add.transaction" onActionPerformed="addEmptyTransaction()" width="150"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="removeButton" text="lima.remove.transaction" onActionPerformed="removeTransaction()" width="150"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton text="lima.add.entry" onActionPerformed="addEmptyEntry()" width="150"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,375 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.model.JournalComboBoxModel;
+import org.chorem.lima.combobox.model.PeriodComboBoxModel;
+import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.enumeration.FilterEnum;
+import org.chorem.lima.listener.ClicRight;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.table.model.*;
+import org.chorem.lima.table.TransactionJXTable;
+import org.chorem.lima.ui.ErrorMessage;
+import org.chorem.lima.util.Util;
+import static org.nuiton.i18n.I18n._;
+
+
+/**
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class TransactionViewImpl extends TransactionView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(TransactionViewImpl.class);
+ private JComboBox comboJournal;
+ private JComboBox comboPeriod;
+ private TransactionJXTable transactionTable;
+ private TransactionDataTableModel model;
+ private TransactionFilteredTableModel filterModel;
+ private TransactionSortedTableModel sortedModel;
+ private TransactionSortedTableColumnModel columnModel;
+ private TransactionFlattenTableModel flattenModel;
+
+ /**
+ * @param parentContext
+ */
+ public TransactionViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ initJournalComboBox();
+ initPeriodComboBox();
+
+ getTransactionTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ transactionScrollPane.setViewportView(getTransactionTable());
+
+ /**
+ * Property change listeners
+ */
+ getModel().addPropertyChangeListener(getFilterModel());
+ getFilterModel().addPropertyChangeListener(getSortedModel());
+ getSortedModel().addPropertyChangeListener(getFlattenModel());
+
+ getComboJournal().addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ getTransactionTable().removeColorEmptyLine();
+ getFlattenModel().initData();
+
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ JComboBox comboBox = (JComboBox) e.getSource();
+ JournalDTO item = (JournalDTO) comboBox.getSelectedItem();
+ getFlattenModel().filter(FilterEnum.Journal, item, true);
+ LimaContext.getContext().getDataManager().setCurrentJournal(item);
+ }
+
+ if (!(getComboPeriod().getSelectedIndex() == -1 || getComboPeriod().getSelectedIndex() == 0)) {
+ getFlattenModel().filter(FilterEnum.Period, getComboPeriod().getSelectedItem(), true);
+ }
+ }
+ });
+ getComboPeriod().addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ getTransactionTable().removeColorEmptyLine();
+ getFlattenModel().initData();
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ JComboBox comboBox = (JComboBox) e.getSource();
+ PeriodDTO item = (PeriodDTO) comboBox.getSelectedItem();
+ getFlattenModel().filter(FilterEnum.Period, item, true);
+ LimaContext.getContext().getDataManager().setCurrentPeriod(item);
+ }
+
+ if (!(getComboJournal().getSelectedIndex() == -1 || getComboJournal().getSelectedIndex() == 0)) {
+ getFlattenModel().filter(FilterEnum.Journal, getComboJournal().getSelectedItem(), true);
+ }
+ }
+ });
+ /**
+ * Permet de mettre la sélection du combobox par défaut sur le mois actuel lors
+ * de l'ouverture de la page des transactions.
+ */
+ int index = 0;
+ // Récupère la date actuelle
+ Date d = new Date();
+ String dateToday = ServiceHelper.dateToMonth(d) + " " + (d.getYear() + 1900);
+ for (int i = 0; i <= getComboPeriod().getItemCount(); i++) {
+ Object o = getComboPeriod().getItemAt(i);
+ if (o != null) {
+ if (dateToday.equals(((PeriodDTO) o).getIdName())) {
+ index = i;
+ }
+ }
+ }
+ if (index != 0){
+ getComboPeriod().setSelectedIndex(index);
+
+ }
+
+ /**
+ * Implémente le clic droit
+ */
+ MouseListener popupListeneTransr = new ClicRight(MenuRightTransaction);
+ getTransactionTable().addMouseListener(popupListeneTransr);
+ }
+
+ /**
+ * Initialise la combobox contenant les journaux
+ */
+ private void initJournalComboBox() {
+ /** Getting data from journal model **/
+ List<JournalDTO> journals = LimaContext.getContext().getDataManager().getJournalModel().getData();
+ /** Creating combobox model */
+ Vector<JournalDTO> v = new Vector<JournalDTO>(journals.size());
+ /** null item */
+ v.add(null);
+ v.addAll(journals);
+ JournalComboBoxModel comboBoxModel = new JournalComboBoxModel(v);
+ /** Property Change Listener */
+ LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
+ getComboJournal().setModel(comboBoxModel);
+ getComboJournal().setRenderer(JournalComboBoxRenderer.getInstance());
+ // AutoCompletion
+ // AutoCompleteDecorator.decorate(comboJournal, JournalToStringConverter.getInstance());
+ journalPanel.add(getComboJournal());
+ journalPanel.validate();
+ }
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initPeriodComboBox() {
+ // Recherche la liste de toutes les périodes
+
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ getComboPeriod().setModel(periodModel);
+ getComboPeriod().setRenderer(PeriodComboBoxRenderer.getInstance());
+ // AutoCompletion
+ // AutoCompleteDecorator.decorate(comboPeriod, PeriodToStringConverter.getInstance());
+ periodPanel.add(getComboPeriod());
+ periodPanel.validate();
+ }
+
+ /**
+ * @param enabled new value
+ */
+ public void setFiltreEnabled(boolean enabled) {
+ getComboPeriod().setEnabled(enabled);
+ getComboJournal().setEnabled(enabled);
+ }
+
+ /**
+ * ajout de transaction vide avec le bouton
+ */
+ @Override
+ protected void addEmptyTransaction() {
+ String result = transactionTable.getModel().addEmptyTransaction();
+ /**
+ * Si il n'y pas de message success, alors il existe une erreur.
+ * Création de la boite de dialogue avec le message d'erreur correspondant
+ */
+ ErrorMessage.showMessage(result);
+ }
+
+ /**
+ * suppression de transaction avec le bouton
+ */
+ @Override
+ protected void removeTransaction() {
+ // Any row selected
+ Integer indexSelectedRow = transactionTable.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ String message = DTOHelper.isTransaction(
+ transactionTable.getModel().getElementAt(indexSelectedRow))
+ ? _("lima.question.remove.transaction")
+ : _("lima.question.remove.entry");
+ int n = Util.showConfirmDialog(message);
+ if (n == JOptionPane.YES_OPTION) {
+ TransactionTableModel model = transactionTable.getModel();
+ // Message de retour
+ String result = "";
+ if (TransactionFlattenTableModel.isFlattenModel(model)) {
+ // Flatten
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) transactionTable.getModel();
+ flattenModel.removeEmptyLine();
+ /**
+ * Supprime la ligne sélectionnée : transaction ou entry
+ */
+ if (DTOHelper.isTransaction(model.getElementAt(indexSelectedRow))) {
+ // Transaction
+ result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
+ } else {
+ // Entry
+ result = flattenModel.removeEntry((EntryDTO) model.getElementAt(indexSelectedRow));
+ }
+ transactionTable.addColorEmptyLine();
+ } else {
+ // Not Flatten
+ result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
+ }
+ /**
+ * Messages erreurs
+ */
+ if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ ErrorMessage.showMessage(message);
+ }
+ }
+ }
+ }
+
+ /**
+ * Implémente le bouton ajout d'une entrée.
+ * Permet d'ajouter une ligne comptable sur la transaction sélectionnée.
+ */
+ @Override
+ protected void addEmptyEntry() {
+ if (transactionTable.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ } else {
+ // Line selected
+ int selectedRow = transactionTable.getSelectedRow();
+ int parentIndex = flattenModel.getParentIndex(selectedRow);
+ /**
+ * Is transaction editable ?
+ */
+ Object o = flattenModel.getElementAt(parentIndex);
+ if (DTOHelper.isTransaction(o)) {
+ // Transaction n'est pas éditable
+ if (!ServiceHelper.isEditable((TransactionDTO) o)) {
+ Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ }
+
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = flattenModel.emptyLineNextPosition(selectedRow);
+ /**
+ * Once traitement for transaction
+ */
+ if (flattenModel.isEmptyLineEmpty()) {
+ flattenModel.createEmptyLine();
+ } else {
+ flattenModel.removeEmptyLine();
+ selectedRow = transactionTable.getSelectedRow();
+ parentIndex = flattenModel.getParentIndex(selectedRow);
+ posNext = flattenModel.emptyLineNextPosition(selectedRow);
+ flattenModel.createEmptyLine();
+ }
+ flattenModel.addEmptyLine(posNext);
+
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+ /**
+ * New Line Color
+ */
+ transactionTable.addColorEmptyLine();
+ }
+ }
+
+ public TransactionDataTableModel getModel() {
+ if (model == null) {
+ model = LimaContext.getContext().getDataManager().getTransactionModel();
+ }
+ return model;
+ }
+
+ public TransactionFilteredTableModel getFilterModel() {
+ if (filterModel == null) {
+ filterModel = new TransactionFilteredTableModel(getModel());
+ }
+ return filterModel;
+ }
+
+ public TransactionSortedTableColumnModel getColumnModel() {
+ if (columnModel == null) {
+ columnModel = new TransactionSortedTableColumnModel(getSortedModel());
+ }
+ return columnModel;
+ }
+
+ public TransactionSortedTableModel getSortedModel() {
+ if (sortedModel == null) {
+ sortedModel = new TransactionSortedTableModel(getFilterModel());
+ }
+ return sortedModel;
+ }
+
+ public TransactionFlattenTableModel getFlattenModel() {
+ if (flattenModel == null) {
+ flattenModel = new TransactionFlattenTableModel(getSortedModel());
+ }
+ return flattenModel;
+ }
+
+ public TransactionJXTable getTransactionTable() {
+ if (transactionTable == null) {
+ transactionTable = new TransactionJXTable(getFlattenModel(), getColumnModel());
+ transactionTable.setName("TransactionTable");
+ }
+ return transactionTable;
+ }
+
+ public JComboBox getComboJournal() {
+ if (comboJournal == null) {
+ comboJournal = new JComboBox();
+ comboJournal.setName("Liste journal");
+ }
+ return comboJournal;
+ }
+
+ public JComboBox getComboPeriod() {
+ if (comboPeriod == null) {
+ comboPeriod = new JComboBox();
+ comboPeriod.setName("Liste periode");
+ }
+ return comboPeriod;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,112 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Opened financial period combo box model.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookComboBoxModel implements ComboBoxModel {
+
+ protected Object selectedMonth;
+
+ protected EntryBookService entryBookService;
+
+ public EntryBookComboBoxModel(Object selectedMonth) {
+ entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int result = 0;
+ // TODO add cache
+ try {
+ result = entryBookService.getAllEntryBooks().size();
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ Object result = null;
+ // TODO add cache
+ try {
+ result = entryBookService.getAllEntryBooks().get(index);
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedMonth = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedMonth;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,113 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.chorem.lima.business.FinancialPeriodService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.nuiton.util.MonthEnum;
+
+/**
+ * Opened financial period combo box model.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialPeriodComboBoxModel implements ComboBoxModel {
+
+ protected Object selectedMonth;
+
+ protected FinancialPeriodService financialPeriodService;
+
+ public FinancialPeriodComboBoxModel(Object selectedMonth) {
+ financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int result = 0;
+ // TODO add cache
+ try {
+ result = financialPeriodService.getNonLockedFinancialPeriods().size();
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ Object result = null;
+ // TODO add cache
+ try {
+ result = financialPeriodService.getNonLockedFinancialPeriods().get(index);
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedMonth = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedMonth;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,295 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import java.awt.Color;
+import java.awt.Component;
+
+import javax.swing.ListSelectionModel;
+import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.listener.EmptyLineSelectionListener;
+import org.chorem.lima.listener.TransactionHeaderListener;
+import org.chorem.lima.listener.TransactionKeyListener;
+import org.chorem.lima.table.editor.AccountTableCellEditor;
+import org.chorem.lima.table.editor.DateTableCellEditor;
+import org.chorem.lima.table.editor.JournalTableCellEditor;
+import org.chorem.lima.table.editor.NumberTableCellEditor;
+import org.chorem.lima.table.editor.PeriodTableCellEditor;
+import org.chorem.lima.table.editor.TextTableCellEditor;
+import org.chorem.lima.table.model.TransactionFlattenTableModel;
+import org.chorem.lima.table.model.TransactionSortedTableColumnModel;
+import org.chorem.lima.table.model.TransactionTableModel;
+import org.chorem.lima.table.renderer.AccountTableCellRenderer;
+import org.chorem.lima.table.renderer.AmountTableCellRenderer;
+import org.chorem.lima.table.renderer.DateTableCellRenderer;
+import org.chorem.lima.table.renderer.JournalTableCellRenderer;
+import org.chorem.lima.table.renderer.PeriodTableCellRenderer;
+import org.chorem.lima.table.renderer.StatusTableCellRenderer;
+import org.chorem.lima.table.renderer.TextTableCellRenderer;
+import org.chorem.lima.table.renderer.TransactionHeaderRenderer;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+/**
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class TransactionTable extends JXTable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(TransactionTable.class);
+
+ private ColorHighlighter colorEmptyLine;
+
+ private ColorHighlighter colorTransaction;
+
+ private ColorHighlighter colorBalance;
+
+ private EmptyLineSelectionListener emptyLineSelectionListener;
+
+ private TransactionKeyListener keyListener;
+
+ /**
+ * @param model
+ * @param columnModel
+ */
+ public TransactionTable(TransactionTableModel model, TransactionSortedTableColumnModel columnModel) {
+ super(model, columnModel);
+ createDefaultColumnsFromModel();
+
+ //setSelectionBackground(new Color(250,250,250));
+ //setSelectionForeground(new Color(0,0,0));
+
+ setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250)));
+ setColumnControlVisible(true);
+ getColumnExt(TransactionEnum.LETTERING.ordinal()).setVisible(false);
+ /**
+ * New Table Header
+ */
+ getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ getTableHeader().addMouseListener(new TransactionHeaderListener(this));
+
+ /**
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
+ * automatiquement une nouvelle ligne (une entrée comptable)
+ */
+ //addMouseListener(getEmptyLineSelectionListener());
+ /**
+ * Fin mod
+ */
+
+ /**
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
+ * programme insère une ligne comptable.
+ */
+ addKeyListener(getKeyListener());
+
+
+ /**
+ * Editing true
+ */
+ setTransactionEditable(true);
+
+ // cell rendering
+ TableColumnModel tcm = getColumnModel();
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellRenderer(PeriodTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.STATUS.ordinal()).setCellRenderer(StatusTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.BALANCE.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+
+ // cell editoring
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellEditor(DateTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellEditor(AccountTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(JournalTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());
+ packAll();
+ /**
+ * Color transactions
+ */
+ addColorTransaction();
+ addColorBalance();
+ }
+
+ /**
+ * @param editable
+ */
+ public void setTransactionEditable(boolean editable) {
+ if (editable) {
+ addMouseListener(emptyLineSelectionListener);
+ addKeyListener(keyListener);
+ } else {
+ removeMouseListener(emptyLineSelectionListener);
+ removeKeyListener(keyListener);
+ }
+ TransactionTableModel model = (TransactionTableModel) getModel();
+ model.setEditable(editable);
+ }
+
+ /**
+ *
+ */
+ public void addColorEmptyLine() {
+ /*
+ * Renvoie une couleur jaune pour chaque nouvelle ligne créée
+ removeColorEmptyLine();
+ if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
+ final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ return adapter.row == posNext;
+ }
+ };
+ colorEmptyLine = new ColorHighlighter(predicate, new Color(248,255,136), Color.BLACK,new Color(248,255,136), Color.BLACK);
+ addHighlighter(colorEmptyLine);
+ }*/
+ }
+
+ /**
+ *
+ */
+ public void removeColorEmptyLine() {
+ if (colorEmptyLine != null) {
+ removeHighlighter(colorEmptyLine);
+ }
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les transactions dans le tableau
+ * afin de bien distinguer les transactions et entrées comptables.
+ */
+ public void addColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ return DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) ? true : false;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null);
+ addHighlighter(colorTransaction);
+ }
+
+
+ /**
+ * Permet de surligner une transaction dans le tableau lorsque cette dernière
+ * n'est pas équilibrée.
+ */
+ public void addColorBalance() {
+ if (colorBalance != null) {
+ removeHighlighter(colorBalance);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ boolean isHighlighted = false;
+ // Si c'est une transaction
+ if ( DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) )
+ {
+ if ( !DTOHelper.isBalanced((TransactionDTO) getModel().getElementAt(adapter.row)) )
+ {
+ isHighlighted = true;
+ }
+ }
+ return isHighlighted;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(255,198,209),null,null,null);
+ addHighlighter(colorTransaction);
+ }
+
+ /**
+ *
+ */
+ public void removeColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ }
+
+ @Override
+ public TransactionTableModel getModel() {
+ return (TransactionTableModel) this.dataModel;
+ }
+
+ @Override
+ public TransactionSortedTableColumnModel getColumnModel() {
+ return (TransactionSortedTableColumnModel) this.columnModel;
+ }
+
+ public EmptyLineSelectionListener getEmptyLineSelectionListener() {
+ if (emptyLineSelectionListener == null) {
+ return new EmptyLineSelectionListener();
+ }
+ return emptyLineSelectionListener;
+ }
+
+ /**
+ * @return
+ */
+ public TransactionKeyListener getKeyListener() {
+ if (keyListener == null) {
+ return new TransactionKeyListener();
+ }
+ return keyListener;
+ }
+
+ /**
+ * @param model
+ * @return
+ */
+ public boolean isFlattenModel(TableModel model) {
+ return TransactionFlattenTableModel.isFlattenModel(model);
+ }
+
+ @Override
+ public void setModel(TableModel arg0) {
+ super.setModel(arg0);
+ removeColorEmptyLine();
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,204 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+import javax.xml.rpc.ServiceFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.RecordService;
+import org.chorem.lima.business.TransactionService;
+import org.chorem.lima.comparator.JournalComparator;
+import org.chorem.lima.comparator.PeriodComparator;
+import org.chorem.lima.comparator.StatusComparator;
+import org.chorem.lima.enumeration.FilterEnum;
+import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ServiceHelper;
+
+/**
+ * Basic transaction table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TransactionTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3914954536809622358L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(TransactionTableModel.class);
+
+ /**
+ * Services
+ */
+ protected final RecordService recordService;
+ protected final TransactionService transactionService;
+
+ /**
+ * Model constructor.
+ *
+ * Just init service proxies.
+ */
+ public TransactionTableModel() {
+ /* Services */
+ recordService = LimaServiceFactory.getInstance().getRecordService();
+ transactionService = LimaServiceFactory.getInstance().getTransactionService();
+ }
+
+ @Override
+ public int getRowCount() {
+ return model.getRowCount();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return model.getColumnCount();
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ return model.getValueAt(getSortedRow(row), column);
+ }
+
+ @Override
+ public Object getElementAt(int row) {
+ return model.getElementAt(getSortedRow(row));
+ }
+
+ @Override
+ public boolean isEditable() {
+ return model.isEditable();
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+ return model.getColumnClass(column);
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return model.getColumnName(column);
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return model.isCellEditable(getSortedRow(row), column);
+ }
+
+ @Override
+ public void setValueAt(Object value, int row, int col) {
+ row = getSortedRow(row);
+ String response;
+ /**
+ * TransactionDTO
+ */
+ TransactionDTO trans = (TransactionDTO) getElementAt(row);
+ TransactionDTO cloneTrans = DTOHelper.cloneTransaction(trans);
+ switch (TransactionEnum.values()[col]) {
+ case PERIOD:
+ cloneTrans.setPeriod((PeriodDTO) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setPeriod(cloneTrans.getPeriod());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case JOURNAL:
+ cloneTrans.setJournal((JournalDTO) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setJournal(cloneTrans.getJournal());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case DATE:
+ cloneTrans.setEntryDate((Date) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setEntryDate(cloneTrans.getEntryDate());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case DOCUMENT:
+ cloneTrans.setVoucherRef((String) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setVoucherRef(cloneTrans.getVoucherRef());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case DESCRIPTION:
+ cloneTrans.setDescription((String) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setDescription(cloneTrans.getDescription());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ }
+ }
+
+ /**
+ *
+ */
+ @Override
+ public String addEmptyTransaction() {
+ return model.addEmptyTransaction();
+ }
+
+ /**
+ * @param trans
+ */
+ @Override
+ public String removeTransaction(TransactionDTO trans) {
+ return model.removeTransaction(trans);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0