Ignore:
Timestamp:
06/22/13 21:51:33 (11 years ago)
Author:
psniegowski
Message:

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.

Location:
java/main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • java/main

    • Property svn:ignore set to
      target
  • java/main/src/main/java/com/framsticks/core/Program.java

    r78 r84  
    11package com.framsticks.core;
    22
    3 import com.framsticks.util.Pair;
    4 import com.framsticks.util.Strings;
     3import com.framsticks.util.lang.IterableIterator;
     4import com.framsticks.util.lang.Pair;
     5import com.framsticks.util.lang.Strings;
    56import org.apache.commons.configuration.*;
    67import org.apache.log4j.Logger;
    78import org.apache.log4j.PropertyConfigurator;
    8 //import sun.misc.Signal;
    9 //import sun.misc.SignalHandler;
    109
    1110import java.lang.reflect.Constructor;
     
    1514 * @author Piotr Sniegowski
    1615 */
    17 public class Program extends com.framsticks.util.Thread {
     16public class Program extends com.framsticks.util.dispatching.Thread {
    1817
    19     private final static Logger LOGGER = Logger.getLogger(Program.class.getName());
     18        private final static Logger log = Logger.getLogger(Program.class.getName());
    2019
    21 /*
    22     protected SignalHandler signalHandler = new SignalHandler() {
    23         @Override
    24         public void handle(Signal signal) {
    25             LOGGER.info("caught " + signal);
    26             Runtime.getRuntime().exit(0);
    27         }
    28     };
    29 */
     20        protected Entity entity;
    3021
    31     protected Entity entity;
     22        Configuration config;
    3223
    33     Configuration config;
     24        public Program(String name) {
     25                super(name, java.lang.Thread.currentThread());
     26        }
    3427
     28        public static Entity configureEntity(Configuration config) {
     29                String typeName = config.getString("class");
     30                log.info("configuring instance " + typeName);
     31                try {
     32                        Class<?> type = Class.forName(typeName);
     33                        Constructor<?> constructor = type.getConstructor();
     34                        Entity entity = (Entity) constructor.newInstance();
     35                        return entity;
     36                } catch (Exception e) {
     37                        log.error("failed to instantiate: " + e);
     38                }
     39                return null;
     40        }
    3541
    36     public Program(String name) {
    37         super(name, java.lang.Thread.currentThread());
    38 //        Signal.handle(new Signal("INT"), signalHandler);
    39 //        Signal.handle(new Signal("TERM"), signalHandler);
    40     }
     42        protected static void resolve(Configuration config, String prefix) {
     43                for (String p : new IterableIterator<String>(prefix == null ? config.getKeys() : config.getKeys(prefix))) {
     44                        if (p.endsWith(".mount")) {
     45                                String source = config.getString(p);
     46                                log.info("mounting " + source + " at " + p);
     47                                config.clearProperty(p);
     48                                Configuration mount = config.subset(source);
     49                                for (String mk : new IterableIterator<String>(mount.getKeys())) {
     50                                        config.addProperty(p.substring(0, p.length() - 6) + "." + mk, mount.getProperty(mk));
     51                                }
     52                        }
     53                }
     54        }
    4155
    42     public static Entity configureEntity(Parameters parameters) {
    43         String typeName = parameters.getConfig().getString("class");
    44         LOGGER.info("configuring instance " + typeName);
    45         try {
    46             Class type = Class.forName(typeName);
    47             Constructor constructor = type.getConstructor(Parameters.class);
    48             return (Entity) constructor.newInstance(parameters);
    49         } catch (Exception e) {
    50             LOGGER.error("failed to instantiate: " + e);
    51         }
    52         return null;
    53     }
    54 
    55     protected static void resolve(Configuration config, String prefix) {
    56 
    57         Iterator i = prefix == null ? config.getKeys() : config.getKeys(prefix);
    58         while (i.hasNext()) {
    59             String p = (String) i.next();
    60             if (p.endsWith(".mount")) {
    61                 String source = config.getString(p);
    62                 LOGGER.info("mounting " + source + " at " + p);
    63                 config.clearProperty(p);
    64                 Configuration mount = config.subset(source);
    65                 Iterator mi = mount.getKeys();
    66                 while (mi.hasNext()) {
    67                     String mk = (String) mi.next();
    68                     config.addProperty(p.substring(0, p.length() - 6) + "." + mk, mount.getProperty(mk));
    69                 }
    70             }
    71         }
    72     }
    73 
    74     public void run(String[] args) {
     56        public void run(String[] args) {
    7557
    7658                PropertyConfigurator.configure(getClass().getResource("/configs/log4j.properties"));
    77                 LOGGER.debug("started in " + System.getProperty("user.dir"));
    78         try {
     59                log.debug("started in " + System.getProperty("user.dir"));
     60                try {
    7961                        config = new PropertiesConfiguration(getClass().getResource("/configs/framsticks.properties"));
    8062
    81             for (String a : args) {
    82                 Pair<String, String> p = Strings.splitIntoPair(a, '=', "true");
    83                 config.setProperty(p.first, p.second);
    84             }
     63                        for (String a : args) {
     64                                Pair<String, String> p = Strings.splitIntoPair(a, '=', "true");
     65                                config.setProperty(p.first, p.second);
     66                        }
    8567
    86             resolve(config, null);
     68                        resolve(config, null);
    8769
    88             Iterator i = config.getKeys();
    89             while (i.hasNext()) {
    90                 String p = (String) i.next();
    91                 LOGGER.debug(p + " = " + config.getProperty(p));
    92             }
     70                        Iterator<?> i = config.getKeys();
     71                        while (i.hasNext()) {
     72                                String p = (String) i.next();
     73                                log.debug(p + " = " + config.getProperty(p));
     74                        }
    9375
    94         } catch (ConfigurationException e) {
    95             System.err.print("failed to parse configuration:" + e);
    96             return;
    97         }
     76                } catch (ConfigurationException e) {
     77                        System.err.print("failed to parse configuration:" + e);
     78                        return;
     79                }
     80                Configuration entityConfig = config.subset("com.framsticks.entity");
    9881
    99         entity = configureEntity(new Parameters(config.subset("com.framsticks.entity"), "main", null, new EntityOwner() {
     82                entity = configureEntity(entityConfig);
     83                entity.setOwner(new EntityOwner() {
    10084                        @Override
    10185                        public void onDone() {
    102                                 LOGGER.info("exiting");
     86                                log.info("exiting");
    10387                                Runtime.getRuntime().exit(0);
    10488                        }
    105                 }));
     89                });
     90                entity.setName("main");
    10691                try {
    107                 entity.configurePublic();
     92                        entity.configure(entityConfig);
    10893                } catch (Exception e) {
    109                         LOGGER.fatal("exception caught during configuration: " + e);
     94                        log.fatal("exception caught during configuration: " + e);
    11095                }
    111         LOGGER.info("all entities were configured");
    112         entity.start();
    113     }
     96                log.info("all entities were configured");
     97                entity.start();
     98        }
    11499
    115     public static void main(final String[] args) {
    116         final Program program = new Program("program");
    117         program.invokeLater(new Runnable() {
    118             @Override
    119             public void run() {
    120                 program.run(args);
    121             }
    122         });
    123         program.routine();
    124     }
     100        public static void main(final String[] args) {
     101
     102                final Program program = new Program("program");
     103                program.invokeLater(new Runnable() {
     104                        @Override
     105                        public void run() {
     106                                program.run(args);
     107                        }
     108                });
     109                program.routine();
     110        }
    125111
    126112}
Note: See TracChangeset for help on using the changeset viewer.