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

    r77 r84  
    11package com.framsticks.gui;
    22
    3 import java.util.HashMap;
    4 import java.util.Map;
     3import org.apache.log4j.Logger;
     4
     5import com.framsticks.core.Instance;
     6import com.framsticks.core.InstanceListener;
     7import com.framsticks.core.ListChange;
     8import com.framsticks.core.Node;
     9import com.framsticks.core.Path;
     10import com.framsticks.params.CompositeParam;
     11import com.framsticks.params.FramsClass;
     12
     13import java.util.*;
     14
     15import javax.swing.tree.TreePath;
    516
    617/**
    718 * @author Piotr Sniegowski
    819 */
    9 public class EndpointAtFrame {
    10     protected final BrowserEndpoint endpoint;
    11     protected final Frame frame;
    12     protected final Map<String, Panel> knownPanels = new HashMap<String, Panel>();
     20public class EndpointAtFrame implements InstanceListener {
    1321
    14     public EndpointAtFrame(BrowserEndpoint endpoint, Frame frame) {
    15         this.endpoint = endpoint;
    16         this.frame = frame;
    17     }
     22        private static final Logger log = Logger.getLogger(EndpointAtFrame.class);
    1823
     24        protected final BrowserEndpoint endpoint;
     25        protected final Frame frame;
     26        protected final Instance instance;
     27        protected final Map<String, Panel> knownPanels = new HashMap<String, Panel>();
     28        protected TreeNode rootTreeNode;
    1929
    20     public BrowserEndpoint getEndpoint() {
    21         return endpoint;
    22     }
     30        public EndpointAtFrame(BrowserEndpoint endpoint, Frame frame) {
     31                this.endpoint = endpoint;
     32                this.frame = frame;
     33                this.instance = endpoint.getInstance();
     34        }
    2335
    24     public Frame getFrame() {
    25         return frame;
    26     }
     36        public BrowserEndpoint getEndpoint() {
     37                return endpoint;
     38        }
    2739
    28     public void registerPanel(Panel panel) {
    29         assert frame.isActive();
    30         knownPanels.put(panel.getClassName(), panel);
    31         frame.cardPanel.add(panel, panel.getFullName());
    32     }
     40        public Frame getFrame() {
     41                return frame;
     42        }
    3343
    34     public Panel findPanel(String className) {
    35         assert frame.isActive();
    36         return (knownPanels.containsKey(className) ? knownPanels.get(className) : null);
    37     }
     44        public void registerPanel(Panel panel) {
     45        }
    3846
    39     public final String getName() {
    40         return endpoint.getName();
    41     }
     47        public Panel findPanel(String accessId) {
     48                assert frame.isActive();
     49                return (knownPanels.containsKey(accessId) ? knownPanels.get(accessId) : null);
     50        }
     51
     52        public final String getName() {
     53                return endpoint.getName();
     54        }
     55
     56        public Panel preparePanel(CompositeParam param, FramsClass framsClass) {
     57                assert frame.isActive();
     58                Panel panel = preparePanelImpl(param, framsClass);
     59                assert panel != null;
     60                String accessId = param.computeAccessId();
     61                panel.uniqueName = accessId + "@" + endpoint.getName();
     62                knownPanels.put(accessId, panel);
     63                frame.cardPanel.add(panel, panel.uniqueName);
     64                log.debug("prepared panel for " + panel);
     65                return panel;
     66        }
     67
     68        protected Panel preparePanelImpl(CompositeParam param, FramsClass framsClass) {
     69                assert frame.isActive();
     70                List<Panel> panels = new ArrayList<Panel>();
     71
     72                Panel.Parameters parameters = new Panel.Parameters(this, param,
     73                                framsClass);
     74                for (PanelProvider pp : frame.browser.panelProviders) {
     75                        Panel p = pp.providePanel(parameters);
     76                        if (p != null) {
     77                                panels.add(p);
     78                        }
     79                }
     80
     81                if (panels.isEmpty()) {
     82                        return new EmptyPanel(parameters);
     83                }
     84                if (panels.size() == 1) {
     85                        return panels.get(0);
     86                }
     87                return new MultiPanel(parameters, panels);
     88
     89        }
     90
     91        @Override
     92        public void onListChange(Path path, ListChange change) {
     93
     94        }
     95
     96        public TreePath getTreePath(Path path, boolean create) {
     97                assert frame.isActive();
     98                TreeNode t = rootTreeNode;
     99                TreePath result = new TreePath(frame.rootNode).pathByAddingChild(rootTreeNode);
     100                List<Node> nodes = path.getNodes();
     101                Iterator<Node> i = nodes.iterator();
     102                i.next();
     103                // Node first = i.next();
     104
     105                // if (!t.path.isResolved()) {
     106                //      t.path = new Path(path.getInstance(), nodes, first);
     107                // }
     108                while (i.hasNext()) {
     109                        Node n = i.next();
     110                        TreeNode r = null;
     111                        for (TreeNode c : t.childrenIterable()) {
     112                                if (c.paramId.equals(n.getParam().getId())) {
     113                                        r = c;
     114                                        break;
     115                                }
     116                        }
     117                        if (r == null) {
     118                                log.debug("missing " + n.getParam().getId() + " in " + t);
     119                                if (!create) {
     120                                        return result;
     121                                }
     122                                Path p = new Path(path.getInstance(), nodes, n);
     123                                log.debug("forced resolution: creating treenode for " + p);
     124                                TreeNode childNode = new TreeNode(EndpointAtFrame.this, p);
     125
     126                                frame.addNode(childNode, t);
     127                                // frame.treeModel.reload();
     128                                // t.add(childNode);
     129                                // frame.treeModel.nodeStructureChanged(t);
     130
     131                                r = childNode;
     132                        } else {
     133                                // if (!r.path.isResolved()) {
     134                                //      r.path = new Path(path.getInstance(), nodes, n);
     135                                // }
     136                        }
     137                        result = result.pathByAddingChild(r);
     138                        t = r;
     139                }
     140                return result;
     141        }
     142
     143        @Override
     144        public void onFetch(final Path path) {
     145                assert instance.isActive();
     146                log.trace("fetched " + path);
     147
     148                frame.invokeLater(new Runnable() {
     149                        @Override
     150                        public void run() {
     151
     152                                TreePath treePath = getTreePath(path, true);
     153                                assert treePath.getPathCount() == path.size() + 1;
     154
     155                                final TreeNode result = (TreeNode) treePath.getLastPathComponent();
     156                                // log.trace("found " + result + " == " + path);
     157                                instance.invokeLater(new Runnable() {
     158                                        @Override
     159                                        public void run() {
     160                                                result.reactForFetchResult(path, null);
     161                                        }
     162                                });
     163                        }
     164                });
     165        }
     166
     167        @Override
     168        public void onRun(Exception e) {
     169
     170        }
     171
     172        @Override
     173        public void onStop(Exception e) {
     174
     175        }
    42176}
Note: See TracChangeset for help on using the changeset viewer.