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

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

HIGHLIGHTS:

CHANGELOG:
Get data also on tree expansion.

Use nice framstick icon for empty nodes.

Update panel after reload if it is current.

Add shallow reload procedure.

Cut Gui prefix from several tree classes.

Bring back counter of GuiTreeNode?.

Use IdentityHashMap? were it is more appriopriate.

Remove TreeListener?.

Do not use TreeListener? in GUI.

Minor change.

Done migration to GuiTreeModel?.

BrowserTest? in that version always crashes frams.linux.

Move rendering implementation into GuiAbstractNode?.

Use hand-crafted list in GuiTreeNode?.

Generally, it would be a great place for WeakIdentityHashMap?
(but there is none in Java Collection Framework).

Remove superfluous logging.

Fix bug in GuiTreeNode?.

Use IdentityHashMap? instead of HashMap?.

Improve structure update.

Filter out invalid uids in UniqueListAccess?.

Improve TreeCellRenderer?.

Add filtering in TrackConsole?.

Improve TreeModel?.

More changes.

More improvements.

More changes.

Remove TreeNode?.

Support MetaNode? in the GuiTreeModel?.

Implement more in GuiTreeModel?.

Add CompositeParam? interface to FramsClass? and AccessInterface?.

Allow access by number to UniqueList?.

Add UidComparator?.

Use TreeMap? as a default accessee in unique list.

It keeps order of keys.

Introduce classes to use with new TreeModel?.

Another step.

Migrate from TreeNode? to Node in many places.

Remove some uses of TreeNode? as DefaultMutableTreeNode?.

Remove Path from TreeNode? interface.

Remove Path from TreeNode?.

Add Path recration from node feature.

Reworking TreeCellRenderer?.

Minor change of TreeOperations? interface.

Remove last methods from TreeNode?.

Another minor step.

Do not store reference to TreeAtFrame? in TreeNode?.

Add proxy exceptionHandler to StatusBar?.

Move panels management to TreeAtFrame?.

Store localChanges in the NodeAtFrame?.

More cleanup.

Move name computing to TreeCellRenderer?.

Move tooltip and icon computations to TreeCellRenderer?.

More dispatches removed.

Remove most dispatching from TreeNode?.

TreeNode? does not actually redispatch tasks.

Make Tree embedded in Browser use SwingDispatcher?.

Make lazy binding of Tree with Dispatcher.

Minor changes.

Organizational change in AbstractTree?.

Make AbstractTree? compose from Thread instead of inherit from it.

Make SwingDispatcher? and AtOnceDispatcher? Joinable compatible.

Add ListPanelProvider?.

Improve Controls readonly and enabled handling.

Properly pass ExceptionHandlers? in more places.

Make Tree.get accept ValueParam?.

  • This is to allow access number of list elements.

Remove not needed get redirection in ClientAtServer?.

Rename tryResolve to tryGet.

Unify tryResolveAndGet into tryResolve.

Remove resolveTop from Tree interface.

Make Tree.get accept Future<Path>.

Use get to implement resolveTop also in ObjectTree?.

Unify resolveTop and get in RemoteTree?.

Another minor step.

More minor changes in tree operations.

Minor organizational changes.

In RemoteTree? first fetch info for root.

Reworking resolving.

Minor changes.

Make ListAccess? return proxy iterators (instead of creating temporary collection).

Let AccessInterface? return Iterable<Param>.

Improve resolving.

More improvements.

First working completion in ManagedConsole?.

Rename resolve to resolveTop.

This reflects the actuall functionality.

Change semantic of tryResolve and tryResolveAndGet.

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