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.JMoneyPlugin;
026: import net.sf.jmoney.fields.AccountControlFactory;
027: import net.sf.jmoney.fields.CurrencyControlFactory;
028: import net.sf.jmoney.fields.IntegerControlFactory;
029: import net.sf.jmoney.fields.TextControlFactory;
030: import net.sf.jmoney.model2.Account;
031: import net.sf.jmoney.model2.Currency;
032: import net.sf.jmoney.model2.ExtendablePropertySet;
033: import net.sf.jmoney.model2.IExtendableObjectConstructors;
034: import net.sf.jmoney.model2.IObjectKey;
035: import net.sf.jmoney.model2.IPropertyControlFactory;
036: import net.sf.jmoney.model2.IPropertySetInfo;
037: import net.sf.jmoney.model2.IReferenceControlFactory;
038: import net.sf.jmoney.model2.IValues;
039: import net.sf.jmoney.model2.ListKey;
040: import net.sf.jmoney.model2.PropertySet;
041: import net.sf.jmoney.model2.ReferencePropertyAccessor;
042: import net.sf.jmoney.model2.ScalarPropertyAccessor;
043:
044: /**
045: * This class is a listener class to the net.sf.jmoney.fields
046: * extension point. It implements an extension.
047: * <P>
048: * This extension registers the Pattern properties. By registering
049: * the properties, every one can know how to display, edit, and store
050: * the properties.
051: *
052: * @author Nigel Westbury
053: */
054: public class MemoPatternInfo implements IPropertySetInfo {
055:
056: private static ExtendablePropertySet<MemoPattern> propertySet = PropertySet
057: .addBaseFinalPropertySet(MemoPattern.class,
058: "Account Import Entry Pattern",
059: new IExtendableObjectConstructors<MemoPattern>() {
060:
061: public MemoPattern construct(
062: IObjectKey objectKey, ListKey parentKey) {
063: return new MemoPattern(objectKey, parentKey);
064: }
065:
066: public MemoPattern construct(
067: IObjectKey objectKey,
068: ListKey parentKey, IValues values) {
069: return new MemoPattern(
070: objectKey,
071: parentKey,
072: values
073: .getScalarValue(MemoPatternInfo
074: .getOrderingIndexAccessor()),
075: values
076: .getScalarValue(MemoPatternInfo
077: .getPatternAccessor()),
078: values
079: .getScalarValue(MemoPatternInfo
080: .getCheckAccessor()),
081: values
082: .getScalarValue(MemoPatternInfo
083: .getDescriptionAccessor()),
084: values
085: .getReferencedObjectKey(MemoPatternInfo
086: .getAccountAccessor()),
087: values
088: .getScalarValue(MemoPatternInfo
089: .getMemoAccessor()),
090: values
091: .getReferencedObjectKey(MemoPatternInfo
092: .getIncomeExpenseCurrencyAccessor()),
093: values);
094: }
095: });
096:
097: private static ScalarPropertyAccessor<Integer> orderingIndexAccessor = null;
098: private static ScalarPropertyAccessor<String> patternAccessor = null;
099: private static ScalarPropertyAccessor<String> checkAccessor = null;
100: private static ScalarPropertyAccessor<String> descriptionAccessor = null;
101: private static ReferencePropertyAccessor<Account> accountAccessor = null;
102: private static ScalarPropertyAccessor<String> memoAccessor = null;
103: private static ReferencePropertyAccessor<Currency> incomeExpenseCurrencyAccessor = null;
104:
105: public PropertySet registerProperties() {
106: IPropertyControlFactory<Integer> integerControlFactory = new IntegerControlFactory();
107:
108: IPropertyControlFactory<String> textControlFactory = new TextControlFactory();
109:
110: IReferenceControlFactory<MemoPattern, Account> accountControlFactory = new AccountControlFactory<MemoPattern, Account>() {
111: public IObjectKey getObjectKey(MemoPattern parentObject) {
112: return parentObject.accountKey;
113: }
114: };
115:
116: IReferenceControlFactory<MemoPattern, Currency> currencyControlFactory = new CurrencyControlFactory<MemoPattern>() {
117: public IObjectKey getObjectKey(MemoPattern parentObject) {
118: return parentObject.incomeExpenseCurrencyKey;
119: }
120: };
121:
122: orderingIndexAccessor = propertySet.addProperty(
123: "orderingIndex", "Ordering Index", Integer.class, 1,
124: 20, integerControlFactory, null);
125: patternAccessor = propertySet.addProperty("pattern", "Pattern",
126: String.class, 2, 50, textControlFactory, null);
127: checkAccessor = propertySet.addProperty("check", JMoneyPlugin
128: .getResourceString("Entry.check"), String.class, 2, 50,
129: textControlFactory, null);
130: descriptionAccessor = propertySet.addProperty("description",
131: JMoneyPlugin.getResourceString("Entry.description"),
132: String.class, 5, 100, textControlFactory, null);
133: accountAccessor = propertySet.addProperty("account",
134: JMoneyPlugin.getResourceString("Entry.category"),
135: Account.class, 2, 70, accountControlFactory, null);
136: memoAccessor = propertySet.addProperty("memo", JMoneyPlugin
137: .getResourceString("Entry.memo"), String.class, 5, 100,
138: textControlFactory, null);
139: incomeExpenseCurrencyAccessor = propertySet.addProperty(
140: "incomeExpenseCurrency", JMoneyPlugin
141: .getResourceString("Entry.currency"),
142: Currency.class, 2, 70, currencyControlFactory, null);
143:
144: return propertySet;
145: }
146:
147: /**
148: * @return
149: */
150: public static ExtendablePropertySet<MemoPattern> getPropertySet() {
151: return propertySet;
152: }
153:
154: /**
155: * @return
156: */
157: public static ScalarPropertyAccessor<Integer> getOrderingIndexAccessor() {
158: return orderingIndexAccessor;
159: }
160:
161: /**
162: * @return
163: */
164: public static ScalarPropertyAccessor<String> getPatternAccessor() {
165: return patternAccessor;
166: }
167:
168: /**
169: * @return
170: */
171: public static ScalarPropertyAccessor<String> getCheckAccessor() {
172: return checkAccessor;
173: }
174:
175: /**
176: * @return
177: */
178: public static ScalarPropertyAccessor<String> getDescriptionAccessor() {
179: return descriptionAccessor;
180: }
181:
182: /**
183: * @return
184: */
185: public static ReferencePropertyAccessor<Account> getAccountAccessor() {
186: return accountAccessor;
187: }
188:
189: /**
190: * @return
191: */
192: public static ScalarPropertyAccessor<String> getMemoAccessor() {
193: return memoAccessor;
194: }
195:
196: /**
197: * @return
198: */
199: public static ReferencePropertyAccessor<Currency> getIncomeExpenseCurrencyAccessor() {
200: return incomeExpenseCurrencyAccessor;
201: }
202: }
|