KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > helloworld > listeners > HelloWorldRemove_li


1 /*******************************************************************************
2  * Copyright (c) 2004, Dirk von der Weiden.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * Dirk von der Weiden - initial API and implementation
10  *
11  * Created on 13.02.2005
12  *
13  * date: 13.02.2005
14  * project: WiSer-HelloWorld
15  *
16  * *******************************************************************************/

17
18 package helloworld.listeners;
19
20 import Jmc.baseGui.*;
21 import Jmc.commonGui.*;
22 import Jmc.baseTools.*;
23
24 /**
25  * @author Dirk
26  *
27  * date: 13.02.2005
28  *
29  * <p>
30  * Purpose: The listener removes the selected node from the tree.
31  * </p>
32  */

33 public class HelloWorldRemove_li implements base_guiListener
34 {
35     /**
36          * <p>
37          * Is called by the framework whenever an event has been fired by the corresponding widget
38          * </p><p>
39          *
40          * </p><p>
41          * @param Widget which generated the event
42          * </p>
43          */

44     public void pcmf_execListener(base_guiObj xParam) throws Exception JavaDoc
45     {
46     // get all relevant widgets from the registry
47
base_treeView_if l_tree = (base_treeView_if) base_registredObject.pcmf_getObjByName("atree");
48
49     // get selected node in the tree
50
base_treeNode l_selected = (base_treeNode)l_tree.pcmf_getValue();
51     
52     // sorry no selection: return
53
if (l_selected == null)
54       return;
55
56     // get parent node of the selected node
57
base_treeNode l_parent = l_selected.pcmf_getParentNode();
58         
59     // root node can not be removed
60
if (l_selected != l_tree.pcmf_getRoot())
61       l_parent.pcmf_removeNode(l_selected);
62     else
63       return;
64     
65     // delete removed node from registry
66
l_selected.pcmf_delete();
67     
68     // be shure that the tree repaints
69
l_tree.pcmf_repaint();
70     
71     return;
72     }
73 }
74
Popular Tags