source: java/main/src/main/java/com/framsticks/gui/TreeAtFrame.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: 3.2 KB
Line 
1package com.framsticks.gui;
2
3import org.apache.logging.log4j.Logger;
4import org.apache.logging.log4j.LogManager;
5
6import com.framsticks.core.Tree;
7import com.framsticks.core.Node;
8import com.framsticks.core.Path;
9import com.framsticks.core.TreeOperations;
10import com.framsticks.gui.controls.ValueControl;
11import com.framsticks.params.CompositeParam;
12import com.framsticks.params.FramsClass;
13
14import java.util.*;
15
16
17
18import com.framsticks.util.dispatching.FutureHandler;
19
20/**
21 * @author Piotr Sniegowski
22 */
23public class TreeAtFrame {
24
25        private static final Logger log = LogManager.getLogger(TreeAtFrame.class);
26
27        protected final Frame frame;
28        protected final Tree tree;
29        protected final Map<String, TreePanel> knownPanels = new HashMap<>();
30        protected Node rootNode;
31
32        public TreeAtFrame(Tree tree, Frame frame) {
33                this.frame = frame;
34                this.tree = tree;
35        }
36
37        public Frame getFrame() {
38                return frame;
39        }
40
41        /**
42         * @return the tree
43         */
44        public Tree getTree() {
45                return tree;
46        }
47
48        public final String getName() {
49                return tree.getName();
50        }
51
52        public TreePanel preparePanel(final CompositeParam param) {
53                assert frame.isActive();
54
55                TreePanel panel = knownPanels.get(param.getFramsTypeName());
56                if (panel != null) {
57                        return panel;
58                }
59
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);
64                for (PanelProvider pp : frame.browser.panelProviders) {
65                        TreePanel p = pp.providePanel(parameters);
66                        if (p != null) {
67                                panels.add(p);
68                        }
69                }
70
71                if (panels.isEmpty()) {
72                        panel = new EmptyTreePanel(parameters);
73                } else  if (panels.size() == 1) {
74                        panel = panels.get(0);
75                } else {
76                        panel = new MultiPanel(parameters, panels);
77                }
78
79                knownPanels.put(param.getFramsTypeName(), panel);
80
81                log.debug("prepared panel for {}", panel);
82                return panel;
83        }
84
85
86        public boolean hasLocalChanges(Object object) {
87                NodeAtFrame nodeAtFrame = tree.getSideNote(object, this, NodeAtFrame.class);
88                if (nodeAtFrame == null) {
89                        return false;
90                }
91                return !nodeAtFrame.localChanges.isEmpty();
92        }
93
94        public NodeAtFrame assureLocalInfo(Object object) {
95                assert frame.isActive();
96                NodeAtFrame nodeAtFrame = tree.getSideNote(object, this, NodeAtFrame.class);
97
98                if (nodeAtFrame == null) {
99                        nodeAtFrame = new NodeAtFrame();
100                        // log.debug();
101                        tree.putSideNote(object, this, nodeAtFrame);
102                }
103                return nodeAtFrame;
104        }
105
106        public NodeAtFrame getLocalInfo(Object object) {
107                return tree.getSideNote(object, this, NodeAtFrame.class);
108        }
109
110        public boolean changeValue(Object object, ValueControl component, Object newValue) {
111                log.debug("changing value of {} to '{}'", component, newValue);
112
113                assureLocalInfo(object).localChanges.put(component, newValue);
114
115                return true;
116        }
117
118        public void pushLocalChanges(Path path) {
119                assert frame.isActive();
120                path.assureResolved();
121
122                NodeAtFrame nodeAtFrame = getLocalInfo(path.getTopObject());
123                if (nodeAtFrame == null) {
124                        return;
125                }
126                for (Map.Entry<ValueControl, Object> e : nodeAtFrame.localChanges.entrySet()) {
127                        TreeOperations.set(path, e.getKey().getParam(), e.getValue(), new FutureHandler<Integer>(frame) {
128                                @Override
129                                protected void result(Integer flag) {
130                                }
131                        });
132                }
133        }
134
135}
Note: See TracBrowser for help on using the repository browser.