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.MultiTextControlFactory;
027: import net.sf.jmoney.fields.TextControlFactory;
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 CapitalAccountInfo implements IPropertySetInfo {
047:
048: private static ExtendablePropertySet<CapitalAccount> propertySet = PropertySet
049: .addDerivedAbstractPropertySet(CapitalAccount.class,
050: "Capital Account", AccountInfo.getPropertySet());
051:
052: private static ListPropertyAccessor<CapitalAccount> subAccountAccessor = null;
053: private static ScalarPropertyAccessor<String> abbreviationAccessor = null;
054: private static ScalarPropertyAccessor<String> commentAccessor = null;
055:
056: public PropertySet registerProperties() {
057: IPropertyControlFactory<String> textControlFactory = new TextControlFactory();
058: IPropertyControlFactory<String> commentControlFactory = new MultiTextControlFactory();
059:
060: IListGetter<CapitalAccount, CapitalAccount> accountGetter = new IListGetter<CapitalAccount, CapitalAccount>() {
061: public ObjectCollection<CapitalAccount> getList(
062: CapitalAccount parentObject) {
063: return parentObject.getSubAccountCollection();
064: }
065: };
066:
067: subAccountAccessor = propertySet.addPropertyList("subAccount",
068: JMoneyPlugin.getResourceString("<not used???>"),
069: CapitalAccountInfo.getPropertySet(), accountGetter);
070: abbreviationAccessor = propertySet
071: .addProperty(
072: "abbreviation",
073: JMoneyPlugin
074: .getResourceString("AccountPropertiesPanel.abbrevation"),
075: String.class, 5, 70, textControlFactory, null);
076: commentAccessor = propertySet
077: .addProperty(
078: "comment",
079: JMoneyPlugin
080: .getResourceString("AccountPropertiesPanel.comment"),
081: String.class, 5, 150, commentControlFactory,
082: null);
083:
084: propertySet.setIcon("icons/account.gif");
085:
086: return propertySet;
087: }
088:
089: /**
090: * @return
091: */
092: public static ExtendablePropertySet<CapitalAccount> getPropertySet() {
093: return propertySet;
094: }
095:
096: /**
097: * @return
098: */
099: public static ListPropertyAccessor<CapitalAccount> getSubAccountAccessor() {
100: return subAccountAccessor;
101: }
102:
103: /**
104: * @return
105: */
106: public static ScalarPropertyAccessor<String> getAbbreviationAccessor() {
107: return abbreviationAccessor;
108: }
109:
110: /**
111: * @return
112: */
113: public static ScalarPropertyAccessor<String> getCommentAccessor() {
114: return commentAccessor;
115: }
116: }
|