source: java/main/src/main/java/com/framsticks/params/Flags.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.4 KB
Line 
1package com.framsticks.params;
2
3import java.lang.reflect.Field;
4import org.apache.log4j.Logger;
5
6import com.framsticks.util.lang.Delimeted;
7
8/**
9 * The class Flags contains constants connected with parameter features as
10 * well as feedback about set operation (when setting parameter value).
11 *
12 * Based on c++ defines located in: cpp/gdk/param.h
13 *
14 * @author Jarek Szymczak <name.surname@gmail.com>
15 * (please replace name and surname with my personal data)
16 *
17 * @@author Piotr Sniegowski
18 */
19public final class Flags {
20
21        private final static Logger log = Logger.getLogger(Flags.class.getName());
22
23        public static final int READONLY = 1;
24
25        public static final int DONTSAVE = 2;
26
27        public static final int USERREADONLY = 16;
28
29        public static final int USERHIDDEN = 32;
30
31        public static final int MUTALLOCENTRY = 64;
32
33        public static final int MUTALLOCDATA = 128;
34
35        public static final int NOSTATIC = 256;
36
37        public static final int CONST = 512;
38
39        public static final int CANOMITNAME = 1024;
40
41        public static final int DONTLOAD = 2048;
42
43        public static final int PSET_RONLY = 1;
44
45        public static final int PSET_CHANGED = 2;
46
47        public static final int PSET_HITMIN = 4;
48
49        public static final int PSET_HITMAX = 8;
50
51        public static String write(int flags, String empty) {
52                Delimeted d = new Delimeted("+", empty);
53                try {
54                        for (Field f : Flags.class.getDeclaredFields()) {
55                                if (f.getType() != int.class) {
56                                        continue;
57                                }
58                                if ((flags & f.getInt(null)) != 0) {
59                                        d.append(f.getName());
60                                }
61                        }
62                } catch (IllegalArgumentException e) {
63                        e.printStackTrace();
64                } catch (IllegalAccessException e) {
65                        e.printStackTrace();
66                }
67                return d.build();
68        }
69
70        public static Integer read(String flags) {
71                Integer allFlags = 0;
72                String[] flagsSplitted = flags.split("\\+");
73                for (String flag : flagsSplitted) {
74                        try {
75                                allFlags |= Integer.valueOf(flag);
76                        } catch (NumberFormatException ex) {
77                                try {
78                                        Field field = Flags.class.getDeclaredField(flag.toUpperCase());
79                                        allFlags |= Integer.parseInt(field.get(null).toString());
80                                } catch (SecurityException e) {
81                                        log.warn("security exception was thrown while trying to read flag (" + flag + ")");
82                                } catch (NoSuchFieldException e) {
83                                        log.warn("selected flag is not known (" + flag + ")");
84                                } catch (IllegalArgumentException e) {
85                                        log.warn("selected flag is not known (" + flag + ")");
86                                } catch (IllegalAccessException e) {
87                                        log.warn("selected flag is not known (" + flag + ")");
88                                }
89                        }
90                }
91                return allFlags;
92        }
93}
Note: See TracBrowser for help on using the repository browser.