01: /*
02: JSmooth: a VM wrapper toolkit for Windows
03: Copyright (C) 2003 Rodrigo Reyes <reyes@charabia.net>
04:
05: This program is free software; you can redistribute it and/or modify
06: it under the terms of the GNU General Public License as published by
07: the Free Software Foundation; either version 2 of the License, or
08: (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License
16: along with this program; if not, write to the Free Software
17: Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18:
19: */
20:
21: package net.charabia.jsmoothgen.application.gui;
22:
23: import java.util.*;
24:
25: public class EditorPool {
26: private Hashtable m_classToInstance = new Hashtable();
27:
28: public EditorPool() {
29: add(net.charabia.jsmoothgen.application.gui.editors.SkeletonChooser.class);
30: add(net.charabia.jsmoothgen.application.gui.editors.SkeletonProperties.class);
31: add(net.charabia.jsmoothgen.application.gui.editors.ExecutableName.class);
32: add(net.charabia.jsmoothgen.application.gui.editors.ExecutableIcon.class);
33: add(net.charabia.jsmoothgen.application.gui.editors.CurrentDirectory.class);
34: add(net.charabia.jsmoothgen.application.gui.editors.MainClass.class);
35: add(net.charabia.jsmoothgen.application.gui.editors.ApplicationArguments.class);
36: add(net.charabia.jsmoothgen.application.gui.editors.EmbeddedJar.class);
37: add(net.charabia.jsmoothgen.application.gui.editors.ClassPath.class);
38: add(net.charabia.jsmoothgen.application.gui.editors.MinVersion.class);
39: add(net.charabia.jsmoothgen.application.gui.editors.MaxVersion.class);
40: add(net.charabia.jsmoothgen.application.gui.editors.JVMBundle.class);
41: add(net.charabia.jsmoothgen.application.gui.editors.JVMSearchSequence.class);
42: add(net.charabia.jsmoothgen.application.gui.editors.MaxMemoryHeap.class);
43: add(net.charabia.jsmoothgen.application.gui.editors.InitialMemoryHeap.class);
44: add(net.charabia.jsmoothgen.application.gui.editors.JavaProperties.class);
45: }
46:
47: private void add(Class clzz) {
48: try {
49: m_classToInstance.put(clzz, clzz.newInstance());
50: } catch (Exception exc) {
51: exc.printStackTrace();
52: }
53: }
54:
55: public Editor getInstance(Class clzz) {
56: Editor e = (Editor) m_classToInstance.get(clzz);
57: if (e == null) {
58: try {
59: e = (Editor) clzz.newInstance();
60: m_classToInstance.put(clzz, e);
61: } catch (Exception exc) {
62: exc.printStackTrace();
63: }
64: }
65: return e;
66: }
67: }
|