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/windows/console/ConsoleFrame.java

    r77 r84  
    33import com.framsticks.communication.*;
    44import com.framsticks.gui.ImageProvider;
    5 import com.framsticks.util.Pair;
    6 import com.framsticks.util.Strings;
     5import com.framsticks.util.lang.Pair;
     6import com.framsticks.util.lang.Strings;
    77import org.apache.log4j.Logger;
    88
     
    1919public class ConsoleFrame extends JFrame {
    2020
    21         private static final Logger LOGGER = Logger.getLogger(ConsoleFrame.class.getName());
    22 
    23         /**
    24     * Painter coloring manager responses before display.
    25     */
    26     private final ConsolePainter consolePainter;
    27 
    28     /**
    29     * Text field for typing commands.
    30     */
    31     private final JTextField commandLine;
    32         /**
    33     * Reference to connection.
    34     */
    35     protected final ClientConnection connection;
     21        private static final Logger log = Logger.getLogger(ConsoleFrame.class.getName());
     22
     23        /**
     24        * Painter coloring manager responses before display.
     25        */
     26        private final ConsolePainter consolePainter;
     27
     28        /**
     29        * Text field for typing commands.
     30        */
     31        private final JTextField commandLine;
     32        /**
     33        * Reference to connection.
     34        */
     35        protected final ClientConnection connection;
    3636
    3737        /**
     
    5252
    5353        /**
    54     * Default constructor creates frame with console.
    55     */
    56     @SuppressWarnings("unchecked")
    57     public ConsoleFrame(ClientConnection connection) {
    58             this.connection = connection;
    59         this.setTitle("Console");
    60         this.setLayout(new BorderLayout());
    61         this.setSize(new Dimension(440, 400));
    62         this.setMinimumSize(new Dimension(440, 400));
    63         this.setIconImage(ImageProvider.loadImage(ImageProvider.LOGO).getImage());
    64         JFrame.setDefaultLookAndFeelDecorated(true);
    65 
    66             JTextPane text = new JTextPane();
    67         consolePainter = new ConsolePainter(text);
    68 
    69         text.setEditable(false);
    70         final JScrollPane scrollText = new JScrollPane(text);
    71         scrollText.setBorder(BorderFactory.createEtchedBorder());
    72 
    73         JPanel scrollPanel = new JPanel();
    74         scrollPanel.setLayout(new BorderLayout());
    75         scrollPanel.add(scrollText, BorderLayout.CENTER);
    76         scrollPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
    77 
    78         commandLine = new JTextField();
    79 
    80         commandLine.addKeyListener(new KeyListener() {
    81                 @Override
    82                 public void keyTyped(KeyEvent e) {
    83 
    84                 }
    85 
    86                 @Override
    87                 public void keyPressed(KeyEvent e) {
    88                         onKeyPressed(e.getKeyCode());
    89                 }
    90 
    91                 @Override
    92                 public void keyReleased(KeyEvent e) {
    93                 }
    94         });
    95 
    96         commandLine.setFocusTraversalKeys(
    97                         KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
    98                         Collections.EMPTY_SET);
    99 
    100         this.addWindowListener(new WindowAdapter() {
    101             public void windowActivated(WindowEvent e) {
    102                 commandLine.requestFocusInWindow();
    103             }
    104         });
    105 
    106             JButton sendButton = new JButton("Send");
    107         sendButton.addActionListener(new ActionListener() {
    108 
    109                 public void actionPerformed(final ActionEvent e) {
    110                         buttonSendAction();
    111                 }
    112 
    113         });
    114 
    115         final Box cmdBox = new Box(BoxLayout.LINE_AXIS);
    116         cmdBox.add(commandLine);
    117         cmdBox.add(Box.createHorizontalStrut(10));
    118         cmdBox.add(sendButton);
    119         cmdBox.setBorder(BorderFactory.createEmptyBorder(0, 7, 7, 7));
    120 
    121         this.getContentPane().add(scrollPanel, BorderLayout.CENTER);
    122         this.getContentPane().add(cmdBox, BorderLayout.PAGE_END);
    123         this.setVisible(false);
    124 
    125     }
     54        * Default constructor creates frame with console.
     55        */
     56        @SuppressWarnings("unchecked")
     57        public ConsoleFrame(ClientConnection connection) {
     58                this.connection = connection;
     59                this.setTitle("Console");
     60                this.setLayout(new BorderLayout());
     61                this.setSize(new Dimension(440, 400));
     62                this.setMinimumSize(new Dimension(440, 400));
     63                this.setIconImage(ImageProvider.loadImage(ImageProvider.LOGO).getImage());
     64                JFrame.setDefaultLookAndFeelDecorated(true);
     65
     66                JTextPane text = new JTextPane();
     67                consolePainter = new ConsolePainter(text);
     68
     69                text.setEditable(false);
     70                final JScrollPane scrollText = new JScrollPane(text);
     71                scrollText.setBorder(BorderFactory.createEtchedBorder());
     72
     73                JPanel scrollPanel = new JPanel();
     74                scrollPanel.setLayout(new BorderLayout());
     75                scrollPanel.add(scrollText, BorderLayout.CENTER);
     76                scrollPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
     77
     78                commandLine = new JTextField();
     79
     80                commandLine.addKeyListener(new KeyListener() {
     81                        @Override
     82                        public void keyTyped(KeyEvent e) {
     83
     84                        }
     85
     86                        @Override
     87                        public void keyPressed(KeyEvent e) {
     88                                onKeyPressed(e.getKeyCode());
     89                        }
     90
     91                        @Override
     92                        public void keyReleased(KeyEvent e) {
     93                        }
     94                });
     95
     96                commandLine.setFocusTraversalKeys(
     97                                KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
     98                                Collections.EMPTY_SET);
     99
     100                this.addWindowListener(new WindowAdapter() {
     101                        public void windowActivated(WindowEvent e) {
     102                                commandLine.requestFocusInWindow();
     103                        }
     104                });
     105
     106                JButton sendButton = new JButton("Send");
     107                sendButton.addActionListener(new ActionListener() {
     108
     109                        public void actionPerformed(final ActionEvent e) {
     110                                buttonSendAction();
     111                        }
     112
     113                });
     114
     115                final Box cmdBox = new Box(BoxLayout.LINE_AXIS);
     116                cmdBox.add(commandLine);
     117                cmdBox.add(Box.createHorizontalStrut(10));
     118                cmdBox.add(sendButton);
     119                cmdBox.setBorder(BorderFactory.createEmptyBorder(0, 7, 7, 7));
     120
     121                this.getContentPane().add(scrollPanel, BorderLayout.CENTER);
     122                this.getContentPane().add(cmdBox, BorderLayout.PAGE_END);
     123                this.setVisible(false);
     124
     125        }
    126126
    127127        public void setCommandLine(String command) {
     
    130130
    131131
    132     /**
    133     * Shows console frame, sets location relative to parent.
    134     *
    135     * @param parent Frame relative to which console window will be localized.
    136     */
    137     public void show(JFrame parent) {
    138         final Point parentLocation = parent.getLocation();
    139         final Point location = new Point(parentLocation.x + 20, parentLocation.y + 20);
    140         this.setLocation(location);
    141         this.setVisible(true);
    142     }
    143 
    144     /**
    145     * Adds query to console window.
    146     *
    147     * @param line Line of string query.
    148     */
    149     private void addQuery(String line) {
    150         consolePainter.userMsg(line + "\n");
    151     }
    152 
    153 
    154     /**
    155     * Sends message to manager and adds message to console frame.
    156     */
    157     public void buttonSendAction() {
    158         if (!connection.isConnected()) {
    159             JOptionPane.showMessageDialog(this, "missing connection to manager");
    160             return;
    161         }
    162         String commandText = commandLine.getText();
    163             Pair<String, String> command = Strings.splitIntoPair(commandText, ' ', "\n");
    164         Request request = Request.createRequestByTypeString(command.first);
    165         if (request == null) {
    166             LOGGER.warn("not a valid request: " + commandText);
    167             return;
    168         }
    169         request.parseRest(command.second);
    170 
    171             addQuery(commandText);
    172             addSentMessage(commandText);
    173             commandLine.setText("");
    174         connection.send(request, new ResponseCallback() {
    175             @Override
    176             public void process(Response response) {
    177                 for (File f : response.getFiles()) {
    178                     consolePainter.paintMessage(f);
    179                 }
    180             }
    181         });
    182     }
     132        /**
     133        * Shows console frame, sets location relative to parent.
     134        *
     135        * @param parent Frame relative to which console window will be localized.
     136        */
     137        public void show(JFrame parent) {
     138                final Point parentLocation = parent.getLocation();
     139                final Point location = new Point(parentLocation.x + 20, parentLocation.y + 20);
     140                this.setLocation(location);
     141                this.setVisible(true);
     142        }
     143
     144        /**
     145        * Adds query to console window.
     146        *
     147        * @param line Line of string query.
     148        */
     149        private void addQuery(String line) {
     150                consolePainter.userMsg(line + "\n");
     151        }
     152
     153
     154        /**
     155        * Sends message to manager and adds message to console frame.
     156        */
     157        public void buttonSendAction() {
     158                if (!connection.isConnected()) {
     159                        JOptionPane.showMessageDialog(this, "missing connection to manager");
     160                        return;
     161                }
     162                String commandText = commandLine.getText();
     163                Pair<String, String> command = Strings.splitIntoPair(commandText, ' ', "\n");
     164                Request request = Request.createRequestByTypeString(command.first);
     165                if (request == null) {
     166                        log.warn("not a valid request: " + commandText);
     167                        return;
     168                }
     169                request.parseRest(command.second);
     170
     171                addQuery(commandText);
     172                addSentMessage(commandText);
     173                commandLine.setText("");
     174                connection.send(request, new ResponseCallback() {
     175                        @Override
     176                        public void process(Response response) {
     177                                for (File f : response.getFiles()) {
     178                                        consolePainter.paintMessage(f);
     179                                }
     180                        }
     181                });
     182        }
    183183
    184184        private void onKeyPressed(int keyCode) {
Note: See TracChangeset for help on using the changeset viewer.