1 18 19 package de.gulden.framework.amoda.generic.core; 20 21 import de.gulden.framework.amoda.generic.data.GenericCompositeGroup; 22 import de.gulden.framework.amoda.generic.metadata.*; 23 import de.gulden.framework.amoda.generic.option.*; 24 import de.gulden.framework.amoda.model.behaviour.*; 25 import de.gulden.framework.amoda.model.core.Feature; 26 import de.gulden.framework.amoda.model.interaction.*; 27 import java.lang.*; 28 import java.util.*; 29 30 36 public class GenericFeature extends GenericCompositeGroup implements Feature, Command { 37 38 42 static final String [] FEATURE_MEMBERS = {"command","rule","state","message","dialog","question","feature-group","feature"}; 43 44 public static final Object [][] XML_COLLECTION_ELEMENTS = {{"all",FEATURE_MEMBERS}}; 45 46 public boolean enabled = true; 47 48 public boolean system = false; 49 50 public boolean constant = false; 51 52 public String shortcut = null; 53 54 public String style = null; 55 56 57 61 public boolean isEnabled() { 62 return enabled; 63 } 64 65 public void setEnabled(boolean _enabled) { 66 enabled = _enabled; 67 } 68 69 public Message getMessage(String id) { 70 return (Message)get(id); 71 } 72 73 public Question getQuestion(String id) { 74 return (Question)get(id); 75 } 76 77 public Dialog getDialog(String id) { 78 return (Dialog)get(id); 79 } 80 81 public Command getCommand(String id) { 82 return (Command)get(id); 83 } 84 85 public Rule getRule(String id) { 86 return (Rule)get(id); 87 } 88 89 public State getState(String id) { 90 return null; 92 } 93 94 public boolean isSystem() { 95 return system; 96 } 97 98 public void setSystem(boolean _system) { 99 system = _system; 100 } 101 102 public boolean isConstant() { 103 return constant; 104 } 105 106 public void setConstant(boolean _constant) { 107 constant = _constant; 108 } 109 110 public String getShortcut() { 111 return shortcut; 112 } 113 114 public void setShortcut(String _shortcut) { 115 shortcut = _shortcut; 116 } 117 118 public GenericFeature getByShortcut(String shortcut, boolean recursive) { 119 125 Map children = getAll(GenericFeature.class, recursive); 126 for (Iterator it = children.values().iterator(); it.hasNext(); ) { 127 GenericFeature f = (GenericFeature)it.next(); 128 String s = f.getShortcut(); 129 if (s!=null) { 130 if (shortcut.equals(f.getShortcut())) { 131 return f; 132 } 133 } 134 } 135 return null; 136 } 137 138 public void perform() { 139 for (Iterator it = getAll(de.gulden.framework.amoda.model.behaviour.Command.class, false).values().iterator(); it.hasNext(); ) { 140 de.gulden.framework.amoda.model.behaviour.Command command = (de.gulden.framework.amoda.model.behaviour.Command)it.next(); 141 if (command.getParent()==null) { command.setParent(this); 143 } 144 command.perform(); 145 } 146 } 147 148 public String getStyle() { 149 return style; 150 } 151 152 public void setStyle(String _style) { 153 style = _style; 154 } 155 156 public Properties getStyleAttributes() { 157 String style = getStyle(); 158 if (style != null) { 159 return de.gulden.util.Toolbox.parseKeyValuePairs(style); 160 } else { 161 return new Properties(); 162 } 163 } 164 165 } | Popular Tags |