Source Code Cross Referenced for StockAccountInfo.java in  » ERP-CRM-Financial » jmoney » net » sf » jmoney » stocks » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » jmoney » net.sf.jmoney.stocks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *  JMoney - A Personal Finance Manager
004:         *  Copyright (c) 2004 Nigel Westbury <westbury@users.sourceforge.net>
005:         *
006:         *
007:         *  This program is free software; you can redistribute it and/or modify
008:         *  it under the terms of the GNU General Public License as published by
009:         *  the Free Software Foundation; either version 2 of the License, or
010:         *  (at your option) any later version.
011:         *
012:         *  This program is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         *  GNU General Public License for more details.
016:         *
017:         *  You should have received a copy of the GNU General Public License
018:         *  along with this program; if not, write to the Free Software
019:         *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020:         *
021:         */
022:
023:        package net.sf.jmoney.stocks;
024:
025:        import java.util.Comparator;
026:
027:        import net.sf.jmoney.fields.AccountControlFactory;
028:        import net.sf.jmoney.fields.CurrencyControlFactory;
029:        import net.sf.jmoney.fields.TextControlFactory;
030:        import net.sf.jmoney.model2.AccountInfo;
031:        import net.sf.jmoney.model2.CapitalAccountInfo;
032:        import net.sf.jmoney.model2.Currency;
033:        import net.sf.jmoney.model2.ExtendableObject;
034:        import net.sf.jmoney.model2.ExtendablePropertySet;
035:        import net.sf.jmoney.model2.IExtendableObjectConstructors;
036:        import net.sf.jmoney.model2.IObjectKey;
037:        import net.sf.jmoney.model2.IPropertyControl;
038:        import net.sf.jmoney.model2.IPropertyControlFactory;
039:        import net.sf.jmoney.model2.IPropertySetInfo;
040:        import net.sf.jmoney.model2.IReferenceControlFactory;
041:        import net.sf.jmoney.model2.IValues;
042:        import net.sf.jmoney.model2.IncomeExpenseAccount;
043:        import net.sf.jmoney.model2.ListKey;
044:        import net.sf.jmoney.model2.PropertySet;
045:        import net.sf.jmoney.model2.ReferencePropertyAccessor;
046:        import net.sf.jmoney.model2.ScalarPropertyAccessor;
047:
048:        import org.eclipse.swt.widgets.Composite;
049:
050:        /**
051:         * @author Nigel
052:         *
053:         * This class is a listener class to the net.sf.jmoney.fields
054:         * extension point.  It implements an extension.
055:         * <P>
056:         * This extension registers the CapitalAccount properties.  By registering
057:         * the properties, every one can know how to display, edit, and store
058:         * the properties.
059:         * <P>
060:         * These properties are supported in the JMoney base code, so everyone
061:         * including plug-ins will know about these properties.  However, to
062:         * follow the Eclipse paradigm (every one should be treated equal,
063:         * including oneself), these are registered through the same extension
064:         * point that plug-ins must also use to register their properties.
065:         */
066:        public class StockAccountInfo implements  IPropertySetInfo {
067:
068:            private static ExtendablePropertySet<StockAccount> propertySet = PropertySet
069:                    .addDerivedFinalPropertySet(StockAccount.class,
070:                            "Stock Account", CapitalAccountInfo
071:                                    .getPropertySet(),
072:                            new IExtendableObjectConstructors<StockAccount>() {
073:
074:                                public StockAccount construct(
075:                                        IObjectKey objectKey, ListKey parentKey) {
076:                                    return new StockAccount(objectKey,
077:                                            parentKey);
078:                                }
079:
080:                                public StockAccount construct(
081:                                        IObjectKey objectKey,
082:                                        ListKey parentKey, IValues values) {
083:                                    return new StockAccount(
084:                                            objectKey,
085:                                            parentKey,
086:                                            values.getScalarValue(AccountInfo
087:                                                    .getNameAccessor()),
088:                                            values
089:                                                    .getListManager(
090:                                                            objectKey,
091:                                                            CapitalAccountInfo
092:                                                                    .getSubAccountAccessor()),
093:                                            values
094:                                                    .getScalarValue(CapitalAccountInfo
095:                                                            .getAbbreviationAccessor()),
096:                                            values
097:                                                    .getScalarValue(CapitalAccountInfo
098:                                                            .getCommentAccessor()),
099:                                            values
100:                                                    .getReferencedObjectKey(StockAccountInfo
101:                                                            .getCurrencyAccessor()),
102:                                            values
103:                                                    .getScalarValue(StockAccountInfo
104:                                                            .getBrokerageFirmAccessor()),
105:                                            values
106:                                                    .getScalarValue(StockAccountInfo
107:                                                            .getAccountNumberAccessor()),
108:                                            values
109:                                                    .getScalarValue(StockAccountInfo
110:                                                            .getTax1NameAccessor()),
111:                                            values
112:                                                    .getScalarValue(StockAccountInfo
113:                                                            .getTax2NameAccessor()),
114:                                            values
115:                                                    .getReferencedObjectKey(StockAccountInfo
116:                                                            .getCommissionAccountAccessor()),
117:                                            values
118:                                                    .getReferencedObjectKey(StockAccountInfo
119:                                                            .getTax1AccountAccessor()),
120:                                            values
121:                                                    .getReferencedObjectKey(StockAccountInfo
122:                                                            .getTax2AccountAccessor()),
123:                                            values
124:                                                    .getScalarValue(StockAccountInfo
125:                                                            .getBuyCommissionRatesAccessor()),
126:                                            values
127:                                                    .getScalarValue(StockAccountInfo
128:                                                            .getSellCommissionRatesAccessor()),
129:                                            values
130:                                                    .getScalarValue(StockAccountInfo
131:                                                            .getTax1RatesAccessor()),
132:                                            values
133:                                                    .getScalarValue(StockAccountInfo
134:                                                            .getTax2RatesAccessor()),
135:                                            values);
136:                                }
137:                            });
138:
139:            private static ReferencePropertyAccessor<Currency> currencyAccessor = null;
140:            private static ScalarPropertyAccessor<String> brokerageFirmAccessor = null;
141:            private static ScalarPropertyAccessor<String> accountNumberAccessor = null;
142:            private static ScalarPropertyAccessor<String> tax1NameAccessor = null;
143:            private static ScalarPropertyAccessor<String> tax2NameAccessor = null;
144:            private static ReferencePropertyAccessor<IncomeExpenseAccount> dividendAccountAccessor = null;
145:            private static ReferencePropertyAccessor<IncomeExpenseAccount> withholdingTaxAccountAccessor = null;
146:            private static ReferencePropertyAccessor<IncomeExpenseAccount> commissionAccountAccessor = null;
147:            private static ReferencePropertyAccessor<IncomeExpenseAccount> tax1AccountAccessor = null;
148:            private static ReferencePropertyAccessor<IncomeExpenseAccount> tax2AccountAccessor = null;
149:            private static ScalarPropertyAccessor<RatesTable> buyCommissionRatesAccessor = null;
150:            private static ScalarPropertyAccessor<RatesTable> sellCommissionRatesAccessor = null;
151:            private static ScalarPropertyAccessor<RatesTable> tax1RatesAccessor = null;
152:            private static ScalarPropertyAccessor<RatesTable> tax2RatesAccessor = null;
153:
154:            public PropertySet registerProperties() {
155:
156:                IPropertyControlFactory<String> textControlFactory = new TextControlFactory();
157:
158:                IReferenceControlFactory<StockAccount, Currency> currencyControlFactory = new CurrencyControlFactory<StockAccount>() {
159:                    public IObjectKey getObjectKey(StockAccount parentObject) {
160:                        return parentObject.currencyKey;
161:                    }
162:                };
163:
164:                IPropertyControlFactory<RatesTable> ratesControlFactory = new IPropertyControlFactory<RatesTable>() {
165:                    public IPropertyControl createPropertyControl(
166:                            Composite parent,
167:                            ScalarPropertyAccessor<RatesTable> propertyAccessor) {
168:                        return new RatesEditor(parent, propertyAccessor);
169:                    }
170:
171:                    public String formatValueForMessage(
172:                            ExtendableObject extendableObject,
173:                            ScalarPropertyAccessor<? extends RatesTable> propertyAccessor) {
174:                        RatesTable ratesTable = extendableObject
175:                                .getPropertyValue(propertyAccessor);
176:                        if (ratesTable == null) {
177:                            return "none";
178:                        } else {
179:                            return "rates table";
180:                        }
181:                    }
182:
183:                    public String formatValueForTable(
184:                            ExtendableObject extendableObject,
185:                            ScalarPropertyAccessor<? extends RatesTable> propertyAccessor) {
186:                        RatesTable ratesTable = extendableObject
187:                                .getPropertyValue(propertyAccessor);
188:                        if (ratesTable == null) {
189:                            return "";
190:                        } else {
191:                            return "rates table";
192:                        }
193:                    }
194:
195:                    public boolean isEditable() {
196:                        // TODO Should this be set to allow control editing?
197:                        return false;
198:                    }
199:
200:                    public Comparator<RatesTable> getComparator() {
201:                        // TODO Auto-generated method stub
202:                        return null;
203:                    }
204:
205:                    public RatesTable getDefaultValue() {
206:                        return null;
207:                    }
208:                };
209:
210:                IReferenceControlFactory<StockAccount, IncomeExpenseAccount> dividendAccountControlFactory = new AccountControlFactory<StockAccount, IncomeExpenseAccount>() {
211:                    public IObjectKey getObjectKey(StockAccount parentObject) {
212:                        return parentObject.dividendAccountKey;
213:                    }
214:                };
215:
216:                IReferenceControlFactory<StockAccount, IncomeExpenseAccount> withholdingTaxAccountControlFactory = new AccountControlFactory<StockAccount, IncomeExpenseAccount>() {
217:                    public IObjectKey getObjectKey(StockAccount parentObject) {
218:                        return parentObject.withholdingTaxAccountKey;
219:                    }
220:                };
221:
222:                IReferenceControlFactory<StockAccount, IncomeExpenseAccount> commissionAccountControlFactory = new AccountControlFactory<StockAccount, IncomeExpenseAccount>() {
223:                    public IObjectKey getObjectKey(StockAccount parentObject) {
224:                        return parentObject.commissionAccountKey;
225:                    }
226:                };
227:
228:                IReferenceControlFactory<StockAccount, IncomeExpenseAccount> tax1AccountControlFactory = new AccountControlFactory<StockAccount, IncomeExpenseAccount>() {
229:                    public IObjectKey getObjectKey(StockAccount parentObject) {
230:                        return parentObject.tax1AccountKey;
231:                    }
232:                };
233:
234:                IReferenceControlFactory<StockAccount, IncomeExpenseAccount> tax2AccountControlFactory = new AccountControlFactory<StockAccount, IncomeExpenseAccount>() {
235:                    public IObjectKey getObjectKey(StockAccount parentObject) {
236:                        return parentObject.tax2AccountKey;
237:                    }
238:                };
239:
240:                currencyAccessor = propertySet
241:                        .addProperty("currency", StocksPlugin
242:                                .getResourceString("PropertyDesc.currency"),
243:                                Currency.class, 2, 20, currencyControlFactory,
244:                                null);
245:                brokerageFirmAccessor = propertySet
246:                        .addProperty(
247:                                "brokerageFirm",
248:                                StocksPlugin
249:                                        .getResourceString("PropertyDesc.brokerageFirm"),
250:                                String.class, 5, 30, textControlFactory, null);
251:                accountNumberAccessor = propertySet
252:                        .addProperty(
253:                                "accountNumber",
254:                                StocksPlugin
255:                                        .getResourceString("PropertyDesc.accountNumber"),
256:                                String.class, 2, 30, textControlFactory, null);
257:                dividendAccountAccessor = propertySet
258:                        .addProperty(
259:                                "DividendAccount",
260:                                StocksPlugin
261:                                        .getResourceString("PropertyDesc.dividendAccount"),
262:                                IncomeExpenseAccount.class, 2, 80,
263:                                dividendAccountControlFactory, null);
264:                withholdingTaxAccountAccessor = propertySet
265:                        .addProperty(
266:                                "WithholdingTaxAccount",
267:                                StocksPlugin
268:                                        .getResourceString("PropertyDesc.withholdingTaxAccount"),
269:                                IncomeExpenseAccount.class, 2, 80,
270:                                withholdingTaxAccountControlFactory, null);
271:                commissionAccountAccessor = propertySet
272:                        .addProperty(
273:                                "CommissionAccount",
274:                                StocksPlugin
275:                                        .getResourceString("PropertyDesc.commissionAccount"),
276:                                IncomeExpenseAccount.class, 2, 80,
277:                                commissionAccountControlFactory, null);
278:                buyCommissionRatesAccessor = propertySet
279:                        .addProperty(
280:                                "buyCommissionRates",
281:                                StocksPlugin
282:                                        .getResourceString("PropertyDesc.buyCommissionRates"),
283:                                RatesTable.class, 1, 100, ratesControlFactory,
284:                                null);
285:                sellCommissionRatesAccessor = propertySet
286:                        .addProperty(
287:                                "sellCommissionRates",
288:                                StocksPlugin
289:                                        .getResourceString("PropertyDesc.sellCommissionRates"),
290:                                RatesTable.class, 1, 100, ratesControlFactory,
291:                                null);
292:                tax1NameAccessor = propertySet
293:                        .addProperty("tax1Name", StocksPlugin
294:                                .getResourceString("PropertyDesc.tax1Name"),
295:                                String.class, 2, 50, textControlFactory, null);
296:                tax1AccountAccessor = propertySet.addProperty("tax1Account",
297:                        StocksPlugin
298:                                .getResourceString("PropertyDesc.tax1Account"),
299:                        IncomeExpenseAccount.class, 2, 80,
300:                        tax1AccountControlFactory, null);
301:                tax1RatesAccessor = propertySet.addProperty("tax1Rates",
302:                        StocksPlugin
303:                                .getResourceString("PropertyDesc.tax1Rates"),
304:                        RatesTable.class, 1, 100, ratesControlFactory, null);
305:                tax2NameAccessor = propertySet
306:                        .addProperty("tax2Name", StocksPlugin
307:                                .getResourceString("PropertyDesc.tax2Name"),
308:                                String.class, 2, 50, textControlFactory, null);
309:                tax2AccountAccessor = propertySet.addProperty("tax2Account",
310:                        StocksPlugin
311:                                .getResourceString("PropertyDesc.tax2Account"),
312:                        IncomeExpenseAccount.class, 2, 80,
313:                        tax2AccountControlFactory, null);
314:                tax2RatesAccessor = propertySet.addProperty("tax2Rates",
315:                        StocksPlugin
316:                                .getResourceString("PropertyDesc.tax2Rates"),
317:                        RatesTable.class, 1, 100, ratesControlFactory, null);
318:
319:                return propertySet;
320:            }
321:
322:            /**
323:             * @return
324:             */
325:            public static ReferencePropertyAccessor<Currency> getCurrencyAccessor() {
326:                return currencyAccessor;
327:            }
328:
329:            /**
330:             * @return
331:             */
332:            public static ScalarPropertyAccessor<String> getBrokerageFirmAccessor() {
333:                return brokerageFirmAccessor;
334:            }
335:
336:            /**
337:             * @return
338:             */
339:            public static ScalarPropertyAccessor<String> getAccountNumberAccessor() {
340:                return accountNumberAccessor;
341:            }
342:
343:            /**
344:             * @return
345:             */
346:            public static ScalarPropertyAccessor<String> getTax1NameAccessor() {
347:                return tax1NameAccessor;
348:            }
349:
350:            /**
351:             * @return
352:             */
353:            public static ScalarPropertyAccessor<String> getTax2NameAccessor() {
354:                return tax2NameAccessor;
355:            }
356:
357:            /**
358:             * @return
359:             */
360:            public static ReferencePropertyAccessor<IncomeExpenseAccount> getDividendAccountAccessor() {
361:                return dividendAccountAccessor;
362:            }
363:
364:            public static ScalarPropertyAccessor<IncomeExpenseAccount> getWithholdingTaxAccountAccessor() {
365:                return withholdingTaxAccountAccessor;
366:            }
367:
368:            /**
369:             * @return
370:             */
371:            public static ReferencePropertyAccessor<IncomeExpenseAccount> getCommissionAccountAccessor() {
372:                return commissionAccountAccessor;
373:            }
374:
375:            /**
376:             * @return
377:             */
378:            public static ReferencePropertyAccessor<IncomeExpenseAccount> getTax1AccountAccessor() {
379:                return tax1AccountAccessor;
380:            }
381:
382:            /**
383:             * @return
384:             */
385:            public static ReferencePropertyAccessor<IncomeExpenseAccount> getTax2AccountAccessor() {
386:                return tax2AccountAccessor;
387:            }
388:
389:            /**
390:             * @return
391:             */
392:            public static ScalarPropertyAccessor<RatesTable> getBuyCommissionRatesAccessor() {
393:                return buyCommissionRatesAccessor;
394:            }
395:
396:            /**
397:             * @return
398:             */
399:            public static ScalarPropertyAccessor<RatesTable> getSellCommissionRatesAccessor() {
400:                return sellCommissionRatesAccessor;
401:            }
402:
403:            /**
404:             * @return
405:             */
406:            public static ScalarPropertyAccessor<RatesTable> getTax1RatesAccessor() {
407:                return tax1RatesAccessor;
408:            }
409:
410:            /**
411:             * @return
412:             */
413:            public static ScalarPropertyAccessor<RatesTable> getTax2RatesAccessor() {
414:                return tax2RatesAccessor;
415:            }
416:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.