source: java/main/src/main/java/com/framsticks/params/SimpleUniqueList.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: 2.0 KB
Line 
1package com.framsticks.params;
2
3import java.util.Collections;
4import java.util.Iterator;
5import java.util.Map;
6
7import com.framsticks.core.ListChange;
8
9public class SimpleUniqueList<T extends UniqueObject> implements Iterable<T> {
10
11        protected final Map<String, T> children;
12        protected final Class<T> type;
13        protected final char prefix;
14        protected final EventListeners<ListChange> listeners = new EventListeners<>();
15
16        protected int counter = 0;
17
18        /**
19         * @param type
20         */
21        public SimpleUniqueList(Class<T> type, char prefix) {
22                this.type = type;
23                this.prefix = prefix;
24                children = UniqueListAccess.createMap(type, this);
25        }
26
27        // public static <T2> SimpleUniqueList<T2> make(Class<T2> type) {
28        //      return new SimpleUniqueList<T2>(type);
29        // }
30
31        public String generateId() {
32                return prefix + Integer.toString(counter++);
33        }
34
35        @Override
36        public Iterator<T> iterator() {
37                return children.values().iterator();
38        }
39
40        public void addListener(EventListener<ListChange> listener) {
41                listeners.add(listener);
42        }
43
44        public void removeListener(EventListener<ListChange> listener) {
45                listeners.remove(listener);
46        }
47
48        public void fireChildrenChange(ListChange original, ListChange.Action action, Object... hints) {
49                listeners.actionForAll(new ListChange(action, original.getPosition(), original.getIdentifier(), hints));
50
51        }
52
53        public void fireChildrenChange(T child, ListChange.Action action, Object... hints) {
54                ListChange change = new ListChange(action, UniqueListAccess.getNumberInMap(children, child), child.getUid(), hints);
55                listeners.actionForAll(change);
56        }
57
58        public void add(T child) {
59                child.setUid(generateId());
60                children.put(child.getUid(), child);
61                fireChildrenChange(child, ListChange.Action.Add);
62        }
63
64        public void remove(T child) {
65                fireChildrenChange(child, ListChange.Action.Remove);
66                children.remove(child.getUid());
67        }
68
69        public void modify(T child) {
70                fireChildrenChange(child, ListChange.Action.Modify);
71        }
72
73        public Map<String, T> getView() {
74                return Collections.unmodifiableMap(children);
75        }
76
77        public Map<String, T> getMap() {
78                return children;
79        }
80}
Note: See TracBrowser for help on using the repository browser.