- Timestamp:
- 07/18/13 23:52:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/test/TestClass.java
r101 r103 7 7 8 8 import com.framsticks.core.ListChange; 9 import com.framsticks.core.ValueChange; 9 10 import com.framsticks.params.EventListener; 10 import com.framsticks.params. EventListeners;11 import com.framsticks.params.SimplePrimitive; 11 12 import com.framsticks.params.SimpleUniqueList; 13 import com.framsticks.params.annotations.AutoAppendAnnotation; 12 14 import com.framsticks.params.annotations.FramsClassAnnotation; 13 15 import com.framsticks.params.annotations.ParamAnnotation; … … 27 29 ) 28 30 public class TestClass { 29 private static final Logger log = 30 LogManager.getLogger(TestClass.class); 31 private static final Logger log = LogManager.getLogger(TestClass.class); 31 32 32 33 33 34 protected String name = "test"; 34 protected String history = "initial|"; 35 protected final EventListeners<TestChangeEvent> historyListeners = new EventListeners<>(); 35 protected final SimplePrimitive<String> history = new SimplePrimitive<>("initial|"); 36 36 37 37 protected final SimpleUniqueList<TestChild> children = new SimpleUniqueList<>(TestChild.class, 'c'); … … 64 64 @ParamAnnotation 65 65 public String getHistory() { 66 return history ;66 return history.get(); 67 67 } 68 68 … … 72 72 @ParamAnnotation 73 73 public void setHistory(String history) { 74 this.history = history;74 this.history.set(history); 75 75 } 76 76 … … 80 80 @ParamAnnotation 81 81 public Map<String, TestChild> getChildren() { 82 return children.get View();82 return children.getMap(); 83 83 } 84 84 … … 86 86 public int appendHistory(String line) { 87 87 log.debug("appending '{}'", line); 88 history = history + line + "|";89 fireHistoryChange();90 return history. length();88 history.set(history.get() + line + "|"); 89 // fireHistoryChange(); 90 return history.get().length(); 91 91 } 92 92 … … 94 94 public void resetHistory() { 95 95 log.debug("reseting"); 96 history = ""; 97 fireHistoryChange(); 96 history.set(""); 98 97 } 99 98 100 99 @ParamAnnotation(paramType = ProcedureParam.class) 101 100 public void createChild(String name) { 102 TestChild child = new TestChild( this);101 TestChild child = new TestChild(); 103 102 child.name = name; 103 addChild(child); 104 } 105 106 @AutoAppendAnnotation 107 public void addChild(TestChild child) { 108 child.parent = this; 104 109 children.add(child); 105 110 } 106 111 107 protected void fireHistoryChange() {108 TestChangeEvent event = new TestChangeEvent();109 event.history = history;110 historyListeners.actionForAll(event);111 }112 113 114 112 @ParamAnnotation(id = "history_changed") 115 public void addHistoryListener(EventListener< TestChangeEvent> listener) {116 history Listeners.add(listener);113 public void addHistoryListener(EventListener<ValueChange> listener) { 114 history.addListener(listener); 117 115 } 118 116 119 117 @ParamAnnotation(id = "history_changed") 120 public void removeHistoryListener(EventListener< TestChangeEvent> listener) {121 history Listeners.remove(listener);118 public void removeHistoryListener(EventListener<ValueChange> listener) { 119 history.removeListener(listener); 122 120 } 123 121
Note: See TracChangeset
for help on using the changeset viewer.