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/gui/Browser.java

    r78 r84  
    44import com.framsticks.observers.Endpoint;
    55import com.framsticks.observers.Observer;
    6 import com.framsticks.util.Dispatcher;
     6import com.framsticks.util.Logging;
     7import com.framsticks.util.dispatching.Dispatcher;
     8import com.framsticks.util.dispatching.Future;
     9
     10import org.apache.commons.configuration.Configuration;
     11import org.apache.commons.lang.ArrayUtils;
    712import org.apache.log4j.Logger;
    813
    914import javax.swing.*;
     15
     16import java.awt.Dimension;
     17import java.util.ArrayList;
    1018import java.util.HashSet;
     19import java.util.List;
    1120import java.util.Set;
    1221
     
    1625public class Browser extends Observer implements Dispatcher {
    1726
    18     private static final Logger LOGGER = Logger.getLogger(Browser.class.getName());
    19 
    20     protected final Set<Frame> frames = new HashSet<Frame>();
    21     protected MainFrame mainFrame;
    22 
    23     public void addFrame(Frame frame) {
    24         frames.add(frame);
    25     }
    26 
    27         public Browser(Parameters parameters) {
    28         super(parameters);
    29         dispatcher = SwingDispatcher.instance;
    30         invokeLater(new Runnable() {
    31             @Override
    32             public void run() {
    33                 assert isActive();
    34 
    35             }
    36         });
     27        private static final Logger log = Logger.getLogger(Browser.class.getName());
     28
     29        protected final Set<Frame> frames = new HashSet<Frame>();
     30        protected MainFrame mainFrame;
     31        public List<PanelProvider> panelProviders = new ArrayList<PanelProvider>();
     32        protected Dimension defaultFrameDimension;
     33
     34        public void addFrame(Frame frame) {
     35                frames.add(frame);
     36        }
     37
     38        public Browser() {
     39                JPopupMenu.setDefaultLightWeightPopupEnabled(false);
     40                addPanelProvider(new StandardPanelProvider());
     41        }
     42
     43        @Override
     44        public void configure(Configuration config) {
     45                super.configure(config);
     46
     47                defaultFrameDimension = new Dimension(config.getInteger("size.width", 1000), config.getInteger("size.height", 500));
     48
     49                for (String name : config.getStringArray("panel_providers")) {
     50                        try {
     51                                Class<?> c = Class.forName(name);
     52                                if (ArrayUtils.indexOf(c.getInterfaces(), PanelProvider.class) == -1) {
     53                                        continue;
     54                                }
     55                                PanelProvider p = (PanelProvider)c.newInstance();
     56                                addPanelProvider(p);
     57                        } catch (Exception e) {
     58                                log.error("failed to load PanelProvider " + name + ": " + e);
     59                        }
     60                }
     61
     62                // for (final String path : config.getStringArray("resolve_paths")) {
     63                //      invokeLater()
     64                //      autoResolvePath(path, new Future<Path>() {
     65                //              @Override
     66                //              public void result(Path p, Exception e) {
     67                //                      Logging.log(log, "auto resolve path", path, e);
     68                //              }
     69                //      });
     70                // }
     71        }
     72
     73        public void addPanelProvider(PanelProvider panelProvider) {
     74                log.debug("added panel provider of type: " + panelProvider.getClass().getCanonicalName());
     75                panelProviders.add(panelProvider);
     76        }
     77
     78        public void autoResolvePath(final String path, final Future<Path> future) {
     79                final Instance i = endpoints.get("localhost").getInstance();
     80                i.invokeLater(new Runnable() {
     81                        @Override
     82                        public void run() {
     83                                i.resolveAndFetch(path, new Future<Path>() {
     84                                        @Override
     85                                        public void result(final Path p, Exception e) {
     86                                                Logging.log(log, "auto resolve path", path, e);
     87                                                if (future != null) {
     88                                                        future.result(p, e);
     89                                                }
     90                                                if (e == null) {
     91                                                        mainFrame.invokeLater(new Runnable() {
     92                                                                @Override
     93                                                                public void run() {
     94                                                                        mainFrame.goTo(p);
     95                                                                }
     96                                                        });
     97                                                }
     98                                        }
     99                                });
     100                        }
     101                });
    37102        }
    38103
    39104        public void clear() {
    40         assert isActive();
    41         for (Frame f : frames) {
    42             f.clear();
    43         }
    44         }
    45 
    46     @Override
    47     protected void configure() throws Exception {
    48         super.configure();
    49     }
    50 
    51 
    52     @Override
    53     public void run() {
    54         super.run();
    55 
    56         try {
    57             UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
    58         } catch (Exception ex) {
    59             LOGGER.warn("failed loading Look&Feel: ", ex);
    60         }
    61         javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
    62 
    63         mainFrame = new MainFrame(Browser.this);
    64         addFrame(mainFrame);
    65 
    66         for (Frame f : frames) {
    67             f.configure();
    68         }
    69 
    70         for (final Endpoint e : getEndpoints().values()) {
    71             e.invokeLater(new Runnable() {
    72                 @Override
    73                 public void run() {
    74                     final Path p = new Path(e.getInstance(), "/");
    75                     invokeLater(new Runnable() {
    76                         @Override
    77                         public void run() {
    78                             mainFrame.addRootPath((BrowserEndpoint) e, p);
    79                         }
    80                     });
    81                 }
    82             });
    83 
    84         }
    85 
    86         for (Frame f : frames) {
    87             f.setVisible(true);
    88         }
    89     }
    90 
    91     public void createTreeNodeForChild(final Path path) {
    92         assert !isActive();
    93         //assert instance.isActive();
     105                assert isActive();
     106                for (Frame f : frames) {
     107                        f.clear();
     108                }
     109        }
     110
     111        @Override
     112        public void run() {
     113                super.run();
     114
     115                assert isActive();
     116
     117                try {
     118                        boolean found = false;
     119                        // for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
     120                        //      log.info("look and feel available: " + info.getName());
     121                        //      if ("Nimbus".equals(info.getName())) {
     122                        //              UIManager.setLookAndFeel(info.getClassName());
     123                        //              found = true;
     124                        //              break;
     125                        //      }
     126                        // }
     127                        if (!found) {
     128                                UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
     129                        }
     130                } catch (Exception ex) {
     131                        log.warn("failed loading Look&Feel: ", ex);
     132                }
     133
     134                javax.swing.JFrame.setDefaultLookAndFeelDecorated(true);
     135
     136                mainFrame = new MainFrame(Browser.this);
     137                addFrame(mainFrame);
     138
     139                for (Frame f : frames) {
     140                        f.configure();
     141                }
     142
     143                for (final Endpoint e : getEndpoints().values()) {
     144                        e.invokeLater(new Runnable() {
     145                                @Override
     146                                public void run() {
     147                                        final Path p = e.getInstance().getRootPath();
     148                                        invokeLater(new Runnable() {
     149                                                @Override
     150                                                public void run() {
     151                                                        mainFrame.addRootPath((BrowserEndpoint) e, p);
     152                                                }
     153                                        });
     154                                }
     155                        });
     156                }
     157
     158                for (Frame f : frames) {
     159                        f.setVisible(true);
     160                }
     161
     162                // autoResolvePath("/simulator/genepools/groups/0", null);
     163                // autoResolvePath("/", null);
     164        }
     165
     166        public void createTreeNodeForChild(final Path path) {
     167                assert !isActive();
     168                //assert instance.isActive();
    94169
    95170
    96171/*
    97         final TreeNode parentTreeNode = (TreeNode) child.getParent().getUserObject();
    98         if (parentTreeNode == null) {
    99             Dispatching.invokeDispatch(this, manager, new Runnable() {
    100                 @Override
    101                 public void run() {
    102                     createTreeNodeForChild(child);
    103                 }
    104             });
    105             return;
    106         }
    107         LOGGER.debug(child.getClass().getSimpleName() + " created: " + child);
    108 
    109 
    110         invokeLater(new Runnable() {
    111             @Override
    112             public void run() {
    113                 parentTreeNode.getOrCreateChildTreeNodeFor(child);
    114             }
    115         });
     172                final TreeNode parentTreeNode = (TreeNode) child.getParent().getUserObject();
     173                if (parentTreeNode == null) {
     174                        Dispatching.invokeDispatch(this, manager, new Runnable() {
     175                                @Override
     176                                public void run() {
     177                                        createTreeNodeForChild(child);
     178                                }
     179                        });
     180                        return;
     181                }
     182                log.debug(child.getClass().getSimpleName() + " created: " + child);
     183
     184
     185                invokeLater(new Runnable() {
     186                        @Override
     187                        public void run() {
     188                                parentTreeNode.getOrCreateChildTreeNodeFor(child);
     189                        }
     190                });
    116191*/
    117192        }
    118193
    119194
    120     @Override
    121     protected Endpoint createEndpoint() {
    122         return new BrowserEndpoint();
    123     }
     195        @Override
     196        protected Endpoint createEndpoint() {
     197                return new BrowserEndpoint();
     198        }
     199
     200        @Override
     201        public Dispatcher createDefaultDispatcher() {
     202                return SwingDispatcher.instance;
     203        }
     204
     205        /**
     206         * @return the mainFrame
     207         */
     208        public MainFrame getMainFrame() {
     209                return mainFrame;
     210        }
    124211
    125212}
Note: See TracChangeset for help on using the changeset viewer.