source: java/main/src/main/java/com/framsticks/test/TestClass.java @ 101

Last change on this file since 101 was 101, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • improve tree side notes
  • improve GUI layout
  • add foldable list of occured events to EventControl?
  • improve automatic type conversion in proxy listeners
  • implement several Access functionalities as algorithms independent of Access type
  • introduce draft base classes for distributed experiments
  • automatically register dependant Java classes to FramsClass? registry
  • add testing prime experiment and configuration
  • simplify and improve task dispatching

CHANGELOG:
Improve task dispatching in RemoteTree?.

GUI no longer hangs on connection problems.

Make all dispatchers joinables.

Refactorize Thread dispatcher.

Remove Task and PeriodicTask?.

Use Java utilities in those situations.

Reworking tasks dispatching.

Fix bug in EventControl? listener dispatching.

Minor improvements.

Add testing configuration for ExternalProcess? in GUI.

More improvement to prime.

Support for USERREADONLY in GUI.

Add that flag to various params in Java classes.

Remove redundant register clauses from several FramsClassAnnotations?.

Automatically gather and register dependant classes.

Add configuration for prime.

Improve Simulator class.

Add prime.xml configuration.

Introduce draft Experiment and Simulator classes.

Add prime experiment tests.

Enclose typical map with listeners into SimpleUniqueList?.

Needfile works in GUI.

Improve needfile handling in Browser.

More improvement with NeedFile?.

Implementing needfile.

Update test.

Rename ChangeEvent? to TestChangeEvent?.

Automatic argument type search in RemoteTree? listeners.

MultiParamLoader? uses AccessProvider?. By default old implementation
enclosed in AccessStash? or Registry.

Minor changes.

Rename SourceInterface? to Source.

Also improve toString of File and ListSource?.

Remove unused SimpleSource? class.

Add clearing in HistoryControl?.

Show entries in table at EventControl?.

Improve EventControl?.

Add listeners registration to EventControl?.

Add foldable table to HistoryControl?.

Add control row to Procedure and Event controls.

Improve layout of controls.

Another minor change to gui layout.

Minor improvement in the SliderControl?.

Minor changes.

Move ReflectionAccess?.Backend to separate file.

It was to cluttered.

Cleanup in ReflectionAccess?.

Move setMin, setMax, setDef to AccessOperations?.

Extract loading operation into AccessOperations?.

Append Framsticks to name of UnsupportedOperationException?.

The java.lang.UnsupportedOperationException? was shadowing this class.

Rename params.Util to params.ParamsUtil?.

Several improvements.

Minor changes.

Implement revert functionality.

Improve local changes management.

Minor improvement.

Remove methods rendered superfluous after SideNoteKey? improvement.

Improve SideNoteKey?.

It is now generic type, so explicit type specification at
call site is no more needed.

Introduce SideNoteKey? interface.

Only Objects implementing that key may be used as side note keys.

Minor improvements.

Use strings instead of ValueControls? in several gui mappings.

File size: 3.0 KB
Line 
1package com.framsticks.test;
2
3import java.util.Map;
4
5import org.apache.logging.log4j.Logger;
6import org.apache.logging.log4j.LogManager;
7
8import com.framsticks.core.ListChange;
9import com.framsticks.params.EventListener;
10import com.framsticks.params.EventListeners;
11import com.framsticks.params.SimpleUniqueList;
12import com.framsticks.params.annotations.FramsClassAnnotation;
13import com.framsticks.params.annotations.ParamAnnotation;
14import com.framsticks.params.types.ProcedureParam;
15
16@FramsClassAnnotation(
17        order = {
18                "name",
19                "history",
20                "history_changed",
21                "appendHistory",
22                "resetHistory",
23                "children",
24                "createChild",
25                "children_changed"
26        }
27)
28public class TestClass {
29        private static final Logger log =
30                LogManager.getLogger(TestClass.class);
31
32
33        protected String name = "test";
34        protected String history = "initial|";
35        protected final EventListeners<TestChangeEvent> historyListeners = new EventListeners<>();
36
37        protected final SimpleUniqueList<TestChild> children = new SimpleUniqueList<>(TestChild.class, 'c');
38
39        /**
40         *
41         */
42        public TestClass() {
43        }
44
45        /**
46         * @return the name
47         */
48        @ParamAnnotation
49        public String getName() {
50                return name;
51        }
52
53        /**
54         * @param name the name to set
55         */
56        @ParamAnnotation
57        public void setName(String name) {
58                this.name = name;
59        }
60
61        /**
62         * @return the history
63         */
64        @ParamAnnotation
65        public String getHistory() {
66                return history;
67        }
68
69        /**
70         * @param history the history to set
71         */
72        @ParamAnnotation
73        public void setHistory(String history) {
74                this.history = history;
75        }
76
77        /**
78         * @return the children
79         */
80        @ParamAnnotation
81        public Map<String, TestChild> getChildren() {
82                return children.getView();
83        }
84
85        @ParamAnnotation(paramType = ProcedureParam.class)
86        public int appendHistory(String line) {
87                log.debug("appending '{}'", line);
88                history = history + line + "|";
89                fireHistoryChange();
90                return history.length();
91        }
92
93        @ParamAnnotation(paramType = ProcedureParam.class)
94        public void resetHistory() {
95                log.debug("reseting");
96                history = "";
97                fireHistoryChange();
98        }
99
100        @ParamAnnotation(paramType = ProcedureParam.class)
101        public void createChild(String name) {
102                TestChild child = new TestChild(this);
103                child.name = name;
104                children.add(child);
105        }
106
107        protected void fireHistoryChange() {
108                TestChangeEvent event = new TestChangeEvent();
109                event.history = history;
110                historyListeners.actionForAll(event);
111        }
112
113
114        @ParamAnnotation(id = "history_changed")
115        public void addHistoryListener(EventListener<TestChangeEvent> listener) {
116                historyListeners.add(listener);
117        }
118
119        @ParamAnnotation(id = "history_changed")
120        public void removeHistoryListener(EventListener<TestChangeEvent> listener) {
121                historyListeners.remove(listener);
122        }
123
124        @ParamAnnotation(id = "children_changed")
125        public void addChildrenListener(EventListener<ListChange> listener) {
126                children.addListener(listener);
127        }
128
129        @ParamAnnotation(id = "children_changed")
130        public void removeChildrenListener(EventListener<ListChange> listener) {
131                children.removeListener(listener);
132        }
133
134        @Override
135        public String toString() {
136                return "test class " + history;
137        }
138
139}
Note: See TracBrowser for help on using the repository browser.