1 package com.opensymphony.workflow.loader; 2 3 import java.util.List ; 4 import java.util.ArrayList ; 5 import java.io.PrintWriter ; 6 7 import org.w3c.dom.Element ; 8 9 13 public class ConfigFunctionDescriptor extends FunctionDescriptor implements ArgsAware 14 { 15 protected String plugin; 16 protected String description; 17 protected String displayName; 18 protected List modifiableArgs = new ArrayList (); 19 private PaletteDescriptor palette; 20 21 public ConfigFunctionDescriptor(PaletteDescriptor palette) 22 { 23 this.palette = palette; 24 } 25 26 public ConfigFunctionDescriptor(PaletteDescriptor palette, Element function) 27 { 28 this.palette = palette; 29 init(function); 30 } 31 32 public ConfigFunctionDescriptor(ConfigFunctionDescriptor other) 33 { 34 type = other.getType(); 35 plugin = other.getPlugin(); 36 name = other.getName(); 37 args.putAll(other.getArgs()); 38 displayName = other.displayName; 39 description = other.description; 40 modifiableArgs = other.modifiableArgs; 41 palette = other.palette; 42 } 43 44 public PaletteDescriptor getPalette() 45 { 46 return palette; 47 } 48 49 public void setPalette(PaletteDescriptor palette) 50 { 51 this.palette = palette; 52 } 53 54 public void writeXML(PrintWriter writer, int indent) 55 { 56 throw new UnsupportedOperationException (); 57 } 58 59 protected void init(Element function) 60 { 61 type = function.getAttribute("type"); 62 63 List args = XMLUtil.getChildElements(function, "arg"); 64 for(int l = 0; l < args.size(); l++) 65 { 66 Element arg = (Element )args.get(l); 67 this.args.put(arg.getAttribute("name"), XMLUtil.getText(arg)); 68 if("true".equals(arg.getAttribute("modifiable"))) 69 { 70 modifiableArgs.add(arg.getAttribute("name")); 71 } 72 } 73 74 plugin = XMLUtil.getChildText(function, "plugin"); 75 name = XMLUtil.getChildText(function, "name"); 76 } 77 78 public boolean isArgModifiable(String name) 79 { 80 return modifiableArgs.contains(name); 81 } 82 83 public String getDescription() 84 { 85 return description; 86 } 87 88 public String getPlugin() 89 { 90 return plugin; 91 } 92 93 public void setDescription(String string) 94 { 95 description = string; 96 } 97 98 public void setPlugin(String string) 99 { 100 plugin = string; 101 } 102 103 public String getDisplayName() 104 { 105 return displayName; 106 } 107 108 public void setDisplayName(String displayName) 109 { 110 this.displayName = displayName; 111 } 112 113 public String toString() 114 { 115 return displayName!=null ? displayName : name; 116 } 117 } 118 | Popular Tags |