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 net.sf.jmoney.JMoneyPlugin;
026: import net.sf.jmoney.fields.AmountInCurrencyAccountControlFactory;
027: import net.sf.jmoney.fields.CurrencyControlFactory;
028:
029: /**
030: * This class is a listener class to the net.sf.jmoney.fields
031: * extension point. It implements an extension.
032: * <P>
033: * This extension registers the CapitalAccount properties. By registering
034: * the properties, every one can know how to display, edit, and store
035: * the properties.
036: * <P>
037: * These properties are supported in the JMoney base code, so everyone
038: * including plug-ins will know about these properties. However, to
039: * follow the Eclipse paradigm (every one should be treated equal,
040: * including oneself), these are registered through the same extension
041: * point that plug-ins must also use to register their properties.
042: *
043: * @author Nigel Westbury
044: * @author Johann Gyger
045: */
046: public class CurrencyAccountInfo implements IPropertySetInfo {
047:
048: private static ExtendablePropertySet<CurrencyAccount> propertySet = PropertySet
049: .addDerivedAbstractPropertySet(CurrencyAccount.class,
050: "Account containing a single currency",
051: CapitalAccountInfo.getPropertySet());
052:
053: private static ReferencePropertyAccessor<Currency> currencyAccessor = null;
054: private static ScalarPropertyAccessor<Long> startBalanceAccessor = null;
055:
056: public PropertySet registerProperties() {
057: IPropertyControlFactory<Long> amountControlFactory = new AmountInCurrencyAccountControlFactory();
058: IReferenceControlFactory<CurrencyAccount, Currency> currencyControlFactory = new CurrencyControlFactory<CurrencyAccount>() {
059: public IObjectKey getObjectKey(CurrencyAccount parentObject) {
060: return parentObject.currencyKey;
061: }
062: };
063:
064: currencyAccessor = propertySet
065: .addProperty(
066: "currency",
067: JMoneyPlugin
068: .getResourceString("AccountPropertiesPanel.currency"),
069: Currency.class, 3, 30, currencyControlFactory,
070: null);
071: startBalanceAccessor = propertySet
072: .addProperty(
073: "startBalance",
074: JMoneyPlugin
075: .getResourceString("AccountPropertiesPanel.startBalance"),
076: Long.class, 2, 40, amountControlFactory, null);
077:
078: return propertySet;
079: }
080:
081: /**
082: * @return
083: */
084: public static ExtendablePropertySet<CurrencyAccount> getPropertySet() {
085: return propertySet;
086: }
087:
088: /**
089: * @return
090: */
091: public static ReferencePropertyAccessor<Currency> getCurrencyAccessor() {
092: return currencyAccessor;
093: }
094:
095: /**
096: * @return
097: */
098: public static ScalarPropertyAccessor<Long> getStartBalanceAccessor() {
099: return startBalanceAccessor;
100: }
101: }
|