KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > packager > listeners > AddFolder_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.
6  *
7  * Contributors:
8  * Dirk von der Weiden - initial API and implementation
9  *
10  * Created on 04.04.2004
11  *
12  * date: 04.04.2004
13  * project: WiSer DeployTool
14  *
15  *******************************************************************************/

16
17 package packager.listeners;
18
19 import Jmc.baseGui.*;
20 import Jmc.baseTools.*;
21 import Jmc.commonGui.*;
22
23 import packager.model.*;
24
25 /**
26  * @author Dirk
27  *
28  * date: 13.04.2004
29  * project: DeployTool
30  *
31  * <p>
32  * This listener's execution method is called when the button "create folder" is pressed or the
33  * context menu-entry is called and a new folder name has been typed in.
34  * Everything what happens here is quite similar to the description in "AddFile_li.java".
35  * </p>
36  */

37 /* Corresponding XML definition code:
38  * ----------------------------------
39  *
40  * The following lines from the xml_gui/packager.xml file show the corresponding configuration:
41  *
42  * <optDlg name = "opt2" submit="true" register = "optDlg2">
43  * <srvListener object = "AddFolder_listener"/>
44  * </optDlg>
45  *
46  * The instantiation of the listener is done as described in "AddFile_li.java"
47  */

48 public class AddFolder_li implements base_guiListener
49 {
50   /**
51        * <p>
52        * Execution method of the listener
53        * </p><p>
54        *
55        * </p><p>
56        * @param xParam widget which provided the event
57        * </p>
58        */

59     public void pcmf_execListener(base_guiObj xParam) throws Exception JavaDoc
60     {
61     base_treeView_if l_targetTree = (base_treeView_if)base_registredObject.pcmf_getObjByName("targetTree");
62     base_optionDlg_if l_dlg = (base_optionDlg_if)base_registredObject.pcmf_getObjByName("optDlg2");
63     base_appl_if l_appl = xParam.pcmf_getAppl();
64     String JavaDoc l_name = l_dlg.pcmf_getGuiObj().pcmf_getValue().toString();
65     MainModel l_model = (MainModel)xParam.pcmf_getAppl().pcmf_getGuiObj().pcmf_getModel();
66
67     try
68     {
69       base_treeNode l_node = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("newfolder", false);
70       base_treeNode l_select = (base_treeNode)l_targetTree.pcmf_getValue();
71       if (l_select != null)
72       {
73         if (l_select.pcmf_getSubNode(l_name) != null)
74         {
75           base_treeNode l_message = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("errorMsg", false);
76           l_message.pcmf_setName("insert");
77           l_message.pcmf_setValue("similar node is already available");
78
79           l_model.pcmf_addMessage(l_message);
80           return;
81         }
82         l_node.pcmf_setValue("new folder://" + l_model.pcmf_getTarget().pcmf_getValue().toString() + "\\" + l_name);
83         l_select.pcmf_addNode(l_name, l_node);
84         l_select.pcmf_unhide();
85       };
86
87       l_targetTree.pcmf_repaint();
88     }
89     catch (Exception JavaDoc e)
90     {
91       base_treeNode l_message = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("errorMsg", false);
92       l_message.pcmf_setName("selection");
93       l_message.pcmf_setValue("no insert parent selected");
94
95       l_model.pcmf_addMessage(l_message);
96       return;
97     };
98     }
99 }
100
Popular Tags