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
r3188 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/opening resources/import
by vsalaun@users.chorem.org 28 Jun '11
by vsalaun@users.chorem.org 28 Jun '11
28 Jun '11
Author: vsalaun
Date: 2011-06-28 16:54:14 +0200 (Tue, 28 Jun 2011)
New Revision: 3188
Url: http://chorem.org/repositories/revision/lima/3188
Log:
add a new default french EntryBook
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateEntryBookPanel.jaxx
trunk/lima-swing/src/main/resources/import/eb_default.csv
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateEntryBookPanel.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateEntryBookPanel.jaxx 2011-06-28 13:48:18 UTC (rev 3187)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateEntryBookPanel.jaxx 2011-06-28 14:54:14 UTC (rev 3188)
@@ -34,7 +34,7 @@
</row>
<row>
<cell>
- <JCheckBox id='importEntryBook' text='lima.importexport.defaultentrybooks' selected='false'/>
+ <JCheckBox id='importEntryBook' text='lima.importexport.defaultentrybooks' selected='true'/>
</cell>
</row>
</Table>
Modified: trunk/lima-swing/src/main/resources/import/eb_default.csv
===================================================================
--- trunk/lima-swing/src/main/resources/import/eb_default.csv 2011-06-28 13:48:18 UTC (rev 3187)
+++ trunk/lima-swing/src/main/resources/import/eb_default.csv 2011-06-28 14:54:14 UTC (rev 3188)
@@ -2,3 +2,4 @@
"ENBK";"VTE";"Journal des ventes"
"ENBK";"ODT";"Journal des opérations diverses"
"ENBK";"BQE";"Journal de trésorerie"
+"ENBK";"CSE";"Journal de caisse"
1
0
r3187 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor
by vsalaun@users.chorem.org 28 Jun '11
by vsalaun@users.chorem.org 28 Jun '11
28 Jun '11
Author: vsalaun
Date: 2011-06-28 15:48:18 +0200 (Tue, 28 Jun 2011)
New Revision: 3187
Url: http://chorem.org/repositories/revision/lima/3187
Log:
#410 empeche l'effacement involontaire des montants
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-06-28 10:19:17 UTC (rev 3186)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-06-28 13:48:18 UTC (rev 3187)
@@ -120,7 +120,10 @@
&& e.getKeyCode() <= KeyEvent.VK_9)
|| e.getKeyCode() == KeyEvent.VK_COMMA
|| e.getKeyCode() == KeyEvent.VK_PERIOD) {
- textField.setText(String.valueOf(e.getKeyChar()));
+ //check if the TextField is selectAll
+ if (textField.getSelectedText().equals(textField.getText())) {
+ textField.setText(String.valueOf(e.getKeyChar()));
+ }
keyPressed = true;
} else if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE){
textField.setText("");
1
0
r3186 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor
by vsalaun@users.chorem.org 28 Jun '11
by vsalaun@users.chorem.org 28 Jun '11
28 Jun '11
Author: vsalaun
Date: 2011-06-28 12:19:17 +0200 (Tue, 28 Jun 2011)
New Revision: 3186
Url: http://chorem.org/repositories/revision/lima/3186
Log:
#411 empeche l'effacement involontaire dans les dates
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2011-06-27 16:31:06 UTC (rev 3185)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2011-06-28 10:19:17 UTC (rev 3186)
@@ -48,12 +48,13 @@
* @author ore
*/
public class DateTableCellEditor extends AbstractCellEditor
- implements TableCellEditor, FocusListener, AncestorListener, KeyListener {
+ implements TableCellEditor, FocusListener, AncestorListener {
private final JXDatePicker datePicker;
private static final long serialVersionUID = 1L;
private static DateTableCellEditor editor;
- private boolean keyPressed;
+
+ //used to tell if the user has pressed a key
private Date date;
/**
@@ -63,8 +64,6 @@
datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
datePicker.getEditor().addFocusListener(this);
datePicker.getEditor().addAncestorListener(this);
- datePicker.getEditor().addKeyListener(this);
- keyPressed = false;
}
@Override
@@ -116,7 +115,7 @@
/**
* Listeners
- */
+ */
public void focusGained(FocusEvent e) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -126,7 +125,6 @@
}
public void focusLost(FocusEvent e) {
- keyPressed = false;
}
@Override
@@ -146,26 +144,4 @@
public void ancestorMoved(AncestorEvent e) {
}
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
- @Override
- public void keyPressed(KeyEvent e) {
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- if (keyPressed == false) {
- if (e.getKeyCode() >= KeyEvent.VK_0
- && e.getKeyCode() <= KeyEvent.VK_Z) {
- datePicker.getEditor().setText(String.valueOf(e.getKeyChar()));
- keyPressed = true;
- }
- else if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE){
- keyPressed = true;
- }
- }
- }
-
}
1
0
r3185 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-business/src/main/resources/i18n lima-swing/src/main/java/org/chorem/lima
by vsalaun@users.chorem.org 27 Jun '11
by vsalaun@users.chorem.org 27 Jun '11
27 Jun '11
Author: vsalaun
Date: 2011-06-27 18:31:06 +0200 (Mon, 27 Jun 2011)
New Revision: 3185
Url: http://chorem.org/repositories/revision/lima/3185
Log:
add OptionsService in order to use some swing config on business config
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/OptionsServiceMonitorable.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsServiceLocal.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2011-06-17 15:32:15 UTC (rev 3184)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -119,6 +119,16 @@
Integer port = Integer.valueOf(httpPort);
return port;
}
+
+ public String getScale() {
+ String scale = getOption(Option.SCALE.getKey());
+ return scale;
+ }
+
+ public void setScale(String locale) {
+ setOption(Option.SCALE.key, locale);
+ saveForUser();
+ }
/**
* Load configuration with custom file name.
@@ -150,7 +160,8 @@
RULES_NATIONALTY("lima.rules", _("lima.config.rulesnationality"), "default", String.class, false, false),
REPORTS_DIR("lima.report.dir", _("lima.config.reportsdir"), "", String.class, false, false),
HTTP_PORT("lima.httpport", _("lima.config.httpport"), "5462", String.class, false, false),
- SERVER_ADRESS("lima.serveraddress", _("lima.config.serveraddress"), "", String.class, false, false);
+ SERVER_ADRESS("lima.serveraddress", _("lima.config.serveraddress"), "", String.class, false, false),
+ SCALE("lima.scale", _("lima.config.scale"), "2", String.class, false, false);
private final String key;
private final String description;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/OptionsServiceMonitorable.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/OptionsServiceMonitorable.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/OptionsServiceMonitorable.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -0,0 +1,7 @@
+package org.chorem.lima.business;
+
+import org.chorem.lima.business.ejbinterface.OptionsService;
+
+public interface OptionsServiceMonitorable extends OptionsService, ServiceMonitorable {
+
+}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-06-17 15:32:15 UTC (rev 3184)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -52,6 +52,7 @@
import org.chorem.lima.business.ejbinterface.FinancialTransactionService;
import org.chorem.lima.business.ejbinterface.FinancialTransactionServiceLocal;
import org.chorem.lima.business.ejbinterface.ReportService;
+import org.chorem.lima.business.ejbinterface.OptionsService;
import org.chorem.lima.business.utils.FinancialPeriodComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
@@ -104,6 +105,9 @@
@EJB
protected EntryBookService entryBookService;
+
+ @EJB
+ protected OptionsService optionsService;
public FinancialTransactionServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -268,6 +272,7 @@
public List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException {
TopiaContext topiaContext = null;
List<FinancialTransaction> result = null;
+ List<FinancialTransaction> checkedResult = new ArrayList<FinancialTransaction>();
try {
topiaContext = beginTransaction();
@@ -294,8 +299,18 @@
.addLoad(entryBookLabelProperty);
result = financialTransactionDAO.findAllByQuery(query);
+ for (FinancialTransaction fTransaction : result) {
+ BigDecimal credit = fTransaction.getAmountCredit();
+ BigDecimal debit = fTransaction.getAmountDebit();
+ credit = credit.setScale(optionsService.getScale(),
+ BigDecimal.ROUND_HALF_UP);
+ debit = debit.setScale(optionsService.getScale(),
+ BigDecimal.ROUND_HALF_UP);
+ if (credit.equals(debit)) {
+ checkedResult.add(fTransaction);
+ }
+ }
-
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/OptionsServiceImpl.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -0,0 +1,30 @@
+package org.chorem.lima.business.ejb;
+
+import javax.ejb.Stateless;
+
+import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.ejbinterface.OptionsService;
+import org.chorem.lima.business.ejbinterface.OptionsServiceLocal;
+
+@Stateless
+public class OptionsServiceImpl extends AbstractLimaService implements OptionsService, OptionsServiceLocal {
+
+ protected String scale;
+
+ public OptionsServiceImpl() {
+ scale = LimaConfig.getInstance().getScale();
+ }
+
+ public int getScale() {
+ if (scale.isEmpty()) {
+ return 2;
+ } else {
+ return Integer.valueOf(scale);
+ }
+ }
+
+ public void setScale(String scale) {
+ LimaConfig.getInstance().setScale(scale);
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsService.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -0,0 +1,32 @@
+package org.chorem.lima.business.ejbinterface;
+
+import javax.ejb.Remote;
+
+/**
+ * Service de report des certaines configurations du swing dans business
+ *
+ * Actuellement :
+ * <ul>
+ * <li>scale</li>
+ * </ul>
+ *
+ * @author salaun
+ *
+ */
+
+@Remote
+public interface OptionsService {
+
+ /**
+ * Sets the swing scale to the business scale
+ * @param String: scale
+ */
+ void setScale(String scale);
+
+ /**
+ * Gets the business scale
+ * @return String: scale
+ */
+ int getScale();
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsServiceLocal.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/OptionsServiceLocal.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -0,0 +1,8 @@
+package org.chorem.lima.business.ejbinterface;
+
+import javax.ejb.Local;
+
+@Local
+public interface OptionsServiceLocal extends OptionsService {
+
+}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2011-06-17 15:32:15 UTC (rev 3184)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2011-06-27 16:31:06 UTC (rev 3185)
@@ -65,4 +65,5 @@
lima.config.httpport=HTTP Port
lima.config.reportsdir=Reports directories
lima.config.rulesnationality=Rules Nationality
+lima.config.scale=Scale
lima.config.serveraddress=Server Address
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2011-06-17 15:32:15 UTC (rev 3184)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2011-06-27 16:31:06 UTC (rev 3185)
@@ -65,4 +65,5 @@
lima.config.httpport=Port HTTP
lima.config.reportsdir=Dossier des rapports
lima.config.rulesnationality=R\u00E8gles nationales
+lima.config.scale=Pr\u00E9cision
lima.config.serveraddress=Addresse serveur
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2011-06-17 15:32:15 UTC (rev 3184)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2011-06-27 16:31:06 UTC (rev 3185)
@@ -27,13 +27,23 @@
import static org.nuiton.i18n.I18n._;
import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.util.Locale;
+import java.util.Properties;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.actions.MiscAction;
+import org.chorem.lima.business.OptionsServiceMonitorable;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
+import org.chorem.lima.service.LimaServiceFactory;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ArgumentsParserException;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.SortedProperties;
import org.nuiton.util.Version;
import org.nuiton.util.VersionUtil;
import org.nuiton.util.converter.ConverterUtil;
@@ -58,6 +68,11 @@
private static final String configFile = "lima-config.properties";
+ //used for services
+ protected static final String SERVICECONFIGFILE = "lima.properties";
+
+ protected OptionsServiceMonitorable optionsService;
+
/**
* La version du logiciel.
*/
@@ -109,6 +124,7 @@
// TODO what is it for ?
//FileUtil.setCurrentDirectory(getLimaUserDirectory());
//getLimaUserDirectory().mkdirs();
+
}
public static LimaConfig getInstance() {
@@ -220,6 +236,8 @@
setOption(Option.SCALE.key, scale);
saveForUser();
firePropertyChange("scale", null, scale);
+ System.out.println("new scale" + scale);
+ optionsService.setScale(scale);
}
/**
@@ -455,4 +473,98 @@
this.aliases = aliases;
}
}
+
+ /**
+ * Save configuration, in user home directory using the
+ * {@link #getConfigFileName}. Default, env and commande line note saved
+ *
+ * @param excludeKeys optional list of keys to exclude from
+ */
+ public void saveForUser(String... excludeKeys) {
+
+ File file = getUserConfigFile();
+ if (log.isDebugEnabled()) {
+ log.debug("will save user configuration in " + file);
+ }
+ try {
+ save(file, false, excludeKeys);
+ } catch (IOException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn(_("nuitonutil.error.applicationconfig.save", file),
+ eee);
+ }
+ }
+ }
+
+ /**
+ * Save configuration, in specified file.
+ *
+ * @param file file where config will be writen
+ * @param forceAll if true save all config option
+ * (with defaults, classpath, env, command line)
+ * @param excludeKeys optional list of keys to exclude from
+ * @throws IOException if IO pb
+ */
+ public void save(File file,
+ boolean forceAll,
+ String... excludeKeys) throws IOException {
+
+ //
+ String[] serverProperties = {"scale"};
+
+ // store sorted in file
+ Properties prop = new SortedProperties();
+
+ // store server properties in file
+ Properties serverProp = new SortedProperties();
+
+ if (forceAll) {
+ prop.putAll(defaults);
+ prop.putAll(classpath);
+ }
+ prop.putAll(etcfile);
+ prop.putAll(homefile);
+ prop.putAll(curfile);
+ if (forceAll) {
+ prop.putAll(jvm);
+ prop.putAll(env);
+ prop.putAll(line);
+ }
+ prop.putAll(options);
+
+ for (String excludeKey : excludeKeys) {
+ prop.remove(excludeKey);
+ }
+
+ for (String serverPropertie : serverProperties) {
+ if (prop.containsKey(serverPropertie)) {
+ serverProp.put(serverPropertie, prop.get(serverPropertie));
+ }
+ }
+
+ // Ano #687 : create parentFile before using it in FileWriter
+ boolean dirCreated = FileUtil.createDirectoryIfNecessary(file.getParentFile());
+ if (dirCreated && log.isDebugEnabled()) {
+ log.debug("Creation of config directory " + file.getParent());
+ }
+
+ OutputStream stream = new FileOutputStream(file);
+ try {
+ prop.store(stream, "Last saved " + new java.util.Date());
+ } finally {
+ stream.close();
+ }
+
+ optionsService =
+ LimaServiceFactory.getInstance().getService(
+ OptionsServiceMonitorable.class);
+
+ if (!serverProp.isEmpty()) {
+ if (serverProp.containsKey("scale")) {
+ if (!serverProp.getProperty("scale").isEmpty()) {
+ optionsService.setScale(serverProp.getProperty("scale"));
+ }
+ }
+ }
+ }
}
1
0
r3184 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: financialtransaction financialtransactionsearch financialtransactionunbalanced
by vsalaun@users.chorem.org 17 Jun '11
by vsalaun@users.chorem.org 17 Jun '11
17 Jun '11
Author: vsalaun
Date: 2011-06-17 17:32:15 +0200 (Fri, 17 Jun 2011)
New Revision: 3184
Url: http://chorem.org/repositories/revision/lima/3184
Log:
correct the selection on the right row while updating datas (FinancialTransactionUnbalanced)
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-06-17 15:23:41 UTC (rev 3183)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-06-17 15:32:15 UTC (rev 3184)
@@ -242,11 +242,6 @@
y_tab++;
}
- System.out.println("x_tab : " + x_tab);
- System.out.println("max_x : " + max_x);
- System.out.println("y_tab : " + y_tab);
- System.out.println("max_y : " + max_y);
-
//skip all cell while not editable or if end of table add entry or transaction or end of table
while (!isCellEditable(y_tab, x_tab) && end ){
//if end of row
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-06-17 15:23:41 UTC (rev 3183)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-06-17 15:32:15 UTC (rev 3184)
@@ -407,14 +407,12 @@
}
}
-
-
/**
*
* @param value
* @param description
* @param row
- * @return int: indexOf new FianancialTransaction
+ * @return int: indexOf new Entry
* @throws LimaException
*/
public int addEmptyEntry(Object value, String description, int row) throws LimaException {
@@ -450,7 +448,7 @@
* @param value
* @param entry
* @param row
- * @return int: indexOf new FianancialTransaction
+ * @return int: indexOf new Entry
* @throws LimaException
*/
public int addEntry(Object value, Entry entry, int row) throws LimaException {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 15:23:41 UTC (rev 3183)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 15:32:15 UTC (rev 3184)
@@ -427,7 +427,7 @@
*
* @param value
* @param row
- * @return int: indexOf new FianancialTransaction
+ * @return int: indexOf new Entry
* @throws LimaException
*/
public int addEmptyEntry(Object value, int row) throws LimaException {
@@ -564,7 +564,7 @@
* @param value
* @param description
* @param row
- * @return int: indexOf new FianancialTransaction
+ * @return int: indexOf new Entry
* @throws LimaException
*/
public int addEmptyEntry(Object value, String description, int row) throws LimaException {
@@ -595,6 +595,14 @@
return newrow;
}
+ /**
+ *
+ * @param value
+ * @param entry
+ * @param row
+ * @return int: indexOf new Entry
+ * @throws LimaException
+ */
public int addEntry(Object value, Entry entry, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
int financialTransactionRow = 0;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2011-06-17 15:23:41 UTC (rev 3183)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2011-06-17 15:32:15 UTC (rev 3184)
@@ -360,10 +360,16 @@
}
+
/**
- * @throws LimaException
+ *
+ * @param value
+ * @param description
+ * @param row
+ * @return int: indexOf new Entry
+ * @throws LimaException
*/
- public void addEmptyEntry(Object value, String description, int row) throws LimaException {
+ public int addEmptyEntry(Object value, String description, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
@@ -382,9 +388,11 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
+ Entry newEntry = financialTransactionService.createEntry(entry);
//on recharge la liste
- refresh();
+ int newrow = cacheDataList.indexOf(newEntry);
+ fireTableRowsInserted(row, row);
+ return newrow;
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2011-06-17 15:23:41 UTC (rev 3183)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2011-06-17 15:32:15 UTC (rev 3184)
@@ -78,13 +78,13 @@
try {
//copy + paste the description
String description = (String) tableModel.getValueAt(indexSelectedRow, 4);
- tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
+ int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(indexSelectedRow+1, indexSelectedRow+1);
//focus on second column
- table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.changeSelection(index, 1, false, false);
table.requestFocusInWindow();
} catch (LimaException eee){
if (log.isErrorEnabled()) {
1
0
r3183 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch
by vsalaun@users.chorem.org 17 Jun '11
by vsalaun@users.chorem.org 17 Jun '11
17 Jun '11
Author: vsalaun
Date: 2011-06-17 17:23:41 +0200 (Fri, 17 Jun 2011)
New Revision: 3183
Url: http://chorem.org/repositories/revision/lima/3183
Log:
correct the selection on the right row while updating datas (FinancialTransactionSearch)
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-06-17 14:59:28 UTC (rev 3182)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-06-17 15:23:41 UTC (rev 3183)
@@ -195,22 +195,22 @@
&& e.getModifiers() == KeyEvent.CTRL_MASK)) {
handler.addEmptyEntry();
}
+
+ // paste : ctrl + c
- // add financial transaction with the key combination : ctrl + tab
+ // add financial transaction with the key combination : ctrl + c
if (e.getKeyCode() == KeyEvent.VK_C
&& e.getModifiers() == KeyEvent.CTRL_MASK) {
handler.copyRow();
}
- // copy : ctrl + c
+ // copy : ctrl + v
- // add financial transaction with the key combination : ctrl + tab
+ // add financial transaction with the key combination : ctrl + v
if (e.getKeyCode() == KeyEvent.VK_V
&& e.getModifiers() == KeyEvent.CTRL_MASK) {
handler.pasteRow();
}
-
- // paste : ctrl + v
// add financial transaction with the key combination : ctrl + tab
if (e.getKeyCode() == KeyEvent.VK_TAB
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 14:59:28 UTC (rev 3182)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 15:23:41 UTC (rev 3183)
@@ -358,10 +358,13 @@
}
+
/**
- * @throws LimaException
+ *
+ * @return int: indexOf new FianancialTransaction
+ * @throws LimaException
*/
- public void addFinancialTransaction() throws LimaException{
+ public int addFinancialTransaction() throws LimaException{
/* Calling transaction service */
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
financialTransaction.setAmountDebit(BigDecimal.ZERO);
@@ -405,12 +408,14 @@
// set date to the financial transaction
financialTransaction.setTransactionDate(transactionDate);
// create it
- financialTransactionService.createFinancialTransaction(financialTransaction);
+ FinancialTransaction fTransaction =
+ financialTransactionService.createFinancialTransaction(financialTransaction);
//on recharge la liste
cacheDataList = getDataList(financialTransactionSearch);
- int row = getDataList(financialTransactionSearch).indexOf(financialTransaction);
+ int row = cacheDataList.indexOf(fTransaction);
fireTableRowsInserted(row, row);
+ return row;
//fireTableDataChanged();
}
else {
@@ -418,11 +423,14 @@
}
}
-
/**
- * @throws LimaException
+ *
+ * @param value
+ * @param row
+ * @return int: indexOf new FianancialTransaction
+ * @throws LimaException
*/
- public void addEmptyEntry(Object value, int row) throws LimaException {
+ public int addEmptyEntry(Object value, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
@@ -438,10 +446,12 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
+ Entry newEntry = financialTransactionService.createEntry(entry);
//on recharge la liste
cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
+ int newrow = cacheDataList.indexOf(newEntry);
+ fireTableRowsInserted(newrow, newrow);
+ return newrow;
}
/**
@@ -549,11 +559,15 @@
fireTableDataChanged();
}
-
/**
- * @throws LimaException
+ *
+ * @param value
+ * @param description
+ * @param row
+ * @return int: indexOf new FianancialTransaction
+ * @throws LimaException
*/
- public void addEmptyEntry(Object value, String description, int row) throws LimaException {
+ public int addEmptyEntry(Object value, String description, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
@@ -572,14 +586,16 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
+ Entry newEntry = financialTransactionService.createEntry(entry);
//on recharge la liste
cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
+ int newrow = cacheDataList.indexOf(newEntry);
+ fireTableRowsInserted(newrow, newrow);
+ return newrow;
}
- public void addEntry(Object value, Entry entry, int row) throws LimaException {
+ public int addEntry(Object value, Entry entry, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
int financialTransactionRow = 0;
Object currentRow = cacheDataList.get(row);
@@ -601,12 +617,14 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
+ Entry newEntry = financialTransactionService.createEntry(entry);
fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
//on recharge la liste
cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
+ int newrow = cacheDataList.indexOf(newEntry);
+ fireTableRowsInserted(newrow, newrow);
+ return newrow;
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-06-17 14:59:28 UTC (rev 3182)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-06-17 15:23:41 UTC (rev 3183)
@@ -246,14 +246,14 @@
try {
//copy + paste the description
String description = (String) tableModel.getValueAt(indexSelectedRow, 4);
- tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
+ int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(
indexSelectedRow+1, indexSelectedRow+1);
//focus on second column
- table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.changeSelection(index, 1, false, false);
table.requestFocusInWindow();
} catch (LimaException eee){
if (log.isErrorEnabled()) {
@@ -289,14 +289,14 @@
Object selectedValue = tableModel.getElementAt(indexSelectedRow);
if (clipBoard instanceof Entry) {
try {
- tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow);
+ int index = tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(
indexSelectedRow+1, indexSelectedRow+1);
//focus on second column
- table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.changeSelection(index, 1, false, false);
table.requestFocusInWindow();
} catch (LimaException eee){
if (log.isErrorEnabled()) {
@@ -317,14 +317,14 @@
tableModel = view.getFinancialTransactionSearchTableModel();
try {
- tableModel.addFinancialTransaction();
+ int index = tableModel.addFinancialTransaction();
//select the new line
int numberRow = table.getRowCount();
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(numberRow-1, numberRow-1);
//focus on first column
- table.changeSelection(numberRow-1, 0, false, false);
+ table.changeSelection(index, 0, false, false);
table.requestFocusInWindow();
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
1
0
r3182 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by vsalaun@users.chorem.org 17 Jun '11
by vsalaun@users.chorem.org 17 Jun '11
17 Jun '11
Author: vsalaun
Date: 2011-06-17 16:59:28 +0200 (Fri, 17 Jun 2011)
New Revision: 3182
Url: http://chorem.org/repositories/revision/lima/3182
Log:
correct the selection on the right row while updating datas (FinancialTransaction)
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-06-17 12:41:53 UTC (rev 3181)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-06-17 14:59:28 UTC (rev 3182)
@@ -118,9 +118,10 @@
}
@Override
- public void createFinancialTransactionWithTransaction(
+ public FinancialTransaction createFinancialTransactionWithTransaction(
FinancialTransaction financialtransaction, TopiaContext topiaContext)
throws LimaException {
+ FinancialTransaction fTransaction = null;
try {
//check if the financial period is blocked
accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
@@ -129,13 +130,16 @@
FinancialTransactionDAO financialtransactionDAO =
LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
- financialtransactionDAO.create(financialtransaction);
+ fTransaction = (FinancialTransaction)
+ financialtransactionDAO.create(financialtransaction);
commitTransaction(topiaContext);
+
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
- }
+ }
+ return fTransaction;
}
/**
@@ -143,13 +147,13 @@
*
*/
@Override
- public void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+ public FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
TopiaContext topiaContext = null;
try {
topiaContext = beginTransaction();
- createFinancialTransactionWithTransaction(financialtransaction, topiaContext);
+ return createFinancialTransactionWithTransaction(financialtransaction, topiaContext);
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
@@ -157,6 +161,7 @@
finally {
doFinally(topiaContext, log);
}
+ return null;
}
/**
@@ -451,9 +456,9 @@
@Override
- public void createEntryWithTransaction(Entry entry,
+ public Entry createEntryWithTransaction(Entry entry,
TopiaContext topiaContext) throws LimaException {
-
+ Entry newEntry = null;
try {
//check if the financial period is blocked
@@ -462,7 +467,7 @@
EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext);
- entryDAO.create(entry);
+ newEntry = entryDAO.create(entry);
//get new entry amounts
BigDecimal entryAmount = entry.getAmount();
@@ -502,7 +507,8 @@
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
- }
+ }
+ return newEntry;
}
/**
@@ -513,20 +519,21 @@
*/
@Override
- public void createEntry(Entry entry) throws LimaException {
+ public Entry createEntry(Entry entry) throws LimaException {
TopiaContext topiaContext = null;
try {
topiaContext = beginTransaction();
- createEntryWithTransaction(entry, topiaContext);
+ return createEntryWithTransaction(entry, topiaContext);
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
}
finally {
doFinally(topiaContext, log);
- }
+ }
+ return null;
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2011-06-17 12:41:53 UTC (rev 3181)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2011-06-17 14:59:28 UTC (rev 3182)
@@ -60,7 +60,7 @@
* @throws LimaException
*/
- void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
+ FinancialTransaction createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException;
@@ -87,7 +87,7 @@
* @throws LimaException
*/
- void createEntry(Entry entry) throws LimaException;
+ Entry createEntry(Entry entry) throws LimaException;
void updateEntry(Entry entry) throws LimaException;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java 2011-06-17 12:41:53 UTC (rev 3181)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionServiceLocal.java 2011-06-17 14:59:28 UTC (rev 3182)
@@ -44,10 +44,10 @@
@Local
public interface FinancialTransactionServiceLocal extends FinancialTransactionService {
- void createFinancialTransactionWithTransaction(FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException;
+ FinancialTransaction createFinancialTransactionWithTransaction(FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException;
void updateFinancialTransactionWithTransaction(FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException;
- void createEntryWithTransaction(Entry entry, TopiaContext topiaContext) throws LimaException;
+ Entry createEntryWithTransaction(Entry entry, TopiaContext topiaContext) throws LimaException;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-06-17 12:41:53 UTC (rev 3181)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-06-17 14:59:28 UTC (rev 3182)
@@ -185,22 +185,22 @@
&& e.getModifiers() == KeyEvent.CTRL_MASK)) {
handler.addEmptyEntry();
}
+
+ // copy : ctrl + c
- // add financial transaction with the key combination : ctrl + tab
+ // add financial transaction with the key combination : ctrl + c
if (e.getKeyCode() == KeyEvent.VK_C
&& e.getModifiers() == KeyEvent.CTRL_MASK) {
handler.copyRow();
}
- // copy : ctrl + c
+ // paste : ctrl + v
- // add financial transaction with the key combination : ctrl + tab
+ // add financial transaction with the key combination : ctrl + v
if (e.getKeyCode() == KeyEvent.VK_V
&& e.getModifiers() == KeyEvent.CTRL_MASK) {
handler.pasteRow();
}
-
- // paste : ctrl + v
// add financial transaction with the key combination : ctrl + tab
if (e.getKeyCode() == KeyEvent.VK_TAB
@@ -230,6 +230,9 @@
y_tab = this.getSelectedRow();
Boolean end = true;
+ System.out.println("x_tab : " + x_tab);
+ System.out.println("y_tab : " + y_tab);
+
if (x_tab < max_x - 1){
x_tab++;
}
@@ -238,8 +241,14 @@
x_tab=0;
y_tab++;
}
+
+ System.out.println("x_tab : " + x_tab);
+ System.out.println("max_x : " + max_x);
+ System.out.println("y_tab : " + y_tab);
+ System.out.println("max_y : " + max_y);
+
//skip all cell while not editable or if end of table add entry or transaction or end of table
- while (!isCellEditable(y_tab, x_tab) && end ){
+ while (!isCellEditable(y_tab, x_tab) && end ){
//if end of row
if (x_tab == max_x-1) {
Object object = this.handler.tableModel.getElementAt(y_tab);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-06-17 12:41:53 UTC (rev 3181)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-06-17 14:59:28 UTC (rev 3182)
@@ -355,9 +355,10 @@
/**
- * @throws LimaException
+ * @return int: indexOf new FianancialTransaction
+ * @throws LimaException
*/
- public void addFinancialTransaction() throws LimaException{
+ public int addFinancialTransaction() throws LimaException{
/* Calling transaction service */
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
financialTransaction.setAmountDebit(BigDecimal.ZERO);
@@ -391,12 +392,14 @@
// set date to the financial transaction
financialTransaction.setTransactionDate(transactionDate);
// create it
- financialTransactionService.createFinancialTransaction(financialTransaction);
+ FinancialTransaction fTransaction =
+ financialTransactionService.createFinancialTransaction(financialTransaction);
//on recharge la liste
cacheDataList = getDataList();
- int row = getDataList().indexOf(financialTransaction);
+ int row = cacheDataList.indexOf(fTransaction);
fireTableRowsInserted(row, row);
+ return row;
//fireTableDataChanged();
}
else {
@@ -407,9 +410,14 @@
/**
- * @throws LimaException
+ *
+ * @param value
+ * @param description
+ * @param row
+ * @return int: indexOf new FianancialTransaction
+ * @throws LimaException
*/
- public void addEmptyEntry(Object value, String description, int row) throws LimaException {
+ public int addEmptyEntry(Object value, String description, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
Entry entry = new EntryImpl();
@@ -428,14 +436,24 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
+ Entry newEntry = financialTransactionService.createEntry(entry);
//on recharge la liste
cacheDataList = getDataList();
- fireTableDataChanged();
+ int newrow = cacheDataList.indexOf(newEntry);
+ fireTableRowsInserted(newrow, newrow);
+ return newrow;
}
- public void addEntry(Object value, Entry entry, int row) throws LimaException {
+ /**
+ *
+ * @param value
+ * @param entry
+ * @param row
+ * @return int: indexOf new FianancialTransaction
+ * @throws LimaException
+ */
+ public int addEntry(Object value, Entry entry, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
int financialTransactionRow = 0;
Object currentRow = cacheDataList.get(row);
@@ -457,12 +475,14 @@
}
//create it
entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
+ Entry newEntry = financialTransactionService.createEntry(entry);
fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
//on recharge la liste
cacheDataList = getDataList();
- fireTableDataChanged();
+ int newrow = cacheDataList.indexOf(newEntry);
+ fireTableRowsInserted(newrow, newrow);
+ return newrow;
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-06-17 12:41:53 UTC (rev 3181)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-06-17 14:59:28 UTC (rev 3182)
@@ -91,14 +91,14 @@
Object selectedValue = tableModel.getElementAt(indexSelectedRow);
if (clipBoard instanceof Entry) {
try {
- tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow);
+ int index = tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(
indexSelectedRow+1, indexSelectedRow+1);
//focus on second column
- table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.changeSelection(index, 1, false, false);
table.requestFocusInWindow();
} catch (LimaException eee){
if (log.isErrorEnabled()) {
@@ -118,14 +118,14 @@
tableModel = view.getFinancialTransactionTableModel();
try {
- tableModel.addFinancialTransaction();
+ int index = tableModel.addFinancialTransaction();
//select the new line
int numberRow = table.getRowCount();
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(numberRow-1, numberRow-1);
//focus on first column
- table.changeSelection(numberRow-1, 0, false, false);
+ table.changeSelection(index, 0, false, false);
table.requestFocusInWindow();
} catch (LimaException eee) {
if (log.isErrorEnabled()) {
@@ -148,14 +148,14 @@
try {
//copy + paste the description
String description = (String) tableModel.getValueAt(indexSelectedRow, 4);
- tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
+ int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(
indexSelectedRow+1, indexSelectedRow+1);
//focus on second column
- table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.changeSelection(index, 1, false, false);
table.requestFocusInWindow();
} catch (LimaException eee){
if (log.isErrorEnabled()) {
1
0
r3181 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch
by vsalaun@users.chorem.org 17 Jun '11
by vsalaun@users.chorem.org 17 Jun '11
17 Jun '11
Author: vsalaun
Date: 2011-06-17 14:41:53 +0200 (Fri, 17 Jun 2011)
New Revision: 3181
Url: http://chorem.org/repositories/revision/lima/3181
Log:
add key shortcuts for transactions search (except tab key)
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-06-17 08:22:47 UTC (rev 3180)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-06-17 12:41:53 UTC (rev 3181)
@@ -33,14 +33,22 @@
import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.util.Date;
+
+import javax.swing.SwingWorker;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
import org.chorem.lima.ui.celleditor.DateTableCellEditor;
import org.chorem.lima.ui.celleditor.EmptyCellRenderer;
import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
@@ -59,12 +67,19 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(FinancialTransactionSearchTable.class);
protected FinancialTransactionSearchViewHandler handler;
private Highlighter colorTransaction;
private ColorHighlighter colorBalance;
+
+ private int x_tab;
+ private int y_tab;
/**
*/
@@ -164,12 +179,150 @@
@Override
public void keyPressed(KeyEvent e) {
+ //TODO combinaison de touches dans la config
+
+ // delete selected row with the key : delete or ctrl + clear
+ // ou de l'entree
+ if ((e.getKeyCode() == KeyEvent.VK_DELETE )
+ || (e.getKeyCode() == KeyEvent.VK_CLEAR
+ && e.getModifiers() == KeyEvent.CTRL_MASK)){
+ handler.deleteSelectedRow();
+ }
+
+ // add entry with the key combination : insert or ctrl + enter
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT )
+ || (e.getKeyCode() == KeyEvent.VK_ENTER
+ && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ handler.addEmptyEntry();
+ }
+
+ // add financial transaction with the key combination : ctrl + tab
+ if (e.getKeyCode() == KeyEvent.VK_C
+ && e.getModifiers() == KeyEvent.CTRL_MASK) {
+ handler.copyRow();
+ }
+
+ // copy : ctrl + c
+
+ // add financial transaction with the key combination : ctrl + tab
+ if (e.getKeyCode() == KeyEvent.VK_V
+ && e.getModifiers() == KeyEvent.CTRL_MASK) {
+ handler.pasteRow();
+ }
+
+ // paste : ctrl + v
+
+ // add financial transaction with the key combination : ctrl + tab
+ if (e.getKeyCode() == KeyEvent.VK_TAB
+ && e.getModifiers() == KeyEvent.CTRL_MASK) {
+ handler.addFinancialTransaction();
+ }
+
// clear row selection with the key: escape
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!this.isEditing()) {
+ if (!this.isEditing()) {
this.clearSelection();
- }
+ }
}
+
+
+ //FIXME 2011.06.11
+ //Needs fixing
+ //Exception in thread "AWT-EventQueue-0"
+ //java.lang.IndexOutOfBoundsException:
+ //valid viewIndex: 0 <= index < 42 but was: 42
+ /**
+ * Touche tab
+ * Incrémente le curseur de case tant que la case n'est pas editable
+ * Ajoute une entrée comptable si tab est sur
+ * la dernière cellule et si la transaction est non équilibré
+ * sinon rajoute une transaction
+ */
+
+ /*if (e.getKeyChar() == KeyEvent.VK_TAB) {
+ int max_x = this.getColumnCount();
+ int max_y = this.getRowCount();
+ x_tab = this.getSelectedColumn();
+ y_tab = this.getSelectedRow();
+ Boolean end = true;
+
+ if (x_tab < max_x - 1){
+ x_tab++;
+ }
+ //end of row
+ else {
+ x_tab=0;
+ y_tab++;
+ }
+
+ //skip all cell while not editable or if end of table add entry or transaction or end of table
+ while (!isCellEditable(y_tab, x_tab) && end ){
+ System.out.println("coucou");
+ //if end of row
+ if (x_tab == max_x-1) {
+ Object object = this.handler.tableModel.getElementAt(y_tab);
+
+ //if transaction, add entry
+ if (object instanceof FinancialTransaction){
+ FinancialTransaction financialTransaction = (FinancialTransaction) object;
+ if (financialTransaction.getEntry().size() == 0){
+ handler.addEmptyEntry();
+ this.setColumnSelectionInterval(1, 1);
+ }
+ }
+ //if entry
+ else {
+ //FIXME set value is doing after key pressed
+ // so update not terminated before get balanced
+ //Swing Worker stop the UI 500ms
+ // found best solution ?
+ final JXTable table = this;
+ final int y_t = y_tab;
+ final int m_t = max_y;
+ new SwingWorker<Void,Void>() {
+ @Override protected Void doInBackground() throws InterruptedException {
+ Thread.sleep(500);
+ return null;
+ }
+ @Override protected void done() {
+ Object object = handler.tableModel.getElementAt(y_tab-1);
+ FinancialTransaction financialTransaction = null;
+ if (object instanceof Entry){
+ financialTransaction = ((Entry) object).getFinancialTransaction();
+ }
+ else if (object instanceof FinancialTransaction){
+ financialTransaction = (FinancialTransaction) object;
+ }
+ BigDecimal amountC = financialTransaction.getAmountCredit();
+ BigDecimal amountD = financialTransaction.getAmountDebit();
+ if (amountC == amountD){
+ if (y_t == m_t-1){
+ handler.addFinancialTransaction();
+ table.setColumnSelectionInterval(0, 0);
+ }
+ }
+ else {
+ handler.addEmptyEntry();
+ table.setColumnSelectionInterval(1, 1);
+ y_tab++;
+ // positionne la sélection sur la nouvelle ligne créée
+ table.setRowSelectionInterval(y_tab, y_tab);
+ x_tab=0;
+ }
+ }
+ }.execute();
+ }
+ end = false;
+ }
+ else {
+ if (x_tab < max_x){
+ this.setRowSelectionInterval(y_tab, y_tab);
+ this.setColumnSelectionInterval(x_tab, x_tab);
+ x_tab++;
+ }
+ }
+ }
+ }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 08:22:47 UTC (rev 3180)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-06-17 12:41:53 UTC (rev 3181)
@@ -27,20 +27,28 @@
import static org.nuiton.i18n.I18n._;
import java.math.BigDecimal;
+import java.util.Calendar;
import java.util.Date;
import java.util.List;
import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.FinancialTransactionSearch;
+import org.chorem.lima.business.FinancialPeriodServiceMonitorable;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.Letter;
import org.chorem.lima.service.LimaServiceFactory;
@@ -71,6 +79,9 @@
/** Transaction service. */
protected final FinancialTransactionServiceMonitorable financialTransactionService;
+ /** Financial service */
+ protected final FinancialPeriodServiceMonitorable financialPeriodService;
+
/** selected financial period */
protected FiscalPeriod selectedFiscalPeriod;
@@ -90,6 +101,9 @@
LimaServiceFactory.getInstance().getService(
FinancialTransactionServiceMonitorable.class);
financialTransactionService.addListener(this);
+ financialPeriodService =
+ LimaServiceFactory.getInstance().getService(
+ FinancialPeriodServiceMonitorable.class);
}
/**
@@ -141,32 +155,33 @@
switch (column) {
case 0:
- result = Date.class;
+ result = Date.class; //Date
break;
case 1:
- result = EntryBook.class;
+ result = EntryBook.class; //EntryBook
break;
case 2:
- result = String.class;
+ result = String.class; //Voucher
break;
case 3:
- result = Account.class;
+ result = Account.class; //Account
break;
case 4:
- result = String.class;
+ result = String.class; //Description
break;
case 5:
- result = BigDecimal.class;
+ result = Letter.class; //Letter
break;
case 6:
- result = BigDecimal.class;
+ result = BigDecimal.class; //Debit
break;
case 7:
- result = BigDecimal.class;
+ result = BigDecimal.class; //Credit
break;
case 8:
- result = Letter.class;
+ result = BigDecimal.class; //Balance
break;
+
}
return result;
@@ -193,17 +208,18 @@
result = _("lima.table.description");
break;
case 5:
- result = _("lima.table.debit");
+ result = _("lima.table.letter");
break;
case 6:
- result = _("lima.table.credit");
+ result = _("lima.table.debit");
break;
case 7:
- result = _("lima.table.balance");
+ result = _("lima.table.credit");
break;
case 8:
- result = _("lima.table.letter");
+ result = _("lima.table.balance");
break;
+
}
return result;
@@ -247,39 +263,40 @@
}
break;
case 2:
- result = null; //entrybook
+ result = null; //EntryBook
break;
case 3:
- result = null; // account
+ result = null; //Account
break;
case 4:
- result = null; // description
+ result = null; //Description
break;
- case 5 :
- result = amountDebit;
+ case 5:
+ result = null; //Letter
break;
- case 6:
- result = amountCredit;
+ case 6 :
+ result = amountDebit; //Debit
break;
case 7:
- result = amountDebit.subtract(amountCredit);
+ result = amountCredit; //Credit
break;
case 8:
- result = null;
+ result = amountDebit.subtract(amountCredit); //Balance
break;
+
}
}
else if (result instanceof Entry) {
Entry currentEntry = (Entry)result;
switch (column) {
case 0:
- result = null; // date
+ result = null; //Date
break;
- case 1 : // entry book
+ case 1 : //EntryBook
result = null;
break;
case 2:
- result = currentEntry.getVoucher();
+ result = currentEntry.getVoucher(); //Voucher
break;
case 3: // account
if (currentEntry.getAccount() != null){
@@ -290,18 +307,9 @@
}
break;
case 4:
- result = currentEntry.getDescription();
+ result = currentEntry.getDescription(); //Description
break;
- case 5 :
- result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO;
- break;
- case 6:
- result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount();
- break;
- case 7:
- result = null;
- break;
- case 8:
+ case 5:
if (currentEntry.getLetter() != null){
result = currentEntry.getLetter().getCode();
}
@@ -309,6 +317,15 @@
result = null;
}
break;
+ case 6: //Debit
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO;
+ break;
+ case 7: //Credit
+ result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount();
+ break;
+ case 8:
+ result = null; //Balance
+ break;
}
}
@@ -344,6 +361,67 @@
/**
* @throws LimaException
*/
+ public void addFinancialTransaction() throws LimaException{
+ /* Calling transaction service */
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ financialTransaction.setAmountDebit(BigDecimal.ZERO);
+ financialTransaction.setAmountCredit(BigDecimal.ZERO);
+ //if a period is selected
+ if (selectedFiscalPeriod != null){
+ List<FinancialPeriod> financialPeriodsList =
+ financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(),
+ selectedFiscalPeriod.getEndDate());
+ FinancialPeriod financialPeriod = null;
+ if (financialPeriodsList != null) {
+ financialPeriod = financialPeriodsList.get(0);
+ } else {
+ throw new LimaException("Can't set new transaction");
+ }
+ financialTransaction.setFinancialPeriod(financialPeriod);
+ //financialTransaction.setFinancialPeriod(selectedFiscalPeriod);
+ // get today
+ Calendar actualCalendar = Calendar.getInstance();
+ // get the financial period date
+ Date transactionDate = financialPeriod.getBeginDate();
+
+ Calendar calEnd = Calendar.getInstance();
+ calEnd.setTime(financialPeriod.getEndDate());
+ int dayMax = calEnd.get(Calendar.DAY_OF_MONTH);
+ Calendar calBegin = Calendar.getInstance();
+ calBegin.setTime(financialPeriod.getBeginDate());
+ int dayMin = calBegin.get(Calendar.DAY_OF_MONTH);
+ int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH);
+
+ if ((toDay>dayMax) || (toDay<dayMin)){
+ // change the day
+ transactionDate = DateUtils.setDays(transactionDate, dayMax);
+ }
+ else{
+ // change the day
+ transactionDate = DateUtils.setDays(transactionDate, toDay);
+ }
+
+
+ // set date to the financial transaction
+ financialTransaction.setTransactionDate(transactionDate);
+ // create it
+ financialTransactionService.createFinancialTransaction(financialTransaction);
+
+ //on recharge la liste
+ cacheDataList = getDataList(financialTransactionSearch);
+ int row = getDataList(financialTransactionSearch).indexOf(financialTransaction);
+ fireTableRowsInserted(row, row);
+ //fireTableDataChanged();
+ }
+ else {
+ throw new LimaBusinessException("No financial period selected");
+ }
+ }
+
+
+ /**
+ * @throws LimaException
+ */
public void addEmptyEntry(Object value, int row) throws LimaException {
FinancialTransaction currentTransaction = null;
Object currentRow = cacheDataList.get(row);
@@ -471,6 +549,66 @@
fireTableDataChanged();
}
+
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyEntry(Object value, String description, int row) throws LimaException {
+ FinancialTransaction currentTransaction = null;
+ Object currentRow = cacheDataList.get(row);
+ Entry entry = new EntryImpl();
+ entry.setAmount(BigDecimal.ZERO);
+ if (description != null) {
+ entry.setDescription(description);
+ }
+ //check if current row is a transaction or an entry
+ if (currentRow instanceof FinancialTransaction) {
+ currentTransaction = (FinancialTransaction)currentRow;
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //get back the parent transaction of the entry
+ currentTransaction = currentEntry.getFinancialTransaction();
+ }
+ //create it
+ entry.setFinancialTransaction(currentTransaction);
+ financialTransactionService.createEntry(entry);
+
+ //on recharge la liste
+ cacheDataList = getDataList(financialTransactionSearch);
+ fireTableDataChanged();
+ }
+
+ public void addEntry(Object value, Entry entry, int row) throws LimaException {
+ FinancialTransaction currentTransaction = null;
+ int financialTransactionRow = 0;
+ Object currentRow = cacheDataList.get(row);
+ //check if current row is a transaction or an entry
+ if (currentRow instanceof FinancialTransaction) {
+ currentTransaction = (FinancialTransaction)currentRow;
+ //update the financial transaction in entire
+ financialTransactionRow =
+ getDataList(financialTransactionSearch).indexOf(((FinancialTransaction) currentRow));
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //get back the parent transaction of the entry
+ currentTransaction = currentEntry.getFinancialTransaction();
+ //update the financial transaction in entire
+ financialTransactionRow =
+ getDataList(financialTransactionSearch).indexOf(((Entry) currentRow).
+ getFinancialTransaction());
+ }
+ //create it
+ entry.setFinancialTransaction(currentTransaction);
+ financialTransactionService.createEntry(entry);
+ fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
+
+ //on recharge la liste
+ cacheDataList = getDataList(financialTransactionSearch);
+ fireTableDataChanged();
+ }
+
@Override
public void notifyMethod(String serviceName, String methodeName) {
if ((serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries")
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-06-17 08:22:47 UTC (rev 3180)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-06-17 12:41:53 UTC (rev 3181)
@@ -25,19 +25,29 @@
package org.chorem.lima.ui.financialtransactionsearch;
+import static org.nuiton.i18n.I18n._;
+
import java.util.Date;
+
+import javax.swing.JOptionPane;
+import javax.swing.ListSelectionModel;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.beans.FinancialTransactionSearch;
import org.chorem.lima.beans.FinancialTransactionSearchImpl;
import org.chorem.lima.business.FinancialTransactionServiceMonitorable;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ejbinterface.FinancialTransactionService;
import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.Letter;
import org.chorem.lima.service.LimaServiceFactory;
import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
+import org.chorem.lima.util.DialogHelper;
/**
* Handler associated with financial transaction view.
@@ -67,6 +77,8 @@
/** data cache */
protected FinancialTransactionSearch financialTransactionSearch;
+
+ protected Object clipBoard;
protected FinancialTransactionSearchViewHandler(FinancialTransactionSearchView view) {
this.view = view;
@@ -169,8 +181,160 @@
}
financialTransactionSearch.setOperator(result);
}
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @throws LimaException
+ */
+ public void deleteSelectedRow(){
+ table = view.getFinancialTransactionSearchTable();
+ tableModel = view.getFinancialTransactionSearchTableModel();
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
+ String message = null;
+ if (selectedValue instanceof FinancialTransaction) {
+ message = _("lima.charts.financialtransaction.question.removetransaction");
+ }
+ else {
+ message = _("lima.charts.financialtransaction.question.removeentry");
+ }
+
+ int response = JOptionPane.showConfirmDialog(view, message,
+ _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
+
+ if (response == JOptionPane.YES_OPTION) {
+
+ try {
+ tableModel.removeObject(selectedValue, indexSelectedRow);
+ //select the upper line
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow-1, indexSelectedRow-1);
+ } catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't remove transaction or entry", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call delete selected row without selection");
+ }
+ }
+ }
+
+
+ //implement new transaction button
+ //add a new entry to the selected transaction
+ public void addEmptyEntry(){
+
+ table = view.getFinancialTransactionSearchTable();
+ tableModel = view.getFinancialTransactionSearchTableModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
+ try {
+ //copy + paste the description
+ String description = (String) tableModel.getValueAt(indexSelectedRow, 4);
+ tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
+ //select the new line
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow+1, indexSelectedRow+1);
+ //focus on second column
+ table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.requestFocusInWindow();
+ } catch (LimaException eee){
+ if (log.isErrorEnabled()) {
+ log.error("Can't add emptyentry", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
+ else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call addentry selected transaction without selection");
+ }
+ }
+ }
+
+
+ //copy entry
+ public void copyRow(){
+ table = view.getFinancialTransactionSearchTable();
+ int indexSelectedRow = table.getSelectedRow();
+
+ if (indexSelectedRow != -1) {
+ clipBoard = tableModel.getElementAt(indexSelectedRow);
+ }
+ }
+
+ //paste entry
+ public void pasteRow(){
+ table = view.getFinancialTransactionSearchTable();
+ int indexSelectedRow = table.getSelectedRow();
+
+ if (indexSelectedRow != -1) {
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
+ if (clipBoard instanceof Entry) {
+ try {
+ tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow);
+ //select the new line
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow+1, indexSelectedRow+1);
+ //focus on second column
+ table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.requestFocusInWindow();
+ } catch (LimaException eee){
+ if (log.isErrorEnabled()) {
+ log.error("Can't past entry", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
+
+ }
+
+ }
+
+
+ //add a new transaction
+ public void addFinancialTransaction() {
+ table = view.getFinancialTransactionSearchTable();
+ tableModel = view.getFinancialTransactionSearchTableModel();
+
+ try {
+ tableModel.addFinancialTransaction();
+ //select the new line
+ int numberRow = table.getRowCount();
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(numberRow-1, numberRow-1);
+ //focus on first column
+ table.changeSelection(numberRow-1, 0, false, false);
+ table.requestFocusInWindow();
+ } catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add financialtransaction", eee);
+ }
+ DialogHelper.showMessageDialog(eee.getMessage());
+ }
+ }
+
+
public void refresh(){
tableModel = view.getFinancialTransactionSearchTableModel();
if (tableModel != null){
1
0
r3180 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by vsalaun@users.chorem.org 17 Jun '11
by vsalaun@users.chorem.org 17 Jun '11
17 Jun '11
Author: vsalaun
Date: 2011-06-17 10:22:47 +0200 (Fri, 17 Jun 2011)
New Revision: 3180
Url: http://chorem.org/repositories/revision/lima/3180
Log:
#310 modify order: FinancialTransaction DATE, then FinancialTrasaction TOPIA CREATE DATE
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-06-15 13:54:16 UTC (rev 3179)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2011-06-17 08:22:47 UTC (rev 3180)
@@ -190,7 +190,8 @@
.addBetween(FinancialTransaction.TRANSACTION_DATE, beginDate, endDate)
.addDistinct()
- .addOrder("T."+FinancialTransaction.TOPIA_CREATE_DATE)
+ .addOrder("T." + FinancialTransaction.TRANSACTION_DATE)
+ .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
//load for lazy
.addLoad(financialPeriodProperty)
.addLoad(entryBookLabelProperty)
@@ -235,7 +236,8 @@
query.addEquals("financialPeriod", financialPeriod);
}
query.addDistinct()
- .addOrder("T."+FinancialTransaction.TOPIA_CREATE_DATE)
+ .addOrder("T." + FinancialTransaction.TRANSACTION_DATE)
+ .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
//load for lazy
.addLoad(financialPeriodProperty)
.addLoad(entryBookLabelProperty)
@@ -273,7 +275,8 @@
TopiaQuery query = financialTransactionDAO.createQuery("T");
query.addDistinct()
- .addOrder("T."+FinancialTransaction.TOPIA_CREATE_DATE)
+ .addOrder("T." + FinancialTransaction.TRANSACTION_DATE)
+ .addOrder("T." + FinancialTransaction.TOPIA_CREATE_DATE)
.addFrom(FiscalPeriod.class, "F")
.addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true)
.addWhere("T.amountCredit != T.amountDebit OR E.account = null OR T.entryBook = null OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = ''")
1
0
r3179 - in trunk/lima-business/src/main/java/org/chorem/lima/business: ejb ejbinterface
by vsalaun@users.chorem.org 15 Jun '11
by vsalaun@users.chorem.org 15 Jun '11
15 Jun '11
Author: vsalaun
Date: 2011-06-15 15:54:16 +0200 (Wed, 15 Jun 2011)
New Revision: 3179
Url: http://chorem.org/repositories/revision/lima/3179
Log:
#347 sets generateSubAccountBalanceWithTransaction to public in ReportService
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2011-06-15 13:11:18 UTC (rev 3178)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2011-06-15 13:54:16 UTC (rev 3179)
@@ -269,7 +269,7 @@
*
* Get all entries if true
*/
- protected ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException {
+ public ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
BigDecimal credit = new BigDecimal(0);
BigDecimal debit = new BigDecimal(0);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java 2011-06-15 13:11:18 UTC (rev 3178)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/ReportService.java 2011-06-15 13:54:16 UTC (rev 3179)
@@ -36,6 +36,7 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FiscalPeriod;
+import org.nuiton.topia.TopiaContext;
/**
* Service de generation des rapports.
@@ -87,7 +88,15 @@
*/
ReportsDatas generateAccountsReports(Account account, Boolean thirdPartAccountsMode, Date beginDate, Date endDate) throws LimaException;
+
/**
+ * Calculate all credit, debit and solde amounts for the balance
+ *
+ * Get all entries if true
+ */
+ ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException;
+
+ /**
* Generation du rapports des journaux
*/
ReportsDatas generateEntryBooksReports(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException;
1
0