001: // @@
002: // @@
003: /*
004: * Wi.Ser Framework
005: *
006: * Version: 1.8.1, 20-September-2007
007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
008: *
009: * This library is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU Lesser General Public
011: * License as published by the Free Software Foundation; either
012: * version 2 of the License, or (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: * Lesser General Public License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library located in LGPL.txt in the
021: * license directory; if not, write to the
022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023: * Boston, MA 02111-1307, USA.
024: *
025: * If this agreement does not cover your requirements, please contact us
026: * via email to get detailed information about the commercial license
027: * or our service offerings!
028: *
029: */
030: // @@
031: package de.ug2t.unifiedGui.plugins;
032:
033: import java.io.*;
034: import java.util.*;
035:
036: import de.ug2t.kernel.*;
037: import de.ug2t.unifiedGui.*;
038: import de.ug2t.unifiedGui.interfaces.*;
039:
040: public class PlBasicComponentAggregat extends KeRegisteredObject {
041: /**
042: * @author Dirk
043: *
044: * date: 29.05.2007 project: WiSer-Framework
045: *
046: * <p>
047: * Factory is a convenience class to create components of the surrounding
048: * interface's type without taking care for the WidgetServer MultiChannel API.
049: * It's use is similar to a constructor.
050: * </p>
051: */
052: public static class Factory {
053: /**
054: * Creates a standard version of this component as described in the factory.
055: * If you create masses of components for e.g. within a renderer use
056: * <i> create(IUnApplication xAppl)</i> for performance
057: * reasons.
058: *
059: * @param xPlugin
060: * the plugin name
061: * @param xAddParams
062: * Additional prameters
063: * @return new component
064: */
065: public static PlBasicComponentAggregat create(String xPlugin,
066: Object xAddParams) {
067: IUnApplication l_appl = (IUnApplication) KeRegisteredObject
068: .pcmf_getObjByName(IUnApplication.MY_APPL);
069: return (l_appl.pcmf_getComponentFactory()
070: .pcmf_createAggregatedPlugin(xPlugin, l_appl
071: .pcmf_getApplType(), l_appl, xAddParams));
072: }
073:
074: /**
075: * Creates a special version of this component as described in the factory
076: * configuration under the descriptor xFactoryDesc. If you create masses of
077: * components for e.g. within a renderer use <i>
078: * create(IUnApplication xAppl, String xFactoryDesc)</i> for performance
079: * reasons.
080: *
081: * @param xPlugin
082: * the plugin name
083: * @param xAddParams
084: * Additional prameters
085: * @param xFactoryDesc
086: * descriptor
087: * @return new component
088: */
089: public static PlBasicComponentAggregat create(String xPlugin,
090: Object xAddParams, String xFactoryDesc) {
091: IUnApplication l_appl = (IUnApplication) KeRegisteredObject
092: .pcmf_getObjByName(IUnApplication.MY_APPL);
093: return (l_appl.pcmf_getComponentFactory()
094: .pcmf_createAggregatedPlugin(xPlugin, l_appl
095: .pcmf_getApplType(), l_appl, xAddParams));
096: }
097:
098: /**
099: * Creates a standard version of this component as described in the factory
100: * within the given application-context. If you create masses of components
101: * for e.g. within a renderer use this method for performance reasons.
102: *
103: * @param xPlugin
104: * the plugin name
105: * @param xAddParams
106: * Additional prameters
107: * @param xAppl
108: * application in which context the component is created
109: * @return new component
110: */
111: public static PlBasicComponentAggregat create(String xPlugin,
112: Object xAddParams, IUnApplication xAppl) {
113: return (xAppl.pcmf_getComponentFactory()
114: .pcmf_createAggregatedPlugin(xPlugin, xAppl
115: .pcmf_getApplType(), xAppl, xAddParams));
116: }
117:
118: /**
119: * Creates a special version of this component as described in the factory
120: * configuration under the descriptor xFactoryDesc. If you create masses of
121: * components for e.g. within a renderer use this function for performance
122: * reasons.
123: *
124: * @param xPlugin
125: * the plugin name
126: * @param xAddParams
127: * Additional prameters
128: * @param xFactoryDesc
129: * descriptor
130: * @param xAppl
131: * application in which context the component is created
132: * @return new component
133: */
134: public static PlBasicComponentAggregat create(String xPlugin,
135: Object xAddParams, IUnApplication xAppl,
136: String xFactoryDesc) {
137: return (xAppl.pcmf_getComponentFactory()
138: .pcmf_createAggregatedPlugin(xPlugin, xAppl
139: .pcmf_getApplType(), xAppl, xAddParams));
140: }
141: }
142:
143: private UnComponent pem_guiObj = null;
144: private String pem_rootDir = null;
145: public static final String MY_CURRENTPARSED_PLUGIN = "MY_CURRENTPARSED_PLUGIN";
146: private HashMap pem_locals = null;
147: private HashMap pem_localNames = null;
148:
149: public PlBasicComponentAggregat(UnComponent xPl, Object xParam,
150: String xRoot) {
151: super (false);
152:
153: this .pcmf_initPlugin(xPl, xParam, xRoot);
154: return;
155: }
156:
157: public PlBasicComponentAggregat() {
158: super (false);
159:
160: return;
161: }
162:
163: public void pcmf_preParse(String xRoot) {
164: this .pem_rootDir = xRoot;
165: return;
166: }
167:
168: public void pcmf_initPlugin(UnComponent xPl, Object xParam,
169: String xRoot) {
170: this .pem_guiObj = xPl;
171: return;
172: }
173:
174: public final UnComponent pcmf_getPluginObject() {
175: return (this .pem_guiObj);
176: }
177:
178: protected final void pcmf_setPluginObject(UnComponent xPl) {
179: this .pem_guiObj = xPl;
180: return;
181: }
182:
183: public final String pcmf_getRootDir() {
184: if (this .pem_rootDir != null)
185: return (KeEnvironment.pcmf_buildPath(this .pem_rootDir));
186: else
187: return (KeEnvironment.pcmf_buildPath(""));
188: }
189:
190: public final String pcmf_buildPath(String xPath) {
191: xPath = xPath.replace('\\', File.separator.charAt(0));
192:
193: File l_file = new File(xPath.trim());
194: if (l_file.isAbsolute())
195: return (xPath);
196: else
197: return (this .pcmf_getRootDir() + File.separator.charAt(0) + xPath);
198: }
199:
200: public void pcmf_delete() throws Exception {
201: try {
202: this .pem_guiObj.pcmf_clearAndRelease();
203: this .pcmf_clearLocals();
204: } catch (Exception e) {
205: KeLog.pcmf_log("ug2t",
206: "error deleting plugin, root object not defined",
207: this , KeLog.ERROR);
208: } finally {
209: super .pcmf_delete();
210: }
211: };
212:
213: public Object pcmf_addLocalObject(Object xName, Object xValue) {
214: if (this .pem_locals == null) {
215: this .pem_locals = new HashMap();
216: this .pem_localNames = new HashMap();
217: }
218: this .pem_localNames.put(xValue, xName);
219: return (this .pem_locals.put(xName, xValue));
220: }
221:
222: public Object pcmf_removeLocalObject(Object xName) {
223: if (this .pem_locals == null)
224: return (null);
225:
226: return (this .pem_localNames.remove(this .pem_locals
227: .remove(xName)));
228: }
229:
230: public Object pcmf_getLocalByName(String xName) {
231: if (this .pem_locals == null)
232: return (null);
233:
234: return (this .pem_locals.get(xName));
235: }
236:
237: public String pcmf_getLocalName(Object xObj) {
238: if (this .pem_localNames == null)
239: return (null);
240:
241: return (this .pem_localNames.get(xObj).toString());
242: }
243:
244: public void pcmf_clearLocals() {
245: this.pem_locals = null;
246: this.pem_localNames = null;
247: }
248:
249: }
|