1 19 package org.openharmonise.him.swing.resourcetree.formresourcetree; 20 21 import java.util.*; 22 23 import org.openharmonise.him.swing.resourcetree.*; 24 import org.openharmonise.vfs.*; 25 26 27 35 public class FormResourceTree extends ResourceTree { 36 37 40 private boolean m_bIsMultiSelect = true; 41 42 45 private List m_pathValues = new ArrayList(); 46 47 50 private Map m_cells = new TreeMap(); 51 52 55 private List m_formResoruceTreeListeners = new ArrayList(); 56 57 60 private boolean m_bAllowVirtualDirectorySelect = false; 61 62 67 public FormResourceTree(List pathValues) { 68 super(); 69 this.m_pathValues.addAll(pathValues); 70 } 71 72 78 public FormResourceTree(boolean bUseScrollPane, List pathValues) { 79 super(bUseScrollPane); 80 this.m_pathValues.addAll(pathValues); 81 } 82 83 86 protected void setup() { 87 super.setup(); 88 89 super.m_tree.setCellRenderer( new FormTreeCellRenderer(this) ); 90 91 FormTreeMouseListener listener = new FormTreeMouseListener(this); 92 super.m_tree.addTreeSelectionListener(listener); 93 super.m_tree.setSelectionModel(listener); 94 } 95 96 101 public boolean isMultiSelect() { 102 return this.m_bIsMultiSelect; 103 } 104 105 110 public void setIsMultiSelect(boolean bIsMultiSelect) { 111 this.m_bIsMultiSelect = bIsMultiSelect; 112 super.m_tree.setCellRenderer( new FormTreeCellRenderer(this) ); 113 } 114 115 120 public List getPathValues() { 121 return this.m_pathValues; 122 } 123 124 129 public void addPathValue(String sFullPath) { 130 this.m_pathValues.add(sFullPath); 131 this.repaint(); 132 } 133 134 139 public void removePathValue(String sFullPath) { 140 this.m_pathValues.remove(sFullPath); 141 this.repaint(); 142 } 143 144 149 protected void addCell(FormTreeCell cell) { 150 this.m_cells.put(cell.getFullPath(), cell); 151 } 152 153 158 protected List getCellPaths() { 159 return new ArrayList(this.m_cells.keySet()); 160 } 161 162 167 protected void cellSelected(String sFullPath) { 168 169 Iterator itorTemp = this.m_cells.keySet().iterator(); 170 while (itorTemp.hasNext()) { 171 String sPath = (String ) itorTemp.next(); 172 } 173 174 if(!this.isMultiSelect()) { 175 this.m_pathValues.clear(); 176 } 177 if(!this.m_pathValues.contains(sFullPath)) { 178 this.m_pathValues.add(sFullPath); 179 this.firePathValuesChanged(); 180 } 181 182 this.m_tree.revalidate(); 183 this.m_tree.repaint(); 184 } 185 186 191 protected void cellUnSelected(String sFullPath) { 192 if(this.m_pathValues.contains(sFullPath)) { 193 this.m_pathValues.remove(sFullPath); 194 this.firePathValuesChanged(); 195 } 196 } 197 198 204 protected FormTreeCell getCellForPath(String sFullPath) { 205 return (FormTreeCell) this.m_cells.get(sFullPath); 206 } 207 208 213 public void addFormResourceTreeListener(FormResourceTreeListener listener) { 214 this.m_formResoruceTreeListeners.add(listener); 215 } 216 217 222 public void removeFormResourceTreeListener(FormResourceTreeListener listener) { 223 this.m_formResoruceTreeListeners.remove(listener); 224 } 225 226 231 private void firePathValuesChanged() { 232 Iterator itor = this.m_formResoruceTreeListeners.iterator(); 233 while (itor.hasNext()) { 234 FormResourceTreeListener listener = (FormResourceTreeListener) itor.next(); 235 listener.pathValuesChanged(new ArrayList(this.m_pathValues)); 236 } 237 } 238 239 244 public void setAllowVirtualDirectorySelect(boolean bAllow) { 245 this.m_bAllowVirtualDirectorySelect = bAllow; 246 } 247 248 253 public boolean isAllowVirtualDirectorySelect() { 254 return this.m_bAllowVirtualDirectorySelect; 255 } 256 257 260 protected AbstractVirtualFileSystem getVFS() { 261 return super.getVFS(); 262 } 263 } 264 | Popular Tags |