01: // @@
02: // @@
03: /*
04: * Wi.Ser Framework
05: *
06: * Version: 1.8.1, 20-September-2007
07: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library located in LGPL.txt in the
21: * license directory; if not, write to the
22: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23: * Boston, MA 02111-1307, USA.
24: *
25: * If this agreement does not cover your requirements, please contact us
26: * via email to get detailed information about the commercial license
27: * or our service offerings!
28: *
29: */
30: // @@
31: package de.ug2t.unifiedGui.listener;
32:
33: import de.ug2t.kernel.*;
34: import de.ug2t.unifiedGui.*;
35: import de.ug2t.unifiedGui.interfaces.*;
36:
37: public class UnTreeMoveNodeListener implements IUnGuiEventListener {
38: private int pem_idx = 0;
39: private IUnTreeView pem_tree = null;
40:
41: public UnTreeMoveNodeListener(int xIdx, IUnTreeView xTree) {
42: this .pem_idx = xIdx;
43: this .pem_tree = xTree;
44:
45: return;
46: }
47:
48: public void pcmf_execListener(UnComponent xParam) throws Exception {
49: try {
50: KeTreeNode l_sel = (KeTreeNode) this .pem_tree
51: .pcmf_getUnComponent().pcmf_getValue();
52: KeTreeNode l_parent = l_sel.pcmf_getParentNode();
53: if (l_parent == null)
54: return;
55:
56: int idx = l_parent.pcmf_indexOf(l_sel);
57:
58: l_parent.pcmf_removeNode(l_sel);
59:
60: if (idx + this .pem_idx < 0) {
61: l_parent.pcmf_addNode(l_sel.pcmf_getName(), l_sel, 0);
62: } else if (idx + this .pem_idx >= l_parent
63: .pcmf_getChildCount()) {
64: l_parent.pcmf_addNode(l_sel.pcmf_getName(), l_sel,
65: l_parent.pcmf_getChildCount());
66: } else {
67: l_parent.pcmf_addNode(l_sel.pcmf_getName(), l_sel, idx
68: + this .pem_idx);
69: }
70:
71: this .pem_tree.pcmf_getUnComponent().pcmf_repaint();
72: } catch (Exception e) {
73: KeLog.pcmf_logException(xParam.pcmf_getAppl()
74: .pcmf_getUnComponent().pcmf_getName(), this , e);
75: KeLog.pcmf_log(xParam.pcmf_getAppl().pcmf_getUnComponent()
76: .pcmf_getName(), "error moving tree-node", this,
77: KeLog.ERROR);
78: }
79: }
80:
81: }
|