source: java/main/src/main/java/com/framsticks/params/PropertiesAccess.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 java.util.HashMap;
4import java.util.Map;
5
6import com.framsticks.params.types.EventParam;
7import com.framsticks.params.types.ProcedureParam;
8
9
10/**
11 * The Class PropertiesAccess.
12 *
13 * @author Jarek Szymczak <name.surname@gmail.com> (please replace name and
14 *         surname with my personal data)
15 *
16 * @author Piotr Śniegowski
17 */
18public class PropertiesAccess extends SimpleAbstractAccess {
19
20        public Map<String, Object> properties;
21
22        @Override
23        public Map<String, Object> createAccessee() {
24                return PropertiesAccess.createPropertiesMap();
25        }
26
27        public static Map<String, Object> createPropertiesMap() {
28                return new HashMap<String, Object>();
29        }
30
31        public PropertiesAccess(FramsClass framsClass) {
32                super(framsClass);
33        }
34
35        @Override
36        public void clearValues() {
37                assert properties != null;
38                properties.clear();
39        }
40
41        @Override
42        public <T> T get(ValueParam param, Class<T> type) {
43                assert properties != null;
44                assert param != null;
45                Object object = properties.get(param.getId());
46                if (object != null) {
47                        try {
48                                return type.cast(object);
49                        } catch (ClassCastException e) {
50                                throw (ClassCastException) new ClassCastException("property " + param + " type is " + object.getClass().getName() + ", not " + type.getName()).initCause(e);
51                        }
52                }
53                try {
54                        return param.getDef(type);
55                } catch (ClassCastException e) {
56                        throw (ClassCastException) new ClassCastException("default value of property " + param + " is not of type " + type.getName()).initCause(e);
57                }
58
59        }
60
61        @Override
62        protected <T> void internalSet(ValueParam param, T value) {
63                properties.put(param.getId(), value);
64        }
65
66        /**
67         * Sets the new values to operate on. It does not check whether the values
68         * which are set through this method are correct. If set values are not
69         * correct exceptions might occurred while getting / setting the parameters
70         * values
71         *
72         * @param object
73         *            the properties with parameters values
74         */
75        @SuppressWarnings("unchecked")
76        @Override
77        public PropertiesAccess select(Object object) {
78                this.properties = (Map<String, Object>)object;
79                return this;
80        }
81
82        /** covariant */
83        @Override
84        public Map<String, Object> getSelected() {
85                return properties;
86        }
87
88        @Override
89        public PropertiesAccess cloneAccess() {
90                return new PropertiesAccess(framsClass);
91        }
92
93        @Override
94        public void tryAutoAppend(Object object) {
95                throw new InvalidOperationException();
96        }
97
98        @Override
99        public Object call(String id, Object[] arguments) {
100                throw new InvalidOperationException().msg("properties access does not support calling methods").arg("id", id);
101        }
102
103        @Override
104        public Object call(ProcedureParam param, Object[] arguments) {
105                throw new InvalidOperationException().msg("properties access does not support calling methods").arg("param", param);
106        }
107
108        @Override
109        public void reg(EventParam param, EventListener<?> listener) {
110                throw new InvalidOperationException().msg("properties access does not support registering events").arg("param", param).arg("access", this);
111        }
112
113        @Override
114        public void regRemove(EventParam param, EventListener<?> listener) {
115                throw new InvalidOperationException().msg("properties access does not support registering events").arg("param", param).arg("access", this);
116        }
117
118}
Note: See TracBrowser for help on using the repository browser.