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

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

HIGHLIGHTS:

  • add auto loading and saving algorithms between

frams files format and Java classes

  • respect ValueChange? events in GUI (do not reload object)
  • support results of procedures in Java server
  • make Experiment automatically convert between frams file and NetFile? object
  • add MessageLogger? (compatible with original frams server messages)
  • WorkPackageLogic? now validates results, is able to discard them, reschedule

whole package, or only uncomputed remainder

CHANGELOG:
Show just a short description in PrimeExperiment?.

Add primes_changed event to the PrimeExperiment?.

Make WorkPackageLogic? robust to frams server returning invalid results.

Add MessageLogger? to logics.

Add NetFile? interface. Support Messages from server.

Minor changes to connections.

Merge results in the PrimeExperiment?.

More netload class->file conversion to Simulator.

Move netsave parsing to Simulator.

Fix bug with inverted ordering of events firing in Experiment.

Minor changes.

Minor logging changes.

Use AccessOperations?.convert in NetLoadSaveLogic?

NetLoadSaveLogic? now encloses the conversion.

Use more generic AccessOperations? saveAll and loadAll in PrimePackage?.

Add Result class for enclosing of call invocations' results.

Improve feature request handling in Connections.

Use AccessOperations?.convert in RemoteTree? events parsing.

Minor change.

Add some information params to Java server root and CLI objects.

A draft implementation of loadAll algorithm.

That algorithm tries to load objects into a tree structure.

Add AccessOperationsTest? test.

Develop WorkPackageLogic?.

  • add state tracking fields
  • add work package generation

Add utility class SimplePrimitive?.

Meant for Java backend classes, enclose a single primitive value
and set of listeners.

Improve primitive value refresh in GUI.

When ValueChange? found in called event, do not reload whole
object, but only update GUI (no communication is performed).

Use ValueChange? in the TestClass? test.

Minor changes.

Sending all packages in PrimeExperiment? to the frams servers.

Develop AccessOperations?.loadComposites().

Remove addAccess from MultiParamLoader? interface.

There is now no default AccessProvider? in MultiParamLoader?.
User must explicitely set AccessStash? or Registry.

Improve saving algorithms in AccessOperations?.

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.core.ValueChange;
10import com.framsticks.params.EventListener;
11import com.framsticks.params.SimplePrimitive;
12import com.framsticks.params.SimpleUniqueList;
13import com.framsticks.params.annotations.AutoAppendAnnotation;
14import com.framsticks.params.annotations.FramsClassAnnotation;
15import com.framsticks.params.annotations.ParamAnnotation;
16import com.framsticks.params.types.ProcedureParam;
17
18@FramsClassAnnotation(
19        order = {
20                "name",
21                "history",
22                "history_changed",
23                "appendHistory",
24                "resetHistory",
25                "children",
26                "createChild",
27                "children_changed"
28        }
29)
30public class TestClass {
31        private static final Logger log = LogManager.getLogger(TestClass.class);
32
33
34        protected String name = "test";
35        protected final SimplePrimitive<String> history = new SimplePrimitive<>("initial|");
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.get();
67        }
68
69        /**
70         * @param history the history to set
71         */
72        @ParamAnnotation
73        public void setHistory(String history) {
74                this.history.set(history);
75        }
76
77        /**
78         * @return the children
79         */
80        @ParamAnnotation
81        public Map<String, TestChild> getChildren() {
82                return children.getMap();
83        }
84
85        @ParamAnnotation(paramType = ProcedureParam.class)
86        public int appendHistory(String line) {
87                log.debug("appending '{}'", line);
88                history.set(history.get() + line + "|");
89                // fireHistoryChange();
90                return history.get().length();
91        }
92
93        @ParamAnnotation(paramType = ProcedureParam.class)
94        public void resetHistory() {
95                log.debug("reseting");
96                history.set("");
97        }
98
99        @ParamAnnotation(paramType = ProcedureParam.class)
100        public void createChild(String name) {
101                TestChild child = new TestChild();
102                child.name = name;
103                addChild(child);
104        }
105
106        @AutoAppendAnnotation
107        public void addChild(TestChild child) {
108                child.parent = this;
109                children.add(child);
110        }
111
112        @ParamAnnotation(id = "history_changed")
113        public void addHistoryListener(EventListener<ValueChange> listener) {
114                history.addListener(listener);
115        }
116
117        @ParamAnnotation(id = "history_changed")
118        public void removeHistoryListener(EventListener<ValueChange> listener) {
119                history.removeListener(listener);
120        }
121
122        @ParamAnnotation(id = "children_changed")
123        public void addChildrenListener(EventListener<ListChange> listener) {
124                children.addListener(listener);
125        }
126
127        @ParamAnnotation(id = "children_changed")
128        public void removeChildrenListener(EventListener<ListChange> listener) {
129                children.removeListener(listener);
130        }
131
132        @Override
133        public String toString() {
134                return "test class " + history;
135        }
136
137}
Note: See TracBrowser for help on using the repository browser.