1 package com.genimen.djeneric.tools.generator.tree; 2 3 import java.util.ArrayList ; 4 5 import javax.swing.ImageIcon ; 6 7 import com.genimen.djeneric.repository.exceptions.DjenericException; 8 import com.genimen.djeneric.tools.generator.Generator; 9 import com.genimen.djeneric.tools.generator.util.ProjectProperties; 10 import com.genimen.djeneric.tools.generator.util.Template; 11 import com.genimen.djeneric.tools.generator.util.TemplateSetManager; 12 import com.genimen.djeneric.tools.specifier.tree.DjenericTreeNode; 13 14 public class GlobalTemplatesFolder extends DjenericTreeNode 15 { 16 private static final long serialVersionUID = 1L; 17 TemplateSetManager _templateSetManager; 18 ProjectProperties _projectProps; 19 20 public GlobalTemplatesFolder(TemplateSetManager templateSetManager, ProjectProperties projectProps) 21 { 22 _templateSetManager = templateSetManager; 23 _projectProps = projectProps; 24 } 25 26 public String toString() 27 { 28 return "Global templates"; 29 } 30 31 public void reload() throws DjenericException 32 { 33 _alreadyLoaded = false; 34 expandNode(); 35 } 36 37 public void expandNode() throws DjenericException 38 { 39 if (_alreadyLoaded) 40 { 41 return; 42 } 43 removeAllChildren(); 44 Template[] tpls = _templateSetManager.getTemplates(_projectProps.getTemplateSets()); 45 for (int i = 0; i < tpls.length; i++) 46 { 47 if (!tpls[i].isRootBased()) 48 { 49 insertAsChild(new GlobalTemplateNode(tpls[i])); 50 } 51 } 52 53 getModel().nodeStructureChanged(this); 54 _alreadyLoaded = true; 55 } 56 57 public ImageIcon getImageIcon() 58 { 59 return Generator.getImageIcon("globaltemplatesfolder.gif"); 60 } 61 62 public void delete() throws Exception 63 { 64 } 65 66 public boolean canDelete() 67 { 68 return false; 69 } 70 71 public boolean canCreate() 72 { 73 return false; 74 } 75 76 public boolean canFilter() 77 { 78 return false; 79 } 80 81 public boolean canEdit() 82 { 83 return false; 84 } 85 86 public void filter() 87 { 88 } 89 90 public GlobalTemplateNode[] getChildNodes() throws Exception 91 { 92 expandNode(); 93 ArrayList result = new ArrayList (); 94 for (int i = 0; i < getChildCount(); i++) 95 result.add(getChildAt(i)); 96 return (GlobalTemplateNode[]) result.toArray(new GlobalTemplateNode[0]); 97 } 98 99 } | Popular Tags |