Source Code Cross Referenced for ReconciliationEntryInfo.java in  » ERP-CRM-Financial » jmoney » net » sf » jmoney » reconciliation » 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.reconciliation 
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.reconciliation;
024:
025:        import net.sf.jmoney.model2.EntryInfo;
026:        import net.sf.jmoney.model2.ExtendableObject;
027:        import net.sf.jmoney.model2.ExtensionPropertySet;
028:        import net.sf.jmoney.model2.IExtensionObjectConstructors;
029:        import net.sf.jmoney.model2.IPropertyControl;
030:        import net.sf.jmoney.model2.IPropertyControlFactory;
031:        import net.sf.jmoney.model2.IPropertySetInfo;
032:        import net.sf.jmoney.model2.IValues;
033:        import net.sf.jmoney.model2.PropertyControlFactory;
034:        import net.sf.jmoney.model2.PropertySet;
035:        import net.sf.jmoney.model2.ScalarPropertyAccessor;
036:
037:        import org.eclipse.swt.SWT;
038:        import org.eclipse.swt.widgets.Composite;
039:        import org.eclipse.swt.widgets.Control;
040:        import org.eclipse.swt.widgets.Label;
041:        import org.eclipse.swt.widgets.Text;
042:
043:        /**
044:         * Provides the metadata for the extra properties added to each
045:         * entry by this plug-in.
046:         * 
047:         * @author Nigel Westbury
048:         */
049:        public class ReconciliationEntryInfo implements  IPropertySetInfo {
050:
051:            private static ExtensionPropertySet<ReconciliationEntry> propertySet = PropertySet
052:                    .addExtensionPropertySet(
053:                            ReconciliationEntry.class,
054:                            EntryInfo.getPropertySet(),
055:                            new IExtensionObjectConstructors<ReconciliationEntry>() {
056:
057:                                public ReconciliationEntry construct(
058:                                        ExtendableObject extendedObject) {
059:                                    return new ReconciliationEntry(
060:                                            extendedObject);
061:                                }
062:
063:                                public ReconciliationEntry construct(
064:                                        ExtendableObject extendedObject,
065:                                        IValues values) {
066:                                    return new ReconciliationEntry(
067:                                            extendedObject,
068:                                            values
069:                                                    .getScalarValue(getStatusAccessor()),
070:                                            values
071:                                                    .getScalarValue(getStatementAccessor()),
072:                                            values
073:                                                    .getScalarValue(getUniqueIdAccessor()));
074:                                }
075:                            });
076:
077:            private static ScalarPropertyAccessor<Integer> statusAccessor = null;
078:            private static ScalarPropertyAccessor<BankStatement> statementAccessor = null;
079:            private static ScalarPropertyAccessor<String> uniqueIdAccessor = null;
080:
081:            public PropertySet registerProperties() {
082:                class NonEditableTextControlFactory extends
083:                        PropertyControlFactory<String> {
084:
085:                    public IPropertyControl createPropertyControl(
086:                            Composite parent,
087:                            final ScalarPropertyAccessor<String> propertyAccessor) {
088:
089:                        // Property is not editable
090:                        final Label control = new Label(parent, SWT.NONE);
091:                        return new IPropertyControl() {
092:
093:                            public Control getControl() {
094:                                return control;
095:                            }
096:
097:                            public void load(ExtendableObject object) {
098:                                String text = object
099:                                        .getPropertyValue(propertyAccessor);
100:                                if (text == null) {
101:                                    control.setText("");
102:                                } else {
103:                                    control.setText(text);
104:                                }
105:                            }
106:
107:                            public void save() {
108:                                /*
109:                                 * The property is not editable so there is nothing
110:                                 * to do here.
111:                                 */
112:                            }
113:                        };
114:                    }
115:
116:                    @Override
117:                    public String formatValueForMessage(
118:                            ExtendableObject extendableObject,
119:                            ScalarPropertyAccessor<? extends String> propertyAccessor) {
120:                        String value = extendableObject
121:                                .getPropertyValue(propertyAccessor);
122:                        return (value == null) ? "<blank>" : value;
123:                    }
124:
125:                    @Override
126:                    public String formatValueForTable(
127:                            ExtendableObject extendableObject,
128:                            ScalarPropertyAccessor<? extends String> propertyAccessor) {
129:                        String value = extendableObject
130:                                .getPropertyValue(propertyAccessor);
131:                        return (value == null) ? "" : value;
132:                    }
133:
134:                    public String getDefaultValue() {
135:                        return null;
136:                    }
137:
138:                    public boolean isEditable() {
139:                        return true;
140:                    }
141:                }
142:
143:                IPropertyControlFactory<BankStatement> statementControlFactory = new PropertyControlFactory<BankStatement>() {
144:                    public IPropertyControl createPropertyControl(
145:                            Composite parent,
146:                            final ScalarPropertyAccessor<BankStatement> propertyAccessor) {
147:                        final Text control = new Text(parent, SWT.NONE);
148:                        return new IPropertyControl() {
149:
150:                            private ExtendableObject object;
151:
152:                            public Control getControl() {
153:                                return control;
154:                            }
155:
156:                            public void load(ExtendableObject object) {
157:                                this .object = object;
158:                                BankStatement statement = object
159:                                        .getPropertyValue(propertyAccessor);
160:                                if (statement == null) {
161:                                    control.setText("");
162:                                } else {
163:                                    control.setText(statement.toString());
164:                                }
165:                            }
166:
167:                            public void save() {
168:                                // TODO: make this more robust.
169:                                // And the control is better if a Combo.
170:                                String text = control.getText();
171:                                BankStatement value;
172:                                if (text.length() == 0) {
173:                                    value = null;
174:                                } else {
175:                                    value = new BankStatement(control.getText());
176:                                }
177:                                object
178:                                        .setPropertyValue(propertyAccessor,
179:                                                value);
180:                            }
181:                        };
182:                    }
183:
184:                    @Override
185:                    public String formatValueForMessage(
186:                            ExtendableObject extendableObject,
187:                            ScalarPropertyAccessor<? extends BankStatement> propertyAccessor) {
188:                        BankStatement statement = extendableObject
189:                                .getPropertyValue(propertyAccessor);
190:                        if (statement == null) {
191:                            return "unreconciled";
192:                        } else {
193:                            return statement.toString();
194:                        }
195:                    }
196:
197:                    @Override
198:                    public String formatValueForTable(
199:                            ExtendableObject extendableObject,
200:                            ScalarPropertyAccessor<? extends BankStatement> propertyAccessor) {
201:                        BankStatement statement = extendableObject
202:                                .getPropertyValue(propertyAccessor);
203:                        if (statement == null) {
204:                            return "unreconciled";
205:                        } else {
206:                            return statement.toString();
207:                        }
208:                    }
209:
210:                    public BankStatement getDefaultValue() {
211:                        // By default, not on any statement (unreconciled)
212:                        return null;
213:                    }
214:
215:                    public boolean isEditable() {
216:                        return true;
217:                    }
218:                };
219:
220:                // TODO: correct localized text:
221:                statusAccessor = propertySet.addProperty("status",
222:                        ReconciliationPlugin
223:                                .getResourceString("Entry.statusShort"),
224:                        Integer.class, 1, 30, new StatusControlFactory(), null);
225:                statementAccessor = propertySet.addProperty("statement",
226:                        ReconciliationPlugin
227:                                .getResourceString("Entry.statementShort"),
228:                        BankStatement.class, 1, 80, statementControlFactory,
229:                        null);
230:                uniqueIdAccessor = propertySet.addProperty("uniqueId",
231:                        ReconciliationPlugin
232:                                .getResourceString("Entry.uniqueIdShort"),
233:                        String.class, 1, 80,
234:                        new NonEditableTextControlFactory(), null);
235:
236:                return propertySet;
237:            }
238:
239:            /**
240:             * @return
241:             */
242:            public static ExtensionPropertySet<ReconciliationEntry> getPropertySet() {
243:                return propertySet;
244:            }
245:
246:            /**
247:             * @return
248:             */
249:            public static ScalarPropertyAccessor<Integer> getStatusAccessor() {
250:                return statusAccessor;
251:            }
252:
253:            /**
254:             * @return
255:             */
256:            public static ScalarPropertyAccessor<BankStatement> getStatementAccessor() {
257:                return statementAccessor;
258:            }
259:
260:            /**
261:             * @return
262:             */
263:            public static ScalarPropertyAccessor<String> getUniqueIdAccessor() {
264:                return uniqueIdAccessor;
265:            }
266:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.