source: java/main/src/main/java/com/framsticks/gui/ObjectPanel.java @ 98

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

HIGHLIGHTS:

CHANGELOG:
Get data also on tree expansion.

Use nice framstick icon for empty nodes.

Update panel after reload if it is current.

Add shallow reload procedure.

Cut Gui prefix from several tree classes.

Bring back counter of GuiTreeNode?.

Use IdentityHashMap? were it is more appriopriate.

Remove TreeListener?.

Do not use TreeListener? in GUI.

Minor change.

Done migration to GuiTreeModel?.

BrowserTest? in that version always crashes frams.linux.

Move rendering implementation into GuiAbstractNode?.

Use hand-crafted list in GuiTreeNode?.

Generally, it would be a great place for WeakIdentityHashMap?
(but there is none in Java Collection Framework).

Remove superfluous logging.

Fix bug in GuiTreeNode?.

Use IdentityHashMap? instead of HashMap?.

Improve structure update.

Filter out invalid uids in UniqueListAccess?.

Improve TreeCellRenderer?.

Add filtering in TrackConsole?.

Improve TreeModel?.

More changes.

More improvements.

More changes.

Remove TreeNode?.

Support MetaNode? in the GuiTreeModel?.

Implement more in GuiTreeModel?.

Add CompositeParam? interface to FramsClass? and AccessInterface?.

Allow access by number to UniqueList?.

Add UidComparator?.

Use TreeMap? as a default accessee in unique list.

It keeps order of keys.

Introduce classes to use with new TreeModel?.

Another step.

Migrate from TreeNode? to Node in many places.

Remove some uses of TreeNode? as DefaultMutableTreeNode?.

Remove Path from TreeNode? interface.

Remove Path from TreeNode?.

Add Path recration from node feature.

Reworking TreeCellRenderer?.

Minor change of TreeOperations? interface.

Remove last methods from TreeNode?.

Another minor step.

Do not store reference to TreeAtFrame? in TreeNode?.

Add proxy exceptionHandler to StatusBar?.

Move panels management to TreeAtFrame?.

Store localChanges in the NodeAtFrame?.

More cleanup.

Move name computing to TreeCellRenderer?.

Move tooltip and icon computations to TreeCellRenderer?.

More dispatches removed.

Remove most dispatching from TreeNode?.

TreeNode? does not actually redispatch tasks.

Make Tree embedded in Browser use SwingDispatcher?.

Make lazy binding of Tree with Dispatcher.

Minor changes.

Organizational change in AbstractTree?.

Make AbstractTree? compose from Thread instead of inherit from it.

Make SwingDispatcher? and AtOnceDispatcher? Joinable compatible.

Add ListPanelProvider?.

Improve Controls readonly and enabled handling.

Properly pass ExceptionHandlers? in more places.

Make Tree.get accept ValueParam?.

  • This is to allow access number of list elements.

Remove not needed get redirection in ClientAtServer?.

Rename tryResolve to tryGet.

Unify tryResolveAndGet into tryResolve.

Remove resolveTop from Tree interface.

Make Tree.get accept Future<Path>.

Use get to implement resolveTop also in ObjectTree?.

Unify resolveTop and get in RemoteTree?.

Another minor step.

More minor changes in tree operations.

Minor organizational changes.

In RemoteTree? first fetch info for root.

Reworking resolving.

Minor changes.

Make ListAccess? return proxy iterators (instead of creating temporary collection).

Let AccessInterface? return Iterable<Param>.

Improve resolving.

More improvements.

First working completion in ManagedConsole?.

Rename resolve to resolveTop.

This reflects the actuall functionality.

Change semantic of tryResolve and tryResolveAndGet.

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