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.scripting;
032:
033: import bsh.*;
034: import de.ug2t.kernel.*;
035: import de.ug2t.unifiedGui.*;
036:
037: public class UnBeanShellIntegrator implements IUnScriptIntegrator {
038: private boolean pem_synced = false;
039: private String pem_script = "";
040: private static Interpreter pem_bsh = new Interpreter();
041: private String pem_type = null;
042:
043: static {
044: try {
045: pem_bsh.setClassLoader(pem_bsh.getClass().getClassLoader());
046: pem_bsh
047: .eval("import de.ug2t.kernel.*;import de.ug2t.unifiedGui.interfaces.*;import de.ug2t.unifiedGui.*");
048: } catch (Exception e) {
049: KeLog.pcmf_logException("ug2t", null, e);
050: }
051: }
052:
053: public void pcmf_setType(String xType) {
054: this .pem_type = xType;
055: }
056:
057: public String pcmf_getType() {
058: return (this .pem_type);
059: }
060:
061: /* (non-Javadoc)
062: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_setSynced(boolean)
063: */
064: public void pcmf_setSynced(boolean xSynced) {
065: this .pem_synced = xSynced;
066: }
067:
068: /* (non-Javadoc)
069: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_setScript(java.lang.String)
070: */
071: public void pcmf_setScript(String xScript) {
072: this .pem_script = xScript;
073: }
074:
075: /* (non-Javadoc)
076: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_synchronize()
077: */
078: public boolean pcmf_synchronize() {
079: return this .pem_synced;
080: }
081:
082: /* (non-Javadoc)
083: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_execListener(de.ug2t.unifiedGui.UnComponent)
084: */
085: public void pcmf_execListener(UnComponent xParam) throws Exception {
086: this .pcmf_execObj(xParam);
087: }
088:
089: /* (non-Javadoc)
090: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_execPreFct(de.ug2t.unifiedGui.UnComponent)
091: */
092: public void pcmf_execPreFct(UnComponent xParam) throws Exception {
093: this .pcmf_execObj(xParam);
094: }
095:
096: /* (non-Javadoc)
097: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_execPostFct(de.ug2t.unifiedGui.UnComponent)
098: */
099: public void pcmf_execPostFct(UnComponent xParam) throws Exception {
100: this .pcmf_execObj(xParam);
101: }
102:
103: /* (non-Javadoc)
104: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_execObj(java.lang.Object)
105: */
106: public Object pcmf_execObj(Object xObj) {
107: try {
108: pem_bsh.set("xParam", xObj);
109: pem_bsh.eval(this .pem_script);
110: } catch (Exception e) {
111: KeLog.pcmf_logException("ug2t", this , e);
112: }
113:
114: return null;
115: }
116:
117: /* (non-Javadoc)
118: * @see de.ug2t.unifiedGui.IUnScriptIntegrator#pcmf_execObj(java.lang.Object)
119: */
120: public void pcmf_mapped(KeRegisteredObject xComponent, Object xOld,
121: Object xNew) {
122: try {
123: pem_bsh.set("xComponent", xComponent);
124: pem_bsh.set("xOld", xOld);
125: pem_bsh.set("xNew", xNew);
126: pem_bsh.eval(this .pem_script);
127: } catch (Exception e) {
128: KeLog.pcmf_logException("ug2t", this, e);
129: }
130:
131: return;
132: }
133: }
|