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/MainFrame.java

    r77 r84  
    11package com.framsticks.gui;
    22
    3 import com.framsticks.gui.components.Control;
    4 import com.framsticks.gui.view.*;
    53import com.framsticks.gui.windows.console.ConsoleFrame;
     4import com.framsticks.util.swing.MenuConstructor;
    65import org.apache.log4j.Logger;
    76
     
    1110import java.awt.event.ActionEvent;
    1211import java.awt.event.ActionListener;
     12import java.awt.event.KeyEvent;
    1313import java.awt.event.WindowAdapter;
    1414import java.awt.event.WindowEvent;
     
    1717 * Application Main Frame.
    1818 */
     19@SuppressWarnings("serial")
    1920public class MainFrame extends Frame {
    2021
    21         private final static Logger LOGGER = Logger.getLogger(MainFrame.class.getName());
     22        private final static Logger log = Logger.getLogger(MainFrame.class.getName());
    2223
    2324        JButton start, stop, step;
     
    2829        public MainFrame(final Browser browser) {
    2930                super("Framsticks Network Client", browser);
    30                 LOGGER.debug("creating main frame");
     31                log.debug("creating main frame");
    3132
    3233                statusBar = new JLabel("not connected");
    33 
    34 
    35         }
     34        }
     35
    3636
    3737        @Override
    3838        public void configure() {
    3939                super.configure();
     40
     41                new MenuConstructor(fileMenu)
     42                        .add(null, new AbstractAction("Console") {
     43                                @Override
     44                                public void actionPerformed(ActionEvent actionEvent) {
     45                                        showConsoleFrame();
     46                                }
     47                        })
     48                        .add(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK), new AbstractAction("Goto") {
     49                                @Override
     50                                public void actionPerformed(ActionEvent actionEvent) {
     51                                        browser.autoResolvePath("/simulator/genepools/groups/0", null);
     52                                        // browser.autoResolvePath("/simulator/populations/groups/0", null;
     53                                        // browser.autoResolvePath("/simulator/genepools/groups/0/genotypes", null);
     54                                        // browser.autoResolvePath("/simulator/populations/groups", null);
     55                                }
     56                        })
     57                        .add(null, new AbstractAction("Disconnect") {
     58                                @Override
     59                                public void actionPerformed(ActionEvent actionEvent) {
     60                                        disconnect();
     61                                }
     62                        })
     63                        .add(null, new AbstractAction("Quit") {
     64                                @Override
     65                                public void actionPerformed(ActionEvent actionEvent) {
     66                                }
     67                        })
     68                        ;
     69
    4070                setFrameProperties();
    4171        }
    4272
    43         private void onConnectionEstablished() {
    44         assert isActive();
    45 
    46         addNodeActionToTreePopupMenu("Open in console", new NodeAction() {
    47             @Override
    48             public void actionPerformed(TreeNode treeNode) {
    49                 assert isActive();
    50                 //showConsoleFrame().setCommandLine("info " + treeNode.getNode().getPath());
    51             }
    52         });
    53 
    54 
    55 
    56 /*
    57         browser.addNodeActionToTreePopupMenu("Resolve recursively", new NodeAction() {
    58             @Override
    59             public void actionPerformed(TreeNode treeNode) {
    60                 final Child child = treeNode.getChild();
    61                 //server.invokeLater(new Runnable() {
    62                     @Override
    63                     public void run() {
    64                         resolveRecursively(child);
    65                     }
    66                 });
    67             }
    68         });
    69 */
    70 
    71         addNodeActionToTreePopupMenu("Store in file", new NodeAction() {
    72             @Override
    73             public void actionPerformed(final TreeNode treeNode) {
    74 
    75 /*
    76                 final Node node = treeNode.getNode();
    77                 server.invokeLater(new Runnable() {
    78                     @Override
    79                     public void run() {
    80                         try {
    81                             LOGGER.info("storing");
    82                             //File file = new File();
    83                             PrintStream file = new PrintStream("/home/piotr/Desktop/test.param");
    84                             StoreStream stream = new StoreStream(file, server.getManager());
    85                             stream.store(node);
    86 
    87                         } catch (FileNotFoundException e) {
    88                             e.printStackTrace();
    89                         }
    90                     }
    91                 });
    92 */
    93             }
    94         });
    95 
    96 /*
    97         arguments.forEach("resolve", new UnaryFunctor<Boolean, String>() {
    98             @Override
    99             public Boolean call(final String s) {
    100                 server.getManager().resolvePath(s, new StateFunctor() {
    101                     @Override
    102                     public void call(Exception e) {
    103                         if (e != null) {
    104                             LOGGER.error("failed to resolve: " + s);
    105                             return;
    106                         }
    107                         LOGGER.info("succeeded to resolve: " + s);
    108 
    109                     }
    110                 });
    111                 return true;
    112             }
    113         });
    114 */
    115 
    116         /*
    117         arguments.forEach("console", new UnaryFunctor<Boolean, String>() {
     73        // private void onConnectionEstablished() {
     74                // assert isActive();
     75
     76                // addNodeActionToTreePopupMenu("Open in console", new NodeAction() {
     77                        // @Override
     78                        // public void actionPerformed(TreeNode treeNode) {
     79                                // assert isActive();
     80                        // }
     81                // });
     82
     83
     84
     85
     86        //      // browser.addNodeActionToTreePopupMenu("Resolve recursively", new NodeAction() {
     87        //      //      @Override
     88        //      //      public void actionPerformed(TreeNode treeNode) {
     89        //      //              final Child child = treeNode.getChild();
     90        //      //              //server.invokeLater(new Runnable() {
     91        //              //              @Override
     92        //              //              public void run() {
     93        //              //                      resolveRecursively(child);
     94        //              //              }
     95        //              //      });
     96        //      // }
     97        //      // });
     98
     99
     100                // // addNodeActionToTreePopupMenu("Store in file", new NodeAction() {
     101                // //     @Override
     102                // //     public void actionPerformed(final TreeNode treeNode) {
     103                // //         // final Node node = treeNode.getNode();
     104                // //         // server.invokeLater(new Runnable() {
     105                // //         //     @Override
     106                // //         //     public void run() {
     107                // //         //         try {
     108                // //         //             log.info("storing");
     109                // //         //             //File file = new File();
     110                // //         //             StoreStream stream = new StoreStream(file, server.getManager());
     111                // //         //             stream.store(node);
     112                // //         //         } catch (FileNotFoundException e) {
     113                // //         //             e.printStackTrace();
     114                // //         //         }
     115                // //         //     }
     116                // //         // });
     117                // //     }
     118                // // });
     119
     120
     121        //      // arguments.forEach("resolve", new UnaryFunctor<Boolean, String>() {
     122        //      //      @Override
     123        //      //      public Boolean call(final String s) {
     124        //      //              server.getManager().resolvePath(s, new StateFunctor() {
     125        //      //                      @Override
     126        //      //                      public void call(Exception e) {
     127        //      //                              if (e != null) {
     128        //      //                                      log.error("failed to resolve: " + s);
     129        //      //                                      return;
     130        //      //                              }
     131        //      //                              log.info("succeeded to resolve: " + s);
     132        //      //                      }
     133        //      //              });
     134        //      //              return true;
     135        //      //      }
     136        //      // });
     137
     138
     139        //      // arguments.forEach("console", new UnaryFunctor<Boolean, String>() {
     140        //      //      @Override
     141        //      //      public Boolean call(String s) {
     142        //      //              showConsoleFrame().setCommandLine(s);
     143        //      //              return true;
     144        //      //      }
     145        //      // });
     146        // }
     147
     148        public void setSimulationRunning(final boolean run) {
     149                assert isActive();
     150                /*
     151                remoteInstance.invokeLater(new Runnable() {
    118152                        @Override
    119                         public Boolean call(String s) {
    120                                 showConsoleFrame().setCommandLine(s);
    121                                 return true;
     153                        public void run() {
     154                                remoteInstance.setRunning(run);
    122155                        }
    123156                });
     
    125158        }
    126159
    127         public void setSimulationRunning(final boolean run) {
    128         assert isActive();
    129         /*
    130         remoteInstance.invokeLater(new Runnable() {
    131             @Override
    132             public void run() {
    133                 remoteInstance.setRunning(run);
    134             }
    135         });
    136         */
    137         }
    138 
    139160        /**
    140161         * Creates panel with start, step, stop buttons.
    141162         */
    142     @Override
     163        @Override
    143164        protected JPanel createLeftTopPanel() {
    144         assert isActive();
    145         Dimension buttonDimension = new Dimension(45, 45);
     165                assert isActive();
     166                Dimension buttonDimension = new Dimension(45, 45);
    146167
    147168                JPanel panel = new JPanel();
     
    161182
    162183                step = new JButton(ImageProvider.loadImage(ImageProvider.SIM_STEP));
    163         /*
     184                /*
    164185                step.addActionListener(new ActionListener() {
    165186
     
    212233         */
    213234        private void setFrameProperties() {
    214         assert isActive();
    215         setMinimumSize(this.getPreferredSize());
     235                assert isActive();
     236                setMinimumSize(this.getPreferredSize());
    216237                setSize(this.getPreferredSize());
    217238                setMaximumSize(screenDimension);
     
    224245                addWindowListener(new WindowAdapter() {
    225246                        public void windowClosing(WindowEvent e) {
    226                 assert isActive();
    227                 /*
    228                 if (connection != null) {
     247                                assert isActive();
     248                                /*
     249                                if (connection != null) {
    229250                                        connection.close();
    230251                                }
     
    237258
    238259        public ConsoleFrame showConsoleFrame() {
    239         assert isActive();
    240         /*
    241         ConsoleFrame consoleFrame = new ConsoleFrame(connection);
     260                assert isActive();
     261                /*
     262                ConsoleFrame consoleFrame = new ConsoleFrame(connection);
    242263                consoleFrame.show(MainFrame.this);
    243264                return consoleFrame;
    244265                */
    245         return null;
    246         }
    247 
    248         /**
    249          * Creates menu bar.
    250          *
    251          * @return JMenuBar Menu bar.
    252          */
    253     @Override
    254         protected JMenuBar createMenu() {
    255         assert isActive();
    256         final JMenuBar menuBar = new JMenuBar();
    257                 final JMenu menu = new JMenu("Main");
    258 
    259                 final JMenuItem consoleItem = new JMenuItem("Console");
    260                 consoleItem.addActionListener(new ActionListener() {
    261 
    262                         public void actionPerformed(ActionEvent e) {
    263                                 showConsoleFrame();
    264                         }
    265 
    266                 });
    267 
    268         /*
    269                 final JMenuItem serverLogItem = new JMenuItem("Sever Log");
    270                 serverLogItem.addActionListener(new ActionListener() {
    271 
    272                         public void actionPerformed(ActionEvent e) {
    273                                 serverLogFrame.show(MainFrame.this);
    274                         }
    275 
    276                 });
    277                 */
    278 
    279                 final JMenuItem disconnectItem = new JMenuItem("Disconnect");
    280                 disconnectItem.addActionListener(new ActionListener() {
    281 
    282                         public void actionPerformed(ActionEvent e) {
    283                                 disconnect();
    284                         }
    285                 });
    286 
    287                 /** @todo do something proper with UI on close */
    288                 menu.add(consoleItem);
    289                 //menu.add(serverLogItem);
    290                 menu.add(disconnectItem);
    291                 menuBar.add(menu);
    292                 return menuBar;
     266                return null;
    293267        }
    294268
     
    297271         */
    298272        private void disconnect() {
    299         assert isActive();
    300         //remoteInstance.disconnect();
     273                assert isActive();
     274                //remoteInstance.disconnect();
    301275                browser.clear();
    302276                onWindowClosing();
     
    308282         */
    309283        private void onWindowClosing() {
    310         assert isActive();
     284                assert isActive();
    311285
    312286        }
    313287
    314288        public void setRunningButtons(boolean running) {
    315         assert isActive();
    316         step.setEnabled(!running);
     289                assert isActive();
     290                step.setEnabled(!running);
    317291                stop.setEnabled(running);
    318292                start.setEnabled(!running);
Note: See TracChangeset for help on using the changeset viewer.