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