source: java/main/src/main/java/com/framsticks/params/ArrayListAccess.java @ 90

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

HIGHLIGHTS:

CHANGELOG:
Make ProcedureParam? hold only ValueParams?.

Use id instead of names when naming gui components internally.

Basic procedure calling in GUI.

The actual procedure call is currently only backed
by the ObjectInstance?.

Add UnimplementedException?.

Improve naming of various gui elements.

Allow easy navigating in FEST Swing testing.

Add optional explicit order attribute to FramsClassAnnotation?.

That's because java reflection does return declared members
in any specific order. That ordering is needed only for
classes that have no representation in framsticks and need
a deterministic ordering of params.

Add ControlOwner? interface.

Add test for procedure calling in Browser.

First version of ParamAnnotation? for procedures.

Development of ProcedureParam?.

Add draft version of ProcedureParam? implementation in ReflectionAccess?.

Allow viewing FramsClasses? in gui Browser.

Extract ResourceBuilder? from ModelBuilder?.

Remove internalId from Param.

It was currently completely not utilised. Whether it is still needed
after introduction of ParamAnnotation? is arguable.

Add remaining param attributes to ParamAnnotation?.

Change AutoBuilder? semantics.

AutoBuilder? returns list of objects that are to be appended
with methods @AutoAppendAnnotation?.

This allows to omit explicit addition of ModelPackage? to instance
if the instance uses ModelBuilder? (registration of ModelPackage? comes
from schema).

Fix params ordering problem in auto created FramsClasses?.

Improve ObjectInstance?.

Several fixes to ModelBuilder?.

Improve test for ObjectInstance? in Browser.

Make initialization of robot static.

With robot recreated for second browser test, the test hanged
deep in AWT.

Add base convenience base test for Browser tests.

More tests to ObjectInstance?.

Rename Dispatcher.invokeLater() to dispatch().

Add assertDispatch.

It allows assertions in other threads, than TestNGInvoker.
Assertions are gathered after each method invocation and rethrown.

Use timeOut annotation attribute for tests involving some waiting.

Remove firstTask method (merge with joinableStart).

Clean up leftovers.

Remove unused FavouritesXMLFactory (the reading part is already
completely done with generic XmlLoader?, and writing part will be done
based on the same approach if needed).
Move UserFavourite? to the com.framsticks.gui.configuration package.

Remove GenotypeBrowser? as to specific.

This functionality will be available in ObjectInstance?.

Add interface ParamsPackage?.

Package containing registration of Java classes meant to use with
ReflectionAccess? may be in Instance using configuration.

Minor changes.

Make Group immutable.

Add AutoBuilder? interface extending Builder - only those would
be used to automatically build from XML.

Fix groups in FramsClass?.

Minor naming cleanup in Registry.

Add ModelComponent? interface.

All class creating the Model are implementing that interface.

Extract Model.build into ModelBuilder?.

ModelBuilder? will be compatible with other builders
and allow using it from configuration.

Fix NeuroConnection?.

Add synchronous get operation for dispatchers.

Rename JoinableMonitor? to Monitor.

Add ObjectInstance?.

This class is mainly for demonstration
and testing purposes.

Improve FramsServer? runner.

  • improve ExternalProcess? runner,
  • runner can kill the server but also react properly, when the server exists on it's own,
  • set default path to search for framsticks server installation,
  • add LoggingOutputListener?.
File size: 2.3 KB
Line 
1package com.framsticks.params;
2
3import com.framsticks.util.lang.Numbers;
4
5import java.util.ArrayList;
6import java.util.Collection;
7import java.util.LinkedList;
8import java.util.List;
9
10/**
11 * @author Piotr Sniegowski
12 */
13public class ArrayListAccess extends ListAccess {
14
15        List<Object> list;
16
17        public ArrayListAccess(AccessInterface elementAccess) {
18                super(elementAccess);
19        }
20
21        @Override
22        public ArrayListAccess cloneAccess() throws ConstructionException {
23                return new ArrayListAccess(elementAccess.cloneAccess());
24        }
25
26        @Override
27        public List<?> createAccessee() {
28                return new ArrayList<Object>();
29        }
30
31        @Override
32        public Param getParam(int i) {
33                //TODO listAccessParam
34                return Param.build().id(Integer.toString(i)).forAccess(elementAccess).finish();
35        }
36
37        @Override
38        public Param getParam(String id) {
39                Integer i = Numbers.parse(id, Integer.class);
40                return (i == null ? null : getParam(i));
41        }
42
43        @Override
44        public String getId() {
45                return "l " + elementAccess.getId();
46        }
47
48        @Override
49        public int getParamCount() {
50                return list.size();
51        }
52
53        @Override
54        public <T> T get(int i, Class<T> type) {
55                if (i < list.size()) {
56                        return type.cast(list.get(i));
57                }
58                return null;
59        }
60
61        @Override
62        public <T> T get(String id, Class<T> type) {
63                return get(Integer.parseInt(id), type);
64        }
65
66        @Override
67        public <T> T get(ValueParam param, Class<T> type) {
68                return get(param.getId(), type);
69        }
70
71        @Override
72        public <T> int set(int i, T value) {
73                while (i >= list.size()) {
74                        list.add(null);
75                }
76                list.set(i, value);
77                return 0;
78        }
79
80        @Override
81        public <T> int set(String id, T value) {
82                return set(Integer.parseInt(id), value);
83        }
84
85        @Override
86        public <T> int set(ValueParam param, T value) {
87                return set(param.getId(), value);
88        }
89
90        @Override
91        public void clearValues() {
92                list.clear();
93        }
94
95        /** covariant */
96        @Override
97        public List<Object> getSelected() {
98                return list;
99        }
100
101        @SuppressWarnings("unchecked")
102        @Override
103        public ArrayListAccess select(Object object) {
104                list = (List<Object>) object;
105                return this;
106        }
107
108        @Override
109        public String computeIdentifierFor(Object selected) {
110                return Integer.toString(list.size());
111        }
112
113        @Override
114        public Collection<Param> getParams() {
115                List<Param> result = new LinkedList<Param>();
116                if (list == null) {
117                        return result;
118                }
119                for (int i = 0; i < list.size(); ++i) {
120                        result.add(getParam(i));
121                }
122                return result;
123        }
124
125
126}
Note: See TracBrowser for help on using the repository browser.