01: /*
02: *
03: * JMoney - A Personal Finance Manager
04: * Copyright (c) 2004 Nigel Westbury <westbury@users.sourceforge.net>
05: *
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20: *
21: */
22:
23: package net.sf.jmoney.model2;
24:
25: import net.sf.jmoney.JMoneyPlugin;
26: import net.sf.jmoney.fields.TextControlFactory;
27:
28: /**
29: * This class is a listener class to the net.sf.jmoney.fields
30: * extension point. It implements an extension.
31: * <P>
32: * This extension registers the CapitalAccount properties. By registering
33: * the properties, every one can know how to display, edit, and store
34: * the properties.
35: * <P>
36: * These properties are supported in the JMoney base code, so everyone
37: * including plug-ins will know about these properties. However, to
38: * follow the Eclipse paradigm (every one should be treated equal,
39: * including oneself), these are registered through the same extension
40: * point that plug-ins must also use to register their properties.
41: *
42: * @author Nigel Westbury
43: * @author Johann Gyger
44: */
45: public class AccountInfo implements IPropertySetInfo {
46:
47: /**
48: * An instance of this object is created initially for all property sets.
49: * Other property sets reference this to indicate base or extendable
50: * property sets, and also the property sets used in lists.
51: * This enables type safety and also avoids the need to worry about
52: * the order in which
53: */
54: private static ExtendablePropertySet<Account> propertySet = PropertySet
55: .addBaseAbstractPropertySet(Account.class, "Account");
56:
57: private static ScalarPropertyAccessor<String> nameAccessor = null;
58:
59: public PropertySet registerProperties() {
60: IPropertyControlFactory<String> textControlFactory = new TextControlFactory();
61:
62: nameAccessor = propertySet.addProperty("name", JMoneyPlugin
63: .getResourceString("AccountPropertiesPanel.name"),
64: String.class, 5, 100, textControlFactory, null);
65:
66: return propertySet;
67: }
68:
69: /**
70: * @return
71: */
72: public static ExtendablePropertySet<Account> getPropertySet() {
73: return propertySet;
74: }
75:
76: /**
77: * @return
78: */
79: public static ScalarPropertyAccessor<String> getNameAccessor() {
80: return nameAccessor;
81: }
82: }
|