source: java/main/src/main/java/com/framsticks/gui/MainFrame.java @ 100

Last change on this file since 100 was 100, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • add <include/> to configuration
  • add side notes to tree
    • used to store arbitrary information alongside the tree structure
  • migrate to log4j2
    • supports lazy string evaluation of passed arguments
  • improve GUI tree
    • it stays in synchronization with actual state (even in high load test scenario)
  • improve panel management in GUI
  • make loading objects in GUI more lazy
  • offload parsing to connection receiver thread
    • info parsing
    • first step of objects parsing
  • fix connection parsing bug (eof in long values)
  • support zero-arguments procedure in table view

CHANGELOG:
Implement procedure calls from table view.

Refactorization around procedures in tables.

Add table editor for buttons.

Render buttons in the the list view.

Further improve Columns.

Add Column class for TableModel?.

Accept also non-arguments ProcedureParams? in tableView.

Increase maximal TextAreaControl? size.

Add tooltip to ProcedureControl?.

Fix bug of interpreting eofs in long values by connection reader.

Further rework connection parsing.

Simplify client connection processing.

Test ListChange? modification.

Test ListChange? events with java server.

Add TestChild?.

Fix bug with fast deregistering when connecting to running server.

Another minor refactorization in TreeOperations?.

Fix bug in SimpleAbstractAccess? loading routine.

Another minor improvement.

Minor change.

Make reading of List objects two-phase.

Another minor change.

Dispatch parsing into receiver thread.

Another step.

Enclose passing value in ObjectParam? case in closure.

Minor step.

Minor change on way to offload parsing.

Temporarily comment out single ValueParam? get.

It will be generalized to multi ValueParam?.

Process info in receiver thread.

Add DispatchingExceptionHandler?.

Make waits in browser test longer.

Use FETCHED_MARK.

It is honored in GUI, where it used to decide whether to get values

after user action.

It is set in standard algorithm for processing fetched values.

Add remove operation to side notes.

Make loading more lazy.

Improve loading policy.

On node choose load itself, on node expansion, load children.

Minor improvement.

Fix bug with panel interleaving.

Minor improvements.

Improve panel management.

More cleaning around panels.

Reorganize panels.

Further improve tree.

Fix bug in TreeModel?.

Remove children from TreeNode?.

Implement TreeNode? hashCode and equals.

Make TreeNode? delegate equals and hashcode to internal reference.

Move listeners from TreeNode? to side notes.

Store path.textual as a side note.

Side note params instead of accesses for objects.

More refactorizations.

In TreeNode? bindAccess based on side notes.

Minor step.

Hide createAccess.

Rename AccessInterface? to Access.

Minor changes.

Several improvements in high load scenarios.

Change semantics of ArrayListAccess?.set(index, null);

It now removes the element, making list shorter
(it was set to null before).

Add path remove handler.

Handle exceptions in Connection.

Update .gitignore

Configure logging to file.

Move registration to TreeModel?.

Further refactorization.

Minor refactorization.

Minor improvements.

Use specialized event also for Modify action of ListChange?.

Use remove events.

Use the insertion events for tree.

Further improve tree refreshing.

Further improve reacting on events in GUI.

Fix problem with not adding objects on addition list change.

Migrate to log4j lazy String construction interface.

Migrate imports to log4j2.

Drop dependency on adapter to version 1.2.

Switch log4j implementation to log4j2.

Add dirty mark to the NodeAtFrame?.

Make selecting in AccessInterfaces? type safe.

Ignore containers size settings in Model and Genotype.

Use tree side notes to remember local changes and panels.

Add sideNotes to tree.

They will be used to store various accompanying information
right in the tree.

Use ReferenceIdentityMap? from apache in TreeNode?.

It suits the need perfectly (weak semantics on both key and value).

Make ArrayListParam? do not react size changes.

Guard in TableModel? before not yet loaded objects.

Add <include/> clause and AutoInjector?.

Extract common columns configuration to separate xml,
that can be included by other configurations.

File size: 7.5 KB
Line 
1package com.framsticks.gui;
2
3import java.awt.event.ActionEvent;
4import java.awt.event.KeyEvent;
5import java.awt.event.WindowAdapter;
6import java.awt.event.WindowEvent;
7
8import javax.swing.AbstractAction;
9import javax.swing.JButton;
10import javax.swing.KeyStroke;
11import javax.swing.WindowConstants;
12
13import org.apache.logging.log4j.Logger;
14import org.apache.logging.log4j.LogManager;
15
16import com.framsticks.util.swing.MenuConstructor;
17
18/**
19 * Application Main Frame.
20 */
21@SuppressWarnings("serial")
22public class MainFrame extends Frame {
23
24        private final static Logger log = LogManager.getLogger(MainFrame.class.getName());
25
26        JButton start, stop, step;
27
28        /**
29         * Builds main frame.
30         */
31        public MainFrame(final Browser browser) {
32                super(browser);
33                setTitle("framsticks");
34                log.debug("creating main frame");
35
36        }
37
38
39        @Override
40        protected void initializeGui() {
41                super.initializeGui();
42
43                new MenuConstructor(fileMenu)
44                        .add(null, new AbstractAction("Console") {
45                                @Override
46                                public void actionPerformed(ActionEvent actionEvent) {
47                                        // showConsoleFrame();
48                                }
49                        })
50                        .add(KeyStroke.getKeyStroke(KeyEvent.VK_G, ActionEvent.CTRL_MASK), new AbstractAction("Goto") {
51                                @Override
52                                public void actionPerformed(ActionEvent actionEvent) {
53                                        browser.autoResolvePath("/simulator/genepools/groups/0", null);
54                                        // browser.autoResolvePath("/simulator/populations/groups/0", null;
55                                        // browser.autoResolvePath("/simulator/genepools/groups/0/genotypes", null);
56                                        // browser.autoResolvePath("/simulator/populations/groups", null);
57                                }
58                        })
59                        .add(null, new AbstractAction("Disconnect") {
60                                @Override
61                                public void actionPerformed(ActionEvent actionEvent) {
62                                        disconnect();
63                                }
64                        })
65                        .add(null, new AbstractAction("Quit") {
66                                @Override
67                                public void actionPerformed(ActionEvent actionEvent) {
68                                }
69                        })
70                        ;
71
72                setFrameProperties();
73        }
74
75        // private void onConnectionEstablished() {
76                // assert isActive();
77
78                // addNodeActionToTreePopupMenu("Open in console", new NodeAction() {
79                        // @Override
80                        // public void actionPerformed(TreeNode treeNode) {
81                                // assert isActive();
82                        // }
83                // });
84
85
86
87
88        //      // browser.addNodeActionToTreePopupMenu("Resolve recursively", new NodeAction() {
89        //      //      @Override
90        //      //      public void actionPerformed(TreeNode treeNode) {
91        //      //              final Child child = treeNode.getChild();
92        //      //              //server.invokeLater(new Runnable() {
93        //              //              @Override
94        //              //              public void run() {
95        //              //                      resolveRecursively(child);
96        //              //              }
97        //              //      });
98        //      // }
99        //      // });
100
101
102                // // addNodeActionToTreePopupMenu("Store in file", new NodeAction() {
103                // //     @Override
104                // //     public void actionPerformed(final TreeNode treeNode) {
105                // //         // final Node node = treeNode.getNode();
106                // //         // server.invokeLater(new Runnable() {
107                // //         //     @Override
108                // //         //     public void run() {
109                // //         //         try {
110                // //         //             log.info("storing");
111                // //         //             //File file = new File();
112                // //         //             StoreStream stream = new StoreStream(file, server.getManager());
113                // //         //             stream.store(node);
114                // //         //         } catch (FileNotFoundException e) {
115                // //         //             e.printStackTrace();
116                // //         //         }
117                // //         //     }
118                // //         // });
119                // //     }
120                // // });
121
122
123        //      // arguments.forEach("resolve", new UnaryFunctor<Boolean, String>() {
124        //      //      @Override
125        //      //      public Boolean call(final String s) {
126        //      //              server.getManager().resolvePath(s, new StateFunctor() {
127        //      //                      @Override
128        //      //                      public void call(Exception e) {
129        //      //                              if (e != null) {
130        //      //                                      log.error("failed to resolve: {}", s);
131        //      //                                      return;
132        //      //                              }
133        //      //                              log.info("succeeded to resolve: {}", s);
134        //      //                      }
135        //      //              });
136        //      //              return true;
137        //      //      }
138        //      // });
139
140
141        //      // arguments.forEach("console", new UnaryFunctor<Boolean, String>() {
142        //      //      @Override
143        //      //      public Boolean call(String s) {
144        //      //              showConsoleFrame().setCommandLine(s);
145        //      //              return true;
146        //      //      }
147        //      // });
148        // }
149
150
151        // /**
152        //  * Creates panel with start, step, stop buttons.
153        //  */
154        // @Override
155        // protected JPanel createLeftTopPanel() {
156        //      assert isActive();
157        //      Dimension buttonDimension = new Dimension(45, 45);
158
159        //      JPanel panel = new JPanel();
160
161        //      stop = new JButton(ImageProvider.loadImage(ImageProvider.SIM_STOP));
162        //      stop.addActionListener(new ActionListener() {
163
164        //              public void actionPerformed(ActionEvent e) {
165        //                      setSimulationRunning(false);
166        //              }
167
168        //      });
169
170        //      stop.setPreferredSize(buttonDimension);
171        //      stop.setToolTipText("Simulation Stop");
172        //      stop.setEnabled(false);
173
174        //      step = new JButton(ImageProvider.loadImage(ImageProvider.SIM_STEP));
175        //      /*
176        //      step.addActionListener(new ActionListener() {
177
178        //              public void actionPerformed(ActionEvent e) {
179        //                      connection.send(new CallQuery().setMethod("step").setPath("/simulator"));
180        //              }
181
182        //      });
183        //      */
184
185        //      step.setPreferredSize(buttonDimension);
186        //      step.setToolTipText("Simulation Step");
187
188        //      start = new JButton(ImageProvider.loadImage(ImageProvider.SIM_START));
189        //      start.addActionListener(new ActionListener() {
190
191        //              public void actionPerformed(ActionEvent e) {
192        //                      setSimulationRunning(true);
193        //              }
194
195        //      });
196
197        //      start.setPreferredSize(buttonDimension);
198        //      start.setToolTipText("Start Simulation");
199
200        //      JPanel buttonPanel = new JPanel();
201        //      buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
202        //      buttonPanel.add(Box.createHorizontalStrut(5));
203        //      buttonPanel.add(stop);
204        //      buttonPanel.add(Box.createHorizontalStrut(10));
205        //      buttonPanel.add(step);
206        //      buttonPanel.add(Box.createHorizontalStrut(10));
207        //      buttonPanel.add(start);
208        //      buttonPanel.add(Box.createHorizontalStrut(5));
209
210        //      buttonPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory
211        //                      .createRaisedBevelBorder(), "Simulation Control",
212        //                      TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION
213        //                      ));
214
215        //      panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
216        //      panel.add(Box.createHorizontalGlue());
217        //      panel.add(buttonPanel);
218        //      panel.add(Box.createHorizontalGlue());
219        //      return panel;
220        // }
221
222        /**
223         * Sets frame properties.
224         */
225        private void setFrameProperties() {
226                assert isActive();
227                getSwing().setMinimumSize(getSwing().getPreferredSize());
228                getSwing().setSize(getSwing().getPreferredSize());
229                getSwing().setMaximumSize(screenDimension);
230                getSwing().setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
231
232                getSwing().setIconImage(ImageProvider.loadImage(ImageProvider.LOGO)
233                                .getImage());
234
235
236                getSwing().addWindowListener(new WindowAdapter() {
237                        public void windowClosing(WindowEvent e) {
238                                assert isActive();
239                                /*
240                                if (connection != null) {
241                                        connection.close();
242                                }
243                                */
244                                onWindowClosing();
245                                getSwing().dispose();
246                        }
247                });
248        }
249
250        // public ConsoleFrame showConsoleFrame() {
251        //      assert isActive();
252        //      /*
253        //      ConsoleFrame consoleFrame = new ConsoleFrame(connection);
254        //      consoleFrame.show(MainFrame.this);
255        //      return consoleFrame;
256        //      */
257        //      return null;
258        // }
259
260        /**
261         * Closes connection with manager.
262         */
263        private void disconnect() {
264                assert isActive();
265                browser.clear();
266                onWindowClosing();
267                // statusBar.setText("You are disconnected");
268        }
269
270        /**
271         * Method used while window is closing.
272         */
273        private void onWindowClosing() {
274                assert isActive();
275
276        }
277
278        public void setRunningButtons(boolean running) {
279                assert isActive();
280                step.setEnabled(!running);
281                stop.setEnabled(running);
282                start.setEnabled(!running);
283        }
284
285}
286
Note: See TracBrowser for help on using the repository browser.