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

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

HIGHLIGTS:

  • complete events implementation
  • add CLI in Java Framsticks server
  • add automatic registration for events in GUI
  • improve objects fetching (object are never overwritten with new instances)
  • properly react for ListChange? events
  • add ListPanel? with table view
    • columns to be shown may be statically specified in configuration
    • currently modyfying data through tables is not available
  • improve maven configuration
    • configuration file may be specified without touching pom.xml

CHANGELOG:
Extract constants from Flags into ParamFlags? and SetStateFlags?.

Extract flags I/O to FlagsUtils? class.

Configured maven to exec given resource configuration.

For example:
mvn exec:exec -Dframsticks.config=/configs/managed-console.xml

Cleanup pom.xml

Rename ObjectTree? to LocalTree? (also make LocalTree? and RemoteTree? final).

Minor change.

Add maximum number of columns in ListPanelProvider?.

Improve ColumnsConfig? interpretation.

Automatically fill FramsClass?.name if trying to construct empty.

Improve identitifer case mangling in XmlLoader?.

Introduce configurable ColumnsConfig?.

Draft working version of ListPanel?.

Table is being shown (although empty).

More improvements to table building.

Move some functionality from Frame to TreeModel?.

Move tree classes in gui to separate package.

Remove old table related classes.

Add draft implementation of TableModel?.

Redirect ParamBuilder?.forAccess to AccessInterface?.

Optimize ParamBuilder?.forAccess()

Do not clear list when loading.

Do not load fetched values directly.

Implement different AccessInterface? copying policy.

Optimize fetching values routine.

Remove Mode enum (work out get semantics).

Some improvements to ListChange? handling.

Improve UniqueListAccess?.

Add reaction for ListChanges? in the TreeNode?.

EventListeners? are being added in the TreeNode?.

Listeners for ListParams? are now very naive (they download
whole list).

Automatially register on events in GUI.

Events are working in RemoteTree? and Server.

Move listeners to the ClientSideManagedConnection?.

Remove old classes responsible for event subscriptions.

Improve event reading.

Improve events handling at server side.

Add register attribute in FramsClassAnnotation?
to automatically also register other classes.

Registering events works.

Setup for remote listeners registration.

More improvements.

Minor changes.

Add rootTree to the ClientAtServer?.

Moving CLI to the ClientAtServer?.

Fix bug: use Void.TYPE instead of Void.class

More development around CLI.

  • Improve Path resolving.

Add synthetic root to ObjectTree?.

It is needed to allow sybling for the original root
that would containg CLI.

Some work with registering events in RemoteTree?.

Draft implementation of listener registering in RemoteTree?.

Support events registration in the ObjectTree?.

Add events support to ReflectionAccess?.

EventParam? is recognized by ParamCandidate?.

Prepare interface for Events across project.

Add EventListener? and API for listeners in Tree.

File size: 3.2 KB
Line 
1package com.framsticks.params;
2
3import com.framsticks.params.types.ArrayListParam;
4import com.framsticks.util.UnimplementedException;
5import com.framsticks.util.lang.Numbers;
6
7import java.util.ArrayList;
8import java.util.Iterator;
9import java.util.List;
10import java.util.ListIterator;
11
12/**
13 * @author Piotr Sniegowski
14 */
15public class ArrayListAccess extends ListAccess {
16
17        List<Object> list;
18
19
20        public ArrayListAccess(AccessInterface elementAccess) {
21                super(elementAccess);
22        }
23
24        @Override
25        public ArrayListAccess cloneAccess() throws ConstructionException {
26                return new ArrayListAccess(elementAccess.cloneAccess());
27        }
28
29        @Override
30        public List<?> createAccessee() {
31                return new ArrayList<Object>();
32        }
33
34        @Override
35        public CompositeParam getParam(int i) {
36                if ((i < 0) ||  (i >= list.size())) {
37                        return null;
38                }
39                return paramBuilder.id(Integer.toString(i)).finish(CompositeParam.class);
40        }
41
42        @Override
43        public CompositeParam getParam(String id) {
44                Integer i = Numbers.parse(id, Integer.class);
45                return (i == null ? null : getParam(i));
46        }
47
48        @Override
49        public String getId() {
50                return "l " + elementAccess.getId();
51        }
52
53        @Override
54        public int getParamCount() {
55                return list.size();
56        }
57
58        @Override
59        public <T> T get(int i, Class<T> type) {
60                if ((i < 0) ||  (i >= list.size())) {
61                        return null;
62                }
63                return type.cast(list.get(i));
64        }
65
66        @Override
67        public <T> T get(String id, Class<T> type) {
68                return get(Integer.parseInt(id), type);
69        }
70
71        @Override
72        public <T> T get(ValueParam param, Class<T> type) {
73                return get(param.getId(), type);
74        }
75
76        @Override
77        public <T> int set(int i, T value) {
78                while (i >= list.size()) {
79                        list.add(null);
80                }
81                list.set(i, value);
82                return 0;
83        }
84
85        @Override
86        public <T> int set(String id, T value) {
87                return set(Integer.parseInt(id), value);
88        }
89
90        @Override
91        public <T> int set(ValueParam param, T value) {
92                return set(param.getId(), value);
93        }
94
95        @Override
96        public void clearValues() {
97                list.clear();
98        }
99
100        /** covariant */
101        @Override
102        public List<Object> getSelected() {
103                return list;
104        }
105
106        @SuppressWarnings("unchecked")
107        @Override
108        public ArrayListAccess select(Object object) {
109                list = (List<Object>) object;
110                return this;
111        }
112
113
114        @Override
115        public Iterable<Param> getParams() {
116                return new Iterable<Param>() {
117
118                        @Override
119                        public Iterator<Param> iterator() {
120                                return new Iterator<Param>() {
121
122                                        protected ListIterator<Object> internal = list.listIterator();
123
124                                        @Override
125                                        public boolean hasNext() {
126                                                return internal.hasNext();
127                                        }
128
129                                        @Override
130                                        public Param next() {
131                                                Param param = paramBuilder.id(Integer.toString(internal.nextIndex())).finish(CompositeParam.class);
132                                                internal.next();
133                                                return param;
134                                        }
135
136                                        @Override
137                                        public void remove() {
138                                                throw new UnimplementedException().msg("remove element from list").arg("list", ArrayListAccess.this);
139
140                                        }
141                                };
142                        }
143                };
144        }
145
146        @Override
147        public int getCompositeParamCount() {
148                return list.size();
149        }
150
151        @Override
152        public CompositeParam getCompositeParam(int number) {
153                return getParam(number);
154        }
155
156        @Override
157        public ParamBuilder buildParam(ParamBuilder builder) {
158                return builder.name(containedTypeName + " list").type(ArrayListParam.class).containedTypeName(containedTypeName);
159        }
160
161}
Note: See TracBrowser for help on using the repository browser.