KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > packager > listeners > SelectSource_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 import java.io.*;
23 import java.util.*;
24
25 import packager.model.*;
26
27   /**
28    * @author Dirk
29    *
30    * date: 13.04.2004
31    * project: DeployTool
32    *
33    * <p>
34    * This listener's execution method is called whenever a selection on the source tree-view has been made.
35    * </p>
36    */

37 public class SelectSource_li implements base_guiListener
38 {
39   private base_table pem_tableValues = null;
40
41   /**
42        * <p>
43        * Execution method of the listener
44        * </p><p>
45        *
46        * </p><p>
47        * @param xParam widget which provided the event
48        * </p>
49        */

50     public void pcmf_execListener(base_guiObj xParam) throws Exception JavaDoc
51     {
52     // get all relevant objects
53
base_treeView_if l_tree = (base_treeView_if)xParam;
54     base_table_if l_table = (base_table_if)base_registredObject.pcmf_getObjByName("sourceTable");
55     base_text_if l_label = (base_text_if)base_registredObject.pcmf_getObjByName("sourceLabel");
56     MainModel l_model = (MainModel)xParam.pcmf_getAppl().pcmf_getGuiObj().pcmf_getModel();
57     base_appl_if l_appl = xParam.pcmf_getAppl();
58         
59     // test whether a selection or an expansion event occurred - only selection is processed here
60
if (l_tree.pcmf_getToggled() != null || l_tree.pcmf_getValue() instanceof base_treeNode == false)
61       return;
62    
63     // cleanup table
64
if (this.pem_tableValues != null)
65       this.pem_tableValues.pcmf_delete();
66     
67     // cleanup registry
68
l_model.pcmf_deleteTmpNodes();
69       
70     // create new table model
71
pem_tableValues = new base_table(0,2);
72     File l_file = (File)((base_treeNode)l_tree.pcmf_getValue()).pcmf_getValue();
73     l_label.pcmf_getGuiObj().pcmf_setValue("Source: " + l_file.getAbsolutePath());
74     
75     // fill new table model
76
File l_subs[] = l_file.listFiles();
77     for (int i = 0; i < l_subs.length; i++)
78     {
79       if (l_subs[i].isDirectory())
80       {
81         String JavaDoc l_fname = l_subs[i].getAbsolutePath();
82
83         ArrayList l_row = new ArrayList(2);
84         // for the meaning this model things of have a look at "AddFile_li.java"
85
base_treeNode l_modelV = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("folder", false);
86         l_modelV.pcmf_setName(l_fname);
87         l_row.add(l_modelV);
88         l_row.add("Directory");
89         this.pem_tableValues.pcmf_addRowArrayList(l_row);
90       }
91       else
92       {
93         ArrayList l_row = new ArrayList(2);
94         String JavaDoc l_fname = l_subs[i].getAbsolutePath();
95         
96         if (l_subs[i].getName().toLowerCase().indexOf(".class") != -1)
97         {
98           base_treeNode l_modelV = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("classFile", false);
99           l_modelV.pcmf_setName(l_fname);
100           l_model.pcmf_addTmpNode(l_modelV);
101           l_row.add(l_modelV);
102         }
103         else
104         if (l_subs[i].getName().toLowerCase().indexOf(".xml") != -1)
105         {
106           base_treeNode l_modelV = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("xmlFile", false);
107           l_modelV.pcmf_setName(l_fname);
108           l_model.pcmf_addTmpNode(l_modelV);
109           l_row.add(l_modelV);
110         }
111         else
112         if (l_subs[i].getName().toLowerCase().indexOf(".java") != -1)
113         {
114           base_treeNode l_modelV = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("javaFile", false);
115           l_modelV.pcmf_setName(l_fname);
116           l_model.pcmf_addTmpNode(l_modelV);
117           l_row.add(l_modelV);
118         }
119         else
120         if (l_subs[i].getName().toLowerCase().indexOf(".jar") != -1 ||
121             l_subs[i].getName().toLowerCase().indexOf(".war") != -1 ||
122             l_subs[i].getName().toLowerCase().indexOf(".ear") != -1 ||
123             l_subs[i].getName().toLowerCase().indexOf(".zip") != -1)
124         {
125           base_treeNode l_modelV = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("archiveFile", false);
126           l_modelV.pcmf_setName(l_fname);
127           l_model.pcmf_addTmpNode(l_modelV);
128           l_row.add(l_modelV);
129         }
130         else
131         {
132           base_treeNode l_modelV = (base_treeNode)l_appl.pcmf_getGuiObj().pcmf_newModelValue("otherFile", false);
133           l_modelV.pcmf_setName(l_fname);
134           l_model.pcmf_addTmpNode(l_modelV);
135           l_row.add(l_modelV);
136         }
137         
138         l_row.add("File");
139         this.pem_tableValues.pcmf_addRowArrayList(l_row);
140       }
141     }
142     // put table model to table widget
143
l_table.pcmf_setRowsOnly(pem_tableValues);
144     
145     // set source in the main model
146
l_model.pcmf_setSource((base_treeNode)l_tree.pcmf_getValue());
147     }
148 }
149
Popular Tags