source: java/main/src/main/java/com/framsticks/params/PropertiesAccess.java @ 84

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

HIGHLIGHTS:

  • simplification of entities management model
  • cleanup around params (improve hierarchy)
  • migrate from JUnit to TestNG
  • introduce FEST to automatically test GUI
  • improve slider control
  • loosen synchronization between gui tree and backend representation
  • and many other bug fixes

NOTICE:

  • a great many of lines is changed only because of substituting spaces with tabs

CHANGELOG (oldest changes at the bottom):

Some cleaning after fix found.

Fix bug with tree.

More changes with TreeNodes?.

Finally fix issue with tree.

Improve gui tree management.

Decouple update of values from fetch request in gui.

Minor changes.

Minor changes.

Minor change.

Change Path construction wording.

More fixes to SliderControl?.

Fix SliderControl?.

Fix SliderControl?.

Minor improvement.

Several changes.

Make NumberParam? a generic class.

Add robot to the gui test.

Setup common testing logging configuration.

Remove Parameters class.

Remove entityOwner from Parameters.

Move name out from Parameters class.

Move configuration to after the construction.

Simplify observers and endpoints.

Remove superfluous configureEntity overrides.

Add dependency on fest-swing-testng.

Use FEST for final print test.

Use FEST for more concise and readable assertions.

Divide test of F0Parser into multiple methods.

Migrate to TestNG

Minor change.

Change convention from LOGGER to log.

Fix reporting of errors during controls filling.

Bound maximal height of SliderControl?.

Minor improvements.

Improve tooltips for controls.

Also use Delimeted in more places.

Move static control utilities to Gui.

Rename package gui.components to controls.

Some cleaning in controls.

Improve Param classes placing.

Move ValueParam?, PrimitiveParam? and CompositeParam? one package up.

Improve ParamBuilder?.

Move getDef to ValueParam? and PrimitiveParam?.

Move getMax and getDef to ValueParam?.

Move getMin to ValueParam?.

Upgrade to laters apache commons versions.

Use filterInstanceof extensively.

Add instanceof filters.

Make ValueParam? in many places of Param.

Place assertions about ValueParam?.

Add ValueParam?

Rename ValueParam? to PrimitiveParam?

Minor changes.

Several improvements to params types.

Add NumberParam?.

Add TextControl? component.

Add .swp files to .gitignore

Greatly improved slider component.

Some improvements.

Make Param.reassign return also a state.

Add IterableIterator?.

Several changes.

  • Move util classes to better packages.
  • Remove warnings from eclim.

Several improvements.

Fix bug with BooleanParam?.

Some experiments with visualization.

Another fix to panel management.

Improve panel management.

Some refactorization around panels.

Add root class for panel.

File size: 2.0 KB
Line 
1package com.framsticks.params;
2
3import java.util.HashMap;
4import java.util.Map;
5
6
7/**
8 * The Class PropertiesAccess.
9 *
10 * @author Jarek Szymczak <name.surname@gmail.com> (please replace name and
11 *         surname with my personal data)
12 *
13 * @author Piotr Śniegowski
14 */
15public class PropertiesAccess extends SimpleAbstractAccess {
16
17        public Map<String, Object> properties;
18
19        @Override
20        public Map<String, Object> createAccessee() {
21                return PropertiesAccess.createPropertiesMap();
22        }
23
24        public static Map<String, Object> createPropertiesMap() {
25                return new HashMap<String, Object>();
26        }
27
28        public PropertiesAccess(FramsClass framsClass) {
29                setFramsClass(framsClass);
30        }
31
32        @Override
33        public void clearValues() {
34                assert properties != null;
35                properties.clear();
36        }
37
38        @Override
39        public <T> T get(ValueParam param, Class<T> type) {
40                assert properties != null;
41                assert param != null;
42                Object object = null;
43                try {
44                        object = properties.get(param.getId());
45                        if (object == null) {
46                                return param.getDef(type);
47                        }
48                        return type.cast(object);
49                } catch (ClassCastException e) {
50                        throw new ClassCastException("property " + param.getId() + " type is " + object.getClass().getName() + ", not " + type.getName());
51                }
52
53        }
54
55        @Override
56        protected <T> void internalSet(ValueParam param, T value) {
57                properties.put(param.getId(), value);
58        }
59
60        /**
61         * Sets the new values to operate on. It does not check whether the values
62         * which are set through this method are correct. If set values are not
63         * correct exceptions might occurred while getting / setting the parameters
64         * values
65         *
66         * @param object
67         *            the properties with parameters values
68         */
69        @SuppressWarnings("unchecked")
70        @Override
71        public PropertiesAccess select(Object object) {
72                this.properties = (Map<String, Object>)object;
73                return this;
74        }
75
76        /** covariant */
77        @Override
78        public Map<String, Object> getSelected() {
79                return properties;
80        }
81
82        @Override
83        public PropertiesAccess cloneAccess() {
84                return new PropertiesAccess(framsClass);
85        }
86
87
88}
Note: See TracBrowser for help on using the repository browser.