Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | mogray | ||||||||
Approved revision: | no longer in the source branch. | ||||||||
Merged at revision: | 67 | ||||||||
Proposed branch: | lp:infinitypfm/0.7 | ||||||||
Merge into: | lp:infinitypfm/trunk | ||||||||
Diff against target: |
8873 lines (+2880/-2208) 51 files modified
infinitypfm/.classpath (+2/-1) infinitypfm/debbootstrap.txt (+8/-6) infinitypfm/debian/changelog (+6/-0) infinitypfm/debian/control (+4/-1) infinitypfm/src/main/java/org/infinitypfm/client/InfinityPfm.java (+2/-2) infinitypfm/src/main/java/org/infinitypfm/core/action/MainAction.java (+76/-25) infinitypfm/src/main/java/org/infinitypfm/core/conf/LangLoader.java (+13/-6) infinitypfm/src/main/java/org/infinitypfm/core/conf/MM.java (+8/-5) infinitypfm/src/main/java/org/infinitypfm/core/currency/RateParser.java (+23/-23) infinitypfm/src/main/java/org/infinitypfm/core/data/Account.xml (+20/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/DataFormatUtil.java (+89/-93) infinitypfm/src/main/java/org/infinitypfm/core/data/Database.java (+7/-5) infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRule.java (+61/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRules.xml (+74/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/InfinityUpdates.java (+18/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/Manage.xml (+21/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/ReportData.java (+69/-62) infinitypfm/src/main/java/org/infinitypfm/core/data/Reports.xml (+13/-13) infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfig.xml (+1/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfigSvr.xml (+1/-0) infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.java (+27/-23) infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.xml (+3/-3) infinitypfm/src/main/java/org/infinitypfm/core/data/Updates.xml (+2/-1) infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BaseImport.java (+9/-18) infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BitcoinImport.java (+40/-35) infinitypfm/src/main/java/org/infinitypfm/core/data/imports/OfxImport.java (+10/-30) infinitypfm/src/main/java/org/infinitypfm/core/data/imports/QfxImport.java (+11/-21) infinitypfm/src/main/java/org/infinitypfm/core/reporting/AccountHistory.java (+74/-73) infinitypfm/src/main/java/org/infinitypfm/core/types/AccountTypes.java (+26/-0) infinitypfm/src/main/java/org/infinitypfm/core/types/ImportRuleNames.java (+30/-0) infinitypfm/src/main/java/org/infinitypfm/ui/MainFrame.java (+147/-181) infinitypfm/src/main/java/org/infinitypfm/ui/MoneyTree.java (+186/-213) infinitypfm/src/main/java/org/infinitypfm/ui/ViewHandler.java (+126/-131) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/AccountSelectorDialog.java (+53/-45) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/BudgetSelector.java (+2/-1) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/DefaultAccountSelectorDialog.java (+74/-79) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportDialog.java (+250/-178) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportRulesDialog.java (+280/-0) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/InfoDialog.java (+28/-46) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/NewAccountDialog.java (+72/-83) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/OptionsDialog.java (+63/-86) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/TransactionDialog.java (+12/-13) infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/UpdateMethodSelectorDialog.java (+19/-2) infinitypfm/src/main/java/org/infinitypfm/ui/view/menus/MainMenu.java (+96/-103) infinitypfm/src/main/java/org/infinitypfm/ui/view/menus/TreeMenu.java (+3/-0) infinitypfm/src/main/java/org/infinitypfm/ui/view/views/BudgetView.java (+368/-322) infinitypfm/src/main/java/org/infinitypfm/ui/view/views/CurrencyView.java (+118/-135) infinitypfm/src/main/java/org/infinitypfm/ui/view/views/RecurrenceView.java (+170/-81) infinitypfm/src/main/java/org/infinitypfm/ui/view/views/RegisterView.java (+63/-52) infinitypfm/src/main/java/org/infinitypfm/ui/view/views/ReportView.java (+1/-10) infinitypfm/src/main/java/ru/paradoxs/bitcoin/client/BitcoinClient.java (+1/-1) |
||||||||
To merge this branch: | bzr merge lp:infinitypfm/0.7 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
mogray | Approve | ||
Review via email: mp+243089@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
mogray (mogray5) wrote : | # |
Revision history for this message
mogray (mogray5) : | # |
review:
Approve
lp:infinitypfm/0.7
updated
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'DOC/images/infinitylogo2.png' |
2 | Binary files DOC/images/infinitylogo2.png 2012-03-21 00:23:47 +0000 and DOC/images/infinitylogo2.png 1970-01-01 00:00:00 +0000 differ |
3 | === modified file 'infinitypfm/.classpath' |
4 | --- infinitypfm/.classpath 2012-08-26 22:11:17 +0000 |
5 | +++ infinitypfm/.classpath 2014-11-27 22:23:48 +0000 |
6 | @@ -2,7 +2,6 @@ |
7 | <classpath> |
8 | <classpathentry kind="src" path="src/main/java"/> |
9 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
10 | - <classpathentry kind="lib" path="/usr/share/java/swt.jar"/> |
11 | <classpathentry kind="lib" path="/usr/share/java/hsqldb.jar"/> |
12 | <classpathentry kind="lib" path="/usr/share/java/hsqldbutil.jar"/> |
13 | <classpathentry kind="lib" path="/usr/share/java/ibatis.jar"/> |
14 | @@ -17,5 +16,7 @@ |
15 | <classpathentry kind="lib" path="/usr/share/java/commons-lang.jar"/> |
16 | <classpathentry kind="lib" path="/usr/share/java/ezmorph.jar"/> |
17 | <classpathentry kind="lib" path="/usr/share/java/commons-collections3.jar"/> |
18 | + <classpathentry kind="lib" path="/usr/share/java/swt.jar"/> |
19 | + <classpathentry kind="lib" path="/usr/share/java/ant.jar"/> |
20 | <classpathentry kind="output" path="bin"/> |
21 | </classpath> |
22 | |
23 | === modified file 'infinitypfm/debbootstrap.txt' |
24 | --- infinitypfm/debbootstrap.txt 2012-12-02 04:37:54 +0000 |
25 | +++ infinitypfm/debbootstrap.txt 2014-11-27 22:23:48 +0000 |
26 | @@ -1,9 +1,3 @@ |
27 | -sudo apt-get install openjdk-6-jre-headless |
28 | -sudo apt-get install libswt-gtk-3.5-java libswt-mozilla-gtk-3.5-jni libhsqldb-java libibatis-java libxerces2-java libcommons-io-java libcommons-compress-java libjson-java |
29 | - |
30 | -core: libhsqldb-java, libibatis-java, libxerces2-java, libcommons-io-java, libcommons-compress-java |
31 | -ui: libswt-gtk-3.5-java libswt-mozilla-gtk-3.5-jni, libhsqldb-java, libibatis-java, libxerces2-java, libcommons-io-java |
32 | - |
33 | UBUNTU |
34 | |
35 | debuild -us -uc #unsigned |
36 | @@ -11,6 +5,7 @@ |
37 | dput ppa:mogray5/ppa-infinitypfm <source.changes> #upload to ppa |
38 | sign files: gpg -r wgray@infinitypfm.org --armor --sign --detach-sig <filename>. |
39 | |
40 | + |
41 | sudo apt-get install gettext |
42 | |
43 | xgettext -ktrc:1c,2 -ktrnc:1c,2,3 -ktr -kmarktr -ktrn:1,2 -o org/infinitypfm/core/po/infinitypfm.pot org/infinitypfm/core/conf/LangLoader.java |
44 | @@ -24,6 +19,13 @@ |
45 | debian-el devscripts devscripts-el dh-make dpatch dpkg-awk \ |
46 | dpkg-dev dpkg-dev-el equivs fakeroot lintian quilt sbuild javahelper ant |
47 | |
48 | +apt-get install build-essential devscripts javahelper ant equivs |
49 | + |
50 | +#Install dependencies from control file |
51 | +mk-build-deps --install debian/control |
52 | + |
53 | +pbuilder-dist lucid build infinitypfm-ui_0.7.0-2ppa2.dsc |
54 | + |
55 | java -cp /usr/share/java/hsqldb.jar org.hsqldb.util.DatabaseManagerSwing |
56 | |
57 | ...or... |
58 | |
59 | === modified file 'infinitypfm/debian/changelog' |
60 | --- infinitypfm/debian/changelog 2012-12-07 02:42:24 +0000 |
61 | +++ infinitypfm/debian/changelog 2014-11-27 22:23:48 +0000 |
62 | @@ -1,3 +1,9 @@ |
63 | +infinitypfm-ui (0.7.0-1ppa1) precise; urgency=low |
64 | + |
65 | + * Fix for lp:1121332 Bitcoin import not working with version 0.7.2 |
66 | + |
67 | + -- Wayne Gray <wgray@infinitypfm.org> Mon, 11 Feb 2013 19:57:00 -0000 |
68 | + |
69 | infinitypfm-ui (0.6.0-5ppa1) precise; urgency=low |
70 | |
71 | * Split transaction support |
72 | |
73 | === modified file 'infinitypfm/debian/control' |
74 | --- infinitypfm/debian/control 2012-09-09 14:35:10 +0000 |
75 | +++ infinitypfm/debian/control 2014-11-27 22:23:48 +0000 |
76 | @@ -17,6 +17,9 @@ |
77 | |
78 | Package: infinitypfm-ui |
79 | Architecture: all |
80 | -Depends: ${java:Depends}, ${misc:Depends}, libswt-mozilla-gtk-3.5-jni | libswt-webkit-gtk-3-jni | libswt-webkit-gtk-3.6-jni |
81 | +Depends: ${java:Depends}, |
82 | + ${misc:Depends}, |
83 | + libswt-mozilla-gtk-3.5-jni | libswt-webkit-gtk-3-jni | libswt-webkit-gtk-3.6-jni, |
84 | + libswt-cairo-gtk-3-jni | libswt-cairo-gtk-3.5-jni |
85 | Description: Desktop client for Infinity PFM |
86 | Infinity PFM is personal finance manager with support for budgets, OFX/QIF/QFX import, color reports and charts. |
87 | |
88 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/client/InfinityPfm.java' |
89 | --- infinitypfm/src/main/java/org/infinitypfm/client/InfinityPfm.java 2012-08-26 22:11:17 +0000 |
90 | +++ infinitypfm/src/main/java/org/infinitypfm/client/InfinityPfm.java 2014-11-27 22:23:48 +0000 |
91 | @@ -227,8 +227,8 @@ |
92 | e.printStackTrace(); |
93 | } finally { |
94 | |
95 | - try {out.close();} catch (Exception e) {} |
96 | - try {in.close();} catch (Exception e) {} |
97 | + try {out.close();} catch (Exception e) {System.err.println(e.getMessage());} |
98 | + try {in.close();} catch (Exception e) {System.err.println(e.getMessage());} |
99 | |
100 | } |
101 | |
102 | |
103 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/action/MainAction.java' |
104 | --- infinitypfm/src/main/java/org/infinitypfm/core/action/MainAction.java 2012-08-26 22:11:17 +0000 |
105 | +++ infinitypfm/src/main/java/org/infinitypfm/core/action/MainAction.java 2014-11-27 22:23:48 +0000 |
106 | @@ -1,5 +1,5 @@ |
107 | /* |
108 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
109 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
110 | * |
111 | * This file is part of Infinity PFM. |
112 | * |
113 | @@ -34,7 +34,6 @@ |
114 | import org.eclipse.swt.widgets.DirectoryDialog; |
115 | import org.eclipse.swt.widgets.FileDialog; |
116 | import org.infinitypfm.client.InfinityPfm; |
117 | -import org.infinitypfm.core.conf.LangLoader; |
118 | import org.infinitypfm.core.conf.MM; |
119 | import org.infinitypfm.core.data.Account; |
120 | import org.infinitypfm.core.data.Budget; |
121 | @@ -58,6 +57,7 @@ |
122 | import org.infinitypfm.ui.view.dialogs.DefaultAccountSelectorDialog; |
123 | import org.infinitypfm.ui.view.dialogs.HelpDialog; |
124 | import org.infinitypfm.ui.view.dialogs.ImportDialog; |
125 | +import org.infinitypfm.ui.view.dialogs.ImportRulesDialog; |
126 | import org.infinitypfm.ui.view.dialogs.InfoDialog; |
127 | import org.infinitypfm.ui.view.dialogs.MessageDialog; |
128 | import org.infinitypfm.ui.view.dialogs.NewAccountDialog; |
129 | @@ -68,13 +68,10 @@ |
130 | import org.infinitypfm.ui.view.views.BaseView; |
131 | import org.infinitypfm.ui.view.views.ReportView; |
132 | |
133 | -//import org.apache.commons.io.*; |
134 | - |
135 | /** |
136 | - * @author WGGRAY |
137 | + * This class contains handlers for the majority of menu item actions. |
138 | * |
139 | - * To change the template for this generated type comment go to |
140 | - * Window>Preferences>Java>Code Generation>Code and Comments |
141 | + * @author Wayne Gray |
142 | */ |
143 | public class MainAction { |
144 | |
145 | @@ -84,20 +81,28 @@ |
146 | |
147 | public void ProcessMenuItem(int item) { |
148 | |
149 | + int selectedAccount = -1; |
150 | + |
151 | + if (InfinityPfm.qzMain.getTrMain().getSelectedAccount() != null) { |
152 | + selectedAccount = InfinityPfm.qzMain.getTrMain().getSelectedAccount().getActId(); |
153 | + } |
154 | + |
155 | switch (item) { |
156 | case MM.MENU_FILE_EXIT: |
157 | InfinityPfm.shMain.dispose(); |
158 | break; |
159 | case MM.MENU_FILE_SAVE: |
160 | - |
161 | break; |
162 | case MM.MENU_FILE_IMPORT_QFX: |
163 | case MM.MENU_FILE_IMPORT_OFX: |
164 | case MM.MENU_FILE_IMPORT_QIF: |
165 | - this.LoadImportDialog(item); |
166 | + this.LoadImportDialog(item, selectedAccount); |
167 | + break; |
168 | + case MM.MENU_FILE_IMPORT_RULES: |
169 | + this.LoadImportRulesDialog(); |
170 | break; |
171 | case MM.MENU_FILE_IMPORT_BTC: |
172 | - this.BitcoinImport(); |
173 | + this.BitcoinImport(selectedAccount); |
174 | break; |
175 | case MM.MENU_EDIT_ADD_ACCOUNT: |
176 | this.LoadNewAccountDialog(); |
177 | @@ -120,6 +125,9 @@ |
178 | case MM.MENU_TREE_ACT_ADD: |
179 | this.LoadNewAccountDialog(); |
180 | break; |
181 | + case MM.MENU_TREE_EDIT_ACT: |
182 | + LoadEditAccountDialog(); |
183 | + break; |
184 | case MM.MENU_TREE_ADD_ACT_FROM_TEMP: |
185 | this.LoadNewAccountSelectorDialog(); |
186 | break; |
187 | @@ -256,12 +264,17 @@ |
188 | BaseDialog act = new NewAccountDialog(); |
189 | act.Open(); |
190 | } |
191 | - |
192 | + |
193 | + public void LoadEditAccountDialog() { |
194 | + BaseDialog act = new NewAccountDialog(); |
195 | + act.Open(); |
196 | + } |
197 | public void LoadNewAccountSelectorDialog() { |
198 | BaseDialog act = new DefaultAccountSelectorDialog(); |
199 | act.Open(); |
200 | } |
201 | |
202 | + @SuppressWarnings("rawtypes") |
203 | public void AddToBudget() { |
204 | AccountSelectorDialog dlg = new AccountSelectorDialog(); |
205 | dlg.Open(); |
206 | @@ -300,6 +313,7 @@ |
207 | |
208 | } |
209 | |
210 | + @SuppressWarnings("rawtypes") |
211 | public void RemoveFromBudget() { |
212 | AccountSelectorDialog dlg = new AccountSelectorDialog(); |
213 | dlg.Open(); |
214 | @@ -332,7 +346,7 @@ |
215 | |
216 | } |
217 | |
218 | - public void LoadImportDialog(int importType) { |
219 | + public void LoadImportDialog(int importType, int showAccount) { |
220 | |
221 | FileDialog dlg = new FileDialog(InfinityPfm.shMain); |
222 | dlg.setText(MM.PHRASES.getPhrase("18")); |
223 | @@ -360,7 +374,7 @@ |
224 | try { |
225 | |
226 | List<Transaction> trans = fileImport.ImportFile(sFile); |
227 | - ShowImportDialog(trans); |
228 | + ShowImportDialog(trans, showAccount); |
229 | |
230 | } catch (FileNotFoundException e) { |
231 | InfinityPfm.LogMessage(e.getMessage(), true); |
232 | @@ -372,18 +386,55 @@ |
233 | |
234 | } |
235 | |
236 | - public void BitcoinImport(){ |
237 | + public void LoadImportRulesDialog(){ |
238 | + ImportRulesDialog rulesDialog = new ImportRulesDialog(); |
239 | + rulesDialog.Open(); |
240 | + } |
241 | + |
242 | + public void BitcoinImport(int showAccount){ |
243 | |
244 | |
245 | if (MM.bitcoinUser == null){ |
246 | - PasswordDialog pwdDlg = new PasswordDialog(); |
247 | - |
248 | - String[] creds = pwdDlg.getCredentials(); |
249 | - |
250 | - if (creds.length==2){ |
251 | - |
252 | - MM.bitcoinUser = creds[0]; |
253 | - MM.bitcoinPwd = creds[1]; |
254 | + |
255 | + //Check if bitcoin.conf exists |
256 | + FileHandler fileHandler = new FileHandler(); |
257 | + |
258 | + try { |
259 | + fileHandler.FileOpenRead(System.getProperty("user.home") + "/.bitcoin/bitcoin.conf"); |
260 | + String temp = fileHandler.LineInput(); |
261 | + while (temp!=null){ |
262 | + |
263 | + if (MM.bitcoinUser!=null && MM.bitcoinPwd != null) break; |
264 | + |
265 | + if (temp.startsWith("rpcuser")){ |
266 | + MM.bitcoinUser = temp.split("=")[1].trim(); |
267 | + } else if (temp.startsWith("rpcpassword")){ |
268 | + MM.bitcoinPwd = temp.split("=")[1].trim(); |
269 | + } |
270 | + |
271 | + temp = fileHandler.LineInput(); |
272 | + } |
273 | + |
274 | + fileHandler.FileClose(); |
275 | + |
276 | + } catch (FileNotFoundException e) { |
277 | + InfinityPfm.LogMessage(e.getMessage(), true); |
278 | + } catch (IOException e) { |
279 | + InfinityPfm.LogMessage(e.getMessage(), true); |
280 | + } |
281 | + |
282 | + //Show a dialog if bitcoin.conf was not used |
283 | + if (MM.bitcoinUser==null || MM.bitcoinPwd==null){ |
284 | + |
285 | + PasswordDialog pwdDlg = new PasswordDialog(); |
286 | + |
287 | + String[] creds = pwdDlg.getCredentials(); |
288 | + |
289 | + if (creds.length==2){ |
290 | + |
291 | + MM.bitcoinUser = creds[0]; |
292 | + MM.bitcoinPwd = creds[1]; |
293 | + } |
294 | } |
295 | |
296 | if (MM.bitcoinUser==null || MM.bitcoinUser.length()==0){ |
297 | @@ -394,13 +445,13 @@ |
298 | |
299 | BitcoinImport importTest = new BitcoinImport(); |
300 | List<Transaction> trans = importTest.ImportFile("blah"); |
301 | - ShowImportDialog(trans); |
302 | + ShowImportDialog(trans, showAccount); |
303 | |
304 | } |
305 | |
306 | - private void ShowImportDialog(List<Transaction> trans){ |
307 | + private void ShowImportDialog(List<Transaction> trans, int showAccount){ |
308 | |
309 | - ImportDialog importDialog = new ImportDialog(trans); |
310 | + ImportDialog importDialog = new ImportDialog(trans, showAccount); |
311 | importDialog.Open(); |
312 | InfinityPfm.qzMain.getVwMain().RefreshCurrentView(); |
313 | |
314 | |
315 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/conf/LangLoader.java' |
316 | --- infinitypfm/src/main/java/org/infinitypfm/core/conf/LangLoader.java 2012-12-03 03:03:10 +0000 |
317 | +++ infinitypfm/src/main/java/org/infinitypfm/core/conf/LangLoader.java 2014-11-27 22:23:48 +0000 |
318 | @@ -1,5 +1,5 @@ |
319 | /* |
320 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
321 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
322 | * |
323 | * This file is part of Infinity PFM. |
324 | * |
325 | @@ -20,17 +20,13 @@ |
326 | package org.infinitypfm.core.conf; |
327 | |
328 | import java.util.HashMap; |
329 | -import java.util.Locale; |
330 | |
331 | import org.xnap.commons.i18n.I18n; |
332 | import org.xnap.commons.i18n.I18nFactory; |
333 | |
334 | |
335 | /** |
336 | - * @author wggray |
337 | - * |
338 | - * TODO To change the template for this generated type comment go to |
339 | - * Window - Preferences - Java - Code Style - Code Templates |
340 | + * @author Wayne Gray |
341 | */ |
342 | public class LangLoader { |
343 | |
344 | @@ -281,6 +277,17 @@ |
345 | hmPhrases.put("234", i18n.tr("Invalid offset account or amount")); |
346 | hmPhrases.put("235", i18n.tr("Split")); |
347 | hmPhrases.put("236", i18n.tr("Delete Row")); |
348 | + hmPhrases.put("237", i18n.tr("Check")); |
349 | + hmPhrases.put("238", i18n.tr("Post All")); |
350 | + hmPhrases.put("239", i18n.tr("pending transactions posted")); |
351 | + hmPhrases.put("240", i18n.tr("Import Rules")); |
352 | + hmPhrases.put("241", i18n.tr("Assign To")); |
353 | + hmPhrases.put("242", i18n.tr("New Rule")); |
354 | + hmPhrases.put("243", i18n.tr("Contains")); |
355 | + hmPhrases.put("244", i18n.tr("Starts With")); |
356 | + hmPhrases.put("245", i18n.tr("Ends With")); |
357 | + hmPhrases.put("246", i18n.tr("Import rule contains an invalid account!")); |
358 | + |
359 | |
360 | } |
361 | |
362 | |
363 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/conf/MM.java' |
364 | --- infinitypfm/src/main/java/org/infinitypfm/core/conf/MM.java 2012-12-03 03:03:10 +0000 |
365 | +++ infinitypfm/src/main/java/org/infinitypfm/core/conf/MM.java 2014-11-27 22:23:48 +0000 |
366 | @@ -38,10 +38,10 @@ |
367 | * Program Constants |
368 | */ |
369 | public static final String APPTITLE = "Infinity PFM"; |
370 | - public static final String APPVERSION = "0.6.0"; |
371 | - public static final String APPLINK = "https://launchpad.net/infinitypfm"; |
372 | + public static final String APPVERSION = "0.7.0"; |
373 | + public static final String APPLINK = "https://www.infinitypfm.org"; |
374 | public static final String APPLICENCE = "GNU General Public License v3"; |
375 | - public static final String APPCOPYRIGHT = "(c) 2005-2012 by Wayne Gray"; |
376 | + public static final String APPCOPYRIGHT = "(c) 2005-2013 by Wayne Gray"; |
377 | public static final String APPPATH = System.getProperty("INFINITYPFM_HOME") + File.separator; |
378 | public static final int ROW_BACKGROUND = SWT.COLOR_LIST_BACKGROUND; |
379 | |
380 | @@ -80,6 +80,7 @@ |
381 | |
382 | public static final String ACT_TYPE_EXPENSE = "Expense"; |
383 | public static final String ACT_TYPE_LIABILITY = "Liability"; |
384 | + public static final String ACT_TYPE_INCOME = "Income"; |
385 | |
386 | public static final int YES = 0; |
387 | public static final int NO = 1; |
388 | @@ -114,6 +115,7 @@ |
389 | public static final int MENU_TREE_ADD_ACT_BUDGET = 25; |
390 | public static final int MENU_TREE_ADD_ACT_FROM_TEMP = 26; |
391 | public static final int MENU_TREE_REM_ACT_BUDGET = 27; |
392 | + public static final int MENU_TREE_EDIT_ACT = 28; |
393 | |
394 | public static final int MENU_FILE_EXIT = 30; |
395 | public static final int MENU_FILE_SAVE = 31; |
396 | @@ -121,8 +123,9 @@ |
397 | public static final int MENU_FILE_IMPORT_QFX = 33; |
398 | public static final int MENU_FILE_IMPORT_QIF = 34; |
399 | public static final int MENU_FILE_IMPORT_BTC = 35; |
400 | - public static final int MENU_FILE_BACKUP = 36; |
401 | - public static final int MENU_FILE_RESTORE = 37; |
402 | + public static final int MENU_FILE_IMPORT_RULES = 36; |
403 | + public static final int MENU_FILE_BACKUP = 37; |
404 | + public static final int MENU_FILE_RESTORE = 38; |
405 | |
406 | public static final int MENU_REPORT_EXECUTE = 40; |
407 | public static final int MENU_REPORT_SAVE = 41; |
408 | |
409 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/currency/RateParser.java' |
410 | --- infinitypfm/src/main/java/org/infinitypfm/core/currency/RateParser.java 2012-08-26 22:11:17 +0000 |
411 | +++ infinitypfm/src/main/java/org/infinitypfm/core/currency/RateParser.java 2014-11-27 22:23:48 +0000 |
412 | @@ -1,5 +1,5 @@ |
413 | /* |
414 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
415 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
416 | * |
417 | * This file is part of Infinity PFM. |
418 | * |
419 | @@ -15,13 +15,12 @@ |
420 | * |
421 | * You should have received a copy of the GNU General Public License |
422 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
423 | -*/ |
424 | + */ |
425 | package org.infinitypfm.core.currency; |
426 | |
427 | import java.math.BigDecimal; |
428 | import java.math.RoundingMode; |
429 | |
430 | -import net.sf.json.JSONException; |
431 | import net.sf.json.JSONObject; |
432 | import net.sf.json.util.JSONTokener; |
433 | |
434 | @@ -34,39 +33,40 @@ |
435 | public static String getRate(CurrencyMethod method) { |
436 | |
437 | BigDecimal rate = null; |
438 | - String page = null; |
439 | + String page = null; |
440 | page = PageHandler.getPage(method.getMethodUrl()); |
441 | - |
442 | - if (page != null && page.length() > 0){ |
443 | - |
444 | - JSONTokener tokener = new JSONTokener(page); |
445 | - Object rawResponseMessage; |
446 | + |
447 | + if (page != null && page.length() > 0) { |
448 | + |
449 | try { |
450 | - |
451 | + |
452 | + JSONTokener tokener = new JSONTokener(page); |
453 | + Object rawResponseMessage; |
454 | rawResponseMessage = tokener.nextValue(); |
455 | JSONObject part = (JSONObject) rawResponseMessage; |
456 | - |
457 | + |
458 | String[] parts = method.getMethodPath().split("\\."); |
459 | - |
460 | - for (int i=0; i<parts.length; i++){ |
461 | - |
462 | + |
463 | + for (int i = 0; i < parts.length; i++) { |
464 | + |
465 | if (!parts[i].equals("$")) { |
466 | - |
467 | - if (i<parts.length-1){ |
468 | - part = (JSONObject)part.get(parts[i]); |
469 | + |
470 | + if (i < parts.length - 1) { |
471 | + part = (JSONObject) part.get(parts[i]); |
472 | } else { |
473 | rate = new BigDecimal(part.getString(parts[i])); |
474 | - rate.setScale(8, RoundingMode.HALF_UP); |
475 | + rate = rate.setScale(8, RoundingMode.HALF_UP); |
476 | } |
477 | - } |
478 | + } |
479 | } |
480 | - |
481 | - } catch (JSONException e) { |
482 | + |
483 | + } catch (Exception e) { |
484 | InfinityPfm.LogMessage(e.getMessage()); |
485 | + rate = new BigDecimal("-1"); |
486 | } |
487 | - |
488 | + |
489 | } |
490 | - |
491 | + |
492 | return rate.toString(); |
493 | } |
494 | |
495 | |
496 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Account.xml' |
497 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Account.xml 2012-08-26 22:11:17 +0000 |
498 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Account.xml 2014-11-27 22:23:48 +0000 |
499 | @@ -109,6 +109,26 @@ |
500 | WHERE ActId = #actId# |
501 | </select> |
502 | |
503 | + <select id="getAccountByActId" parameterClass="act" |
504 | + resultClass="act"> |
505 | + SELECT |
506 | + ActId as actId, |
507 | + ActName as actName, |
508 | + ActTypeId as actTypeId, |
509 | + ActTypeName as actTypeName, |
510 | + ActNumber as actNumber, |
511 | + ActBalance as actBalance, |
512 | + curr.CurrencyID, |
513 | + curr.Name as currencyName, |
514 | + curr.IsoCode as isoCode |
515 | + FROM Accounts |
516 | + INNER JOIN AccountTypes |
517 | + ON Accounts.ActTypeId = AccountTypes.ActTypeId |
518 | + INNER JOIN Currencies curr |
519 | + ON Accounts.CurrencyID = curr.CurrencyID |
520 | + WHERE ActId = #actId# |
521 | + </select> |
522 | + |
523 | <select id="getAllAccountsByType" resultClass="act"> |
524 | SELECT |
525 | ActId as actId, |
526 | |
527 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/DataFormatUtil.java' |
528 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/DataFormatUtil.java 2012-12-03 03:03:10 +0000 |
529 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/DataFormatUtil.java 2014-11-27 22:23:48 +0000 |
530 | @@ -1,5 +1,5 @@ |
531 | /* |
532 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
533 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
534 | * |
535 | * This file is part of Infinity PFM. |
536 | * |
537 | @@ -15,9 +15,10 @@ |
538 | * |
539 | * You should have received a copy of the GNU General Public License |
540 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
541 | -*/ |
542 | + */ |
543 | package org.infinitypfm.core.data; |
544 | |
545 | +import java.io.Serializable; |
546 | import java.math.BigDecimal; |
547 | import java.math.RoundingMode; |
548 | import java.text.DateFormat; |
549 | @@ -32,31 +33,28 @@ |
550 | import org.infinitypfm.core.conf.MM; |
551 | import org.infinitypfm.core.types.NumberFormat; |
552 | |
553 | - |
554 | /** |
555 | * @author Wayne Gray |
556 | - * |
557 | + * |
558 | */ |
559 | -public class DataFormatUtil { |
560 | - |
561 | - String[] monthName = {"January", "February", |
562 | - "March", "April", "May", "June", "July", |
563 | - "August", "September", "October", "November", |
564 | - "December"}; |
565 | - |
566 | +public class DataFormatUtil implements Serializable { |
567 | + |
568 | + private static final long serialVersionUID = 6215132601470795925L; |
569 | + |
570 | + String[] monthName = { "January", "February", "March", "April", "May", |
571 | + "June", "July", "August", "September", "October", "November", |
572 | + "December" }; |
573 | + |
574 | Date date = null; |
575 | GregorianCalendar calendar = null; |
576 | DateFormat dateFmt = new SimpleDateFormat("M-dd-yyyy"); |
577 | DecimalFormat formatter = new DecimalFormat(NumberFormat.getDefault()); |
578 | GregorianCalendar today = null; |
579 | |
580 | - public DataFormatUtil(){ |
581 | + public DataFormatUtil() { |
582 | today = new GregorianCalendar(); |
583 | } |
584 | - |
585 | - /** |
586 | - * |
587 | - */ |
588 | + |
589 | public void setDate(Date dt) { |
590 | date = dt; |
591 | calendar = new GregorianCalendar(); |
592 | @@ -64,134 +62,132 @@ |
593 | |
594 | } |
595 | |
596 | - public void setDate(int yr, int month) { |
597 | - calendar = new GregorianCalendar(yr, month-1, 1); |
598 | - date = calendar.getTime(); |
599 | - } |
600 | - |
601 | - public void setDate(String sDate){ |
602 | - |
603 | - try { |
604 | - date = dateFmt.parse(sDate); |
605 | + public void setDate(int yr, int month) { |
606 | + calendar = new GregorianCalendar(yr, month - 1, 1); |
607 | + date = calendar.getTime(); |
608 | + } |
609 | + |
610 | + public void setDate(String sDate) { |
611 | + |
612 | + try { |
613 | + date = dateFmt.parse(sDate); |
614 | } catch (ParseException e) { |
615 | InfinityPfm.LogMessage(e.getMessage()); |
616 | } |
617 | - |
618 | - calendar = new GregorianCalendar(); |
619 | - if (date!=null){ |
620 | - calendar.setTime(date); |
621 | - } |
622 | - |
623 | - } |
624 | - |
625 | - public Date getDate() { |
626 | - return calendar.getTime(); |
627 | - } |
628 | - |
629 | - public int getMonth(){ |
630 | + |
631 | + calendar = new GregorianCalendar(); |
632 | + if (date != null) { |
633 | + calendar.setTime(date); |
634 | + } |
635 | + |
636 | + } |
637 | + |
638 | + public Date getDate() { |
639 | + return calendar.getTime(); |
640 | + } |
641 | + |
642 | + public int getMonth() { |
643 | return calendar.get(Calendar.MONTH) + 1; |
644 | - |
645 | + |
646 | } |
647 | - |
648 | + |
649 | public String getMonthName(int offset) { |
650 | - return monthName[calendar.get(Calendar.MONTH)+offset]; |
651 | + return monthName[calendar.get(Calendar.MONTH) + offset]; |
652 | } |
653 | - |
654 | - public int getYear(){ |
655 | + |
656 | + public int getYear() { |
657 | return calendar.get(Calendar.YEAR); |
658 | } |
659 | - |
660 | - public String getFormat(String format){ |
661 | + |
662 | + public String getFormat(String format) { |
663 | dateFmt = new SimpleDateFormat(format); |
664 | if (date != null) |
665 | return dateFmt.format(date); |
666 | - else |
667 | + else |
668 | return dateFmt.format(this.getToday()); |
669 | } |
670 | |
671 | - public String getAmountFormatted(long amount){ |
672 | + public String getAmountFormatted(long amount) { |
673 | formatter.applyPattern(NumberFormat.getDefault()); |
674 | - |
675 | - BigDecimal amtD = strictDivide(Long.toString(amount), |
676 | - "100000000", MM.options.getCurrencyPrecision()); |
677 | - |
678 | + |
679 | + BigDecimal amtD = strictDivide(Long.toString(amount), "100000000", |
680 | + MM.options.getCurrencyPrecision()); |
681 | + |
682 | return formatter.format(amtD); |
683 | - |
684 | + |
685 | } |
686 | |
687 | - public String getAmountFormatted(long amount, String format){ |
688 | - |
689 | + public String getAmountFormatted(long amount, String format) { |
690 | + |
691 | formatter.applyPattern(format); |
692 | - |
693 | - BigDecimal amtD = strictDivide(Long.toString(amount), |
694 | - "100000000", MM.options.getCurrencyPrecision()); |
695 | - |
696 | + |
697 | + BigDecimal amtD = strictDivide(Long.toString(amount), "100000000", |
698 | + MM.options.getCurrencyPrecision()); |
699 | + |
700 | return formatter.format(amtD); |
701 | } |
702 | - |
703 | - public double roundDouble(double val, String format){ |
704 | + |
705 | + public double roundDouble(double val, String format) { |
706 | DecimalFormat twoDForm = new DecimalFormat(format); |
707 | return Double.valueOf(twoDForm.format(val)); |
708 | } |
709 | - |
710 | + |
711 | public Date setNext(String frequency) { |
712 | - |
713 | - if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_BIWEEKLY))){ |
714 | + |
715 | + if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_BIWEEKLY))) { |
716 | calendar.add(Calendar.WEEK_OF_YEAR, 2); |
717 | - } else if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_MONTHLY))){ |
718 | + } else if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_MONTHLY))) { |
719 | calendar.add(Calendar.MONTH, 1); |
720 | - } else if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_WEEKLY))){ |
721 | + } else if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_WEEKLY))) { |
722 | calendar.add(Calendar.WEEK_OF_YEAR, 1); |
723 | - } else if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_YEARLY))){ |
724 | + } else if (frequency.equals(MM.PHRASES.getPhrase(MM.RECUR_YEARLY))) { |
725 | calendar.add(Calendar.YEAR, 1); |
726 | } |
727 | - |
728 | + |
729 | return calendar.getTime(); |
730 | } |
731 | |
732 | public Date getToday() { |
733 | return today.getTime(); |
734 | } |
735 | - |
736 | - public static long moneyToLong(String val){ |
737 | - |
738 | - |
739 | - if (val.startsWith("(")){ |
740 | - |
741 | - val = val.replaceAll("\\(", "\\-").replaceAll("\\)",""); |
742 | + |
743 | + public static long moneyToLong(String val) { |
744 | + |
745 | + if (val.startsWith("(")) { |
746 | + |
747 | + val = val.replaceAll("\\(", "\\-").replaceAll("\\)", ""); |
748 | } |
749 | - |
750 | + |
751 | BigDecimal newVal = new BigDecimal(val); |
752 | - |
753 | + |
754 | return moneyToLong(newVal); |
755 | - |
756 | + |
757 | } |
758 | - |
759 | - public static long moneyToLong(BigDecimal val){ |
760 | - |
761 | + |
762 | + public static long moneyToLong(BigDecimal val) { |
763 | + |
764 | return val.multiply(new BigDecimal("100000000")).longValue(); |
765 | - |
766 | + |
767 | } |
768 | - |
769 | - public BigDecimal strictDivide(String numerator, String denominator, int scale){ |
770 | - |
771 | + |
772 | + public BigDecimal strictDivide(String numerator, String denominator, |
773 | + int scale) { |
774 | + |
775 | BigDecimal num = new BigDecimal(numerator); |
776 | BigDecimal den = new BigDecimal(denominator); |
777 | BigDecimal result = num.divide(den, scale, RoundingMode.HALF_UP); |
778 | - |
779 | + |
780 | return result; |
781 | - |
782 | - |
783 | + |
784 | } |
785 | - |
786 | - public BigDecimal strictMultiply(String x, String y){ |
787 | - |
788 | + |
789 | + public BigDecimal strictMultiply(String x, String y) { |
790 | + |
791 | BigDecimal valX = new BigDecimal(x); |
792 | BigDecimal valY = new BigDecimal(y); |
793 | BigDecimal result = valX.multiply(valY); |
794 | - |
795 | + |
796 | return result; |
797 | - |
798 | - |
799 | + |
800 | } |
801 | } |
802 | |
803 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Database.java' |
804 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Database.java 2012-08-26 22:11:17 +0000 |
805 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Database.java 2014-11-27 22:23:48 +0000 |
806 | @@ -48,14 +48,16 @@ |
807 | "createPKRecurHeader", "createPKRecurDetail", |
808 | "createFK2RecurDetail", "createPKAccountTypes", |
809 | "createPKAccounts", "createPKAccountTemplates", |
810 | - "createPKImportHistory", "createFKTransactions", |
811 | + "createPKImportHistory", "createTableImportRules", |
812 | + "createFKTransactions", |
813 | "createFKAccounts", "createPKMonthlyBalance", "createPKBudget", |
814 | "createPKBudgetDetail", "createFKBudgetDetail", |
815 | "createFK2BudgetDetail", "createFKMonthlyBalance", |
816 | "createTableCurrencies", "createPKCurrencies", |
817 | "createTableCurrencyMethods", "createPKCurrencyMethods", |
818 | "createFKCurrencyMethods", "createTableTrades", "createPKTrades", |
819 | - "createFKTrades1", "createFKTrades2" |
820 | + "createFKTrades1", "createFKTrades2", "createPKImportRules", |
821 | + "createFKImportRules" |
822 | }; |
823 | |
824 | |
825 | @@ -270,9 +272,9 @@ |
826 | return tarFile.getPath(); |
827 | |
828 | } finally { |
829 | - try {aos.finish();} catch (Exception e){} |
830 | - try {aos.close();} catch (Exception e){} |
831 | - try {out.close();} catch (Exception e){} |
832 | + try {aos.finish();} catch (Exception e){System.err.println(e.getMessage());} |
833 | + try {aos.close();} catch (Exception e){System.err.println(e.getMessage());} |
834 | + try {out.close();} catch (Exception e){System.err.println(e.getMessage());} |
835 | } |
836 | } |
837 | |
838 | |
839 | === added file 'infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRule.java' |
840 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRule.java 1970-01-01 00:00:00 +0000 |
841 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRule.java 2014-11-27 22:23:48 +0000 |
842 | @@ -0,0 +1,61 @@ |
843 | +/* |
844 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
845 | + * |
846 | + * This file is part of Infinity PFM. |
847 | + * |
848 | + * Infinity PFM is free software: you can redistribute it and/or modify |
849 | + * it under the terms of the GNU General Public License as published by |
850 | + * the Free Software Foundation, either version 3 of the License, or |
851 | + * (at your option) any later version. |
852 | + * |
853 | + * Infinity PFM is distributed in the hope that it will be useful, |
854 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
855 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
856 | + * GNU General Public License for more details. |
857 | + * |
858 | + * You should have received a copy of the GNU General Public License |
859 | + * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
860 | + */ |
861 | + |
862 | +package org.infinitypfm.core.data; |
863 | + |
864 | +import java.io.Serializable; |
865 | + |
866 | +import org.infinitypfm.core.types.ImportRuleNames; |
867 | + |
868 | +public class ImportRule implements Serializable { |
869 | + |
870 | + private static final long serialVersionUID = -3578852899322050549L; |
871 | + |
872 | + private int actId; |
873 | + private String keyword=null; |
874 | + private String ruleName=ImportRuleNames.CONTAINS; |
875 | + private String actName = null; |
876 | + public int getActId() { |
877 | + return actId; |
878 | + } |
879 | + public void setActId(int actId) { |
880 | + this.actId = actId; |
881 | + } |
882 | + public String getKeyword() { |
883 | + return keyword; |
884 | + } |
885 | + public void setKeyword(String keyword) { |
886 | + this.keyword = keyword; |
887 | + } |
888 | + public String getRuleName() { |
889 | + return ruleName; |
890 | + } |
891 | + public void setRuleName(String ruleName) { |
892 | + this.ruleName = ruleName; |
893 | + } |
894 | + public String getActName() { |
895 | + return actName; |
896 | + } |
897 | + public void setActName(String actName) { |
898 | + this.actName = actName; |
899 | + } |
900 | + |
901 | + |
902 | + |
903 | +} |
904 | |
905 | === added file 'infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRules.xml' |
906 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRules.xml 1970-01-01 00:00:00 +0000 |
907 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/ImportRules.xml 2014-11-27 22:23:48 +0000 |
908 | @@ -0,0 +1,74 @@ |
909 | +<?xml version="1.0" encoding="UTF-8" ?> |
910 | +<!-- Copyright (c) 2005-2013 Wayne Gray All rights reserved This file is |
911 | + part of Infinity PFM. Infinity PFM is free software: you can redistribute |
912 | + it and/or modify it under the terms of the GNU General Public License as |
913 | + published by the Free Software Foundation, either version 3 of the License, |
914 | + or (at your option) any later version. Infinity PFM is distributed in the |
915 | + hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
916 | + warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
917 | + GNU General Public License for more details. You should have received a copy |
918 | + of the GNU General Public License along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. --> |
919 | + |
920 | + |
921 | +<!DOCTYPE sqlMap PUBLIC |
922 | + "-//iBATIS.com//DTD SQL Map 2.0//EN" |
923 | + "http://www.ibatis.com/dtd/sql-map-2.dtd"> |
924 | +<sqlMap namespace="ImportRules"> |
925 | + |
926 | + <typeAlias alias="importRule" type="org.infinitypfm.core.data.ImportRule" /> |
927 | + |
928 | + <insert id="insertImportRule" parameterClass="importRule"> |
929 | + |
930 | + INSERT INTO ImportRules |
931 | + ( |
932 | + ActID, |
933 | + Keyword, |
934 | + RuleName |
935 | + ) |
936 | + VALUES |
937 | + ( |
938 | + #actId#, |
939 | + #keyword#, |
940 | + #ruleName# |
941 | + ) |
942 | + |
943 | + </insert> |
944 | + |
945 | + <select id="getImportRules" |
946 | + resultClass="importRule"> |
947 | + |
948 | + SELECT |
949 | + ActId as actId, |
950 | + Keyword as keyword, |
951 | + RuleName as ruleName, |
952 | + ActName as actName |
953 | + FROM ImportRules |
954 | + INNER JOIN Accounts |
955 | + ON ImportRules.ActId = Accounts.ActId |
956 | + |
957 | + </select> |
958 | + |
959 | + <select id="getImportRule" |
960 | + parameterClass="importRule" |
961 | + resultClass="importRule"> |
962 | + |
963 | + SELECT |
964 | + ActId as actId, |
965 | + Keyword as keyword, |
966 | + RuleName as ruleName |
967 | + FROM ImportRules |
968 | + WHERE ActId = #actId# |
969 | + AND Keyword = #keyword# |
970 | + |
971 | + </select> |
972 | + |
973 | + <delete id="deleteImportrule" |
974 | + parameterClass="importRule"> |
975 | + |
976 | + DELETE FROM ImportRules |
977 | + WHERE ActId = #actId# |
978 | + AND Keyword = #keyword# |
979 | + |
980 | + </delete> |
981 | + |
982 | +</sqlMap> |
983 | \ No newline at end of file |
984 | |
985 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/InfinityUpdates.java' |
986 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/InfinityUpdates.java 2012-08-26 22:11:17 +0000 |
987 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/InfinityUpdates.java 2014-11-27 22:23:48 +0000 |
988 | @@ -57,6 +57,7 @@ |
989 | ApplyVersion040(); |
990 | ApplyVersion050(); |
991 | ApplyVersion060(); |
992 | + ApplyVersion070(); |
993 | } else if (sVersion.equals("0.0.2")) { |
994 | ApplyVersion010(); |
995 | ApplyVersion030(); |
996 | @@ -64,38 +65,48 @@ |
997 | ApplyVersion040(); |
998 | ApplyVersion050(); |
999 | ApplyVersion060(); |
1000 | + ApplyVersion070(); |
1001 | } else if (sVersion.equals("0.1.0")) { |
1002 | ApplyVersion030(); |
1003 | ApplyVersion035(); |
1004 | ApplyVersion040(); |
1005 | ApplyVersion050(); |
1006 | ApplyVersion060(); |
1007 | + ApplyVersion070(); |
1008 | } else if (sVersion.equals("0.2.0")) { |
1009 | ApplyVersion030(); |
1010 | ApplyVersion035(); |
1011 | ApplyVersion040(); |
1012 | ApplyVersion050(); |
1013 | ApplyVersion060(); |
1014 | + ApplyVersion070(); |
1015 | } else if (sVersion.equals("0.2.1")) { |
1016 | ApplyVersion030(); |
1017 | ApplyVersion035(); |
1018 | ApplyVersion040(); |
1019 | ApplyVersion050(); |
1020 | ApplyVersion060(); |
1021 | + ApplyVersion070(); |
1022 | } else if (sVersion.equals("0.3.0")) { |
1023 | ApplyVersion035(); |
1024 | ApplyVersion040(); |
1025 | ApplyVersion050(); |
1026 | ApplyVersion060(); |
1027 | + ApplyVersion070(); |
1028 | } else if (sVersion.equals("0.3.5")) { |
1029 | ApplyVersion040(); |
1030 | ApplyVersion050(); |
1031 | ApplyVersion060(); |
1032 | + ApplyVersion070(); |
1033 | } else if (sVersion.equals("0.4.0")) { |
1034 | ApplyVersion050(); |
1035 | ApplyVersion060(); |
1036 | + ApplyVersion070(); |
1037 | } else if (sVersion.equals("0.5.0")) { |
1038 | ApplyVersion060(); |
1039 | + ApplyVersion070(); |
1040 | + } else if (sVersion.equalsIgnoreCase("0.6.0")){ |
1041 | + ApplyVersion070(); |
1042 | } |
1043 | |
1044 | } |
1045 | @@ -207,5 +218,12 @@ |
1046 | |
1047 | MM.sqlMap.update("bumpVersion", "0.6.0"); |
1048 | } |
1049 | + |
1050 | + private void ApplyVersion070() throws SQLException { |
1051 | + MM.sqlMap.insert("createTableImportRules"); |
1052 | + MM.sqlMap.insert("createPKImportRules"); |
1053 | + MM.sqlMap.insert("createFKImportRules"); |
1054 | + MM.sqlMap.update("bumpVersion", "0.7.0"); |
1055 | + } |
1056 | |
1057 | } |
1058 | |
1059 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Manage.xml' |
1060 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Manage.xml 2012-08-26 22:11:17 +0000 |
1061 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Manage.xml 2014-11-27 22:23:48 +0000 |
1062 | @@ -113,6 +113,15 @@ |
1063 | ) |
1064 | </statement> |
1065 | |
1066 | + <statement id="createTableImportRules"> |
1067 | + CREATE CACHED TABLE ImportRules |
1068 | + ( |
1069 | + ActID INT, |
1070 | + Keyword VARCHAR(100), |
1071 | + RuleName VARCHAR(25) |
1072 | + ) |
1073 | + </statement> |
1074 | + |
1075 | <statement id="createTableRecurHeader"> |
1076 | CREATE CACHED TABLE RecurHeader |
1077 | ( |
1078 | @@ -216,6 +225,12 @@ |
1079 | UNIQUE(ActID, Memo) |
1080 | </statement> |
1081 | |
1082 | + <statement id="createPKImportRules"> |
1083 | + ALTER TABLE ImportRules ADD |
1084 | + CONSTRAINT ImportRules_PK |
1085 | + UNIQUE (ActID, Keyword, RuleName) |
1086 | + </statement> |
1087 | + |
1088 | <statement id="createPKCurrencies"> |
1089 | ALTER TABLE Currencies ADD |
1090 | CONSTRAINT Currencies_IsoCode |
1091 | @@ -329,6 +344,12 @@ |
1092 | FOREIGN KEY (CurrencyID) REFERENCES Currencies (CurrencyID); |
1093 | </statement> |
1094 | |
1095 | + <statement id="createFKImportRules"> |
1096 | + ALTER TABLE ImportRules ADD |
1097 | + CONSTRAINT FK_ImportRules_Account |
1098 | + FOREIGN KEY (ActID) REFERENCES Accounts (ActID) |
1099 | + </statement> |
1100 | + |
1101 | <insert id="addAppSetting" parameterClass="java.lang.String"> |
1102 | INSERT INTO |
1103 | AppSettings (AppVersion) VALUES (#value#) |
1104 | |
1105 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/ReportData.java' |
1106 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/ReportData.java 2012-08-26 22:11:17 +0000 |
1107 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/ReportData.java 2014-11-27 22:23:48 +0000 |
1108 | @@ -1,5 +1,5 @@ |
1109 | /* |
1110 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
1111 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1112 | * |
1113 | * This file is part of Infinity PFM. |
1114 | * |
1115 | @@ -15,7 +15,7 @@ |
1116 | * |
1117 | * You should have received a copy of the GNU General Public License |
1118 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
1119 | -*/ |
1120 | + */ |
1121 | package org.infinitypfm.core.data; |
1122 | |
1123 | import java.sql.SQLException; |
1124 | @@ -31,6 +31,7 @@ |
1125 | public class ReportData { |
1126 | |
1127 | private DataFormatUtil dateUtil; |
1128 | + @SuppressWarnings("rawtypes") |
1129 | private List reportData; |
1130 | private String incomeTotal; |
1131 | private String expenseTotal; |
1132 | @@ -39,59 +40,56 @@ |
1133 | private String budget; |
1134 | private String account; |
1135 | private Boolean userCancelled = false; |
1136 | - |
1137 | - public ReportData(int reportType){ |
1138 | - |
1139 | + |
1140 | + public ReportData(int reportType) { |
1141 | + |
1142 | dateUtil = new DataFormatUtil(); |
1143 | ParamDateRange reportParam = new ParamDateRange(); |
1144 | - |
1145 | - switch (reportType){ |
1146 | - |
1147 | + |
1148 | + switch (reportType) { |
1149 | + |
1150 | case MM.THIS_MONTH: |
1151 | - |
1152 | + |
1153 | dateUtil.setDate(new Date()); |
1154 | initTotals(); |
1155 | title = MM.PHRASES.getPhrase("123") + " " |
1156 | - + dateUtil.getMonthName(0) + " " |
1157 | - + dateUtil.getYear(); |
1158 | + + dateUtil.getMonthName(0) + " " + dateUtil.getYear(); |
1159 | reportParam.setMth(dateUtil.getMonth()); |
1160 | reportParam.setYr(dateUtil.getYear()); |
1161 | setReportData("getReportMonthlyBalances", reportParam); |
1162 | - |
1163 | - |
1164 | + |
1165 | break; |
1166 | case MM.LAST_MONTH: |
1167 | - |
1168 | + |
1169 | promptForMonthYr(); |
1170 | initTotals(); |
1171 | title = MM.PHRASES.getPhrase("123") + " " |
1172 | - + dateUtil.getMonthName(0) + " " |
1173 | - + dateUtil.getYear(); |
1174 | + + dateUtil.getMonthName(0) + " " + dateUtil.getYear(); |
1175 | reportParam.setMth(dateUtil.getMonth()); |
1176 | reportParam.setYr(dateUtil.getYear()); |
1177 | setReportData("getReportMonthlyBalances", reportParam); |
1178 | - |
1179 | + |
1180 | break; |
1181 | case MM.MENU_REPORTS_ACCOUNT_HISTORY: |
1182 | - |
1183 | + |
1184 | dateUtil.setDate(new Date()); |
1185 | title = MM.PHRASES.getPhrase("136"); |
1186 | MonthlyBalance monthlyBalance = new MonthlyBalance(); |
1187 | - |
1188 | - account = promptForAccount(); |
1189 | + |
1190 | + account = promptForAccount(true); //Include income accounts |
1191 | |
1192 | if (account != null) { |
1193 | |
1194 | monthlyBalance.setActName(account); |
1195 | monthlyBalance.setMth(dateUtil.getMonth()); |
1196 | - monthlyBalance.setYr(dateUtil.getYear()-1); |
1197 | + monthlyBalance.setYr(dateUtil.getYear() - 1); |
1198 | setReportData("getReportAccountHistory", monthlyBalance); |
1199 | - |
1200 | + |
1201 | } |
1202 | - |
1203 | + |
1204 | break; |
1205 | case MM.MENU_REPORTS_BUDGET_PERFORMANCE: |
1206 | - |
1207 | + |
1208 | dateUtil.setDate(new Date()); |
1209 | title = MM.PHRASES.getPhrase("164"); |
1210 | |
1211 | @@ -107,10 +105,10 @@ |
1212 | setReportData("getBudgetVsExpenseByMonth", args); |
1213 | |
1214 | } |
1215 | - |
1216 | + |
1217 | break; |
1218 | case MM.MENU_REPORTS_BUDGET_PERFORMANCE_ACT: |
1219 | - |
1220 | + |
1221 | dateUtil.setDate(new Date()); |
1222 | |
1223 | account = promptForAccount(); |
1224 | @@ -119,7 +117,7 @@ |
1225 | if (budget != null && account != null) { |
1226 | |
1227 | title = MM.PHRASES.getPhrase("164") + ": " + account; |
1228 | - |
1229 | + |
1230 | BudgetBalance args = new BudgetBalance(); |
1231 | args.setActName(account); |
1232 | args.setBudgetName(budget); |
1233 | @@ -129,38 +127,42 @@ |
1234 | setReportData("getBudgetVsExpenseByMonthAndAccount", args); |
1235 | |
1236 | } |
1237 | - |
1238 | + |
1239 | break; |
1240 | case MM.MENU_REPORTS_INCOME_VS_EXPENSE: |
1241 | - |
1242 | + |
1243 | dateUtil.setDate(new Date()); |
1244 | title = MM.PHRASES.getPhrase("221"); |
1245 | reportParam.setMth(dateUtil.getMonth()); |
1246 | reportParam.setYr(dateUtil.getYear()); |
1247 | setReportData("getIncomeVsExpense", reportParam); |
1248 | - |
1249 | + |
1250 | break; |
1251 | - |
1252 | - |
1253 | + |
1254 | } |
1255 | } |
1256 | |
1257 | + @SuppressWarnings("rawtypes") |
1258 | public List getReportData() { |
1259 | return reportData; |
1260 | } |
1261 | + |
1262 | public String getIncomeTotal() { |
1263 | return incomeTotal; |
1264 | - } |
1265 | + } |
1266 | + |
1267 | public String getExpenseTotal() { |
1268 | return expenseTotal; |
1269 | } |
1270 | + |
1271 | public String getLiabilityTotal() { |
1272 | return liabilityTotal; |
1273 | } |
1274 | - public String getTitle() { |
1275 | + |
1276 | + public String getTitle() { |
1277 | return title; |
1278 | } |
1279 | - |
1280 | + |
1281 | public Boolean getUserCanceled() { |
1282 | return userCancelled; |
1283 | } |
1284 | @@ -170,65 +172,70 @@ |
1285 | } |
1286 | |
1287 | private void initTotals() { |
1288 | - |
1289 | + |
1290 | BudgetDetail budgetDetail = new BudgetDetail(); |
1291 | budgetDetail.setMth(dateUtil.getMonth()); |
1292 | budgetDetail.setYr(dateUtil.getYear()); |
1293 | - |
1294 | + |
1295 | try { |
1296 | - |
1297 | + |
1298 | incomeTotal = (String) MM.sqlMap.queryForObject( |
1299 | "getIncomeTotalForMonth", budgetDetail); |
1300 | expenseTotal = (String) MM.sqlMap.queryForObject( |
1301 | "getExpenseTotalForMonth", budgetDetail); |
1302 | liabilityTotal = (String) MM.sqlMap.queryForObject( |
1303 | "getLiabilityTotalForMonth", budgetDetail); |
1304 | - |
1305 | + |
1306 | } catch (SQLException e) { |
1307 | InfinityPfm.LogMessage(e.getMessage()); |
1308 | } |
1309 | - |
1310 | + |
1311 | } |
1312 | - |
1313 | - private void promptForMonthYr(){ |
1314 | - |
1315 | + |
1316 | + private void promptForMonthYr() { |
1317 | + |
1318 | MonthYearDialog monthPicker = new MonthYearDialog(); |
1319 | monthPicker.Open(); |
1320 | - |
1321 | + |
1322 | dateUtil.setDate(monthPicker.getYear(), monthPicker.getMonth()); |
1323 | userCancelled = monthPicker.userCancelled(); |
1324 | - |
1325 | + |
1326 | } |
1327 | - |
1328 | - private void setReportData (String reportName, Object args){ |
1329 | - |
1330 | + |
1331 | + private void setReportData(String reportName, Object args) { |
1332 | + |
1333 | try { |
1334 | - |
1335 | - reportData = MM.sqlMap.queryForList(reportName,args); |
1336 | - |
1337 | + |
1338 | + reportData = MM.sqlMap.queryForList(reportName, args); |
1339 | + |
1340 | } catch (SQLException e) { |
1341 | InfinityPfm.LogMessage(e.getMessage()); |
1342 | } |
1343 | - |
1344 | + |
1345 | } |
1346 | - |
1347 | - private String promptForBudget(){ |
1348 | - |
1349 | + |
1350 | + private String promptForBudget() { |
1351 | + |
1352 | BudgetSelector budgetDialog = new BudgetSelector(); |
1353 | budgetDialog.Open(); |
1354 | userCancelled = budgetDialog.userCancelled(); |
1355 | - |
1356 | + |
1357 | return budgetDialog.getBudgetName(); |
1358 | } |
1359 | - |
1360 | - private String promptForAccount(){ |
1361 | - |
1362 | + |
1363 | + private String promptForAccount() { |
1364 | + return promptForAccount(false); |
1365 | + } |
1366 | + |
1367 | + private String promptForAccount(boolean inludeIncome) { |
1368 | + |
1369 | AccountSelectorDialog acctSelect = new AccountSelectorDialog(); |
1370 | + acctSelect.setIncludeIncomeAccounts(inludeIncome); |
1371 | acctSelect.Open(); |
1372 | userCancelled = acctSelect.userCancelled(); |
1373 | - |
1374 | + |
1375 | return acctSelect.getAccountName(); |
1376 | - |
1377 | + |
1378 | } |
1379 | - |
1380 | + |
1381 | } |
1382 | |
1383 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Reports.xml' |
1384 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Reports.xml 2012-08-26 22:11:17 +0000 |
1385 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Reports.xml 2014-11-27 22:23:48 +0000 |
1386 | @@ -33,7 +33,7 @@ |
1387 | |
1388 | <select id="getReportMonthlyBalances" resultClass="monthBalance" parameterClass="dateParams"> |
1389 | <![CDATA[ |
1390 | - SELECT at.ACTTYPENAME, |
1391 | + SELECT az.ACTTYPENAME, |
1392 | a.ACTNAME, |
1393 | mb.YR, |
1394 | mb.MTH, |
1395 | @@ -42,12 +42,12 @@ |
1396 | FROM MONTHLYBALANCE mb |
1397 | INNER JOIN ACCOUNTS a |
1398 | ON mb.ACTID = a.ACTID |
1399 | - INNER JOIN ACCOUNTTYPES at |
1400 | - ON a.ACTTYPEID = at.ACTTYPEID |
1401 | + INNER JOIN ACCOUNTTYPES az |
1402 | + ON a.ACTTYPEID = az.ACTTYPEID |
1403 | INNER JOIN CURRENCIES c |
1404 | ON a.CURRENCYID = c.CURRENCYID |
1405 | WHERE mb.YR = #yr# AND mb.MTH = #mth# |
1406 | - ORDER BY at.ACTTYPEID, a.ACTNAME; |
1407 | + ORDER BY az.ACTTYPEID, a.ACTNAME; |
1408 | ]]> |
1409 | </select> |
1410 | <select id="getReportAccountHistory" resultClass="monthBalance" parameterClass="monthBalance"> |
1411 | @@ -80,8 +80,8 @@ |
1412 | FROM MONTHLYBALANCE mb |
1413 | INNER JOIN ACCOUNTS a |
1414 | ON mb.ACTID = a.ACTID |
1415 | - INNER JOIN ACCOUNTTYPES at |
1416 | - ON a.ACTTYPEID = at.ACTTYPEID |
1417 | + INNER JOIN ACCOUNTTYPES az |
1418 | + ON a.ACTTYPEID = az.ACTTYPEID |
1419 | INNER JOIN BUDGETDETAIL bd |
1420 | ON mb.ACTID = bd.ACTID |
1421 | AND mb.MTH = bd.MTH |
1422 | @@ -117,8 +117,8 @@ |
1423 | FROM MONTHLYBALANCE mb |
1424 | INNER JOIN ACCOUNTS a |
1425 | ON mb.ACTID = a.ACTID |
1426 | - INNER JOIN ACCOUNTTYPES at |
1427 | - ON a.ACTTYPEID = at.ACTTYPEID |
1428 | + INNER JOIN ACCOUNTTYPES az |
1429 | + ON a.ACTTYPEID = az.ACTTYPEID |
1430 | INNER JOIN BUDGETDETAIL bd |
1431 | ON mb.ACTID = bd.ACTID |
1432 | AND mb.MTH = bd.MTH |
1433 | @@ -151,14 +151,14 @@ |
1434 | SELECT |
1435 | mb.YR, |
1436 | mb.MTH, |
1437 | - SUM(CASE WHEN at.ACTTYPENAME = 'Expense' THEN mb.ACTBALANCE ELSE 0 END) AS ExpenseBalance, |
1438 | - SUM(CASE WHEN at.ACTTYPENAME = 'Liability' THEN mb.ACTBALANCE ELSE 0 END) AS LiabilityBalance, |
1439 | - SUM(CASE WHEN at.ACTTYPENAME = 'Income' THEN mb.ACTBALANCE ELSE 0 END) AS IncomeBalance |
1440 | + SUM(CASE WHEN az.ACTTYPENAME = 'Expense' THEN mb.ACTBALANCE ELSE 0 END) AS ExpenseBalance, |
1441 | + SUM(CASE WHEN az.ACTTYPENAME = 'Liability' THEN mb.ACTBALANCE ELSE 0 END) AS LiabilityBalance, |
1442 | + SUM(CASE WHEN az.ACTTYPENAME = 'Income' THEN mb.ACTBALANCE ELSE 0 END) AS IncomeBalance |
1443 | FROM MONTHLYBALANCE mb |
1444 | INNER JOIN ACCOUNTS a |
1445 | ON mb.ACTID = a.ACTID |
1446 | - INNER JOIN ACCOUNTTYPES at |
1447 | - ON a.ACTTYPEID = at.ACTTYPEID |
1448 | + INNER JOIN ACCOUNTTYPES az |
1449 | + ON a.ACTTYPEID = az.ACTTYPEID |
1450 | INNER JOIN CURRENCIES c |
1451 | ON a.CURRENCYID = c.CURRENCYID |
1452 | WHERE mb.YR >= #yr#-1 |
1453 | |
1454 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfig.xml' |
1455 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfig.xml 2012-08-26 22:11:17 +0000 |
1456 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfig.xml 2014-11-27 22:23:48 +0000 |
1457 | @@ -66,5 +66,6 @@ |
1458 | <sqlMap resource="org/infinitypfm/core/data/Manage.xml" /> |
1459 | <sqlMap resource="org/infinitypfm/core/data/Options.xml" /> |
1460 | <sqlMap resource="org/infinitypfm/core/data/Currency.xml" /> |
1461 | + <sqlMap resource="org/infinitypfm/core/data/ImportRules.xml" /> |
1462 | |
1463 | </sqlMapConfig> |
1464 | |
1465 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfigSvr.xml' |
1466 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfigSvr.xml 2012-08-26 22:11:17 +0000 |
1467 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/SqlMapConfigSvr.xml 2014-11-27 22:23:48 +0000 |
1468 | @@ -67,4 +67,5 @@ |
1469 | <sqlMap resource="org/infinitypfm/core/data/Manage.xml" /> |
1470 | <sqlMap resource="org/infinitypfm/core/data/Options.xml" /> |
1471 | <sqlMap resource="org/infinitypfm/core/data/Currency.xml" /> |
1472 | + <sqlMap resource="org/infinitypfm/core/data/ImportRules.xml" /> |
1473 | </sqlMapConfig> |
1474 | |
1475 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.java' |
1476 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.java 2012-12-04 03:13:53 +0000 |
1477 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.java 2014-11-27 22:23:48 +0000 |
1478 | @@ -1,5 +1,5 @@ |
1479 | /* |
1480 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
1481 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1482 | * |
1483 | * This file is part of Infinity PFM. |
1484 | * |
1485 | @@ -26,15 +26,8 @@ |
1486 | |
1487 | import org.infinitypfm.core.types.DefaultDateFormat; |
1488 | |
1489 | -/** |
1490 | - * @author wayne |
1491 | - * |
1492 | - * TODO To change the template for this generated type comment go to |
1493 | - * Window - Preferences - Java - Code Style - Code Templates |
1494 | - */ |
1495 | public class Transaction implements Serializable { |
1496 | |
1497 | - |
1498 | private static final long serialVersionUID = -3989677930922526215L; |
1499 | private long tranId; |
1500 | private int actId; |
1501 | @@ -50,6 +43,7 @@ |
1502 | private long recurTranId; |
1503 | private String transactionKey = null; |
1504 | private String exchangeRate = "1"; |
1505 | + private long actBalance = 0; |
1506 | |
1507 | /** |
1508 | * |
1509 | @@ -89,12 +83,12 @@ |
1510 | } |
1511 | |
1512 | public void setTranAmount(BigDecimal amt) { |
1513 | - //assume cents |
1514 | + // assume cents |
1515 | BigDecimal multiplier = new BigDecimal("100000000"); |
1516 | - amt.multiply(multiplier); |
1517 | - this.tranAmount = amt.longValue(); |
1518 | + BigDecimal result = amt.multiply(multiplier); |
1519 | + this.tranAmount = result.longValue(); |
1520 | } |
1521 | - |
1522 | + |
1523 | /** |
1524 | * @return Returns the tranDate. |
1525 | */ |
1526 | @@ -226,26 +220,26 @@ |
1527 | * Still support single offset interface for now. |
1528 | * **************************************************** |
1529 | */ |
1530 | - |
1531 | + |
1532 | public int getActOffset() { |
1533 | initializeOffset(); |
1534 | TransactionOffset offset = offsets.get(0); |
1535 | return offset.getOffsetId(); |
1536 | } |
1537 | - |
1538 | + |
1539 | public void setActOffset(int actOffset) { |
1540 | initializeOffset(); |
1541 | TransactionOffset offset = offsets.get(0); |
1542 | offset.setOffsetId(actOffset); |
1543 | offset.setOffsetAmount(-this.getTranAmount()); |
1544 | } |
1545 | - |
1546 | + |
1547 | public String getActOffsetName() { |
1548 | initializeOffset(); |
1549 | TransactionOffset offset = offsets.get(0); |
1550 | return offset.getOffsetName(); |
1551 | } |
1552 | - |
1553 | + |
1554 | public void setActOffsetName(String actOffsetName) { |
1555 | initializeOffset(); |
1556 | TransactionOffset offset = offsets.get(0); |
1557 | @@ -253,26 +247,36 @@ |
1558 | offset.setOffsetAmount(-this.getTranAmount()); |
1559 | } |
1560 | |
1561 | + public long getActBalance() { |
1562 | + return actBalance; |
1563 | + } |
1564 | + |
1565 | + public void setActBalance(long actBalance) { |
1566 | + this.actBalance = actBalance; |
1567 | + } |
1568 | + |
1569 | /* |
1570 | * **************************************************** |
1571 | */ |
1572 | - |
1573 | + |
1574 | + @SuppressWarnings("rawtypes") |
1575 | public ArrayList getOffsets() { |
1576 | return offsets; |
1577 | } |
1578 | |
1579 | + @SuppressWarnings({ "rawtypes", "unchecked" }) |
1580 | public void setOffsets(ArrayList offsets) { |
1581 | this.offsets = offsets; |
1582 | } |
1583 | - |
1584 | - private void initializeOffset(){ |
1585 | - |
1586 | - if (offsets==null){ |
1587 | + |
1588 | + private void initializeOffset() { |
1589 | + |
1590 | + if (offsets == null) { |
1591 | offsets = new ArrayList<TransactionOffset>(); |
1592 | TransactionOffset newOffset = new TransactionOffset(); |
1593 | offsets.add(newOffset); |
1594 | } |
1595 | - |
1596 | + |
1597 | } |
1598 | - |
1599 | + |
1600 | } |
1601 | |
1602 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.xml' |
1603 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.xml 2012-12-02 04:37:54 +0000 |
1604 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Transaction.xml 2014-11-27 22:23:48 +0000 |
1605 | @@ -233,7 +233,7 @@ |
1606 | a.ActName, |
1607 | rh.OffsetID as ActOffset, |
1608 | aOff.ActName as ActOffsetName, |
1609 | - at.ActTypeName, |
1610 | + az.ActTypeName, |
1611 | rd.TranDate, |
1612 | rh.Memo as TranMemo, |
1613 | rh.Amount as TranAmount |
1614 | @@ -244,8 +244,8 @@ |
1615 | ON rh.ActId = a.ActId |
1616 | INNER JOIN Accounts aOff |
1617 | ON rh.OffsetId = aOff.ActId |
1618 | - INNER JOIN AccountTypes at |
1619 | - ON a.ActTypeId = at.ActTypeId |
1620 | + INNER JOIN AccountTypes az |
1621 | + ON a.ActTypeId = az.ActTypeId |
1622 | </select> |
1623 | |
1624 | <insert id="insertRecurringTransaction" parameterClass="org.infinitypfm.core.data.RecurHeader"> |
1625 | |
1626 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/Updates.xml' |
1627 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/Updates.xml 2012-08-26 22:11:17 +0000 |
1628 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/Updates.xml 2014-11-27 22:23:48 +0000 |
1629 | @@ -1,7 +1,7 @@ |
1630 | <?xml version="1.0" encoding="UTF-8" ?> |
1631 | <!-- |
1632 | |
1633 | -Copyright (c) 2005-2012 Wayne Gray All rights reserved |
1634 | +Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1635 | |
1636 | This file is part of Infinity PFM. |
1637 | |
1638 | @@ -195,4 +195,5 @@ |
1639 | <statement id="v0_6_0_k"> |
1640 | ALTER TABLE CURRENCYMETHODS ADD COLUMN MethodPath VARCHAR(500); |
1641 | </statement> |
1642 | + |
1643 | </sqlMap> |
1644 | |
1645 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BaseImport.java' |
1646 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BaseImport.java 2012-08-26 22:11:17 +0000 |
1647 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BaseImport.java 2014-11-27 22:23:48 +0000 |
1648 | @@ -1,5 +1,5 @@ |
1649 | /* |
1650 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
1651 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1652 | * |
1653 | * This file is part of Infinity PFM. |
1654 | * |
1655 | @@ -29,32 +29,23 @@ |
1656 | |
1657 | |
1658 | /** |
1659 | - * @author wayne |
1660 | - * |
1661 | - * TODO To change the template for this generated type comment go to |
1662 | - * Window - Preferences - Java - Code Style - Code Templates |
1663 | + * @author Wayne Gray |
1664 | */ |
1665 | public abstract class BaseImport { |
1666 | |
1667 | - //private List actList = null; |
1668 | - |
1669 | - /** |
1670 | - * |
1671 | - */ |
1672 | + public static final String FLD_CHECKNUM = "CHECKNUM"; |
1673 | + public static final String FLD_DTPOSTED = "DTPOSTED"; |
1674 | + public static final String FLD_NAME = "NAME"; |
1675 | + public static final String FLD_MEMO = "MEMO"; |
1676 | + public static final String FLD_STMTTRN = "STMTTRN"; |
1677 | + public static final String FLD_TRNAMT = "TRNAMT"; |
1678 | + |
1679 | public BaseImport() { |
1680 | super(); |
1681 | - // TODO Auto-generated constructor stub |
1682 | } |
1683 | |
1684 | public abstract List<Transaction> ImportFile(String sFile) throws FileNotFoundException, IOException, ParseException; |
1685 | |
1686 | -// protected void OpenImportDialog(List aList){ |
1687 | -// |
1688 | -// actList = aList; |
1689 | -// ImportDialog dlg = new ImportDialog(actList); |
1690 | -// dlg.Open(); |
1691 | -// |
1692 | -// } |
1693 | } |
1694 | |
1695 | |
1696 | |
1697 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BitcoinImport.java' |
1698 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BitcoinImport.java 2012-08-26 22:11:17 +0000 |
1699 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/imports/BitcoinImport.java 2014-11-27 22:23:48 +0000 |
1700 | @@ -1,5 +1,5 @@ |
1701 | /* |
1702 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
1703 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1704 | * |
1705 | * This file is part of Infinity PFM. |
1706 | * |
1707 | @@ -32,70 +32,75 @@ |
1708 | |
1709 | public class BitcoinImport extends BaseImport { |
1710 | |
1711 | + @SuppressWarnings("unchecked") |
1712 | @Override |
1713 | public List<Transaction> ImportFile(String sFile) { |
1714 | - |
1715 | + |
1716 | List<Transaction> result = null; |
1717 | - |
1718 | + |
1719 | try { |
1720 | - |
1721 | - BitcoinClient client = new BitcoinClient("localhost", MM.bitcoinUser, MM.bitcoinPwd); |
1722 | + |
1723 | + BitcoinClient client = new BitcoinClient("localhost", |
1724 | + MM.bitcoinUser, MM.bitcoinPwd); |
1725 | AccountInfo accountInfo = null; |
1726 | TransactionInfo tran = null; |
1727 | Transaction t = null; |
1728 | result = new ArrayList<Transaction>(); |
1729 | - List<AccountInfo> activeAccounts = client.listReceivedByAccount(0, false); |
1730 | - |
1731 | + List<AccountInfo> activeAccounts = client.listReceivedByAccount(0, |
1732 | + false); |
1733 | + |
1734 | List<Transaction> transInSystem = null; |
1735 | - |
1736 | - //Add the default account to the list so we get coins sent |
1737 | + |
1738 | + // Add the default account to the list so we get coins sent |
1739 | AccountInfo defaultAccount = new AccountInfo(); |
1740 | defaultAccount.setAccount(""); |
1741 | activeAccounts.add(defaultAccount); |
1742 | - |
1743 | - if (activeAccounts != null){ |
1744 | - |
1745 | - for (int i=0; i<activeAccounts.size(); i++){ |
1746 | - |
1747 | + |
1748 | + if (activeAccounts != null) { |
1749 | + |
1750 | + for (int i = 0; i < activeAccounts.size(); i++) { |
1751 | + |
1752 | accountInfo = activeAccounts.get(i); |
1753 | - |
1754 | - List<TransactionInfo> trans = client.listTransactions(accountInfo.getAccount(), 500); |
1755 | - |
1756 | - if (trans != null){ |
1757 | - |
1758 | - for (int j=0; j<trans.size(); j++){ |
1759 | - |
1760 | + |
1761 | + List<TransactionInfo> trans = client.listTransactions( |
1762 | + accountInfo.getAccount(), 500); |
1763 | + |
1764 | + if (trans != null) { |
1765 | + |
1766 | + for (int j = 0; j < trans.size(); j++) { |
1767 | + |
1768 | tran = trans.get(j); |
1769 | - |
1770 | + |
1771 | try { |
1772 | - transInSystem = MM.sqlMap.queryForList("getTransactionsByKey", tran.getTxId()); |
1773 | - |
1774 | - if (transInSystem == null || transInSystem.size()==0){ |
1775 | - |
1776 | + transInSystem = MM.sqlMap.queryForList( |
1777 | + "getTransactionsByKey", tran.getTxId()); |
1778 | + |
1779 | + if (transInSystem == null |
1780 | + || transInSystem.size() == 0) { |
1781 | + |
1782 | t = new Transaction(); |
1783 | t.setTransactionKey(tran.getTxId()); |
1784 | t.setTranAmount(tran.getAmount()); |
1785 | t.setTranMemo(tran.getCategory()); |
1786 | - t.setTranDate(new Date(tran.getTime() * 1000)); |
1787 | + t.setTranDate(new Date( |
1788 | + tran.getTime() * 1000)); |
1789 | result.add(t); |
1790 | - |
1791 | + |
1792 | } |
1793 | - |
1794 | - |
1795 | + |
1796 | } catch (SQLException e) { |
1797 | e.printStackTrace(); |
1798 | } |
1799 | - |
1800 | - |
1801 | + |
1802 | } |
1803 | - |
1804 | + |
1805 | } |
1806 | } |
1807 | } |
1808 | - } catch (Exception e){ |
1809 | + } catch (Exception e) { |
1810 | e.printStackTrace(); |
1811 | } |
1812 | - |
1813 | + |
1814 | return result; |
1815 | } |
1816 | |
1817 | |
1818 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/imports/OfxImport.java' |
1819 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/imports/OfxImport.java 2012-08-26 22:11:17 +0000 |
1820 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/imports/OfxImport.java 2014-11-27 22:23:48 +0000 |
1821 | @@ -1,5 +1,5 @@ |
1822 | /* |
1823 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
1824 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1825 | * |
1826 | * This file is part of Infinity PFM. |
1827 | * |
1828 | @@ -30,47 +30,30 @@ |
1829 | import java.util.Date; |
1830 | import java.util.List; |
1831 | |
1832 | - |
1833 | import org.apache.commons.io.IOUtils; |
1834 | +import org.infinitypfm.core.conf.MM; |
1835 | import org.infinitypfm.core.data.DataFormatUtil; |
1836 | import org.infinitypfm.core.data.Transaction; |
1837 | |
1838 | /** |
1839 | * @author wayne |
1840 | - * |
1841 | - * TODO To change the template for this generated type comment go to |
1842 | - * Window - Preferences - Java - Code Style - Code Templates |
1843 | */ |
1844 | public class OfxImport extends BaseImport { |
1845 | - |
1846 | - |
1847 | - |
1848 | - /** |
1849 | - * |
1850 | - */ |
1851 | + |
1852 | public OfxImport() { |
1853 | super(); |
1854 | - // TODO Auto-generated constructor stub |
1855 | } |
1856 | |
1857 | - /* (non-Javadoc) |
1858 | - * @see net.mogray.mymoney.data.imports.BaseImport#ImportFile(java.lang.String) |
1859 | - */ |
1860 | public List<Transaction> ImportFile(String sFile) throws IOException, ParseException |
1861 | { |
1862 | |
1863 | - //boolean startTran = false; |
1864 | - //boolean endTran = false; |
1865 | boolean startElement = false; |
1866 | - //boolean endElement = false; |
1867 | boolean inTag = false; |
1868 | |
1869 | String element = ""; |
1870 | String val = ""; |
1871 | Transaction tran = null; |
1872 | ArrayList<Transaction> tranList = new ArrayList<Transaction>(); |
1873 | - |
1874 | -// try { |
1875 | |
1876 | if (sFile==null){return null;} |
1877 | |
1878 | @@ -97,7 +80,7 @@ |
1879 | } else if (l=='>' && startElement){ |
1880 | startElement = false; |
1881 | inTag = true; |
1882 | - if (element.equalsIgnoreCase("STMTTRN")){ |
1883 | + if (element.equalsIgnoreCase(FLD_STMTTRN)){ |
1884 | tran = new Transaction(); |
1885 | tranList.add(tran); |
1886 | } |
1887 | @@ -111,32 +94,29 @@ |
1888 | } |
1889 | |
1890 | return tranList; |
1891 | - |
1892 | - |
1893 | -// } catch (IOException ioe){ |
1894 | -// MM.LogMessage(ioe.getMessage()); |
1895 | -// } |
1896 | |
1897 | } |
1898 | |
1899 | private void SaveElement(String element, String val, Transaction tran) throws ParseException{ |
1900 | |
1901 | - if (element.equalsIgnoreCase("TRNAMT")){ |
1902 | + if (element.equalsIgnoreCase(FLD_TRNAMT)){ |
1903 | |
1904 | tran.setTranAmount(DataFormatUtil.moneyToLong(val)); |
1905 | |
1906 | - } else if (element.equalsIgnoreCase("MEMO") || element.equalsIgnoreCase("NAME")){ |
1907 | + } else if (element.equalsIgnoreCase(FLD_MEMO) || element.equalsIgnoreCase(FLD_NAME)){ |
1908 | |
1909 | tran.setTranMemo(val); |
1910 | |
1911 | - } else if (element.equalsIgnoreCase("DTPOSTED")){ |
1912 | - //tran.setTranDate(val); |
1913 | + } else if (element.equalsIgnoreCase(FLD_DTPOSTED)){ |
1914 | + |
1915 | DateFormat dateFmt = new SimpleDateFormat("yyyymmddhhmmss"); |
1916 | |
1917 | Date dt = dateFmt.parse(val); |
1918 | tran.setTranDate(dt); |
1919 | |
1920 | |
1921 | + } else if (element.equalsIgnoreCase(FLD_CHECKNUM)){ |
1922 | + tran.setTranMemo(MM.PHRASES.getPhrase("237") + " " + val); |
1923 | } |
1924 | } |
1925 | |
1926 | |
1927 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/data/imports/QfxImport.java' |
1928 | --- infinitypfm/src/main/java/org/infinitypfm/core/data/imports/QfxImport.java 2012-08-26 22:11:17 +0000 |
1929 | +++ infinitypfm/src/main/java/org/infinitypfm/core/data/imports/QfxImport.java 2014-11-27 22:23:48 +0000 |
1930 | @@ -1,5 +1,5 @@ |
1931 | /* |
1932 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
1933 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
1934 | * |
1935 | * This file is part of Infinity PFM. |
1936 | * |
1937 | @@ -30,32 +30,20 @@ |
1938 | import java.util.Date; |
1939 | import java.util.List; |
1940 | |
1941 | - |
1942 | import org.apache.commons.io.IOUtils; |
1943 | +import org.infinitypfm.core.conf.MM; |
1944 | import org.infinitypfm.core.data.DataFormatUtil; |
1945 | import org.infinitypfm.core.data.Transaction; |
1946 | |
1947 | /** |
1948 | * @author wayne |
1949 | - * |
1950 | - * TODO To change the template for this generated type comment go to |
1951 | - * Window - Preferences - Java - Code Style - Code Templates |
1952 | */ |
1953 | public class QfxImport extends BaseImport { |
1954 | - |
1955 | - |
1956 | - |
1957 | - /** |
1958 | - * |
1959 | - */ |
1960 | + |
1961 | public QfxImport() { |
1962 | super(); |
1963 | - // TODO Auto-generated constructor stub |
1964 | } |
1965 | - |
1966 | - /* (non-Javadoc) |
1967 | - * @see net.mogray.mymoney.data.imports.BaseImport#ImportFile(java.lang.String) |
1968 | - */ |
1969 | + |
1970 | public List<Transaction> ImportFile(String sFile) throws IOException, ParseException { |
1971 | |
1972 | boolean startElement = false; |
1973 | @@ -91,7 +79,7 @@ |
1974 | } else if (l=='>' && startElement){ |
1975 | startElement = false; |
1976 | inTag = true; |
1977 | - if (element.equalsIgnoreCase("STMTTRN")){ |
1978 | + if (element.equalsIgnoreCase(FLD_STMTTRN)){ |
1979 | tran = new Transaction(); |
1980 | tranList.add(tran); |
1981 | } |
1982 | @@ -110,18 +98,20 @@ |
1983 | |
1984 | private void SaveElement(String element, String val, Transaction tran) throws ParseException{ |
1985 | |
1986 | - if (element.equalsIgnoreCase("TRNAMT")){ |
1987 | + if (element.equalsIgnoreCase(FLD_TRNAMT)){ |
1988 | |
1989 | tran.setTranAmount(DataFormatUtil.moneyToLong(val)); |
1990 | |
1991 | - } else if (element.equalsIgnoreCase("MEMO")){ |
1992 | + } else if (element.equalsIgnoreCase(FLD_MEMO)){ |
1993 | tran.setTranMemo(val); |
1994 | - } else if (element.equalsIgnoreCase("NAME")){ |
1995 | + } else if (element.equalsIgnoreCase(FLD_NAME)){ |
1996 | tran.setTranMemo(val); |
1997 | - } else if (element.equalsIgnoreCase("DTPOSTED")){ |
1998 | + } else if (element.equalsIgnoreCase(FLD_DTPOSTED)){ |
1999 | DateFormat dateFmt = new SimpleDateFormat("yyyyMMddHHmmss"); |
2000 | Date dt = dateFmt.parse(val); |
2001 | tran.setTranDate(dt); |
2002 | + } else if (element.equalsIgnoreCase(FLD_CHECKNUM)){ |
2003 | + tran.setTranMemo(MM.PHRASES.getPhrase("237") + " " + val); |
2004 | } |
2005 | } |
2006 | |
2007 | |
2008 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/core/reporting/AccountHistory.java' |
2009 | --- infinitypfm/src/main/java/org/infinitypfm/core/reporting/AccountHistory.java 2012-08-26 22:11:17 +0000 |
2010 | +++ infinitypfm/src/main/java/org/infinitypfm/core/reporting/AccountHistory.java 2014-11-27 22:23:48 +0000 |
2011 | @@ -1,5 +1,5 @@ |
2012 | /* |
2013 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
2014 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
2015 | * |
2016 | * This file is part of Infinity PFM. |
2017 | * |
2018 | @@ -15,7 +15,7 @@ |
2019 | * |
2020 | * You should have received a copy of the GNU General Public License |
2021 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
2022 | -*/ |
2023 | + */ |
2024 | package org.infinitypfm.core.reporting; |
2025 | |
2026 | import java.io.File; |
2027 | @@ -27,14 +27,14 @@ |
2028 | import org.infinitypfm.core.data.ReportData; |
2029 | import org.infinitypfm.core.types.NumberFormat; |
2030 | |
2031 | - |
2032 | -public class AccountHistory extends BaseReport implements ChartProvider, TableProvider { |
2033 | +public class AccountHistory extends BaseReport implements ChartProvider, |
2034 | + TableProvider { |
2035 | |
2036 | private long total = 0; |
2037 | - |
2038 | + |
2039 | public AccountHistory() throws IOException { |
2040 | super(); |
2041 | - rowColors = new HashMap<String,String>(); |
2042 | + rowColors = new HashMap<String, String>(); |
2043 | rowColors.put("liabilitycolor", "#2e2e2b"); |
2044 | rowColors.put("liabilityback", "#f3f6c2"); |
2045 | rowColors.put("expensecolor", "#381f1f"); |
2046 | @@ -48,79 +48,79 @@ |
2047 | @Override |
2048 | public File execute(ReportData reportData) { |
2049 | try { |
2050 | - |
2051 | + |
2052 | String row = null; |
2053 | - |
2054 | + |
2055 | this.addDocHeader(1, CHART_TYPE_BAR); |
2056 | - |
2057 | + |
2058 | this.addTitle(reportData.getTitle()); |
2059 | - |
2060 | + |
2061 | + @SuppressWarnings("rawtypes") |
2062 | List rows = reportData.getReportData(); |
2063 | - |
2064 | - if (rows.size()>0) { |
2065 | + |
2066 | + if (rows.size() > 0) { |
2067 | IReportable reportRow = (IReportable) rows.get(0); |
2068 | String[] columns = reportRow.toReportRow().split("\\|"); |
2069 | this.startChartData("1", columns[1]); |
2070 | } |
2071 | - |
2072 | - for (int i=0; i< rows.size(); i++){ |
2073 | + |
2074 | + for (int i = 0; i < rows.size(); i++) { |
2075 | IReportable reportRow = (IReportable) rows.get(i); |
2076 | - |
2077 | + |
2078 | addChartRow(reportRow.toReportRow()); |
2079 | } |
2080 | - |
2081 | + |
2082 | this.endChartData("1"); |
2083 | - |
2084 | - |
2085 | + |
2086 | this.startTableData(); |
2087 | - |
2088 | - for (int i=0; i< rows.size(); i++){ |
2089 | - |
2090 | + |
2091 | + for (int i = 0; i < rows.size(); i++) { |
2092 | + |
2093 | IReportable reportRow = (IReportable) rows.get(i); |
2094 | - if(i==0){ |
2095 | + if (i == 0) { |
2096 | addHeaderRow(reportRow.getHeaderRow().split("\\|")); |
2097 | - } |
2098 | - |
2099 | + } |
2100 | + |
2101 | String[] columns = reportRow.toReportRow().split("\\|"); |
2102 | addDataRow(columns); |
2103 | - |
2104 | + |
2105 | } |
2106 | row = "Total|" + total + "|"; |
2107 | addTotalRow(row.split("\\|")); |
2108 | - |
2109 | + |
2110 | this.endTableData(); |
2111 | - |
2112 | + |
2113 | this.Close(); |
2114 | - } catch (IOException ioe){} |
2115 | + } catch (IOException ioe) { |
2116 | + } |
2117 | return this.getOutFile(); |
2118 | } |
2119 | - |
2120 | + |
2121 | @Override |
2122 | public void addHeaderRow(String[] columns) throws IOException { |
2123 | - |
2124 | + |
2125 | this.startRow(); |
2126 | int pos = 0; |
2127 | - for (int i=1; i<columns.length; i++) { |
2128 | - pos = columns.length-i; |
2129 | + for (int i = 1; i < columns.length; i++) { |
2130 | + pos = columns.length - i; |
2131 | this.addHeader(columns[pos]); |
2132 | } |
2133 | this.endRow(); |
2134 | - |
2135 | + |
2136 | } |
2137 | - |
2138 | + |
2139 | @Override |
2140 | - public void addDataRow(String[] columns) throws IOException{ |
2141 | - |
2142 | - this.startRow(rowColors.get("bankback"), |
2143 | - rowColors.get("bankcolor")); |
2144 | - |
2145 | + public void addDataRow(String[] columns) throws IOException { |
2146 | + |
2147 | + this.startRow(rowColors.get("bankback"), rowColors.get("bankcolor")); |
2148 | + |
2149 | int pos = 0; |
2150 | - |
2151 | - for (int i=1; i<columns.length; i++) { |
2152 | - pos = columns.length-i; |
2153 | - if (i==2) { |
2154 | + |
2155 | + for (int i = 1; i < columns.length; i++) { |
2156 | + pos = columns.length - i; |
2157 | + if (i == 2) { |
2158 | long longVal = Long.parseLong(columns[pos]); |
2159 | - if (longVal < 0){ |
2160 | + if (longVal < 0) { |
2161 | longVal = -longVal; |
2162 | } |
2163 | total += longVal; |
2164 | @@ -131,17 +131,16 @@ |
2165 | } |
2166 | this.endRow(); |
2167 | } |
2168 | - |
2169 | + |
2170 | @Override |
2171 | - public void addTotalRow(String[] columns) throws IOException{ |
2172 | - |
2173 | - this.startRow(rowColors.get("bankback"), |
2174 | - rowColors.get("bankcolor")); |
2175 | - |
2176 | - for (int i=0; i<columns.length; i++) { |
2177 | - if (i==1) { |
2178 | + public void addTotalRow(String[] columns) throws IOException { |
2179 | + |
2180 | + this.startRow(rowColors.get("bankback"), rowColors.get("bankcolor")); |
2181 | + |
2182 | + for (int i = 0; i < columns.length; i++) { |
2183 | + if (i == 1) { |
2184 | long longVal = Long.parseLong(columns[i]); |
2185 | - if (longVal < 0){ |
2186 | + if (longVal < 0) { |
2187 | longVal = -longVal; |
2188 | } |
2189 | this.addTotal(longVal); |
2190 | @@ -151,35 +150,37 @@ |
2191 | } |
2192 | this.endRow(); |
2193 | } |
2194 | - |
2195 | + |
2196 | @Override |
2197 | - public void addChartRow(String row) throws IOException{ |
2198 | + public void addChartRow(String row) throws IOException { |
2199 | String[] columns = row.split("\\|"); |
2200 | |
2201 | - this.startRow(); |
2202 | - |
2203 | - this.addChartLabel(columns[4]); |
2204 | - String sChartVal = columns[3].replace('(', ' ').replace(')', ' ').trim(); |
2205 | - |
2206 | - if (sChartVal == null || sChartVal.length()==0){ |
2207 | - sChartVal = "0"; |
2208 | - } |
2209 | - |
2210 | - long longVal = Long.parseLong(sChartVal); |
2211 | - if (longVal < 0){ |
2212 | - longVal = -longVal; |
2213 | - } |
2214 | - |
2215 | - this.addChartValue(formatter.getAmountFormatted(longVal, NumberFormat.getNoCommaNoParems())); |
2216 | - |
2217 | - this.endRow(); |
2218 | + this.startRow(); |
2219 | + |
2220 | + this.addChartLabel(columns[4]); |
2221 | + String sChartVal = columns[3].replace('(', ' ').replace(')', ' ') |
2222 | + .trim(); |
2223 | + |
2224 | + if (sChartVal == null || sChartVal.length() == 0) { |
2225 | + sChartVal = "0"; |
2226 | + } |
2227 | + |
2228 | + long longVal = Long.parseLong(sChartVal); |
2229 | + if (longVal < 0) { |
2230 | + longVal = -longVal; |
2231 | + } |
2232 | + |
2233 | + this.addChartValue(formatter.getAmountFormatted(longVal, |
2234 | + NumberFormat.getNoCommaNoParems())); |
2235 | + |
2236 | + this.endRow(); |
2237 | } |
2238 | |
2239 | @Override |
2240 | public void addChartRow(String row, String actType, float totalVal) |
2241 | throws IOException { |
2242 | // TODO Auto-generated method stub |
2243 | - |
2244 | + |
2245 | } |
2246 | |
2247 | } |
2248 | |
2249 | === added file 'infinitypfm/src/main/java/org/infinitypfm/core/types/AccountTypes.java' |
2250 | --- infinitypfm/src/main/java/org/infinitypfm/core/types/AccountTypes.java 1970-01-01 00:00:00 +0000 |
2251 | +++ infinitypfm/src/main/java/org/infinitypfm/core/types/AccountTypes.java 2014-11-27 22:23:48 +0000 |
2252 | @@ -0,0 +1,26 @@ |
2253 | +/* |
2254 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
2255 | + * |
2256 | + * This file is part of Infinity PFM. |
2257 | + * |
2258 | + * Infinity PFM is free software: you can redistribute it and/or modify |
2259 | + * it under the terms of the GNU General Public License as published by |
2260 | + * the Free Software Foundation, either version 3 of the License, or |
2261 | + * (at your option) any later version. |
2262 | + * |
2263 | + * Infinity PFM is distributed in the hope that it will be useful, |
2264 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2265 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2266 | + * GNU General Public License for more details. |
2267 | + * |
2268 | + * You should have received a copy of the GNU General Public License |
2269 | + * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
2270 | + */ |
2271 | + |
2272 | +package org.infinitypfm.core.types; |
2273 | + |
2274 | +public class AccountTypes { |
2275 | + |
2276 | + public static final String BANK = "Bank"; |
2277 | + |
2278 | +} |
2279 | |
2280 | === added file 'infinitypfm/src/main/java/org/infinitypfm/core/types/ImportRuleNames.java' |
2281 | --- infinitypfm/src/main/java/org/infinitypfm/core/types/ImportRuleNames.java 1970-01-01 00:00:00 +0000 |
2282 | +++ infinitypfm/src/main/java/org/infinitypfm/core/types/ImportRuleNames.java 2014-11-27 22:23:48 +0000 |
2283 | @@ -0,0 +1,30 @@ |
2284 | +/* |
2285 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
2286 | + * |
2287 | + * This file is part of Infinity PFM. |
2288 | + * |
2289 | + * Infinity PFM is free software: you can redistribute it and/or modify |
2290 | + * it under the terms of the GNU General Public License as published by |
2291 | + * the Free Software Foundation, either version 3 of the License, or |
2292 | + * (at your option) any later version. |
2293 | + * |
2294 | + * Infinity PFM is distributed in the hope that it will be useful, |
2295 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2296 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2297 | + * GNU General Public License for more details. |
2298 | + * |
2299 | + * You should have received a copy of the GNU General Public License |
2300 | + * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
2301 | + */ |
2302 | + |
2303 | +package org.infinitypfm.core.types; |
2304 | + |
2305 | +import org.infinitypfm.core.conf.MM; |
2306 | + |
2307 | +public class ImportRuleNames { |
2308 | + |
2309 | + public static final String CONTAINS = MM.PHRASES.getPhrase("243"); |
2310 | + public static final String STARTSWITH = MM.PHRASES.getPhrase("244"); |
2311 | + public static final String ENDSWITH = MM.PHRASES.getPhrase("245"); |
2312 | + |
2313 | +} |
2314 | |
2315 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/MainFrame.java' |
2316 | --- infinitypfm/src/main/java/org/infinitypfm/ui/MainFrame.java 2012-08-26 22:11:17 +0000 |
2317 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/MainFrame.java 2014-11-27 22:23:48 +0000 |
2318 | @@ -1,5 +1,5 @@ |
2319 | /* |
2320 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
2321 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
2322 | * |
2323 | * This file is part of Infinity PFM. |
2324 | * |
2325 | @@ -15,16 +15,13 @@ |
2326 | * |
2327 | * You should have received a copy of the GNU General Public License |
2328 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
2329 | -*/ |
2330 | + */ |
2331 | |
2332 | package org.infinitypfm.ui; |
2333 | |
2334 | - |
2335 | import org.eclipse.swt.SWT; |
2336 | import org.eclipse.swt.events.ShellAdapter; |
2337 | import org.eclipse.swt.events.ShellEvent; |
2338 | -import org.eclipse.swt.graphics.Font; |
2339 | -import org.eclipse.swt.graphics.FontData; |
2340 | import org.eclipse.swt.graphics.Point; |
2341 | import org.eclipse.swt.graphics.Rectangle; |
2342 | import org.eclipse.swt.layout.FormAttachment; |
2343 | @@ -44,9 +41,9 @@ |
2344 | |
2345 | /** |
2346 | * @author Wayne Gray |
2347 | - * |
2348 | - * To change the template for this generated type comment go to |
2349 | - * Window>Preferences>Java>Code Generation>Code and Comments |
2350 | + * |
2351 | + * To change the template for this generated type comment go to |
2352 | + * Window>Preferences>Java>Code Generation>Code and Comments |
2353 | */ |
2354 | public class MainFrame { |
2355 | |
2356 | @@ -54,57 +51,46 @@ |
2357 | private static Sash HorSash; |
2358 | private FormData Vsashdata; |
2359 | private FormData Hsashdata; |
2360 | - //private Color oColor = null; |
2361 | - private Font newFont=null; |
2362 | public Label lblStatus = null; |
2363 | - |
2364 | + |
2365 | private MoneyTree trMain; |
2366 | private ConsoleView msgMain; |
2367 | private ViewHandler vwMain; |
2368 | - private MainMenu mnuMain; |
2369 | + private MainMenu mnuMain; |
2370 | private BaseToolbar cbMain; |
2371 | private StatusView stMain; |
2372 | |
2373 | - //private QueueServers queueServers = null; |
2374 | - |
2375 | - |
2376 | public MainFrame() { |
2377 | super(); |
2378 | - |
2379 | - //save inputs |
2380 | + |
2381 | + // save inputs |
2382 | InfinityPfm.shMain.addShellListener(new onClose()); |
2383 | - |
2384 | - |
2385 | + |
2386 | } |
2387 | - |
2388 | - public void LoadUI(boolean bUseIcons){ |
2389 | + |
2390 | + public void LoadUI(boolean bUseIcons) { |
2391 | InfinityPfm.shMain.setLayout(new FormLayout()); |
2392 | - InfinityPfm.shMain.setText(MM.APPTITLE + " - " + |
2393 | - MM.PHRASES.getPhrase("63")); |
2394 | - InfinityPfm.shMain.setImage(InfinityPfm.imMain.getImage(MM.IMG_QUEZEN_ICON)); |
2395 | + InfinityPfm.shMain.setText(MM.APPTITLE + " - " |
2396 | + + MM.PHRASES.getPhrase("63")); |
2397 | + InfinityPfm.shMain.setImage(InfinityPfm.imMain |
2398 | + .getImage(MM.IMG_QUEZEN_ICON)); |
2399 | |
2400 | /* |
2401 | * Load Status Box |
2402 | */ |
2403 | stMain = new StatusView(InfinityPfm.shMain, SWT.FLAT); |
2404 | - |
2405 | + |
2406 | /* |
2407 | * Load Main Menu |
2408 | */ |
2409 | mnuMain = new MainMenu(InfinityPfm.shMain); |
2410 | InfinityPfm.shMain.setMenuBar(mnuMain.getMenu()); |
2411 | - |
2412 | + |
2413 | /* |
2414 | * Load Main Toolbar |
2415 | */ |
2416 | - //if (bUseIcons==true){ |
2417 | - cbMain = new MainToolbar(InfinityPfm.shMain); |
2418 | -// } else { |
2419 | -// cbMain = new MainToolbar(InfinityPfm.shMain); |
2420 | -// } |
2421 | - |
2422 | - |
2423 | - |
2424 | + cbMain = new MainToolbar(InfinityPfm.shMain); |
2425 | + |
2426 | /* |
2427 | * Load Tree |
2428 | */ |
2429 | @@ -114,299 +100,279 @@ |
2430 | * Load View Handler |
2431 | */ |
2432 | vwMain = new ViewHandler(); |
2433 | - |
2434 | - |
2435 | -// lblStatus = new Label(InfinityPfm.shMain, SWT.FLAT); |
2436 | -// lblStatus.setText(" "); |
2437 | -// lblStatus.setAlignment(SWT.CENTER); |
2438 | -// BigFont(lblStatus); |
2439 | -// oColor = new Color(InfinityPfm.shMain.getDisplay(), 255, 0, 0); |
2440 | -// lblStatus.setForeground(oColor); |
2441 | - |
2442 | - |
2443 | - |
2444 | - |
2445 | + |
2446 | } |
2447 | - |
2448 | - public void Open(){ |
2449 | - |
2450 | + |
2451 | + public void Open() { |
2452 | + |
2453 | setListeners(); |
2454 | InfinityPfm.shMain.open(); |
2455 | VertSash.setFocus(); |
2456 | InfinityPfm.shMain.setSize(1024, 768); |
2457 | - |
2458 | + |
2459 | } |
2460 | - |
2461 | |
2462 | - public void LoadLayout(){ |
2463 | - //create vertical sash |
2464 | + public void LoadLayout() { |
2465 | + // create vertical sash |
2466 | VertSash = new Sash(InfinityPfm.shMain, SWT.FLAT | SWT.VERTICAL); |
2467 | Vsashdata = new FormData(); |
2468 | Vsashdata.bottom = new FormAttachment(stMain, 0); |
2469 | - Vsashdata.left = new FormAttachment(20,0); |
2470 | - Vsashdata.top = new FormAttachment(cbMain.getToolbar(),0); |
2471 | + Vsashdata.left = new FormAttachment(20, 0); |
2472 | + Vsashdata.top = new FormAttachment(cbMain.getToolbar(), 0); |
2473 | VertSash.setLayoutData(Vsashdata); |
2474 | - |
2475 | - //Bind other controls |
2476 | + |
2477 | + // Bind other controls |
2478 | FormData coolbardata = new FormData(); |
2479 | coolbardata.top = new FormAttachment(0, 0); |
2480 | coolbardata.left = new FormAttachment(0, 0); |
2481 | coolbardata.right = new FormAttachment(100, 0); |
2482 | cbMain.getToolbar().setLayoutData(coolbardata); |
2483 | - |
2484 | -// FormData lblstatusdata = new FormData(); |
2485 | -// lblstatusdata.top = new FormAttachment(0,5); |
2486 | -// lblstatusdata.left = new FormAttachment(InfinityPfm.cbMain.getToolbar(), 5); |
2487 | -// lblstatusdata.right = new FormAttachment(100, -5); |
2488 | -// lblStatus.setLayoutData(lblstatusdata); |
2489 | - |
2490 | + |
2491 | FormData stmaindata = new FormData(); |
2492 | stmaindata.left = new FormAttachment(0, 0); |
2493 | stmaindata.bottom = new FormAttachment(100, 0); |
2494 | stmaindata.top = new FormAttachment(100, -20); |
2495 | stmaindata.right = new FormAttachment(100, 0); |
2496 | stMain.setLayoutData(stmaindata); |
2497 | - |
2498 | + |
2499 | FormData trmaindata = new FormData(); |
2500 | trmaindata.left = new FormAttachment(0, 0); |
2501 | trmaindata.right = new FormAttachment(VertSash, 0); |
2502 | trmaindata.top = new FormAttachment(cbMain.getToolbar(), 0); |
2503 | - trmaindata.bottom = new FormAttachment(stMain,0); |
2504 | + trmaindata.bottom = new FormAttachment(stMain, 0); |
2505 | trMain.getTree().setLayoutData(trmaindata); |
2506 | - |
2507 | + |
2508 | FormData rightpanedata = new FormData(); |
2509 | rightpanedata.left = new FormAttachment(VertSash, 0); |
2510 | rightpanedata.bottom = new FormAttachment(stMain, 0); |
2511 | - //rightpanedata.bottom = new FormAttachment(100, -25); |
2512 | rightpanedata.top = new FormAttachment(cbMain.getToolbar(), 0); |
2513 | rightpanedata.right = new FormAttachment(100, 0); |
2514 | - |
2515 | + |
2516 | vwMain.getParent().setLayoutData(rightpanedata); |
2517 | - |
2518 | - |
2519 | - |
2520 | + |
2521 | } |
2522 | |
2523 | - public Point getWindowCenter(){ |
2524 | + public Point getWindowCenter() { |
2525 | Point p = InfinityPfm.shMain.getLocation(); |
2526 | Rectangle rect = InfinityPfm.shMain.getBounds(); |
2527 | int xc = p.x + (rect.height / 2); |
2528 | - int yc = p.y + (rect.width /2); |
2529 | + int yc = p.y + (rect.width / 2); |
2530 | p = null; |
2531 | rect = null; |
2532 | return new Point(xc, yc); |
2533 | - |
2534 | + |
2535 | } |
2536 | - |
2537 | - public void getRightPane(){ |
2538 | + |
2539 | + public void getRightPane() { |
2540 | vwMain = new ViewHandler(); |
2541 | } |
2542 | - |
2543 | - public void LoadConsole(boolean bLoad){ |
2544 | - if (bLoad && msgMain==null){ |
2545 | + |
2546 | + public void LoadConsole(boolean bLoad) { |
2547 | + if (bLoad && msgMain == null) { |
2548 | msgMain = new ConsoleView(InfinityPfm.shMain); |
2549 | - |
2550 | + |
2551 | HorSash = new Sash(InfinityPfm.shMain, SWT.FLAT | SWT.HORIZONTAL); |
2552 | Hsashdata = new FormData(); |
2553 | Hsashdata.left = new FormAttachment(0, 0); |
2554 | - Hsashdata.right = new FormAttachment(100,0); |
2555 | - Hsashdata.bottom = new FormAttachment(80,0); |
2556 | + Hsashdata.right = new FormAttachment(100, 0); |
2557 | + Hsashdata.bottom = new FormAttachment(80, 0); |
2558 | HorSash.setLayoutData(Hsashdata); |
2559 | - |
2560 | + |
2561 | FormData rightbottpanedata = new FormData(); |
2562 | rightbottpanedata.left = new FormAttachment(0, 0); |
2563 | rightbottpanedata.bottom = new FormAttachment(stMain, 0); |
2564 | rightbottpanedata.top = new FormAttachment(HorSash, 0); |
2565 | rightbottpanedata.right = new FormAttachment(100, 0); |
2566 | msgMain.setLayoutData(rightbottpanedata); |
2567 | - |
2568 | - FormData data = (FormData)vwMain.getParent().getLayoutData(); |
2569 | + |
2570 | + FormData data = (FormData) vwMain.getParent().getLayoutData(); |
2571 | data.bottom = new FormAttachment(HorSash, 0); |
2572 | Vsashdata.bottom = new FormAttachment(HorSash, 0); |
2573 | data = (FormData) trMain.getTree().getLayoutData(); |
2574 | data.bottom = new FormAttachment(HorSash, 0); |
2575 | - |
2576 | - HorSash.addListener (SWT.Selection, new Listener () { |
2577 | - public void handleEvent (Event e) { |
2578 | - Rectangle sashRect = HorSash.getBounds (); |
2579 | - Rectangle shellRect = InfinityPfm.shMain.getClientArea (); |
2580 | - int right = shellRect.height - sashRect.height - 10; |
2581 | - e.y = Math.max (Math.min (e.y, right), 29); |
2582 | - |
2583 | - if (e.y != sashRect.y) { |
2584 | - Hsashdata.bottom = new FormAttachment (0, e.y); |
2585 | - InfinityPfm.shMain.layout (); |
2586 | + |
2587 | + HorSash.addListener(SWT.Selection, new Listener() { |
2588 | + public void handleEvent(Event e) { |
2589 | + Rectangle sashRect = HorSash.getBounds(); |
2590 | + Rectangle shellRect = InfinityPfm.shMain.getClientArea(); |
2591 | + int right = shellRect.height - sashRect.height - 10; |
2592 | + e.y = Math.max(Math.min(e.y, right), 29); |
2593 | + |
2594 | + if (e.y != sashRect.y) { |
2595 | + Hsashdata.bottom = new FormAttachment(0, e.y); |
2596 | + InfinityPfm.shMain.layout(); |
2597 | + } |
2598 | } |
2599 | - } |
2600 | }); |
2601 | - |
2602 | - } else if (!bLoad && msgMain != null){ |
2603 | + |
2604 | + } else if (!bLoad && msgMain != null) { |
2605 | msgMain.QZDispose(); |
2606 | msgMain = null; |
2607 | - if (!HorSash.isDisposed()){ |
2608 | + if (!HorSash.isDisposed()) { |
2609 | HorSash.dispose(); |
2610 | } |
2611 | - |
2612 | - FormData data = (FormData)vwMain.getParent().getLayoutData(); |
2613 | + |
2614 | + FormData data = (FormData) vwMain.getParent().getLayoutData(); |
2615 | data.bottom = new FormAttachment(stMain, 0); |
2616 | Vsashdata.bottom = new FormAttachment(stMain, 0); |
2617 | data = (FormData) trMain.getTree().getLayoutData(); |
2618 | data.bottom = new FormAttachment(stMain, 0); |
2619 | - data = (FormData)stMain.getLayoutData(); |
2620 | + data = (FormData) stMain.getLayoutData(); |
2621 | data.top = new FormAttachment(100, -20); |
2622 | } |
2623 | } |
2624 | - |
2625 | - public void setListeners(){ |
2626 | - |
2627 | - VertSash.addListener (SWT.Selection, new Listener () { |
2628 | - public void handleEvent (Event e) { |
2629 | - Rectangle sashRect = VertSash.getBounds (); |
2630 | - Rectangle shellRect = InfinityPfm.shMain.getClientArea (); |
2631 | - int right = shellRect.width - sashRect.width - 100; |
2632 | - e.x = Math.max (Math.min (e.x, right), 100); |
2633 | - if (e.x != sashRect.x) { |
2634 | - Vsashdata.left = new FormAttachment (0, e.x); |
2635 | - InfinityPfm.shMain.layout (); |
2636 | + |
2637 | + public void setListeners() { |
2638 | + |
2639 | + VertSash.addListener(SWT.Selection, new Listener() { |
2640 | + public void handleEvent(Event e) { |
2641 | + Rectangle sashRect = VertSash.getBounds(); |
2642 | + Rectangle shellRect = InfinityPfm.shMain.getClientArea(); |
2643 | + int right = shellRect.width - sashRect.width - 100; |
2644 | + e.x = Math.max(Math.min(e.x, right), 100); |
2645 | + if (e.x != sashRect.x) { |
2646 | + Vsashdata.left = new FormAttachment(0, e.x); |
2647 | + InfinityPfm.shMain.layout(); |
2648 | + } |
2649 | } |
2650 | - } |
2651 | - }); |
2652 | - |
2653 | - /* |
2654 | - HorSash.addListener (SWT.Selection, new Listener () { |
2655 | - public void handleEvent (Event e) { |
2656 | - Rectangle sashRect = HorSash.getBounds (); |
2657 | - Rectangle shellRect = InfinityPfm.shMain.getClientArea (); |
2658 | - int right = shellRect.height - sashRect.height - 10; |
2659 | - e.y = Math.max (Math.min (e.y, right), 29); |
2660 | - |
2661 | - if (e.y != sashRect.y) { |
2662 | - Hsashdata.bottom = new FormAttachment (0, e.y); |
2663 | - InfinityPfm.shMain.layout (); |
2664 | - } |
2665 | - } |
2666 | - }); |
2667 | - */ |
2668 | - |
2669 | -// lblStatus.addDisposeListener(new DisposeListener() { |
2670 | -// public void widgetDisposed(DisposeEvent e) { |
2671 | -// //get rid of fonts and colors used |
2672 | -// try{oColor.dispose();} catch (Exception dl){} |
2673 | -// try{newFont.dispose();} catch (Exception dl){} |
2674 | -// } |
2675 | -// }); |
2676 | - } |
2677 | - |
2678 | - public void QZDispose(){ |
2679 | - |
2680 | - |
2681 | - //if (!HorSash.isDisposed()){ |
2682 | - //HorSash.dispose(); |
2683 | - //} |
2684 | - } |
2685 | - |
2686 | - private void BigFont(Label lbl){ |
2687 | - Font lblFont = lbl.getFont(); |
2688 | - FontData[] lblFontData = lblFont.getFontData(); |
2689 | - for (int i=0; i<lblFontData.length; i++){ |
2690 | - lblFontData[i].setHeight(10); |
2691 | - } |
2692 | - newFont = new Font(InfinityPfm.shMain.getDisplay(), lblFontData); |
2693 | - lbl.setFont(newFont); |
2694 | - |
2695 | - } |
2696 | - |
2697 | + }); |
2698 | + |
2699 | + } |
2700 | + |
2701 | + public void QZDispose() { |
2702 | + } |
2703 | + |
2704 | /** |
2705 | * @return Returns the cbMain. |
2706 | */ |
2707 | public BaseToolbar getCbMain() { |
2708 | return cbMain; |
2709 | } |
2710 | + |
2711 | /** |
2712 | - * @param cbMain The cbMain to set. |
2713 | + * @param cbMain |
2714 | + * The cbMain to set. |
2715 | */ |
2716 | public void setCbMain(BaseToolbar cbMain) { |
2717 | this.cbMain = cbMain; |
2718 | } |
2719 | + |
2720 | /** |
2721 | * @return Returns the mnuMain. |
2722 | */ |
2723 | public MainMenu getMnuMain() { |
2724 | return mnuMain; |
2725 | } |
2726 | + |
2727 | /** |
2728 | - * @param mnuMain The mnuMain to set. |
2729 | + * @param mnuMain |
2730 | + * The mnuMain to set. |
2731 | */ |
2732 | public void setMnuMain(MainMenu mnuMain) { |
2733 | this.mnuMain = mnuMain; |
2734 | } |
2735 | + |
2736 | /** |
2737 | * @return Returns the msgMain. |
2738 | */ |
2739 | public ConsoleView getMsgMain() { |
2740 | return msgMain; |
2741 | } |
2742 | + |
2743 | /** |
2744 | - * @param msgMain The msgMain to set. |
2745 | + * @param msgMain |
2746 | + * The msgMain to set. |
2747 | */ |
2748 | public void setMsgMain(ConsoleView msgMain) { |
2749 | this.msgMain = msgMain; |
2750 | } |
2751 | + |
2752 | /** |
2753 | * @return Returns the stMain. |
2754 | */ |
2755 | public StatusView getStMain() { |
2756 | return stMain; |
2757 | } |
2758 | + |
2759 | /** |
2760 | - * @param stMain The stMain to set. |
2761 | + * @param stMain |
2762 | + * The stMain to set. |
2763 | */ |
2764 | public void setStMain(StatusView stMain) { |
2765 | this.stMain = stMain; |
2766 | } |
2767 | + |
2768 | /** |
2769 | * @return Returns the trMain. |
2770 | */ |
2771 | public MoneyTree getTrMain() { |
2772 | return trMain; |
2773 | } |
2774 | + |
2775 | /** |
2776 | - * @param trMain The trMain to set. |
2777 | + * @param trMain |
2778 | + * The trMain to set. |
2779 | */ |
2780 | public void setTrMain(MoneyTree trMain) { |
2781 | this.trMain = trMain; |
2782 | } |
2783 | + |
2784 | /** |
2785 | * @return Returns the vwMain. |
2786 | */ |
2787 | public ViewHandler getVwMain() { |
2788 | return vwMain; |
2789 | } |
2790 | + |
2791 | /** |
2792 | - * @param vwMain The vwMain to set. |
2793 | + * @param vwMain |
2794 | + * The vwMain to set. |
2795 | */ |
2796 | public void setVwMain(ViewHandler vwMain) { |
2797 | this.vwMain = vwMain; |
2798 | } |
2799 | + |
2800 | class onClose extends ShellAdapter { |
2801 | public void shellClosed(ShellEvent e) { |
2802 | |
2803 | - try {cbMain.QZDispose();} catch (Exception e1){} |
2804 | - try{mnuMain.QZDispose();} catch (Exception e2){} |
2805 | - try {trMain.QZDispose();} catch (Exception e3){} |
2806 | - try {InfinityPfm.imMain.QZDispose();} catch (Exception e5){} |
2807 | - try {vwMain.QZDispose();} catch (Exception e6){} |
2808 | - |
2809 | + try { |
2810 | + cbMain.QZDispose(); |
2811 | + } catch (Exception e1) { |
2812 | + System.err.println(e1.getMessage()); |
2813 | + } |
2814 | + try { |
2815 | + mnuMain.QZDispose(); |
2816 | + } catch (Exception e2) { |
2817 | + System.err.println(e2.getMessage()); |
2818 | + } |
2819 | + try { |
2820 | + trMain.QZDispose(); |
2821 | + } catch (Exception e3) { |
2822 | + System.err.println(e3.getMessage()); |
2823 | + } |
2824 | + try { |
2825 | + InfinityPfm.imMain.QZDispose(); |
2826 | + } catch (Exception e5) { |
2827 | + System.err.println(e5.getMessage()); |
2828 | + } |
2829 | + try { |
2830 | + vwMain.QZDispose(); |
2831 | + } catch (Exception e6) { |
2832 | + System.err.println(e6.getMessage()); |
2833 | + } |
2834 | |
2835 | - if (!VertSash.isDisposed()){ |
2836 | + if (!VertSash.isDisposed()) { |
2837 | VertSash.dispose(); |
2838 | } |
2839 | - |
2840 | - try {msgMain.QZDispose();} catch (Exception e4){} |
2841 | - |
2842 | + |
2843 | + try { |
2844 | + msgMain.QZDispose(); |
2845 | + } catch (Exception e4) { |
2846 | + } |
2847 | + |
2848 | super.shellClosed(e); |
2849 | - |
2850 | + |
2851 | } |
2852 | -} |
2853 | + } |
2854 | |
2855 | } |
2856 | |
2857 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/MoneyTree.java' |
2858 | --- infinitypfm/src/main/java/org/infinitypfm/ui/MoneyTree.java 2012-08-26 22:11:17 +0000 |
2859 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/MoneyTree.java 2014-11-27 22:23:48 +0000 |
2860 | @@ -1,5 +1,5 @@ |
2861 | /* |
2862 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
2863 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
2864 | * |
2865 | * This file is part of Infinity PFM. |
2866 | * |
2867 | @@ -15,14 +15,13 @@ |
2868 | * |
2869 | * You should have received a copy of the GNU General Public License |
2870 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
2871 | -*/ |
2872 | + */ |
2873 | |
2874 | package org.infinitypfm.ui; |
2875 | |
2876 | import java.sql.SQLException; |
2877 | import java.util.List; |
2878 | |
2879 | - |
2880 | import org.eclipse.swt.SWT; |
2881 | import org.eclipse.swt.events.SelectionAdapter; |
2882 | import org.eclipse.swt.events.SelectionEvent; |
2883 | @@ -36,26 +35,17 @@ |
2884 | import org.infinitypfm.core.conf.MM; |
2885 | import org.infinitypfm.core.data.Account; |
2886 | import org.infinitypfm.core.data.Budget; |
2887 | -import org.infinitypfm.graphics.ImageMap; |
2888 | import org.infinitypfm.ui.view.menus.BudgetMenu; |
2889 | import org.infinitypfm.ui.view.menus.TreeMenu; |
2890 | |
2891 | /** |
2892 | * @author Wayne Gray |
2893 | - * |
2894 | - * To change the template for this generated type comment go to |
2895 | - * Window>Preferences>Java>Code Generation>Code and Comments |
2896 | */ |
2897 | public class MoneyTree { |
2898 | |
2899 | - |
2900 | private Tree trMain; |
2901 | private TreeMenu mnuPopup = null; |
2902 | private BudgetMenu mnuBudget = null; |
2903 | - private ImageMap imIcons = null; |
2904 | - //private HashMap hmServers = new HashMap(); |
2905 | - //private String sCurrServer = null; |
2906 | - //private BackgroundLoader thBackgroundLoader = null; |
2907 | private TreeNodeInfo bookmarks = null; |
2908 | private Shell shMain = null; |
2909 | private Account actSelected = null; |
2910 | @@ -63,306 +53,289 @@ |
2911 | |
2912 | public MoneyTree(Shell sh) { |
2913 | super(); |
2914 | - |
2915 | + |
2916 | shMain = sh; |
2917 | - |
2918 | - trMain = new Tree(shMain, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE); |
2919 | + |
2920 | + trMain = new Tree(shMain, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL |
2921 | + | SWT.SINGLE); |
2922 | trMain.addSelectionListener(on_Click); |
2923 | - |
2924 | + |
2925 | bookmarks = new TreeNodeInfo(); |
2926 | - //Reload(); |
2927 | - |
2928 | - |
2929 | - imIcons = InfinityPfm.imMain; |
2930 | - |
2931 | - //init popup menus |
2932 | + |
2933 | + // init popup menus |
2934 | mnuPopup = new TreeMenu(shMain); |
2935 | mnuBudget = new BudgetMenu(shMain); |
2936 | - |
2937 | - |
2938 | + |
2939 | } |
2940 | - |
2941 | - public void Reload(){ |
2942 | + |
2943 | + public void Reload() { |
2944 | BackgroundLoader bl = new BackgroundLoader(); |
2945 | new Thread(bl).start(); |
2946 | } |
2947 | - |
2948 | - private void ReLoadTree(){ |
2949 | - |
2950 | - |
2951 | - //clear the tree |
2952 | + |
2953 | + private void ReLoadTree() { |
2954 | + |
2955 | + // clear the tree |
2956 | trMain.removeAll(); |
2957 | - |
2958 | - //set up root nodes |
2959 | - TreeItem budgetNode = new TreeItem(trMain,0); |
2960 | + |
2961 | + // set up root nodes |
2962 | + TreeItem budgetNode = new TreeItem(trMain, 0); |
2963 | budgetNode.setText(MM.PHRASES.getPhrase("97")); |
2964 | budgetNode.setData("budget"); |
2965 | budgetNode.setImage(InfinityPfm.imMain.getImage(MM.IMG_JMSITEM)); |
2966 | - bookmarks.setBudgetNode(budgetNode); |
2967 | + bookmarks.setBudgetNode(budgetNode); |
2968 | TreeItem bankNode = new TreeItem(trMain, 1); |
2969 | bankNode.setText(MM.PHRASES.getPhrase("8")); |
2970 | bankNode.setData("bank"); |
2971 | bankNode.setImage(InfinityPfm.imMain.getImage(MM.IMG_JMSITEM)); |
2972 | bookmarks.setBankAccountNode(bankNode); |
2973 | - TreeItem liabilityNode = new TreeItem(trMain,2); |
2974 | + TreeItem liabilityNode = new TreeItem(trMain, 2); |
2975 | liabilityNode.setText(MM.PHRASES.getPhrase("53")); |
2976 | liabilityNode.setData("liability"); |
2977 | liabilityNode.setImage(InfinityPfm.imMain.getImage(MM.IMG_JMSITEM)); |
2978 | - TreeItem expenseNode = new TreeItem(trMain,3); |
2979 | + TreeItem expenseNode = new TreeItem(trMain, 3); |
2980 | expenseNode.setText(MM.PHRASES.getPhrase("9")); |
2981 | expenseNode.setData("expense"); |
2982 | expenseNode.setImage(InfinityPfm.imMain.getImage(MM.IMG_JMSITEM)); |
2983 | bookmarks.setExpenseNode(expenseNode); |
2984 | - TreeItem incomeNode = new TreeItem(trMain,4); |
2985 | + TreeItem incomeNode = new TreeItem(trMain, 4); |
2986 | incomeNode.setText(MM.PHRASES.getPhrase("10")); |
2987 | incomeNode.setData("income"); |
2988 | incomeNode.setImage(InfinityPfm.imMain.getImage(MM.IMG_JMSITEM)); |
2989 | - |
2990 | - |
2991 | - //TODO: Remove duplication of code below for each account type. |
2992 | - |
2993 | + |
2994 | + // TODO: Remove duplication of code below for each account type. |
2995 | + |
2996 | try { |
2997 | |
2998 | TreeItem ti = null; |
2999 | Account act = null; |
3000 | - |
3001 | - //add bank accounts |
3002 | - List bankList = MM.sqlMap.queryForList("getAccountsForType", "Bank"); |
3003 | - |
3004 | - if (bankList!=null){ |
3005 | - |
3006 | - for (int i=0; i<bankList.size(); i++){ |
3007 | - act = (Account)bankList.get(i); |
3008 | - ti = new TreeItem(bankNode,i); |
3009 | - ti.setText(act.getActName()); |
3010 | - ti.setData(act); |
3011 | - ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3012 | - System.out.println(act.getActName() + ":" + Integer.toString(act.getActId())); |
3013 | - |
3014 | - } |
3015 | - |
3016 | - } |
3017 | - |
3018 | - //add liability accounts |
3019 | - List liabilityList = MM.sqlMap.queryForList("getAccountsForType", "Liability"); |
3020 | - |
3021 | - if (liabilityList!=null){ |
3022 | - |
3023 | - for (int i=0; i<liabilityList.size(); i++){ |
3024 | - act = (Account)liabilityList.get(i); |
3025 | - ti = new TreeItem(liabilityNode,i); |
3026 | - ti.setText(act.getActName()); |
3027 | - ti.setData(act); |
3028 | - ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3029 | - System.out.println(act.getActName() + ":" + Integer.toString(act.getActId())); |
3030 | - |
3031 | - } |
3032 | - |
3033 | - } |
3034 | - |
3035 | - //add expense accounts |
3036 | - List expenseList = MM.sqlMap.queryForList("getAccountsForType", "Expense"); |
3037 | - |
3038 | - if (expenseList!=null){ |
3039 | - |
3040 | - for (int i=0; i<expenseList.size(); i++){ |
3041 | - act = (Account)expenseList.get(i); |
3042 | - ti = new TreeItem(expenseNode,i); |
3043 | - ti.setText(act.getActName()); |
3044 | - ti.setData(act); |
3045 | - ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3046 | - } |
3047 | - |
3048 | - } |
3049 | - |
3050 | - //add income accounts |
3051 | - List incomeList = MM.sqlMap.queryForList("getAccountsForType", "Income"); |
3052 | - |
3053 | - if (incomeList!=null){ |
3054 | - |
3055 | - for (int i=0; i<incomeList.size(); i++){ |
3056 | - act = (Account)incomeList.get(i); |
3057 | - ti = new TreeItem(incomeNode,i); |
3058 | - ti.setText(act.getActName()); |
3059 | - ti.setData(act); |
3060 | - ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3061 | - } |
3062 | - |
3063 | - } |
3064 | - |
3065 | - //add budgets |
3066 | + |
3067 | + // add bank accounts |
3068 | + @SuppressWarnings("rawtypes") |
3069 | + List bankList = MM.sqlMap |
3070 | + .queryForList("getAccountsForType", "Bank"); |
3071 | + |
3072 | + if (bankList != null) { |
3073 | + |
3074 | + for (int i = 0; i < bankList.size(); i++) { |
3075 | + act = (Account) bankList.get(i); |
3076 | + ti = new TreeItem(bankNode, i); |
3077 | + ti.setText(act.getActName()); |
3078 | + ti.setData(act); |
3079 | + ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3080 | + System.out.println(act.getActName() + ":" |
3081 | + + Integer.toString(act.getActId())); |
3082 | + |
3083 | + } |
3084 | + |
3085 | + } |
3086 | + |
3087 | + // add liability accounts |
3088 | + @SuppressWarnings("rawtypes") |
3089 | + List liabilityList = MM.sqlMap.queryForList("getAccountsForType", |
3090 | + "Liability"); |
3091 | + |
3092 | + if (liabilityList != null) { |
3093 | + |
3094 | + for (int i = 0; i < liabilityList.size(); i++) { |
3095 | + act = (Account) liabilityList.get(i); |
3096 | + ti = new TreeItem(liabilityNode, i); |
3097 | + ti.setText(act.getActName()); |
3098 | + ti.setData(act); |
3099 | + ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3100 | + System.out.println(act.getActName() + ":" |
3101 | + + Integer.toString(act.getActId())); |
3102 | + |
3103 | + } |
3104 | + |
3105 | + } |
3106 | + |
3107 | + // add expense accounts |
3108 | + @SuppressWarnings("rawtypes") |
3109 | + List expenseList = MM.sqlMap.queryForList("getAccountsForType", |
3110 | + "Expense"); |
3111 | + |
3112 | + if (expenseList != null) { |
3113 | + |
3114 | + for (int i = 0; i < expenseList.size(); i++) { |
3115 | + act = (Account) expenseList.get(i); |
3116 | + ti = new TreeItem(expenseNode, i); |
3117 | + ti.setText(act.getActName()); |
3118 | + ti.setData(act); |
3119 | + ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3120 | + } |
3121 | + |
3122 | + } |
3123 | + |
3124 | + // add income accounts |
3125 | + @SuppressWarnings("rawtypes") |
3126 | + List incomeList = MM.sqlMap.queryForList("getAccountsForType", |
3127 | + "Income"); |
3128 | + |
3129 | + if (incomeList != null) { |
3130 | + |
3131 | + for (int i = 0; i < incomeList.size(); i++) { |
3132 | + act = (Account) incomeList.get(i); |
3133 | + ti = new TreeItem(incomeNode, i); |
3134 | + ti.setText(act.getActName()); |
3135 | + ti.setData(act); |
3136 | + ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_TREELEAF)); |
3137 | + } |
3138 | + |
3139 | + } |
3140 | + |
3141 | + // add budgets |
3142 | + @SuppressWarnings("rawtypes") |
3143 | List budgetList = MM.sqlMap.queryForList("getAllBudgets", null); |
3144 | - |
3145 | - if (budgetList != null){ |
3146 | + |
3147 | + if (budgetList != null) { |
3148 | Budget budget = null; |
3149 | - for (int i=0; i<budgetList.size();i++){ |
3150 | - budget = (Budget)budgetList.get(i); |
3151 | + for (int i = 0; i < budgetList.size(); i++) { |
3152 | + budget = (Budget) budgetList.get(i); |
3153 | ti = new TreeItem(budgetNode, i); |
3154 | ti.setText(budget.getBudgetName()); |
3155 | ti.setData(budget); |
3156 | ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_DOLLAR)); |
3157 | } |
3158 | } |
3159 | - |
3160 | - |
3161 | - } catch (SQLException se){ |
3162 | + |
3163 | + } catch (SQLException se) { |
3164 | InfinityPfm.LogMessage(se.getMessage()); |
3165 | } |
3166 | - |
3167 | + |
3168 | bankNode.setExpanded(true); |
3169 | liabilityNode.setExpanded(true); |
3170 | incomeNode.setExpanded(true); |
3171 | expenseNode.setExpanded(true); |
3172 | budgetNode.setExpanded(true); |
3173 | - |
3174 | + |
3175 | } |
3176 | |
3177 | - public Tree getTree(){ |
3178 | + public Tree getTree() { |
3179 | return trMain; |
3180 | } |
3181 | - |
3182 | + |
3183 | private TreeItem getItem(String sName) { |
3184 | - TreeItem ti=null; |
3185 | - TreeItem [] aTI = trMain.getItems(); |
3186 | - |
3187 | - for (int i=0; i< trMain.getItemCount(); i++) { |
3188 | + TreeItem ti = null; |
3189 | + TreeItem[] aTI = trMain.getItems(); |
3190 | + |
3191 | + for (int i = 0; i < trMain.getItemCount(); i++) { |
3192 | if (sName.equals(aTI[i].getText())) { |
3193 | - ti=aTI[i]; |
3194 | + ti = aTI[i]; |
3195 | } |
3196 | } |
3197 | return ti; |
3198 | } |
3199 | - |
3200 | - public void setItemSelected(String sName){ |
3201 | + |
3202 | + public void setItemSelected(String sName) { |
3203 | TreeItem ti = getItem(sName); |
3204 | - if (ti!=null){ |
3205 | - TreeItem[] aTI = {ti}; |
3206 | + if (ti != null) { |
3207 | + TreeItem[] aTI = { ti }; |
3208 | trMain.setSelection(aTI); |
3209 | - trMain.showItem(ti); |
3210 | + trMain.showItem(ti); |
3211 | } |
3212 | } |
3213 | - |
3214 | - public Account getSelectedAccount(){ |
3215 | + |
3216 | + public Account getSelectedAccount() { |
3217 | return actSelected; |
3218 | } |
3219 | - |
3220 | - public Budget getSelectedBudget(){ |
3221 | + |
3222 | + public Budget getSelectedBudget() { |
3223 | return budgetSelected; |
3224 | } |
3225 | - |
3226 | - public void QZDispose(){ |
3227 | - |
3228 | + |
3229 | + public void QZDispose() { |
3230 | + |
3231 | mnuPopup.QZDispose(); |
3232 | - |
3233 | -// if(thBackgroundLoader!=null){ |
3234 | -// thBackgroundLoader.notifyAll(); |
3235 | -// thBackgroundLoader = null; |
3236 | -// } |
3237 | - |
3238 | - if (!trMain.isDisposed()){ |
3239 | + |
3240 | + if (!trMain.isDisposed()) { |
3241 | trMain.dispose(); |
3242 | } |
3243 | } |
3244 | - |
3245 | - public void setConnected(String qs, boolean bConnected){ |
3246 | - //ti.setImage(InfinityPfm.imMain.getImage(MM.IMG_CONNECTED)); |
3247 | - |
3248 | + |
3249 | + public void setConnected(String qs, boolean bConnected) { |
3250 | + |
3251 | } |
3252 | - |
3253 | + |
3254 | private class BackgroundLoader implements Runnable { |
3255 | - |
3256 | - /* (non-Javadoc) |
3257 | - * @see java.lang.Runnable#run() |
3258 | - */ |
3259 | + |
3260 | public void run() { |
3261 | - |
3262 | + |
3263 | Display.getDefault().syncExec(new BusyStatus(true)); |
3264 | Display.getDefault().syncExec(new TreeLoader()); |
3265 | Display.getDefault().syncExec(new BusyStatus(false)); |
3266 | - |
3267 | - } |
3268 | + |
3269 | + } |
3270 | } |
3271 | - |
3272 | |
3273 | private class TreeLoader implements Runnable { |
3274 | - |
3275 | - |
3276 | - public TreeLoader(){ |
3277 | - |
3278 | + |
3279 | + public TreeLoader() { |
3280 | + |
3281 | } |
3282 | - |
3283 | + |
3284 | public void run() { |
3285 | - |
3286 | + |
3287 | ReLoadTree(); |
3288 | } |
3289 | - |
3290 | - protected void AddAccountSection(TreeItem parent, java.util.List actList){ |
3291 | - |
3292 | - } |
3293 | - |
3294 | } |
3295 | |
3296 | private class BusyStatus implements Runnable { |
3297 | - |
3298 | + |
3299 | boolean busy = false; |
3300 | |
3301 | - public BusyStatus (boolean bStatus){ |
3302 | + public BusyStatus(boolean bStatus) { |
3303 | busy = bStatus; |
3304 | } |
3305 | - |
3306 | - /* (non-Javadoc) |
3307 | - * @see java.lang.Runnable#run() |
3308 | - */ |
3309 | + |
3310 | public void run() { |
3311 | InfinityPfm.qzMain.getStMain().setBusy(busy); |
3312 | } |
3313 | - |
3314 | - |
3315 | + |
3316 | } |
3317 | |
3318 | /* |
3319 | - * |
3320 | + * |
3321 | * Listeners |
3322 | */ |
3323 | - |
3324 | - SelectionAdapter on_Click = new SelectionAdapter(){ |
3325 | - public void widgetSelected(SelectionEvent e){ |
3326 | - |
3327 | - TreeItem ti = (TreeItem)e.item; |
3328 | - Object obj = ti.getData(); |
3329 | - |
3330 | - trMain.setMenu(null); |
3331 | - |
3332 | - if (obj==null){ |
3333 | - return; |
3334 | - } |
3335 | - |
3336 | - MainAction action = new MainAction(); |
3337 | - |
3338 | - if (obj instanceof Account){ |
3339 | - trMain.setMenu(mnuPopup.getMenu()); |
3340 | - actSelected = (Account)obj; |
3341 | - budgetSelected = null; |
3342 | - action.LoadView(MM.VIEW_REGISTER); |
3343 | - } else if (obj instanceof Budget){ |
3344 | - trMain.setMenu(mnuBudget.getMenu()); |
3345 | - actSelected = null; |
3346 | - budgetSelected = (Budget)obj; |
3347 | - action.LoadView(MM.VIEW_BUDGET); |
3348 | - } else if (obj instanceof String) { |
3349 | - String acctType = obj.toString(); |
3350 | - if (acctType.equalsIgnoreCase("bank") || |
3351 | - acctType.equalsIgnoreCase("expense") || |
3352 | - acctType.equalsIgnoreCase("liability") || |
3353 | - acctType.equalsIgnoreCase("income")) { |
3354 | - |
3355 | + |
3356 | + SelectionAdapter on_Click = new SelectionAdapter() { |
3357 | + public void widgetSelected(SelectionEvent e) { |
3358 | + |
3359 | + TreeItem ti = (TreeItem) e.item; |
3360 | + Object obj = ti.getData(); |
3361 | + |
3362 | + trMain.setMenu(null); |
3363 | + |
3364 | + if (obj == null) { |
3365 | + return; |
3366 | + } |
3367 | + |
3368 | + MainAction action = new MainAction(); |
3369 | + |
3370 | + if (obj instanceof Account) { |
3371 | trMain.setMenu(mnuPopup.getMenu()); |
3372 | - |
3373 | + actSelected = (Account) obj; |
3374 | + budgetSelected = null; |
3375 | + action.LoadView(MM.VIEW_REGISTER); |
3376 | + } else if (obj instanceof Budget) { |
3377 | + trMain.setMenu(mnuBudget.getMenu()); |
3378 | + actSelected = null; |
3379 | + budgetSelected = (Budget) obj; |
3380 | + action.LoadView(MM.VIEW_BUDGET); |
3381 | + } else if (obj instanceof String) { |
3382 | + String acctType = obj.toString(); |
3383 | + if (acctType.equalsIgnoreCase("bank") |
3384 | + || acctType.equalsIgnoreCase("expense") |
3385 | + || acctType.equalsIgnoreCase("liability") |
3386 | + || acctType.equalsIgnoreCase("income")) { |
3387 | + |
3388 | + trMain.setMenu(mnuPopup.getMenu()); |
3389 | + |
3390 | + } |
3391 | } |
3392 | + |
3393 | } |
3394 | - |
3395 | - } |
3396 | -}; |
3397 | + }; |
3398 | |
3399 | } |
3400 | - |
3401 | |
3402 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/ViewHandler.java' |
3403 | --- infinitypfm/src/main/java/org/infinitypfm/ui/ViewHandler.java 2012-08-26 22:11:17 +0000 |
3404 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/ViewHandler.java 2014-11-27 22:23:48 +0000 |
3405 | @@ -1,5 +1,5 @@ |
3406 | /* |
3407 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
3408 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
3409 | * |
3410 | * This file is part of Infinity PFM. |
3411 | * |
3412 | @@ -15,11 +15,10 @@ |
3413 | * |
3414 | * You should have received a copy of the GNU General Public License |
3415 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
3416 | -*/ |
3417 | + */ |
3418 | |
3419 | package org.infinitypfm.ui; |
3420 | |
3421 | - |
3422 | import org.eclipse.swt.SWT; |
3423 | import org.eclipse.swt.events.PaintEvent; |
3424 | import org.eclipse.swt.events.PaintListener; |
3425 | @@ -27,231 +26,227 @@ |
3426 | import org.eclipse.swt.events.SelectionEvent; |
3427 | import org.eclipse.swt.graphics.Color; |
3428 | import org.eclipse.swt.graphics.Image; |
3429 | -import org.eclipse.swt.layout.FillLayout; |
3430 | import org.eclipse.swt.layout.FormAttachment; |
3431 | import org.eclipse.swt.layout.FormData; |
3432 | import org.eclipse.swt.layout.FormLayout; |
3433 | import org.eclipse.swt.widgets.Canvas; |
3434 | import org.eclipse.swt.widgets.Composite; |
3435 | -import org.eclipse.swt.widgets.Label; |
3436 | import org.eclipse.swt.widgets.Shell; |
3437 | import org.infinitypfm.client.InfinityPfm; |
3438 | import org.infinitypfm.core.conf.MM; |
3439 | import org.infinitypfm.ui.view.dialogs.MessageDialog; |
3440 | -import org.infinitypfm.ui.view.views.*; |
3441 | - |
3442 | +import org.infinitypfm.ui.view.views.BaseView; |
3443 | +import org.infinitypfm.ui.view.views.BudgetView; |
3444 | +import org.infinitypfm.ui.view.views.CurrencyView; |
3445 | +import org.infinitypfm.ui.view.views.RecurrenceView; |
3446 | +import org.infinitypfm.ui.view.views.RegisterView; |
3447 | +import org.infinitypfm.ui.view.views.ReportView; |
3448 | |
3449 | /** |
3450 | * @author Wayne Gray |
3451 | - * |
3452 | + * |
3453 | */ |
3454 | public class ViewHandler { |
3455 | |
3456 | private Composite cmpMain; |
3457 | private Composite cmpWin; |
3458 | private Shell sh = InfinityPfm.shMain; |
3459 | - private int lPluginCount=0; |
3460 | - //private Label lblMsg = null; |
3461 | private Canvas canvas = null; |
3462 | - private final Image banner = InfinityPfm.imMain.getTransparentImage(MM.IMG_QUEZEN_BANNER); |
3463 | - private boolean bShrink = false; |
3464 | + private final Image banner = InfinityPfm.imMain |
3465 | + .getTransparentImage(MM.IMG_QUEZEN_BANNER); |
3466 | |
3467 | - public ViewHandler(){ |
3468 | + public ViewHandler() { |
3469 | cmpWin = new Composite(sh, SWT.BORDER); |
3470 | cmpWin.setLayout(new FormLayout()); |
3471 | - |
3472 | + |
3473 | } |
3474 | |
3475 | - private Composite getDefaultView(){ |
3476 | + private Composite getDefaultView() { |
3477 | Composite cmpResult = new Composite(cmpWin, SWT.FLAT); |
3478 | cmpResult.setLayout(new FormLayout()); |
3479 | - |
3480 | - |
3481 | + |
3482 | FormData cmpresultdata = new FormData(); |
3483 | cmpresultdata.top = new FormAttachment(0, 0); |
3484 | - cmpresultdata.left = new FormAttachment(0,0); |
3485 | - cmpresultdata.right = new FormAttachment(100,0); |
3486 | - cmpresultdata.bottom = new FormAttachment(100,0); |
3487 | + cmpresultdata.left = new FormAttachment(0, 0); |
3488 | + cmpresultdata.right = new FormAttachment(100, 0); |
3489 | + cmpresultdata.bottom = new FormAttachment(100, 0); |
3490 | cmpResult.setLayoutData(cmpresultdata); |
3491 | - |
3492 | - Color color = new Color(InfinityPfm.shMain.getDisplay(), 255,255,255); |
3493 | + |
3494 | + Color color = new Color(InfinityPfm.shMain.getDisplay(), 255, 255, 255); |
3495 | cmpResult.setBackground(color); |
3496 | - |
3497 | - canvas = new Canvas(cmpResult,SWT.NONE); |
3498 | + |
3499 | + canvas = new Canvas(cmpResult, SWT.NONE); |
3500 | canvas.setBackground(color); |
3501 | canvas.addPaintListener(new PaintListener() { |
3502 | - public void paintControl(PaintEvent e) { |
3503 | - e.gc.drawImage(banner,0,0); |
3504 | - } |
3505 | - }); |
3506 | - |
3507 | + public void paintControl(PaintEvent e) { |
3508 | + e.gc.drawImage(banner, 0, 0); |
3509 | + } |
3510 | + }); |
3511 | + |
3512 | FormData canvasdata = new FormData(); |
3513 | canvasdata.top = new FormAttachment(35, 0); |
3514 | - canvasdata.left = new FormAttachment(30,0); |
3515 | - canvasdata.right = new FormAttachment(70,0); |
3516 | - canvasdata.bottom = new FormAttachment(70,0); |
3517 | + canvasdata.left = new FormAttachment(30, 0); |
3518 | + canvasdata.right = new FormAttachment(70, 0); |
3519 | + canvasdata.bottom = new FormAttachment(70, 0); |
3520 | canvas.setLayoutData(canvasdata); |
3521 | - |
3522 | + |
3523 | return cmpResult; |
3524 | } |
3525 | - |
3526 | + |
3527 | public void LoadView(BaseView oView) { |
3528 | - |
3529 | - try{ |
3530 | - if(!cmpMain.isDisposed()){ |
3531 | + |
3532 | + try { |
3533 | + if (!cmpMain.isDisposed()) { |
3534 | cmpMain.dispose(); |
3535 | } |
3536 | - } catch (Exception e){}; |
3537 | - |
3538 | + } catch (Exception e) { |
3539 | + } |
3540 | + |
3541 | cmpMain = oView; |
3542 | - |
3543 | + |
3544 | cmpMain.setVisible(true); |
3545 | cmpWin.layout(true); |
3546 | |
3547 | } |
3548 | |
3549 | - public void LoadDefaultView(){ |
3550 | - |
3551 | - try{ |
3552 | - if(!cmpMain.isDisposed()){ |
3553 | + public void LoadDefaultView() { |
3554 | + |
3555 | + try { |
3556 | + if (!cmpMain.isDisposed()) { |
3557 | cmpMain.dispose(); |
3558 | } |
3559 | - } catch (Exception e){}; |
3560 | - |
3561 | + } catch (Exception e) { |
3562 | + } |
3563 | + ; |
3564 | + |
3565 | cmpMain = this.getDefaultView(); |
3566 | cmpMain.setVisible(true); |
3567 | cmpWin.layout(true); |
3568 | } |
3569 | - |
3570 | - public void UnloadCurrentView(){ |
3571 | - if(!cmpMain.isDisposed()){ |
3572 | + |
3573 | + public void UnloadCurrentView() { |
3574 | + if (!cmpMain.isDisposed()) { |
3575 | cmpMain.dispose(); |
3576 | } |
3577 | cmpMain = getDefaultView(); |
3578 | - |
3579 | + |
3580 | } |
3581 | |
3582 | - public void RefreshCurrentView(){ |
3583 | + public void RefreshCurrentView() { |
3584 | try { |
3585 | - ((BaseView)cmpMain).Refresh(); |
3586 | - } catch (Exception e){} |
3587 | + ((BaseView) cmpMain).Refresh(); |
3588 | + } catch (Exception e) { |
3589 | + System.err.println(e.getMessage()); |
3590 | + } |
3591 | } |
3592 | |
3593 | - public Composite getCurrentView(){ |
3594 | + public Composite getCurrentView() { |
3595 | return cmpMain; |
3596 | } |
3597 | - |
3598 | + |
3599 | public Composite getParent() { |
3600 | - return cmpWin; |
3601 | + return cmpWin; |
3602 | } |
3603 | - |
3604 | + |
3605 | public void QZDispose() { |
3606 | - |
3607 | - if (!banner.isDisposed()){ |
3608 | + |
3609 | + if (!banner.isDisposed()) { |
3610 | banner.dispose(); |
3611 | } |
3612 | - |
3613 | - if (!canvas.isDisposed()){ |
3614 | + |
3615 | + if (!canvas.isDisposed()) { |
3616 | canvas.dispose(); |
3617 | } |
3618 | |
3619 | -// if (!lblMsg.isDisposed()){ |
3620 | -// lblMsg.dispose(); |
3621 | -// } |
3622 | - |
3623 | - if (!cmpMain.isDisposed()){ |
3624 | + if (!cmpMain.isDisposed()) { |
3625 | cmpMain.dispose(); |
3626 | } |
3627 | - |
3628 | - if (!cmpWin.isDisposed()){ |
3629 | + |
3630 | + if (!cmpWin.isDisposed()) { |
3631 | cmpWin.dispose(); |
3632 | } |
3633 | - |
3634 | + |
3635 | } |
3636 | - |
3637 | - |
3638 | - public BaseView getView(int iViewID){ |
3639 | - |
3640 | + |
3641 | + public BaseView getView(int iViewID) { |
3642 | + |
3643 | BaseView vw = null; |
3644 | - |
3645 | - if (iViewID == MM.VIEW_SCRATCH){ |
3646 | - //vw = new ScrachView(MM.qzMain.getVwMain().getParent(), SWT.NONE); |
3647 | - //MM.qzMain.getTrMain().setConnected(qs); |
3648 | - } else if (iViewID==MM.VIEW_REGISTER){ |
3649 | + |
3650 | + if (iViewID == MM.VIEW_REGISTER) { |
3651 | vw = new RegisterView(cmpWin, SWT.NONE); |
3652 | - } else if (iViewID==MM.VIEW_BUDGET){ |
3653 | + } else if (iViewID == MM.VIEW_BUDGET) { |
3654 | vw = new BudgetView(cmpWin, SWT.NONE); |
3655 | - } else if (iViewID==MM.VIEW_RECURRENCE){ |
3656 | + } else if (iViewID == MM.VIEW_RECURRENCE) { |
3657 | vw = new RecurrenceView(cmpWin, SWT.NONE); |
3658 | - } else if (iViewID==MM.VIEW_CURRENCY){ |
3659 | + } else if (iViewID == MM.VIEW_CURRENCY) { |
3660 | vw = new CurrencyView(cmpWin, SWT.NONE); |
3661 | } else { |
3662 | - |
3663 | + |
3664 | return null; |
3665 | } |
3666 | - |
3667 | + |
3668 | vw.setLayout(new FormLayout()); |
3669 | - |
3670 | + |
3671 | FormData cmpmaindata = new FormData(); |
3672 | - cmpmaindata.top = new FormAttachment(0,0); |
3673 | - cmpmaindata.left = new FormAttachment(0,0); |
3674 | - cmpmaindata.bottom = new FormAttachment(100,0); |
3675 | - cmpmaindata.right = new FormAttachment(100,0); |
3676 | + cmpmaindata.top = new FormAttachment(0, 0); |
3677 | + cmpmaindata.left = new FormAttachment(0, 0); |
3678 | + cmpmaindata.bottom = new FormAttachment(100, 0); |
3679 | + cmpmaindata.right = new FormAttachment(100, 0); |
3680 | vw.setLayoutData(cmpmaindata); |
3681 | - |
3682 | + |
3683 | return vw; |
3684 | |
3685 | } |
3686 | - |
3687 | - public void LoadReportView(String sReport){ |
3688 | - |
3689 | - |
3690 | - try { |
3691 | - ReportView reportView = new ReportView(cmpWin, SWT.NONE); |
3692 | - |
3693 | - reportView.setBackground(InfinityPfm.shMain.getDisplay().getSystemColor(SWT.COLOR_WHITE)); |
3694 | - |
3695 | - reportView.setLayout(new FormLayout()); |
3696 | - |
3697 | - reportView.setReportUrl(sReport); |
3698 | - |
3699 | - FormData cmpmaindata = new FormData(); |
3700 | - cmpmaindata.top = new FormAttachment(0,0); |
3701 | - cmpmaindata.left = new FormAttachment(0,0); |
3702 | - cmpmaindata.bottom = new FormAttachment(100,0); |
3703 | - cmpmaindata.right = new FormAttachment(100,0); |
3704 | - reportView.setLayoutData(cmpmaindata); |
3705 | - |
3706 | - |
3707 | - |
3708 | - try{ |
3709 | - if(!cmpMain.isDisposed()){ |
3710 | - cmpMain.dispose(); |
3711 | + |
3712 | + public void LoadReportView(String sReport) { |
3713 | + |
3714 | + try { |
3715 | + ReportView reportView = new ReportView(cmpWin, SWT.NONE); |
3716 | + |
3717 | + reportView.setBackground(InfinityPfm.shMain.getDisplay() |
3718 | + .getSystemColor(SWT.COLOR_WHITE)); |
3719 | + |
3720 | + reportView.setLayout(new FormLayout()); |
3721 | + |
3722 | + reportView.setReportUrl(sReport); |
3723 | + |
3724 | + FormData cmpmaindata = new FormData(); |
3725 | + cmpmaindata.top = new FormAttachment(0, 0); |
3726 | + cmpmaindata.left = new FormAttachment(0, 0); |
3727 | + cmpmaindata.bottom = new FormAttachment(100, 0); |
3728 | + cmpmaindata.right = new FormAttachment(100, 0); |
3729 | + reportView.setLayoutData(cmpmaindata); |
3730 | + |
3731 | + try { |
3732 | + if (!cmpMain.isDisposed()) { |
3733 | + cmpMain.dispose(); |
3734 | + } |
3735 | + } catch (Exception e) { |
3736 | } |
3737 | - } catch (Exception e){}; |
3738 | - |
3739 | - cmpMain = reportView; |
3740 | - cmpMain.setVisible(true); |
3741 | - cmpWin.layout(true); |
3742 | - } catch (Exception e) { |
3743 | - |
3744 | - MessageDialog show = new MessageDialog(MM.DIALOG_INFO, |
3745 | - MM.APPTITLE, e.getMessage()); |
3746 | - show.Open(); |
3747 | + ; |
3748 | + |
3749 | + cmpMain = reportView; |
3750 | + cmpMain.setVisible(true); |
3751 | + cmpWin.layout(true); |
3752 | + } catch (Exception e) { |
3753 | + |
3754 | + MessageDialog show = new MessageDialog(MM.DIALOG_INFO, MM.APPTITLE, |
3755 | + e.getMessage()); |
3756 | + show.Open(); |
3757 | + |
3758 | + } |
3759 | |
3760 | } |
3761 | - |
3762 | - } |
3763 | - |
3764 | + |
3765 | /* |
3766 | - * Listeners |
3767 | + * Listeners |
3768 | */ |
3769 | - |
3770 | + |
3771 | SelectionAdapter on_Click = new SelectionAdapter() { |
3772 | - public void widgetSelected(SelectionEvent e){ |
3773 | + public void widgetSelected(SelectionEvent e) { |
3774 | |
3775 | } |
3776 | - |
3777 | + |
3778 | }; |
3779 | |
3780 | } |
3781 | |
3782 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/AccountSelectorDialog.java' |
3783 | --- infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/AccountSelectorDialog.java 2012-08-26 22:11:17 +0000 |
3784 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/AccountSelectorDialog.java 2014-11-27 22:23:48 +0000 |
3785 | @@ -1,5 +1,5 @@ |
3786 | /* |
3787 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
3788 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
3789 | * |
3790 | * This file is part of Infinity PFM. |
3791 | * |
3792 | @@ -15,12 +15,11 @@ |
3793 | * |
3794 | * You should have received a copy of the GNU General Public License |
3795 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
3796 | -*/ |
3797 | + */ |
3798 | package org.infinitypfm.ui.view.dialogs; |
3799 | |
3800 | import java.sql.SQLException; |
3801 | |
3802 | - |
3803 | import org.eclipse.swt.SWT; |
3804 | import org.eclipse.swt.events.SelectionAdapter; |
3805 | import org.eclipse.swt.events.SelectionEvent; |
3806 | @@ -45,15 +44,15 @@ |
3807 | private Button cmdSelect = null; |
3808 | private Button cmdCancel = null; |
3809 | private String accountName = null; |
3810 | - |
3811 | + |
3812 | + public boolean includeIncomeAccounts = false; |
3813 | |
3814 | public AccountSelectorDialog() { |
3815 | super(); |
3816 | - // TODO Auto-generated constructor stub |
3817 | } |
3818 | |
3819 | protected void LoadUI(Shell sh) { |
3820 | - |
3821 | + |
3822 | lblAccount = new Label(sh, SWT.NONE); |
3823 | lblAccount.setText(MM.PHRASES.getPhrase("93")); |
3824 | cmdSelect = new Button(sh, SWT.PUSH); |
3825 | @@ -62,70 +61,79 @@ |
3826 | cmdCancel = new Button(sh, SWT.PUSH); |
3827 | cmdCancel.setText(MM.PHRASES.getPhrase("4")); |
3828 | cmdCancel.addSelectionListener(cmdCancel_OnClick); |
3829 | - |
3830 | + |
3831 | cmbAccount = new Combo(sh, SWT.DROP_DOWN | SWT.READ_ONLY); |
3832 | - |
3833 | - //TODO: Create a UI utility class to handle common tasks such as below |
3834 | - // load of accounts into a combo |
3835 | - |
3836 | + |
3837 | + // TODO: Create a UI utility class to handle common tasks such as below |
3838 | + // load of accounts into a combo |
3839 | + |
3840 | try { |
3841 | Account act = null; |
3842 | - java.util.List list = MM.sqlMap.queryForList("getAccountsForType", MM.ACT_TYPE_EXPENSE); |
3843 | - |
3844 | + @SuppressWarnings("rawtypes") |
3845 | + java.util.List list = MM.sqlMap.queryForList("getAccountsForType", |
3846 | + MM.ACT_TYPE_EXPENSE); |
3847 | + |
3848 | cmbAccount.removeAll(); |
3849 | - |
3850 | - for (int i=0; i<list.size(); i++) { |
3851 | - act = (Account)list.get(i); |
3852 | - cmbAccount.add(act.getActName()); |
3853 | + |
3854 | + for (int i = 0; i < list.size(); i++) { |
3855 | + act = (Account) list.get(i); |
3856 | + cmbAccount.add(act.getActName()); |
3857 | + |
3858 | + } |
3859 | + list = MM.sqlMap.queryForList("getAccountsForType", |
3860 | + MM.ACT_TYPE_LIABILITY); |
3861 | + |
3862 | + for (int i = 0; i < list.size(); i++) { |
3863 | + act = (Account) list.get(i); |
3864 | + cmbAccount.add(act.getActName()); |
3865 | + |
3866 | + } |
3867 | + |
3868 | + if (includeIncomeAccounts){ |
3869 | |
3870 | - } |
3871 | - list = MM.sqlMap.queryForList("getAccountsForType", MM.ACT_TYPE_LIABILITY); |
3872 | - |
3873 | - for (int i=0; i<list.size(); i++) { |
3874 | - act = (Account)list.get(i); |
3875 | - cmbAccount.add(act.getActName()); |
3876 | + list = MM.sqlMap.queryForList("getAccountsForType", |
3877 | + MM.ACT_TYPE_INCOME); |
3878 | + |
3879 | + for (int i = 0; i < list.size(); i++) { |
3880 | + act = (Account) list.get(i); |
3881 | + cmbAccount.add(act.getActName()); |
3882 | + |
3883 | + } |
3884 | |
3885 | } |
3886 | |
3887 | cmbAccount.select(0); |
3888 | - |
3889 | - } catch (SQLException se){ |
3890 | + |
3891 | + } catch (SQLException se) { |
3892 | InfinityPfm.LogMessage(se.getMessage()); |
3893 | } |
3894 | - |
3895 | |
3896 | } |
3897 | - |
3898 | + |
3899 | protected void LoadLayout() { |
3900 | FormData lblaccountdata = new FormData(); |
3901 | lblaccountdata.top = new FormAttachment(0, 40); |
3902 | lblaccountdata.left = new FormAttachment(20, 0); |
3903 | lblAccount.setLayoutData(lblaccountdata); |
3904 | - |
3905 | + |
3906 | FormData cmbaccountdata = new FormData(); |
3907 | cmbaccountdata.top = new FormAttachment(0, 40); |
3908 | cmbaccountdata.left = new FormAttachment(lblAccount, 10); |
3909 | cmbaccountdata.right = new FormAttachment(100, -30); |
3910 | cmbAccount.setLayoutData(cmbaccountdata); |
3911 | - |
3912 | + |
3913 | FormData cmdcanceldata = new FormData(); |
3914 | cmdcanceldata.top = new FormAttachment(lblAccount, 40); |
3915 | - //cmdcanceldata.left = new FormAttachment(cmdOne, 10); |
3916 | - cmdcanceldata.right = new FormAttachment(40,10); |
3917 | + cmdcanceldata.right = new FormAttachment(40, 10); |
3918 | cmdCancel.setLayoutData(cmdcanceldata); |
3919 | |
3920 | FormData cmdadddata = new FormData(); |
3921 | cmdadddata.top = new FormAttachment(lblAccount, 40); |
3922 | cmdadddata.left = new FormAttachment(cmdCancel, 10); |
3923 | - cmdadddata.right = new FormAttachment(60,10); |
3924 | + cmdadddata.right = new FormAttachment(60, 10); |
3925 | cmdSelect.setLayoutData(cmdadddata); |
3926 | } |
3927 | |
3928 | - /* |
3929 | - * (non-Javadoc) |
3930 | - * |
3931 | - * @see net.mogray.quezen.ui.view.QZDialog#Open() |
3932 | - */ |
3933 | public int Open() { |
3934 | super.Open(); |
3935 | shell.setText(MM.PHRASES.getPhrase("139")); |
3936 | @@ -141,9 +149,7 @@ |
3937 | |
3938 | return 1; |
3939 | } |
3940 | - |
3941 | - |
3942 | - |
3943 | + |
3944 | public String getAccountName() { |
3945 | return accountName; |
3946 | } |
3947 | @@ -151,24 +157,26 @@ |
3948 | public void setAccountName(String accountName) { |
3949 | this.accountName = accountName; |
3950 | } |
3951 | - |
3952 | - |
3953 | + |
3954 | + public void setIncludeIncomeAccounts(boolean include){ |
3955 | + includeIncomeAccounts = include; |
3956 | + } |
3957 | |
3958 | /* |
3959 | * Listeners |
3960 | */ |
3961 | SelectionAdapter cmdSelect_OnClick = new SelectionAdapter() { |
3962 | - public void widgetSelected(SelectionEvent e){ |
3963 | + public void widgetSelected(SelectionEvent e) { |
3964 | accountName = cmbAccount.getText(); |
3965 | shell.dispose(); |
3966 | } |
3967 | }; |
3968 | |
3969 | SelectionAdapter cmdCancel_OnClick = new SelectionAdapter() { |
3970 | - public void widgetSelected(SelectionEvent e){ |
3971 | + public void widgetSelected(SelectionEvent e) { |
3972 | userCancelled = true; |
3973 | shell.dispose(); |
3974 | } |
3975 | }; |
3976 | - |
3977 | + |
3978 | } |
3979 | |
3980 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/BudgetSelector.java' |
3981 | --- infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/BudgetSelector.java 2012-08-26 22:11:17 +0000 |
3982 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/BudgetSelector.java 2014-11-27 22:23:48 +0000 |
3983 | @@ -1,5 +1,5 @@ |
3984 | /* |
3985 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
3986 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
3987 | * |
3988 | * This file is part of Infinity PFM. |
3989 | * |
3990 | @@ -64,6 +64,7 @@ |
3991 | |
3992 | try { |
3993 | Budget budget = null; |
3994 | + @SuppressWarnings("rawtypes") |
3995 | java.util.List list = MM.sqlMap.queryForList("getAllBudgets", null); |
3996 | |
3997 | cmbBudget.removeAll(); |
3998 | |
3999 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/DefaultAccountSelectorDialog.java' |
4000 | --- infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/DefaultAccountSelectorDialog.java 2012-08-26 22:11:17 +0000 |
4001 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/DefaultAccountSelectorDialog.java 2014-11-27 22:23:48 +0000 |
4002 | @@ -1,5 +1,5 @@ |
4003 | /* |
4004 | - * Copyright (c) 2005-2011 Wayne Gray All rights reserved |
4005 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
4006 | * |
4007 | * This file is part of Infinity PFM. |
4008 | * |
4009 | @@ -15,13 +15,12 @@ |
4010 | * |
4011 | * You should have received a copy of the GNU General Public License |
4012 | * along with Infinity PFM. If not, see <http://www.gnu.org/licenses/>. |
4013 | -*/ |
4014 | + */ |
4015 | |
4016 | package org.infinitypfm.ui.view.dialogs; |
4017 | |
4018 | import java.sql.SQLException; |
4019 | |
4020 | - |
4021 | import org.eclipse.swt.SWT; |
4022 | import org.eclipse.swt.events.SelectionAdapter; |
4023 | import org.eclipse.swt.events.SelectionEvent; |
4024 | @@ -33,45 +32,42 @@ |
4025 | import org.eclipse.swt.widgets.Tree; |
4026 | import org.eclipse.swt.widgets.TreeItem; |
4027 | import org.infinitypfm.client.InfinityPfm; |
4028 | -import org.infinitypfm.core.action.MainAction; |
4029 | import org.infinitypfm.core.conf.MM; |
4030 | import org.infinitypfm.core.data.Account; |
4031 | -import org.infinitypfm.core.data.Budget; |
4032 | -import org.infinitypfm.core.data.DataHandler; |
4033 | -import org.infinitypfm.core.data.Transaction; |
4034 | |
4035 | public class DefaultAccountSelectorDialog extends BaseDialog { |
4036 | |
4037 | + @SuppressWarnings("rawtypes") |
4038 | private java.util.List allActList = null; |
4039 | private Tree tree = null; |
4040 | private Button cmdSave = null; |
4041 | private Button cmdCancel = null; |
4042 | |
4043 | - public DefaultAccountSelectorDialog(){ |
4044 | + public DefaultAccountSelectorDialog() { |
4045 | super(); |
4046 | - |
4047 | + |
4048 | try { |
4049 | allActList = MM.sqlMap.queryForList("getAccountTemplates", null); |
4050 | - } catch (SQLException se){ |
4051 | + } catch (SQLException se) { |
4052 | InfinityPfm.LogMessage(se.getMessage()); |
4053 | } |
4054 | - |
4055 | + |
4056 | } |
4057 | - |
4058 | + |
4059 | @Override |
4060 | protected void LoadUI(Shell sh) { |
4061 | - |
4062 | + |
4063 | tree = new Tree(shell, SWT.BORDER | SWT.CHECK); |
4064 | - if (allActList != null){ |
4065 | - |
4066 | + if (allActList != null) { |
4067 | + |
4068 | String oldAcctCategory = null; |
4069 | Account account = null; |
4070 | TreeItem categoryItem = null; |
4071 | - for (int i=0; i<allActList.size(); i++){ |
4072 | - account = (Account)allActList.get(i); |
4073 | - if (!account.getActTypeName().equalsIgnoreCase(oldAcctCategory)){ |
4074 | - |
4075 | - if (categoryItem != null){ |
4076 | + for (int i = 0; i < allActList.size(); i++) { |
4077 | + account = (Account) allActList.get(i); |
4078 | + if (!account.getActTypeName().equalsIgnoreCase(oldAcctCategory)) { |
4079 | + |
4080 | + if (categoryItem != null) { |
4081 | categoryItem.setExpanded(true); |
4082 | } |
4083 | categoryItem = new TreeItem(tree, SWT.NONE); |
4084 | @@ -79,55 +75,53 @@ |
4085 | categoryItem.setData(new Integer(account.getActTypeId())); |
4086 | oldAcctCategory = account.getActTypeName(); |
4087 | } |
4088 | - |
4089 | + |
4090 | TreeItem accountItem = new TreeItem(categoryItem, SWT.NONE); |
4091 | accountItem.setText(account.getActName()); |
4092 | - |
4093 | - |
4094 | + |
4095 | } |
4096 | - //expand the last category |
4097 | - if (categoryItem != null){ |
4098 | + // expand the last category |
4099 | + if (categoryItem != null) { |
4100 | categoryItem.setExpanded(true); |
4101 | } |
4102 | } |
4103 | - |
4104 | + |
4105 | cmdSave = new Button(sh, SWT.PUSH); |
4106 | cmdSave.setText(MM.PHRASES.getPhrase("14")); |
4107 | cmdSave.addSelectionListener(cmdSave_OnClick); |
4108 | cmdCancel = new Button(sh, SWT.PUSH); |
4109 | cmdCancel.setText(MM.PHRASES.getPhrase("4")); |
4110 | cmdCancel.addSelectionListener(cmdCancel_OnClick); |
4111 | - |
4112 | + |
4113 | tree.addSelectionListener(on_Click); |
4114 | } |
4115 | - |
4116 | + |
4117 | @Override |
4118 | protected void LoadLayout() { |
4119 | - |
4120 | + |
4121 | FormData treetdata = new FormData(); |
4122 | treetdata.top = new FormAttachment(0, 10); |
4123 | treetdata.left = new FormAttachment(0, 10); |
4124 | treetdata.right = new FormAttachment(100, -10); |
4125 | treetdata.bottom = new FormAttachment(100, -40); |
4126 | tree.setLayoutData(treetdata); |
4127 | - |
4128 | + |
4129 | FormData cmdcanceldata = new FormData(); |
4130 | cmdcanceldata.top = new FormAttachment(tree, 5); |
4131 | cmdcanceldata.right = new FormAttachment(cmdSave, -10); |
4132 | cmdCancel.setLayoutData(cmdcanceldata); |
4133 | - |
4134 | + |
4135 | FormData cmdsavedata = new FormData(); |
4136 | cmdsavedata.top = new FormAttachment(tree, 5); |
4137 | cmdsavedata.right = new FormAttachment(100, -10); |
4138 | cmdSave.setLayoutData(cmdsavedata); |
4139 | cmdSave.setEnabled(false); |
4140 | - |
4141 | + |
4142 | } |
4143 | |
4144 | public int Open() { |
4145 | super.Open(); |
4146 | - shell.setText(MM.PHRASES.getPhrase("133") + " " + |
4147 | - MM.APPTITLE); |
4148 | + shell.setText(MM.PHRASES.getPhrase("133") + " " + MM.APPTITLE); |
4149 | |
4150 | shell.setSize(300, 400); |
4151 | this.CenterWindow(); |
4152 | @@ -142,93 +136,94 @@ |
4153 | return 1; |
4154 | } |
4155 | |
4156 | - SelectionAdapter on_Click = new SelectionAdapter(){ |
4157 | - public void widgetSelected(SelectionEvent e){ |
4158 | - |
4159 | - TreeItem ti = (TreeItem)e.item; |
4160 | + SelectionAdapter on_Click = new SelectionAdapter() { |
4161 | + public void widgetSelected(SelectionEvent e) { |
4162 | + |
4163 | + TreeItem ti = (TreeItem) e.item; |
4164 | TreeItem parent = ti.getParentItem(); |
4165 | - |
4166 | - if (parent == null){ |
4167 | + |
4168 | + if (parent == null) { |
4169 | TreeItem[] items = ti.getItems(); |
4170 | - for (int i=0; i<items.length; i++){ |
4171 | + for (int i = 0; i < items.length; i++) { |
4172 | TreeItem item = items[i]; |
4173 | item.setChecked(ti.getChecked()); |
4174 | } |
4175 | - } |
4176 | - |
4177 | - if (ti.getChecked()){ |
4178 | - |
4179 | + } |
4180 | + |
4181 | + if (ti.getChecked()) { |
4182 | + |
4183 | cmdSave.setEnabled(true); |
4184 | - |
4185 | + |
4186 | } |
4187 | - |
4188 | - } |
4189 | + |
4190 | + } |
4191 | }; |
4192 | - |
4193 | + |
4194 | /* |
4195 | * Events |
4196 | */ |
4197 | - |
4198 | - SelectionAdapter cmdCancel_OnClick = new SelectionAdapter(){ |
4199 | - |
4200 | + |
4201 | + SelectionAdapter cmdCancel_OnClick = new SelectionAdapter() { |
4202 | + |
4203 | public void widgetSelected(SelectionEvent event) { |
4204 | shell.dispose(); |
4205 | } |
4206 | }; |
4207 | - |
4208 | - SelectionAdapter cmdSave_OnClick = new SelectionAdapter(){ |
4209 | - |
4210 | + |
4211 | + SelectionAdapter cmdSave_OnClick = new SelectionAdapter() { |
4212 | + |
4213 | public void widgetSelected(SelectionEvent event) { |
4214 | - //DataHandler data = new DataHandler(); |
4215 | InfinityPfm.qzMain.getStMain().setBusy(true); |
4216 | - InfinityPfm.qzMain.getStMain().setStatus(MM.PHRASES.getPhrase("89")); |
4217 | - |
4218 | - |
4219 | - //confirm save |
4220 | - MessageDialog msg = new MessageDialog(MM.DIALOG_QUESTION, MM.APPTITLE, |
4221 | - MM.PHRASES.getPhrase("134")); |
4222 | - |
4223 | + InfinityPfm.qzMain.getStMain() |
4224 | + .setStatus(MM.PHRASES.getPhrase("89")); |
4225 | + |
4226 | + // confirm save |
4227 | + MessageDialog msg = new MessageDialog(MM.DIALOG_QUESTION, |
4228 | + MM.APPTITLE, MM.PHRASES.getPhrase("134")); |
4229 | + |
4230 | int answer = msg.Open(); |
4231 | - |
4232 | + |
4233 | if (answer == MM.YES) { |
4234 | - |
4235 | + |
4236 | TreeItem[] categories = tree.getItems(); |
4237 | Account account = null; |
4238 | - for (int i=0; i<categories.length; i++){ |
4239 | - |
4240 | + for (int i = 0; i < categories.length; i++) { |
4241 | + |
4242 | TreeItem category = categories[i]; |
4243 | TreeItem[] items = category.getItems(); |
4244 | - |
4245 | - for (int j=0; j<items.length; j++){ |
4246 | - |
4247 | + |
4248 | + for (int j = 0; j < items.length; j++) { |
4249 | + |
4250 | TreeItem ti = items[j]; |
4251 | - if(ti.getChecked()){ |
4252 | + if (ti.getChecked()) { |
4253 | account = new Account(); |
4254 | account.setActName(ti.getText()); |
4255 | account.setActTypeName(ti.getParentItem().getText()); |
4256 | account.setActBalance(0); |
4257 | - Integer catId = (Integer)ti.getParentItem().getData(); |
4258 | + Integer catId = (Integer) ti.getParentItem() |
4259 | + .getData(); |
4260 | account.setActTypeId(catId.intValue()); |
4261 | try { |
4262 | MM.sqlMap.insert("insertAccount", account); |
4263 | - } catch (SQLException se){ |
4264 | + } catch (SQLException se) { |
4265 | InfinityPfm.LogMessage(se.getMessage()); |
4266 | } |
4267 | - |
4268 | + |
4269 | } |
4270 | - |
4271 | + |
4272 | } |
4273 | } |
4274 | } |
4275 | |
4276 | - InfinityPfm.qzMain.getStMain().setStatus(MM.PHRASES.getPhrase("87")); |
4277 | + InfinityPfm.qzMain.getStMain() |
4278 | + .setStatus(MM.PHRASES.getPhrase("87")); |
4279 | InfinityPfm.qzMain.getStMain().setBusy(false); |
4280 | InfinityPfm.qzMain.getTrMain().Reload(); |
4281 | - |
4282 | - if (answer != MM.CANCEL){ |
4283 | + |
4284 | + if (answer != MM.CANCEL) { |
4285 | shell.dispose(); |
4286 | } |
4287 | - |
4288 | + |
4289 | } |
4290 | }; |
4291 | } |
4292 | |
4293 | === modified file 'infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportDialog.java' |
4294 | --- infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportDialog.java 2012-12-03 03:03:10 +0000 |
4295 | +++ infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportDialog.java 2014-11-27 22:23:48 +0000 |
4296 | @@ -1,5 +1,5 @@ |
4297 | /* |
4298 | - * Copyright (c) 2005-2012 Wayne Gray All rights reserved |
4299 | + * Copyright (c) 2005-2013 Wayne Gray All rights reserved |
4300 | * |
4301 | * This file is part of Infinity PFM. |
4302 | * |
4303 | @@ -20,6 +20,7 @@ |
4304 | package org.infinitypfm.ui.view.dialogs; |
4305 | |
4306 | import java.sql.SQLException; |
4307 | +import java.util.List; |
4308 | |
4309 | import org.eclipse.swt.SWT; |
4310 | import org.eclipse.swt.custom.CCombo; |
4311 | @@ -49,13 +50,15 @@ |
4312 | import org.infinitypfm.core.conf.MM; |
4313 | import org.infinitypfm.core.data.Account; |
4314 | import org.infinitypfm.core.data.AccountHash; |
4315 | -import org.infinitypfm.core.data.Currency; |
4316 | import org.infinitypfm.core.data.DataHandler; |
4317 | +import org.infinitypfm.core.data.ImportRule; |
4318 | import org.infinitypfm.core.data.Transaction; |
4319 | import org.infinitypfm.core.exception.TransactionException; |
4320 | +import org.infinitypfm.core.types.AccountTypes; |
4321 | +import org.infinitypfm.core.types.ImportRuleNames; |
4322 | |
4323 | /** |
4324 | - * Main import dialog. Handles all file types. |
4325 | + * Main import dialog. Handles all file types. |
4326 | * |
4327 | * @author Wayne Gray |
4328 | * |
4329 | @@ -63,8 +66,7 @@ |
4330 | public class ImportDialog extends BaseDialog { |
4331 | |
4332 | private Combo cmbAct = null; |
4333 | - |
4334 | - |
4335 | + |
4336 | private Button cmdSave = null; |
4337 | private Button cmdCancel = null; |
4338 | private Table tblTrans = null; |
4339 | @@ -77,21 +79,22 @@ |
4340 | private java.util.List<Account> allActList = null; |
4341 | private AccountHash actHash = null; |
4342 | private DataHandler data = new DataHandler(); |
4343 | - |
4344 | + |
4345 | private String importCurrency = null; |
4346 | + private final int importAccount; |
4347 | |
4348 | private static final int EDITABLECOLUMN = 2; |
4349 | private static final String RATE_EDITOR = "rateEditor"; |
4350 | private static final String TRAN = "tran"; |
4351 | - private static final String SPLIT = "**" + MM.PHRASES.getPhrase("235") + "**"; |
4352 | + private static final String SPLIT = "**" + MM.PHRASES.getPhrase("235") |
4353 | + + "**"; |
4354 | |
4355 | - /** |
4356 | - * |
4357 | - */ |
4358 | @SuppressWarnings("unchecked") |
4359 | public ImportDialog() { |
4360 | super(); |
4361 | |
4362 | + importAccount = -1; |
4363 | + |
4364 | try { |
4365 | allActList = MM.sqlMap.queryForList("getAllAccountsByType", null); |
4366 | } catch (SQLException se) { |
4367 | @@ -99,13 +102,12 @@ |
4368 | } |
4369 | } |
4370 | |
4371 | - /** |
4372 | - * |
4373 | - */ |
4374 | @SuppressWarnings("unchecked") |
4375 | - public ImportDialog(java.util.List<Transaction> tList) { |
4376 | + public ImportDialog(java.util.List<Transaction> tList, int importAcct) { |
4377 | super(); |
4378 | + |
4379 | tranList = tList; |
4380 | + importAccount = importAcct; |
4381 | |
4382 | try { |
4383 | allActList = MM.sqlMap.queryForList("getAllAccountsByType", null); |
4384 | @@ -116,13 +118,6 @@ |
4385 | |
4386 | } |
4387 | |
4388 | - /* |
4389 | - * (non-Javadoc) |
4390 | - * |
4391 | - * @see |
4392 | - * net.mogray.infinitypfm.ui.view.dialogs.BaseDialog#LoadUI(org.eclipse. |
4393 | - * swt.widgets.Shell) |
4394 | - */ |
4395 | protected void LoadUI(Shell sh) { |
4396 | |
4397 | cmbAct = new Combo(sh, SWT.BORDER); |
4398 | @@ -141,11 +136,10 @@ |
4399 | lblAlert = new Label(sh, SWT.BORDER); |
4400 | lblAlert.setText(MM.PHRASES.getPhrase("135")); |
4401 | |
4402 | - |
4403 | LoadAccountCombo(); |
4404 | LoadColumns(); |
4405 | LoadAccounts(); |
4406 | - |
4407 | + |
4408 | editor = new TableEditor(tblTrans); |
4409 | editor.horizontalAlignment = SWT.LEFT; |
4410 | editor.grabHorizontal = true; |
4411 | @@ -156,11 +150,6 @@ |
4412 | |
4413 | } |
4414 | |
4415 | - /* |
4416 | - * (non-Javadoc) |
4417 | - * |
4418 | - * @see net.mogray.infinitypfm.ui.view.dialogs.BaseDialog#LoadLayout() |
4419 | - */ |
4420 | protected void LoadLayout() { |
4421 | |
4422 | FormData lblactdata = new FormData(); |
4423 | @@ -197,10 +186,6 @@ |
4424 | cmdSave.setLayoutData(cmdsavedata); |
4425 | } |
4426 | |
4427 | - /* |
4428 | - * (non-Javadoc) |
4429 | - * |
4430 | - */ |
4431 | public int Open() { |
4432 | super.Open(); |
4433 | shell.setText(MM.PHRASES.getPhrase("18") + " " + MM.APPTITLE); |
4434 | @@ -229,41 +214,122 @@ |
4435 | |
4436 | final Display display = InfinityPfm.shMain.getDisplay(); |
4437 | |
4438 | + @SuppressWarnings("rawtypes") |
4439 | + List importRules = null; |
4440 | + ImportRule rule = null; |
4441 | + Account offset = null; |
4442 | + |
4443 | + // Load all defined import rules |
4444 | + try { |
4445 | + importRules = MM.sqlMap.queryForList("getImportRules"); |
4446 | + } catch (SQLException e1) { |
4447 | + InfinityPfm.LogMessage("Error loading import rules: " |
4448 | + + e1.getMessage()); |
4449 | + } |
4450 | + |
4451 | if (tranList != null) { |
4452 | |
4453 | for (int i = 0; i < tranList.size(); i++) { |
4454 | tran = tranList.get(i); |
4455 | ti = new TableItem(tblTrans, SWT.NONE); |
4456 | ti.setText(0, tran.getTranDateFmt()); |
4457 | - |
4458 | - if (tran.getTranMemo() != null){ |
4459 | + |
4460 | + if (tran.getTranMemo() != null) { |
4461 | ti.setText(1, tran.getTranMemo()); |
4462 | } |
4463 | |
4464 | try { |
4465 | - accountList = MM.sqlMap.queryForList("getAccountsForMemo", |
4466 | - tran); |
4467 | - |
4468 | - if (accountList != null) { |
4469 | - if (accountList.size() > 0) { |
4470 | - account = accountList.get(0); |
4471 | - tran.setActOffset(account.getActId()); |
4472 | - ti.setText(2, account.getActName()); |
4473 | - ti.setText(4, account.getIsoCode()); |
4474 | - |
4475 | - } |
4476 | - } |
4477 | + |
4478 | + // Apply any import rules if defined |
4479 | + if (importRules != null && importRules.size() > 0) { |
4480 | + |
4481 | + offset = null; |
4482 | + |
4483 | + for (int j = 0; j < importRules.size(); j++) { |
4484 | + |
4485 | + // See if any of the rules match the transaction |
4486 | + // Break out and use the mapped account on first one |
4487 | + // found |
4488 | + rule = (ImportRule) importRules.get(j); |
4489 | + if (rule != null) { |
4490 | + |
4491 | + if (rule.getRuleName().equals( |
4492 | + ImportRuleNames.CONTAINS)) { |
4493 | + |
4494 | + if (tran.getTranMemo().contains( |
4495 | + rule.getKeyword())) { |
4496 | + offset = new Account(); |
4497 | + offset.setActId(rule.getActId()); |
4498 | + break; |
4499 | + } |
4500 | + |
4501 | + } else if (rule.getRuleName().equals( |
4502 | + ImportRuleNames.STARTSWITH)) { |
4503 | + |
4504 | + if (tran.getTranMemo().startsWith( |
4505 | + rule.getKeyword())) { |
4506 | + offset = new Account(); |
4507 | + offset.setActId(rule.getActId()); |
4508 | + break; |
4509 | + } |
4510 | + |
4511 | + } else if (rule.getRuleName().equals( |
4512 | + ImportRuleNames.ENDSWITH)) { |
4513 | + |
4514 | + if (tran.getTranMemo().endsWith( |
4515 | + rule.getKeyword())) { |
4516 | + offset = new Account(); |
4517 | + offset.setActId(rule.getActId()); |
4518 | + break; |
4519 | + } |
4520 | + } |
4521 | + } |
4522 | + } |
4523 | + } |
4524 | + |
4525 | + if (offset != null) { |
4526 | + |
4527 | + // Found a rule match. Add mapped offset to the |
4528 | + // transactions |
4529 | + offset = (Account) MM.sqlMap.queryForObject( |
4530 | + "getAccountByActId", offset); |
4531 | + if (offset != null) { |
4532 | + tran.setActOffset(offset.getActId()); |
4533 | + ti.setText(2, offset.getActName()); |
4534 | + ti.setText(4, offset.getIsoCode()); |
4535 | + } else { |
4536 | + // This should never happen |
4537 | + InfinityPfm.LogMessage(MM.PHRASES.getPhrase("246")); |
4538 | + } |
4539 | + |
4540 | + } else { |
4541 | + |
4542 | + // Try to use last saved offset for this transactions |
4543 | + accountList = MM.sqlMap.queryForList( |
4544 | + "getAccountsForMemo", tran); |
4545 | + |
4546 | + if (accountList != null) { |
4547 | + if (accountList.size() > 0) { |
4548 | + account = accountList.get(0); |
4549 | + tran.setActOffset(account.getActId()); |
4550 | + ti.setText(2, account.getActName()); |
4551 | + ti.setText(4, account.getIsoCode()); |
4552 | + |
4553 | + } |
4554 | + } |
4555 | + } |
4556 | + |
4557 | } catch (SQLException e) { |
4558 | InfinityPfm.LogMessage(e.getMessage()); |
4559 | } |
4560 | - |
4561 | + |
4562 | ti.setData(TRAN, tran); |
4563 | ti.setText(3, |
4564 | formatter.getAmountFormatted(tran.getTranAmount())); |
4565 | - |
4566 | + |
4567 | rateEditor = new TableEditor(tblTrans); |
4568 | Text txtRate = new Text(tblTrans, SWT.CENTER); |
4569 | - txtRate.addFocusListener(ratebox_lostFocus ); |
4570 | + txtRate.addFocusListener(ratebox_lostFocus); |
4571 | txtRate.setData(Integer.toString(i)); |
4572 | txtRate.pack(); |
4573 | rateEditor.grabHorizontal = true; |
4574 | @@ -271,13 +337,14 @@ |
4575 | rateEditor.horizontalAlignment = SWT.CENTER; |
4576 | rateEditor.setEditor(txtRate, ti, 5); |
4577 | ti.setData(RATE_EDITOR, rateEditor); |
4578 | - |
4579 | + |
4580 | setRate(account, actHash.get(cmbAct.getText()), txtRate, tran); |
4581 | |
4582 | if (i % 2D == 0) { |
4583 | - |
4584 | - Color altRowColor = display.getSystemColor(MM.ROW_BACKGROUND); |
4585 | - |
4586 | + |
4587 | + Color altRowColor = display |
4588 | + .getSystemColor(MM.ROW_BACKGROUND); |
4589 | + |
4590 | ti.setBackground(0, altRowColor); |
4591 | ti.setBackground(1, altRowColor); |
4592 | ti.setBackground(2, altRowColor); |
4593 | @@ -323,7 +390,7 @@ |
4594 | try { |
4595 | Account act = null; |
4596 | java.util.List<Account> list = MM.sqlMap.queryForList( |
4597 | - "getAccountsForType", "Bank"); |
4598 | + "getAccountsForType", AccountTypes.BANK); |
4599 | |
4600 | if (list.size() == 0) { |
4601 | lblAlert.setText(MM.PHRASES.getPhrase("64")); |
4602 | @@ -332,18 +399,22 @@ |
4603 | |
4604 | cmbAct.removeAll(); |
4605 | |
4606 | + int showIndex = 0; |
4607 | + |
4608 | for (int i = 0; i < list.size(); i++) { |
4609 | act = list.get(i); |
4610 | cmbAct.add(act.getActName()); |
4611 | - |
4612 | - if (i==0){ |
4613 | + |
4614 | + if (act.getActId() == importAccount) { |
4615 | + showIndex = i; |
4616 | importCurrency = act.getIsoCode(); |
4617 | - lblAct.setText(MM.PHRASES.getPhrase("15") + " (" + importCurrency + ")"); |
4618 | + lblAct.setText(MM.PHRASES.getPhrase("15") + " (" |
4619 | + + importCurrency + ")"); |
4620 | } |
4621 | |
4622 | } |
4623 | |
4624 | - cmbAct.select(0); |
4625 | + cmbAct.select(showIndex); |
4626 | |
4627 | } catch (SQLException se) { |
4628 | InfinityPfm.LogMessage(se.getMessage()); |
4629 | @@ -358,20 +429,20 @@ |
4630 | Button cmdSplit = new Button(cellEditor, SWT.PUSH); |
4631 | cmdSplit.setText("..."); |
4632 | cmdSplit.setToolTipText(MM.PHRASES.getPhrase("233")); |
4633 | - |
4634 | + |
4635 | FormData cmboffsetdata = new FormData(); |
4636 | cmboffsetdata.top = new FormAttachment(0, 0); |
4637 | cmboffsetdata.left = new FormAttachment(0, 0); |
4638 | cmboffsetdata.right = new FormAttachment(100, -23); |
4639 | cmbOffset.setLayoutData(cmboffsetdata); |
4640 | - |
4641 | + |
4642 | FormData cmdsplitdata = new FormData(); |
4643 | cmdsplitdata.top = new FormAttachment(0, 0); |
4644 | cmdsplitdata.left = new FormAttachment(cmbOffset, 0); |
4645 | cmdSplit.setLayoutData(cmdsplitdata); |
4646 | - |
4647 | + |
4648 | Account act = null; |
4649 | - |
4650 | + |
4651 | if (allActList == null) { |
4652 | lblAlert.setText(MM.PHRASES.getPhrase("64")); |
4653 | return null; |
4654 | @@ -381,49 +452,47 @@ |
4655 | act = allActList.get(i); |
4656 | cmbOffset.add(act.getActName()); |
4657 | } |
4658 | - |
4659 | + |
4660 | cmbOffset.add(SPLIT); |
4661 | - |
4662 | - //cmbOffset.addVerifyListener(cmbEditor_onVerify); |
4663 | |
4664 | cellEditor.pack(); |
4665 | return cellEditor; |
4666 | |
4667 | } |
4668 | - |
4669 | - private void setRate(Account offsetAccount, Account importAccount, Text rateBox, Transaction tran){ |
4670 | - |
4671 | - Currency currency = null; |
4672 | - |
4673 | - if (offsetAccount == null || importAccount == null){ |
4674 | + |
4675 | + private void setRate(Account offsetAccount, Account importAccount, |
4676 | + Text rateBox, Transaction tran) { |
4677 | + |
4678 | + if (offsetAccount == null || importAccount == null) { |
4679 | rateBox.setEnabled(false); |
4680 | tran.setExchangeRate("1"); |
4681 | return; |
4682 | } |
4683 | - |
4684 | - if (!offsetAccount.getIsoCode().equalsIgnoreCase(importCurrency)){ |
4685 | + |
4686 | + if (!offsetAccount.getIsoCode().equalsIgnoreCase(importCurrency)) { |
4687 | rateBox.setEnabled(true); |
4688 | - |
4689 | - if (rateBox.getText().length()==0){ |
4690 | + |
4691 | + if (rateBox.getText().length() == 0) { |
4692 | try { |
4693 | - |
4694 | - String rate = data.getExchangeRate(importAccount, offsetAccount); |
4695 | + |
4696 | + String rate = data.getExchangeRate(importAccount, |
4697 | + offsetAccount); |
4698 | tran.setExchangeRate(rate); |
4699 | rateBox.setText(rate); |
4700 | - |
4701 | + |
4702 | } catch (SQLException e) { |
4703 | InfinityPfm.LogMessage(e.getMessage()); |
4704 | } |
4705 | - |
4706 | + |
4707 | } |
4708 | - |
4709 | + |
4710 | } else { |
4711 | rateBox.setText(""); |
4712 | rateBox.setEnabled(false); |
4713 | tran.setExchangeRate("1"); |
4714 | - |
4715 | + |
4716 | } |
4717 | - |
4718 | + |
4719 | } |
4720 | |
4721 | /* |
4722 | @@ -435,12 +504,12 @@ |
4723 | public void widgetSelected(SelectionEvent event) { |
4724 | shell.dispose(); |
4725 | } |
4726 | - }; |
4727 | + }; |
4728 | |
4729 | SelectionAdapter cmdSave_OnClick = new SelectionAdapter() { |
4730 | |
4731 | public void widgetSelected(SelectionEvent event) { |
4732 | - |
4733 | + |
4734 | InfinityPfm.qzMain.getStMain().setBusy(true); |
4735 | InfinityPfm.qzMain.getStMain() |
4736 | .setStatus(MM.PHRASES.getPhrase("89")); |
4737 | @@ -488,7 +557,6 @@ |
4738 | SelectionAdapter tblTrans_OnClick = new SelectionAdapter() { |
4739 | public void widgetSelected(SelectionEvent event) { |
4740 | |
4741 | - |
4742 | // Clean up any previous editor control |
4743 | Control oldEditor = editor.getEditor(); |
4744 | if (oldEditor != null) |
4745 | @@ -501,19 +569,18 @@ |
4746 | |
4747 | // The control that will be the editor must be a child of the Table |
4748 | Composite newEditor = getEditor(); |
4749 | - |
4750 | |
4751 | Control[] childList = newEditor.getChildren(); |
4752 | - for (Control child : childList){ |
4753 | - if (child instanceof CCombo ){ |
4754 | - |
4755 | - ((CCombo)child).addSelectionListener(rowCombo_OnClick); |
4756 | - |
4757 | - } else if (child instanceof Button){ |
4758 | - ((Button)child).addSelectionListener(rowButton_OnClick); |
4759 | + for (Control child : childList) { |
4760 | + if (child instanceof CCombo) { |
4761 | + |
4762 | + ((CCombo) child).addSelectionListener(rowCombo_OnClick); |
4763 | + |
4764 | + } else if (child instanceof Button) { |
4765 | + ((Button) child).addSelectionListener(rowButton_OnClick); |
4766 | } |
4767 | } |
4768 | - |
4769 | + |
4770 | cmdSave.setEnabled(true); |
4771 | |
4772 | if (newEditor != null) { |
4773 | @@ -535,17 +602,17 @@ |
4774 | |
4775 | } |
4776 | }; |
4777 | - |
4778 | -SelectionAdapter rowCombo_OnClick = new SelectionAdapter(){ |
4779 | - |
4780 | + |
4781 | + SelectionAdapter rowCombo_OnClick = new SelectionAdapter() { |
4782 | + |
4783 | public void widgetSelected(SelectionEvent event) { |
4784 | - |
4785 | + |
4786 | Composite c = (Composite) editor.getEditor(); |
4787 | |
4788 | - for (Control child : c.getChildren()){ |
4789 | - if (child instanceof CCombo ){ |
4790 | - |
4791 | - CCombo combo = (CCombo)child; |
4792 | + for (Control child : c.getChildren()) { |
4793 | + if (child instanceof CCombo) { |
4794 | + |
4795 | + CCombo combo = (CCombo) child; |
4796 | String sAct = combo.getText(); |
4797 | Account act = null; |
4798 | Account importAct = null; |
4799 | @@ -555,68 +622,72 @@ |
4800 | if (sAct != null && !sAct.equals(SPLIT)) { |
4801 | editor.getItem().setText(EDITABLECOLUMN, sAct); |
4802 | tran = (Transaction) editor.getItem().getData(TRAN); |
4803 | - rateBox = (Text)((TableEditor)(editor.getItem().getData(RATE_EDITOR))).getEditor(); |
4804 | + rateBox = (Text) ((TableEditor) (editor.getItem() |
4805 | + .getData(RATE_EDITOR))).getEditor(); |
4806 | act = (Account) actHash.get(sAct); |
4807 | |
4808 | - importAct = (Account)actHash.get(cmbAct.getText()); |
4809 | - |
4810 | + importAct = (Account) actHash.get(cmbAct.getText()); |
4811 | + |
4812 | if (act != null) { |
4813 | tran.setActOffset(act.getActId()); |
4814 | } else { |
4815 | rateBox.setEnabled(false); |
4816 | } |
4817 | - |
4818 | + |
4819 | setRate(act, importAct, rateBox, tran); |
4820 | - |
4821 | + |
4822 | editor.getItem().setText(4, act.getIsoCode()); |
4823 | - |
4824 | - } else if (sAct.equals(SPLIT)){ |
4825 | - editor.getItem().setText(EDITABLECOLUMN, SPLIT); |
4826 | - } |
4827 | - } |
4828 | - } |
4829 | - } |
4830 | -}; |
4831 | - |
4832 | -SelectionAdapter rowButton_OnClick = new SelectionAdapter(){ |
4833 | - |
4834 | - public void widgetSelected(SelectionEvent event) { |
4835 | - |
4836 | - Composite c = (Composite) editor.getEditor(); |
4837 | - |
4838 | - Account importAct = (Account)actHash.get(cmbAct.getText()); |
4839 | - Transaction savedTran = (Transaction) editor.getItem().getData(TRAN); |
4840 | - |
4841 | - TransactionDialog dialog = new TransactionDialog(importAct, savedTran); |
4842 | - dialog.setTransactionMode(MM.TRANSACTION_MODE_NOCOMMIT); |
4843 | - dialog.Open(); |
4844 | - Transaction tran = dialog.getTransaction(); |
4845 | - |
4846 | - if (tran != null){ |
4847 | - |
4848 | - savedTran.setOffsets(tran.getOffsets()); |
4849 | - |
4850 | - for (Control child : c.getChildren()){ |
4851 | - if (child instanceof CCombo ){ |
4852 | - CCombo combo = (CCombo)child; |
4853 | - |
4854 | - if (tran.getOffsets() != null && tran.getOffsets().size() > 1){ |
4855 | - editor.getItem().setText(EDITABLECOLUMN, SPLIT); |
4856 | - combo.setText(SPLIT); |
4857 | - } else if (tran.getOffsets().size() == 1) { |
4858 | - editor.getItem().setText(tran.getActOffsetName()); |
4859 | - combo.setText(tran.getActOffsetName()); |
4860 | - } |
4861 | - } |
4862 | - } |
4863 | - } |
4864 | - } |
4865 | -}; |
4866 | - |
4867 | - SelectionAdapter cmbAccount_OnClick = new SelectionAdapter(){ |
4868 | - |
4869 | - public void widgetSelected(SelectionEvent event) { |
4870 | - |
4871 | + |
4872 | + } else if (sAct.equals(SPLIT)) { |
4873 | + editor.getItem().setText(EDITABLECOLUMN, SPLIT); |
4874 | + } |
4875 | + } |
4876 | + } |
4877 | + } |
4878 | + }; |
4879 | + |
4880 | + SelectionAdapter rowButton_OnClick = new SelectionAdapter() { |
4881 | + |
4882 | + public void widgetSelected(SelectionEvent event) { |
4883 | + |
4884 | + Composite c = (Composite) editor.getEditor(); |
4885 | + |
4886 | + Account importAct = (Account) actHash.get(cmbAct.getText()); |
4887 | + Transaction savedTran = (Transaction) editor.getItem() |
4888 | + .getData(TRAN); |
4889 | + |
4890 | + TransactionDialog dialog = new TransactionDialog(importAct, |
4891 | + savedTran); |
4892 | + dialog.setTransactionMode(MM.TRANSACTION_MODE_NOCOMMIT); |
4893 | + dialog.Open(); |
4894 | + Transaction tran = dialog.getTransaction(); |
4895 | + |
4896 | + if (tran != null) { |
4897 | + |
4898 | + savedTran.setOffsets(tran.getOffsets()); |
4899 | + |
4900 | + for (Control child : c.getChildren()) { |
4901 | + if (child instanceof CCombo) { |
4902 | + CCombo combo = (CCombo) child; |
4903 | + |
4904 | + if (tran.getOffsets() != null |
4905 | + && tran.getOffsets().size() > 1) { |
4906 | + editor.getItem().setText(EDITABLECOLUMN, SPLIT); |
4907 | + combo.setText(SPLIT); |
4908 | + } else if (tran.getOffsets().size() == 1) { |
4909 | + editor.getItem().setText(tran.getActOffsetName()); |
4910 | + combo.setText(tran.getActOffsetName()); |
4911 | + } |
4912 | + } |
4913 | + } |
4914 | + } |
4915 | + } |
4916 | + }; |
4917 | + |
4918 | + SelectionAdapter cmbAccount_OnClick = new SelectionAdapter() { |
4919 | + |
4920 | + public void widgetSelected(SelectionEvent event) { |
4921 | + |
4922 | TableItem[] rows = tblTrans.getItems(); |
4923 | TableItem row = null; |
4924 | TableEditor editor = null; |
4925 | @@ -624,48 +695,49 @@ |
4926 | String act = null; |
4927 | Text txtRate = null; |
4928 | Transaction tran = null; |
4929 | - |
4930 | + |
4931 | Account importAccount = actHash.get(cmbAct.getText()); |
4932 | importCurrency = importAccount.getIsoCode(); |
4933 | - |
4934 | - for (int i=0; i<rows.length; i++){ |
4935 | + |
4936 | + for (int i = 0; i < rows.length; i++) { |
4937 | row = rows[i]; |
4938 | - editor = (TableEditor)row.getData(RATE_EDITOR); |
4939 | - tran = (Transaction)row.getData(TRAN); |
4940 | + editor = (TableEditor) row.getData(RATE_EDITOR); |
4941 | + tran = (Transaction) row.getData(TRAN); |
4942 | act = row.getText(2); |
4943 | - |
4944 | - if (act != null){ |
4945 | + |
4946 | + if (act != null) { |
4947 | offset = actHash.get(act); |
4948 | - txtRate = (Text)editor.getEditor(); |
4949 | - |
4950 | + txtRate = (Text) editor.getEditor(); |
4951 | + |
4952 | setRate(offset, importAccount, txtRate, tran); |
4953 | - |
4954 | + |
4955 | } else { |
4956 | txtRate.setEnabled(true); |
4957 | } |
4958 | - |
4959 | + |
4960 | } |
4961 | - |
4962 | - lblAct.setText(MM.PHRASES.getPhrase("15") + " (" + importCurrency + ")"); |
4963 | + |
4964 | + lblAct.setText(MM.PHRASES.getPhrase("15") + " (" + importCurrency |
4965 | + + ")"); |
4966 | } |
4967 | }; |
4968 | - |
4969 | - FocusAdapter ratebox_lostFocus = new FocusAdapter(){ |
4970 | + |
4971 | + FocusAdapter ratebox_lostFocus = new FocusAdapter() { |
4972 | |
4973 | @Override |
4974 | public void focusLost(FocusEvent event) { |
4975 | - |
4976 | - Text ratebox = (Text)event.widget; |
4977 | - int row = Integer.parseInt((String)ratebox.getData()); |
4978 | - Table tbl = (Table)ratebox.getParent(); |
4979 | + |
4980 | + Text ratebox = (Text) event.widget; |
4981 | + int row = Integer.parseInt((String) ratebox.getData()); |
4982 | + Table tbl = (Table) ratebox.getParent(); |
4983 | TableItem[] items = tbl.getItems(); |
4984 | - Transaction tran = (Transaction)items[row].getData(TRAN); |
4985 | + Transaction tran = (Transaction) items[row].getData(TRAN); |
4986 | tran.setExchangeRate(ratebox.getText()); |
4987 | - |
4988 | + |
4989 | super.focusLost(event); |
4990 | - |
4991 | + |
4992 | } |
4993 | - |
4994 | + |
4995 | }; |
4996 | |
4997 | } |
4998 | |
4999 | === added file 'infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportRulesDialog.java' |
5000 | --- infinitypfm/src/main/java/org/infinitypfm/ui/view/dialogs/ImportRulesDialog.java 1970-01-01 00:00:00 +0000 |
The diff has been truncated for viewing.
Merge 0.7 into trunk