Ignore:
Timestamp:
07/12/13 23:41:06 (11 years ago)
Author:
psniegowski
Message:

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:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/gui/TreeAtFrame.java

    r99 r100  
    11package com.framsticks.gui;
    22
    3 import org.apache.log4j.Logger;
     3import org.apache.logging.log4j.Logger;
     4import org.apache.logging.log4j.LogManager;
    45
    56import com.framsticks.core.Tree;
     
    89import com.framsticks.core.TreeOperations;
    910import com.framsticks.gui.controls.ValueControl;
    10 import com.framsticks.gui.tree.TreeNode;
    1111import com.framsticks.params.CompositeParam;
    1212import com.framsticks.params.FramsClass;
     
    1414import java.util.*;
    1515
    16 import javax.swing.tree.TreePath;
    1716
    1817
    1918import com.framsticks.util.dispatching.FutureHandler;
    20 import com.framsticks.util.lang.Casting;
    2119
    2220/**
     
    2523public class TreeAtFrame {
    2624
    27         private static final Logger log = Logger.getLogger(TreeAtFrame.class);
     25        private static final Logger log = LogManager.getLogger(TreeAtFrame.class);
    2826
    2927        protected final Frame frame;
    3028        protected final Tree tree;
    31         protected final Map<String, Panel> knownPanels = new HashMap<String, Panel>();
     29        protected final Map<String, TreePanel> knownPanels = new HashMap<>();
    3230        protected Node rootNode;
    33 
    34         protected Map<TreeNode, NodeAtFrame> nodesStorage = new WeakHashMap<>();
    3531
    3632        public TreeAtFrame(Tree tree, Frame frame) {
     
    5046        }
    5147
    52         public void registerPanel(Panel panel) {
    53         }
    54 
    55         public Panel findPanel(String accessId) {
    56                 assert frame.isActive();
    57                 return (knownPanels.containsKey(accessId) ? knownPanels.get(accessId) : null);
    58         }
    59 
    6048        public final String getName() {
    6149                return tree.getName();
    6250        }
    6351
    64         public Panel preparePanel(CompositeParam param, FramsClass framsClass) {
     52        public TreePanel preparePanel(final CompositeParam param) {
    6553                assert frame.isActive();
    66                 Panel panel = preparePanelImpl(param, framsClass);
    67                 assert panel != null;
    68                 String accessId = param.computeAccessId();
    69                 panel.uniqueName = accessId + "@" + tree.getName();
    70                 knownPanels.put(accessId, panel);
    71                 frame.cardPanel.add(panel, panel.uniqueName);
    72                 log.debug("prepared panel for " + panel);
    73                 return panel;
    74         }
    7554
    76         protected Panel preparePanelImpl(CompositeParam param, FramsClass framsClass) {
    77                 assert frame.isActive();
    78                 List<Panel> panels = new ArrayList<Panel>();
     55                TreePanel panel = knownPanels.get(param.getFramsTypeName());
     56                if (panel != null) {
     57                        return panel;
     58                }
    7959
    80                 Panel.Parameters parameters = new Panel.Parameters(this, param, framsClass);
     60                final FramsClass framsClass = tree.getInfoFromCache(param.getContainedTypeName());
     61                final List<TreePanel> panels = new ArrayList<TreePanel>();
     62
     63                final TreePanel.Parameters parameters = new TreePanel.Parameters(this, param, framsClass);
    8164                for (PanelProvider pp : frame.browser.panelProviders) {
    82                         Panel p = pp.providePanel(parameters);
     65                        TreePanel p = pp.providePanel(parameters);
    8366                        if (p != null) {
    8467                                panels.add(p);
     
    8770
    8871                if (panels.isEmpty()) {
    89                         return new EmptyPanel(parameters);
     72                        panel = new EmptyTreePanel(parameters);
     73                } else  if (panels.size() == 1) {
     74                        panel = panels.get(0);
     75                } else {
     76                        panel = new MultiPanel(parameters, panels);
    9077                }
    91                 if (panels.size() == 1) {
    92                         return panels.get(0);
    93                 }
    94                 return new MultiPanel(parameters, panels);
    9578
     79                knownPanels.put(param.getFramsTypeName(), panel);
     80
     81                log.debug("prepared panel for {}", panel);
     82                return panel;
    9683        }
    9784
    98         public boolean hasLocalChanges(TreePath treePath) {
    99                 NodeAtFrame nodeAtFrame = nodesStorage.get(treePath.getLastPathComponent());
     85
     86        public boolean hasLocalChanges(Object object) {
     87                NodeAtFrame nodeAtFrame = tree.getSideNote(object, this, NodeAtFrame.class);
    10088                if (nodeAtFrame == null) {
    10189                        return false;
     
    10492        }
    10593
    106         public NodeAtFrame assureLocalInfo(TreePath treePath) {
     94        public NodeAtFrame assureLocalInfo(Object object) {
    10795                assert frame.isActive();
    108                 NodeAtFrame nodeAtFrame = nodesStorage.get(treePath.getLastPathComponent());
     96                NodeAtFrame nodeAtFrame = tree.getSideNote(object, this, NodeAtFrame.class);
    10997
    11098                if (nodeAtFrame == null) {
    11199                        nodeAtFrame = new NodeAtFrame();
    112                         nodesStorage.put(Casting.throwCast(TreeNode.class, treePath.getLastPathComponent()), nodeAtFrame);
     100                        // log.debug();
     101                        tree.putSideNote(object, this, nodeAtFrame);
    113102                }
    114103                return nodeAtFrame;
    115104        }
    116105
    117         public NodeAtFrame getLocalInfo(TreePath treePath) {
    118                 return nodesStorage.get(treePath.getLastPathComponent());
     106        public NodeAtFrame getLocalInfo(Object object) {
     107                return tree.getSideNote(object, this, NodeAtFrame.class);
    119108        }
    120109
    121         public boolean changeValue(TreePath treePath, ValueControl component, Object newValue) {
    122                 log.debug("changing value of " + component + " to '" + newValue + "'");
     110        public boolean changeValue(Object object, ValueControl component, Object newValue) {
     111                log.debug("changing value of {} to '{}'", component, newValue);
    123112
    124                 assureLocalInfo(treePath).localChanges.put(component, newValue);
     113                assureLocalInfo(object).localChanges.put(component, newValue);
    125114
    126115                return true;
    127116        }
    128117
    129         public void pushLocalChanges(TreePath treePath) {
     118        public void pushLocalChanges(Path path) {
    130119                assert frame.isActive();
     120                path.assureResolved();
    131121
    132                 NodeAtFrame nodeAtFrame = nodesStorage.get(treePath.getLastPathComponent());
     122                NodeAtFrame nodeAtFrame = getLocalInfo(path.getTopObject());
    133123                if (nodeAtFrame == null) {
    134124                        return;
    135125                }
    136                 Path path = frame.treeModel.convertToPath(treePath);
    137 
    138126                for (Map.Entry<ValueControl, Object> e : nodeAtFrame.localChanges.entrySet()) {
    139127                        TreeOperations.set(path, e.getKey().getParam(), e.getValue(), new FutureHandler<Integer>(frame) {
     
    145133        }
    146134
    147         public void fillPanelWithValues(TreePath treePath) {
    148                 NodeAtFrame nodeAtFrame = assureLocalInfo(treePath);
    149                 if (nodeAtFrame == null) {
    150                         return;
    151                 }
    152 
    153                 if (nodeAtFrame.panel == null) {
    154                         return;
    155                 }
    156                 Node node = TreeNode.tryGetNode(treePath);
    157                 if (node == null) {
    158                         return;
    159                 }
    160                 nodeAtFrame.panel.setCurrentTreePath(treePath);
    161                 nodeAtFrame.panel.pullValuesFromLocalToUser(TreeOperations.bindAccess(node));
    162 
    163                 frame.showPanel(nodeAtFrame.panel);
    164 
    165         }
    166 
    167         public void useOrCreatePanel(TreePath treePath) {
    168                 // node.assureResolved();
    169                 Node node = TreeNode.tryGetNode(treePath);
    170 
    171                 NodeAtFrame nodeAtFrame = assureLocalInfo(treePath);
    172 
    173                 if (nodeAtFrame.panel == null) {
    174                         CompositeParam param = node.getParam();
    175                         nodeAtFrame.panel = findPanel(param.computeAccessId());
    176                         if (nodeAtFrame.panel == null) {
    177                                 FramsClass framsClass = node.getTree().getInfoFromCache(param.getContainedTypeName());
    178                                 nodeAtFrame.panel = preparePanel(param, framsClass);
    179                         }
    180                 }
    181                 fillPanelWithValues(treePath);
    182         }
    183135}
Note: See TracChangeset for help on using the changeset viewer.