1 28 package Jmc.plugins.serverFileChooser; 29 30 import java.io.File ; 31 import java.util.ArrayList ; 32 33 import Jmc.baseGui.base_guiListener; 34 import Jmc.baseGui.base_guiObj; 35 import Jmc.baseTools.base_environment; 36 import Jmc.baseTools.base_log; 37 import Jmc.baseTools.base_registredObject; 38 import Jmc.baseTools.base_table; 39 import Jmc.baseTools.base_treeNode; 40 import Jmc.commonGui.base_table_if; 41 import Jmc.commonGui.base_inputField_if; 42 import Jmc.commonGui.base_text_if; 43 import Jmc.commonGui.base_button_if; 44 import Jmc.commonGui.base_treeView_if; 45 import Jmc.commonGui.simpleNode; 46 import Jmc.plugins.base_aggregatedPlugin; 47 import Jmc.model.base_modelValue_if; 48 49 public class ServerFileChooser extends base_aggregatedPlugin 50 { 51 private base_treeNode pem_tmpnodes = null; 52 private simpleNode pem_root = null; 53 private String pem_rootDir = null; 54 55 private void pemf_addTmpNode(base_treeNode xNode) 56 { 57 this.pem_tmpnodes.pcmf_addNode(xNode.pcmf_getName(), xNode); 58 }; 59 60 private void pemf_removeTmpNode(base_treeNode xNode) 61 { 62 this.pem_tmpnodes.pcmf_removeNode(xNode); 63 }; 64 65 private void pemf_deleteTmpNodes() 66 { 67 this.pem_tmpnodes.pcmf_clearAndRelease(); 68 }; 69 70 80 public class SelectSource_li implements base_guiListener 81 { 82 private base_table pem_tableValues = null; 83 84 93 public void pcmf_execListener(base_guiObj xParam) throws Exception 94 { 95 base_treeView_if l_tree = (base_treeView_if)xParam; 97 base_table_if l_table = (base_table_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_Split").pcmf_getSubNode("ServerFileChooser_FormR").pcmf_getSubNode("ServerFileChooser_Table"); 98 base_text_if l_label = (base_text_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_TopForm").pcmf_getSubNode("ServerFileChooser_TopLabel"); 99 100 if (l_tree.pcmf_getToggled() != null || l_tree.pcmf_getValue() instanceof base_treeNode == false) 102 return; 103 104 if (this.pem_tableValues != null) 106 this.pem_tableValues.pcmf_delete(); 107 108 ServerFileChooser.this.pemf_deleteTmpNodes(); 110 111 pem_tableValues = new base_table(0,2); 113 File l_file = (File )((base_treeNode)l_tree.pcmf_getValue()).pcmf_getValue(); 114 l_label.pcmf_getGuiObj().pcmf_setValue("path: " + l_file.getAbsolutePath()); 115 116 File l_subs[] = l_file.listFiles(); 118 for (int i = 0; i < l_subs.length; i++) 119 { 120 if (l_subs[i].isDirectory()) 121 { 122 String l_fname = l_subs[i].getAbsolutePath(); 123 124 ArrayList l_row = new ArrayList (2); 125 base_treeNode l_modelV = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_folder")).pcmf_cloneModelValue(true, false); 127 l_modelV.pcmf_setName(l_fname); 128 l_row.add(l_modelV); 129 l_row.add("0"); 130 this.pem_tableValues.pcmf_addRowArrayList(l_row); 131 } 132 else 133 { 134 ArrayList l_row = new ArrayList (2); 135 String l_fname = l_subs[i].getAbsolutePath(); 136 String l_flen = Long.toString(l_subs[i].length()); 137 138 if (l_subs[i].getName().toLowerCase().indexOf(".class") != -1) 139 { 140 base_treeNode l_modelV = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_class")).pcmf_cloneModelValue(true, false); 141 l_modelV.pcmf_setName(l_fname); 142 ServerFileChooser.this.pemf_addTmpNode(l_modelV); 143 l_row.add(l_modelV); 144 } 145 else 146 if (l_subs[i].getName().toLowerCase().indexOf(".xml") != -1) 147 { 148 base_treeNode l_modelV = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_xml")).pcmf_cloneModelValue(true, false); 149 l_modelV.pcmf_setName(l_fname); 150 ServerFileChooser.this.pemf_addTmpNode(l_modelV); 151 l_row.add(l_modelV); 152 } 153 else 154 if (l_subs[i].getName().toLowerCase().indexOf(".java") != -1) 155 { 156 base_treeNode l_modelV = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_java")).pcmf_cloneModelValue(true, false); 157 l_modelV.pcmf_setName(l_fname); 158 ServerFileChooser.this.pemf_addTmpNode(l_modelV); 159 l_row.add(l_modelV); 160 } 161 else 162 if (l_subs[i].getName().toLowerCase().indexOf(".jar") != -1 || 163 l_subs[i].getName().toLowerCase().indexOf(".war") != -1 || 164 l_subs[i].getName().toLowerCase().indexOf(".ear") != -1 || 165 l_subs[i].getName().toLowerCase().indexOf(".zip") != -1) 166 { 167 base_treeNode l_modelV = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_archive")).pcmf_cloneModelValue(true, false); 168 l_modelV.pcmf_setName(l_fname); 169 ServerFileChooser.this.pemf_addTmpNode(l_modelV); 170 l_row.add(l_modelV); 171 } 172 else 173 { 174 base_treeNode l_modelV = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_other")).pcmf_cloneModelValue(true, false); 175 l_modelV.pcmf_setName(l_fname); 176 ServerFileChooser.this.pemf_addTmpNode(l_modelV); 177 l_row.add(l_modelV); 178 } 179 180 l_row.add(l_flen); 181 this.pem_tableValues.pcmf_addRowArrayList(l_row); 182 } 183 } 184 l_table.pcmf_setRowsOnly(pem_tableValues); 186 } 187 } 188 189 199 public class SelectFile_li implements base_guiListener 200 { 201 210 public void pcmf_execListener(base_guiObj xParam) throws Exception 211 { 212 base_inputField_if l_inp = (base_inputField_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_SelFile"); 214 l_inp.pcmf_setValue(((base_table_if)xParam).pcmf_getSelectedTableRow().get(0)); 215 } 216 } 217 218 228 public class Reload_li implements base_guiListener 229 { 230 239 public void pcmf_execListener(base_guiObj xParam) throws Exception 240 { 241 ServerFileChooser.this.pcmf_reload(); 242 base_log.pcmf_log(ServerFileChooser.this.pcmf_getPluginObject().pcmf_getAppl().pcmf_getGuiObj().pcmf_getName(), "ServerFileChooser reloaded", this, base_log.MESSAGE); 243 } 244 } 245 246 256 public class SelectBut_li implements base_guiListener 257 { 258 267 public void pcmf_execListener(base_guiObj xParam) throws Exception 268 { 269 base_inputField_if l_inp = (base_inputField_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_SelFile"); 271 272 if (xParam.pcmf_getName().equals("ServerFileChooser_SBut")) 273 ServerFileChooser.this.pcmf_getPluginObject().pcmf_setValue(l_inp.pcmf_getValue()); 274 else 275 ServerFileChooser.this.pcmf_getPluginObject().pcmf_setValue(""); 276 277 ServerFileChooser.this.pcmf_getPluginObject().pcmf_dispatchEvent(); 279 } 280 } 281 282 287 public void pcmf_addCancelListener (base_guiListener xListen) 288 { 289 base_button_if l_canBut = (base_button_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_CBut"); 290 l_canBut.pcmf_addListener(xListen); 291 } 292 293 298 public void pcmf_addSelectListener (base_guiListener xListen) 299 { 300 base_button_if l_selBut = (base_button_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_SBut"); 301 l_selBut.pcmf_addListener(xListen); 302 } 303 304 309 public void pcmf_setRootDir(String xDir) 310 { 311 try 312 { 313 this.pem_rootDir = xDir; 314 this.pcmf_reload(); 315 } 316 catch (Exception e) 317 { 318 base_log.pcmf_log(this.pcmf_getPluginObject().pcmf_getAppl().pcmf_getGuiObj().pcmf_getName(), "ServerFileChooser cannot set rootDir: " + xDir, this, base_log.FATAL); 320 } 321 } 322 323 326 public void pcmf_reload() throws Exception 327 { 328 base_treeView_if l_sourceTree = (base_treeView_if)this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_Split").pcmf_getSubNode("ServerFileChooser_FormL").pcmf_getSubNode("ServerFileChooser_Tree"); 330 base_table_if l_table = (base_table_if)ServerFileChooser.this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_Split").pcmf_getSubNode("ServerFileChooser_FormR").pcmf_getSubNode("ServerFileChooser_Table"); 331 332 this.pemf_deleteTmpNodes(); 333 334 File l_root = new File (base_environment.pcmf_buildPath(pem_rootDir)); 337 338 this.pem_root.pcmf_clearAndRelease(); 339 this.pcmf_buildTree(l_sourceTree.pcmf_getRoot(), l_root, this.pcmf_getPluginObject()); 341 342 l_sourceTree.pcmf_getRoot().pcmf_hideLevel(1); 343 l_table.pcmf_setRowsOnly(new base_table(0,2)); 344 345 l_sourceTree.pcmf_repaint(); 347 l_table.pcmf_repaint(); 348 } 349 350 356 public void pcmf_initPlugin(base_guiObj xPl, Object xParam, String xRoot) 357 { 358 super.pcmf_initPlugin(xPl, xParam, xRoot); 359 360 try 361 { 362 this.pem_root = new simpleNode("root"); 363 this.pem_tmpnodes = new base_treeNode("",null); 364 365 base_treeView_if l_sourceTree = (base_treeView_if)this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_Split").pcmf_getSubNode("ServerFileChooser_FormL").pcmf_getSubNode("ServerFileChooser_Tree"); 367 base_table_if l_table = (base_table_if)this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_Split").pcmf_getSubNode("ServerFileChooser_FormR").pcmf_getSubNode("ServerFileChooser_Table"); 368 base_button_if l_selBut = (base_button_if)this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_SBut"); 369 base_button_if l_canBut = (base_button_if)this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_CBut"); 370 base_button_if l_relBut = (base_button_if)this.pcmf_getPluginObject().pcmf_getSubNode("ServerFileChooser_ButForm").pcmf_getSubNode("ServerFileChooser_RBut"); 371 372 l_sourceTree.pcmf_addListener(new SelectSource_li()); 373 l_table.pcmf_addListener(new SelectFile_li()); 374 l_table.pcmf_addListener(new SelectFile_li()); 375 l_canBut.pcmf_addListener(new SelectBut_li()); 376 l_selBut.pcmf_addListener(new SelectBut_li()); 377 l_relBut.pcmf_addListener(new Reload_li()); 378 379 this.pem_rootDir =(String )base_environment.pcmf_getParameter(this.pcmf_buildPath("xml_parameter/parfile.xml"), "ServerFileCooser", "rootDir"); 380 l_sourceTree.pcmf_setRoot(this.pem_root); 381 this.pcmf_reload(); 382 383 base_log.pcmf_log(xPl.pcmf_getAppl().pcmf_getGuiObj().pcmf_getName(), "ServerFileChooser startup complete - rootDir: " + this.pem_rootDir, this, base_log.MESSAGE); 385 } 386 catch (Exception e) 387 { 388 base_log.pcmf_logException(xPl.pcmf_getAppl().pcmf_getGuiObj().pcmf_getName(), this, e); 390 base_log.pcmf_log(xPl.pcmf_getAppl().pcmf_getGuiObj().pcmf_getName(), "ServerFileChooser startup error", this, base_log.FATAL); 391 } 392 } 393 394 405 public void pcmf_buildTree(base_treeNode xRoot, File xFile, base_guiObj xPl) 406 { 407 File l_subs[] = xFile.listFiles(); 408 if (l_subs == null) 409 return; 410 411 for (int i = 0; i < l_subs.length; i++) 412 { 413 if (l_subs[i].isDirectory()) 414 { 415 base_treeNode l_mod = (base_treeNode)((base_modelValue_if)base_registredObject.pcmf_getObjByName("sfilech_model_folder")).pcmf_cloneModelValue(true, false); 416 l_mod.pcmf_setValue(l_subs[i]); 417 xRoot.pcmf_addNode(l_subs[i].getName(), l_mod); 418 this.pcmf_buildTree(l_mod, l_subs[i], xPl); 419 } 420 } 421 } 422 423 public void pcmf_delete() throws Exception 424 { 425 this.pemf_deleteTmpNodes(); 426 this.pem_root.pcmf_delete(); 427 super.pcmf_delete(); 428 } 429 } 430 | Popular Tags |