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.listener;
032:
033: import de.ug2t.kernel.*;
034: import de.ug2t.unifiedGui.*;
035: import de.ug2t.unifiedGui.interfaces.*;
036:
037: public class UnObjAddListener implements IUnGuiEventListener,
038: IKeExecutable {
039: private String pem_parent;
040: private String pem_child;
041: private boolean pem_useReg;
042: private boolean pem_multiAdd = false;
043: private int pem_x = -1;
044: private int pem_y = -1;
045: private int pem_w = -1;
046: private int pem_h = -1;
047: private String pem_align = "WEST";
048:
049: public UnObjAddListener(String xParent, String xChild,
050: boolean xUseRegistry) {
051: this .pem_parent = xParent;
052: this .pem_child = xChild;
053: this .pem_useReg = xUseRegistry;
054:
055: return;
056: }
057:
058: public UnObjAddListener(String xParent, String xChild,
059: boolean xUseRegistry, boolean xMulti) {
060: this .pem_parent = xParent;
061: this .pem_child = xChild;
062: this .pem_useReg = xUseRegistry;
063: this .pem_multiAdd = xMulti;
064:
065: return;
066: }
067:
068: public UnObjAddListener(String xParent, String xChild) {
069: this .pem_parent = xParent;
070: this .pem_child = xChild;
071: this .pem_useReg = true;
072:
073: return;
074: }
075:
076: public UnObjAddListener(String xParent, String xChild,
077: boolean xUseRegistry, int x, int y, int h, int w,
078: String xAlign) {
079: this .pem_parent = xParent;
080: this .pem_child = xChild;
081: this .pem_useReg = xUseRegistry;
082:
083: this .pem_x = x;
084: this .pem_y = y;
085: this .pem_h = h;
086: this .pem_w = w;
087: this .pem_align = xAlign;
088:
089: return;
090: }
091:
092: public UnObjAddListener(String xParent, String xChild,
093: boolean xUseRegistry, boolean xMulti, int x, int y, int h,
094: int w, String xAlign) {
095: this .pem_parent = xParent;
096: this .pem_child = xChild;
097: this .pem_useReg = xUseRegistry;
098: this .pem_multiAdd = xMulti;
099:
100: this .pem_x = x;
101: this .pem_y = y;
102: this .pem_h = h;
103: this .pem_w = w;
104: this .pem_align = xAlign;
105:
106: return;
107: }
108:
109: public UnObjAddListener(String xParent, String xChild, int x,
110: int y, int h, int w, String xAlign) {
111: this .pem_parent = xParent;
112: this .pem_child = xChild;
113: this .pem_useReg = true;
114:
115: this .pem_x = x;
116: this .pem_y = y;
117: this .pem_h = h;
118: this .pem_w = w;
119: this .pem_align = xAlign;
120:
121: return;
122: }
123:
124: public void pcmf_execListener(UnComponent xParam) throws Exception {
125: UnComponent l_parent;
126: UnComponent l_child;
127:
128: if (this .pem_useReg) {
129: l_parent = (UnComponent) KeRegisteredObject
130: .pcmf_getObjByName(pem_parent);
131: l_child = (UnComponent) KeRegisteredObject
132: .pcmf_getObjByName(pem_child);
133: } else {
134: l_parent = (UnComponent) xParam.pcmf_getAppl()
135: .pcmf_getUnComponent().pcmf_getByPath(pem_parent);
136: l_child = (UnComponent) xParam.pcmf_getAppl()
137: .pcmf_getUnComponent().pcmf_getByPath(pem_child);
138: }
139: if (l_parent != null && l_child != null) {
140: if (l_parent.pcmf_getSubNode(l_child.pcmf_getName()) == null
141: || this .pem_multiAdd) {
142: l_parent.pcmf_addNode(l_child.pcmf_getName(), l_child);
143: if (this .pem_x != -1 && this .pem_y != -1) {
144: if (l_parent instanceof IUnContainer)
145: ((IUnPanel) l_parent).pcmf_setGuiObjPosition(
146: ((UnComponent) l_child).pcmf_getName(),
147: this .pem_x, this .pem_y, this .pem_w,
148: this .pem_h, this .pem_align);
149: else if (l_parent instanceof IUnApplication)
150: ((IUnApplication) l_parent)
151: .pcmf_setGuiObjPosition(
152: ((UnComponent) l_child)
153: .pcmf_getName(),
154: this .pem_x, this .pem_y,
155: this .pem_w, this .pem_h,
156: this .pem_align);
157: else
158: KeLog
159: .pcmf_log(
160: "ug2t",
161: "cannot set position, parent object is no container or application: ",
162: this , KeLog.ERROR);
163: }
164:
165: } else {
166: l_parent.pcmf_removeNode(l_child.pcmf_getName());
167: l_parent.pcmf_addNode(l_child.pcmf_getName(), l_child);
168: if (this .pem_x != -1 && this .pem_y != -1) {
169: if (l_parent instanceof IUnContainer)
170: ((IUnPanel) l_parent).pcmf_setGuiObjPosition(
171: ((UnComponent) l_child).pcmf_getName(),
172: this .pem_x, this .pem_y, this .pem_w,
173: this .pem_h, this .pem_align);
174: else if (l_parent instanceof IUnApplication)
175: ((IUnApplication) l_parent)
176: .pcmf_setGuiObjPosition(
177: ((UnComponent) l_child)
178: .pcmf_getName(),
179: this .pem_x, this .pem_y,
180: this .pem_w, this .pem_h,
181: this .pem_align);
182: else
183: KeLog
184: .pcmf_log(
185: "ug2t",
186: "cannot set position, parent object is no container or application: ",
187: this , KeLog.ERROR);
188: }
189:
190: KeLog.pcmf_log(xParam.pcmf_getAppl()
191: .pcmf_getUnComponent().pcmf_getName(),
192: "change object: " + pem_parent + ", "
193: + pem_child + " name is not unique",
194: this , KeLog.MESSAGE);
195: }
196:
197: l_parent.pcmf_repaint();
198: } else
199: KeLog.pcmf_log(xParam.pcmf_getAppl().pcmf_getUnComponent()
200: .pcmf_getName(), "cannot find parent or child: "
201: + pem_parent + ", " + pem_child, this , KeLog.ERROR);
202: }
203:
204: /**
205: * <p>
206: * Does...
207: * </p>
208: * <p>
209: *
210: * @return a Type with
211: * </p>
212: * <p>
213: * @param
214: * </p>
215: */
216: public Object pcmf_execObj(Object xObj) {
217: try {
218: this .pcmf_execListener((UnComponent) xObj);
219: } catch (Exception e) {
220: KeLog.pcmf_log("ug2t",
221: "maybe cannot find parent or child (Exception): "
222: + pem_parent + ", " + pem_child, this,
223: KeLog.ERROR);
224: }
225:
226: return (xObj);
227: }
228: }
|