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.IBookkeepingPageFactory;
26: import net.sf.jmoney.JMoneyPlugin;
27:
28: import org.eclipse.core.runtime.CoreException;
29: import org.eclipse.core.runtime.IConfigurationElement;
30:
31: /**
32: * This class contains the information needed to construct a page
33: * in an editor. This class does not do much except to keep a reference
34: * to the IConfigurationElement object that is used to load the class that
35: * implements the extension to the page extension point. If and when the
36: * page factory is actually needed, this class loads the extension class.
37: * By doing this, we follow the Eclipse design guidelines and delay loading
38: * plug-ins until we need them.
39: *
40: * @author Nigel Westbury
41: */
42: public class PageEntry {
43: String pageId;
44: IConfigurationElement pageElement;
45: IBookkeepingPageFactory pageFactory = null;
46: int position;
47:
48: public PageEntry(String pageId, IConfigurationElement pageElement,
49: int position) {
50: this .pageId = pageId;
51: this .pageElement = pageElement;
52: this .position = position;
53: }
54:
55: public String getPageId() {
56: return pageId;
57: }
58:
59: public IBookkeepingPageFactory getPageFactory() {
60: if (pageFactory == null) {
61: try {
62: pageFactory = (IBookkeepingPageFactory) pageElement
63: .createExecutableExtension("class");
64: } catch (CoreException e) {
65: JMoneyPlugin.log(e);
66: }
67: }
68: return pageFactory;
69: }
70:
71: public int getPosition() {
72: return position;
73: }
74:
75: }
|