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.model2;
024:
025: import java.util.Date;
026:
027: import net.sf.jmoney.JMoneyPlugin;
028: import net.sf.jmoney.fields.DateControlFactory;
029:
030: /**
031: * This class is a listener class to the net.sf.jmoney.fields
032: * extension point. It implements an extension.
033: * <P>
034: * This extension registers the Entry properties. By registering
035: * the properties, every one can know how to display, edit, and store
036: * the properties.
037: * <P>
038: * These properties are supported in the JMoney base code, so everyone
039: * including plug-ins will know about these properties. However, to
040: * follow the Eclipse paradigm (every one should be treated equal,
041: * including oneself), these are registered through the same extension
042: * point that plug-ins must also use to register their properties.
043: *
044: * @author Nigel Westbury
045: * @author Johann Gyger
046: */
047: public class TransactionInfo implements IPropertySetInfo {
048:
049: private static ExtendablePropertySet<Transaction> propertySet = PropertySet
050: .addBaseFinalPropertySet(Transaction.class,
051: "Financial Transaction",
052: new IExtendableObjectConstructors<Transaction>() {
053:
054: public Transaction construct(
055: IObjectKey objectKey, ListKey parentKey) {
056: return new Transaction(objectKey, parentKey);
057: }
058:
059: public Transaction construct(
060: IObjectKey objectKey,
061: ListKey parentKey, IValues values) {
062: return new Transaction(
063: objectKey,
064: parentKey,
065: values
066: .getListManager(
067: objectKey,
068: TransactionInfo
069: .getEntriesAccessor()),
070: values
071: .getScalarValue(TransactionInfo
072: .getDateAccessor()),
073: values);
074: }
075: });
076:
077: private static ScalarPropertyAccessor<Date> dateAccessor = null;
078: private static ListPropertyAccessor<Entry> entriesAccessor = null;
079:
080: public PropertySet registerProperties() {
081: IListGetter<Transaction, Entry> entryGetter = new IListGetter<Transaction, Entry>() {
082: public ObjectCollection<Entry> getList(
083: Transaction parentObject) {
084: return parentObject.getEntryCollection();
085: }
086: };
087:
088: IPropertyControlFactory<Date> dateControlFactory = new DateControlFactory();
089:
090: entriesAccessor = propertySet.addPropertyList("entry",
091: JMoneyPlugin.getResourceString("<not used???>"),
092: EntryInfo.getPropertySet(), entryGetter);
093: dateAccessor = propertySet.addProperty("date", JMoneyPlugin
094: .getResourceString("Entry.date"), Date.class, 0, 74,
095: dateControlFactory, null);
096:
097: return propertySet;
098: }
099:
100: /**
101: * @return
102: */
103: public static ExtendablePropertySet<Transaction> getPropertySet() {
104: return propertySet;
105: }
106:
107: /**
108: * @return
109: */
110: public static ListPropertyAccessor<Entry> getEntriesAccessor() {
111: return entriesAccessor;
112: }
113:
114: /**
115: * @return
116: */
117: public static ScalarPropertyAccessor<Date> getDateAccessor() {
118: return dateAccessor;
119: }
120:
121: }
|