source: java/main/src/main/java/com/framsticks/gui/ObjectPanel.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.5 KB
Line 
1package com.framsticks.gui;
2
3import com.framsticks.core.Path;
4import com.framsticks.gui.controls.Control;
5import com.framsticks.gui.controls.ControlOwner;
6import com.framsticks.gui.controls.ValueControl;
7import com.framsticks.gui.controls.ValueControlListener;
8import com.framsticks.params.Access;
9import com.framsticks.params.Param;
10import com.framsticks.params.ValueParam;
11
12import org.apache.logging.log4j.Logger;
13import org.apache.logging.log4j.LogManager;
14
15import javax.swing.*;
16
17import java.util.Collection;
18import java.util.IdentityHashMap;
19import java.util.Map;
20import static com.framsticks.util.lang.Containers.filterInstanceof;
21
22import com.framsticks.util.FramsticksException;
23
24@SuppressWarnings("serial")
25public class ObjectPanel extends ModifiablePanel implements ControlOwner {
26
27        private static final Logger log = LogManager.getLogger(ObjectPanel.class);
28
29        final protected Map<Param, Control> components = new IdentityHashMap<Param, Control>();
30        final protected Map<ValueParam, ValueControl> valueControls = new IdentityHashMap<ValueParam, ValueControl>();
31
32        protected final JPanel contentPanel;
33        protected final JScrollPane scrollPane;
34
35        public ObjectPanel(TreePanel.Parameters parameters, Collection<Param> params) {
36                super(parameters);
37
38                contentPanel = new JPanel();
39                scrollPane = new JScrollPane(contentPanel);
40                contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.PAGE_AXIS));
41                setupContentComponent(scrollPane);
42
43                Gui.fillWithControls(this, params, components, Control.class);
44                setName(framsClass.getId());
45
46                for (final ValueControl c : filterInstanceof(components.values(), ValueControl.class)) {
47                        valueControls.put(c.getParam(), c);
48                        c.setUserEnabled(true);
49                        c.setListener(new ValueControlListener() {
50                                @Override
51                                public boolean onChange(Object newValue) {
52                                        if (currentPath == null) {
53                                                return true;
54                                        }
55                                        boolean result = treeAtFrame.changeValue(currentPath.assureResolved().getTopObject(), c, newValue);
56                                        refreshControlButtons();
57                                        return result;
58                                }
59                        });
60                }
61
62                contentPanel.add(Box.createVerticalGlue());
63                this.revalidate();
64        }
65
66        @Override
67        protected void applyChanges() {
68                assert frame.isActive();
69                assert currentPath != null;
70                treeAtFrame.pushLocalChanges(currentPath);
71        }
72
73        protected void refreshControlButtons() {
74                assert frame.isActive();
75                applyButton.setEnabled(treeAtFrame.hasLocalChanges(currentPath.getTopObject()));
76        }
77
78        @Override
79        public void pullValuesFromLocalToUser(Access access) {
80                assert currentPath != null;
81                log.debug("refreshing components");
82
83                final Map<ValueControl, Object> values = new IdentityHashMap<ValueControl, Object>();
84                for (Map.Entry<ValueParam, ValueControl> e : valueControls.entrySet()) {
85                        values.put(e.getValue(), access.get(e.getKey().getId(), Object.class));
86                }
87
88
89                NodeAtFrame nodeAtFrame = treeAtFrame.getLocalInfo(currentPath.getTopObject());
90                if (nodeAtFrame != null) {
91                        for (Map.Entry<ValueControl, Object> e : nodeAtFrame.localChanges.entrySet()) {
92                                values.put(e.getKey(), e.getValue());
93                        }
94                }
95
96                for (Map.Entry<ValueControl, Object> e : values.entrySet()) {
97                        e.getKey().pushValueToUserInterface(e.getValue());
98                }
99                refreshControlButtons();
100                ObjectPanel.this.revalidate();
101
102        }
103
104        @Override
105        public String getTitle() {
106                return "Properties";
107        }
108
109        @Override
110        public JPanel getPanelForControls() {
111                return contentPanel;
112        }
113
114        @Override
115        public void handle(FramsticksException exception) {
116                frame.handle(exception);
117        }
118
119        @Override
120        public Path getCurrentPath() {
121                return super.getCurrentPath();
122        }
123
124}
Note: See TracBrowser for help on using the repository browser.