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

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

HIGHLIGHTS:

  • improve tree side notes
  • improve GUI layout
  • add foldable list of occured events to EventControl?
  • improve automatic type conversion in proxy listeners
  • implement several Access functionalities as algorithms independent of Access type
  • introduce draft base classes for distributed experiments
  • automatically register dependant Java classes to FramsClass? registry
  • add testing prime experiment and configuration
  • simplify and improve task dispatching

CHANGELOG:
Improve task dispatching in RemoteTree?.

GUI no longer hangs on connection problems.

Make all dispatchers joinables.

Refactorize Thread dispatcher.

Remove Task and PeriodicTask?.

Use Java utilities in those situations.

Reworking tasks dispatching.

Fix bug in EventControl? listener dispatching.

Minor improvements.

Add testing configuration for ExternalProcess? in GUI.

More improvement to prime.

Support for USERREADONLY in GUI.

Add that flag to various params in Java classes.

Remove redundant register clauses from several FramsClassAnnotations?.

Automatically gather and register dependant classes.

Add configuration for prime.

Improve Simulator class.

Add prime.xml configuration.

Introduce draft Experiment and Simulator classes.

Add prime experiment tests.

Enclose typical map with listeners into SimpleUniqueList?.

Needfile works in GUI.

Improve needfile handling in Browser.

More improvement with NeedFile?.

Implementing needfile.

Update test.

Rename ChangeEvent? to TestChangeEvent?.

Automatic argument type search in RemoteTree? listeners.

MultiParamLoader? uses AccessProvider?. By default old implementation
enclosed in AccessStash? or Registry.

Minor changes.

Rename SourceInterface? to Source.

Also improve toString of File and ListSource?.

Remove unused SimpleSource? class.

Add clearing in HistoryControl?.

Show entries in table at EventControl?.

Improve EventControl?.

Add listeners registration to EventControl?.

Add foldable table to HistoryControl?.

Add control row to Procedure and Event controls.

Improve layout of controls.

Another minor change to gui layout.

Minor improvement in the SliderControl?.

Minor changes.

Move ReflectionAccess?.Backend to separate file.

It was to cluttered.

Cleanup in ReflectionAccess?.

Move setMin, setMax, setDef to AccessOperations?.

Extract loading operation into AccessOperations?.

Append Framsticks to name of UnsupportedOperationException?.

The java.lang.UnsupportedOperationException? was shadowing this class.

Rename params.Util to params.ParamsUtil?.

Several improvements.

Minor changes.

Implement revert functionality.

Improve local changes management.

Minor improvement.

Remove methods rendered superfluous after SideNoteKey? improvement.

Improve SideNoteKey?.

It is now generic type, so explicit type specification at
call site is no more needed.

Introduce SideNoteKey? interface.

Only Objects implementing that key may be used as side note keys.

Minor improvements.

Use strings instead of ValueControls? in several gui mappings.

File size: 3.2 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.params.Access;
8import com.framsticks.params.Param;
9
10import org.apache.logging.log4j.Logger;
11import org.apache.logging.log4j.LogManager;
12
13import javax.swing.*;
14
15import java.util.Collection;
16import java.util.HashMap;
17import java.util.Map;
18import static com.framsticks.util.lang.Containers.filterInstanceof;
19
20import com.framsticks.util.FramsticksException;
21
22import static com.framsticks.core.TreeOperations.*;
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<String, Control> controls = new HashMap<String, Control>();
30        final protected Map<String, ValueControl> valueControls = new HashMap<String, 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
41                setupContentComponent(scrollPane);
42
43                Gui.fillWithControls(this, contentPanel, params, controls, Control.class);
44                setName(framsClass.getId());
45
46                for (final ValueControl c : filterInstanceof(controls.values(), ValueControl.class)) {
47                        valueControls.put(c.getParam().getId(), c);
48                        c.setUserEnabled(true);
49                }
50
51                contentPanel.add(Box.createVerticalGlue());
52                this.revalidate();
53        }
54
55        @Override
56        protected void applyChanges() {
57                assert frame.isActive();
58                assert currentPath != null;
59                treeAtFrame.pushUserChangesToTree(currentPath);
60                refreshControlButtons();
61        }
62
63
64        @Override
65        protected void revertChanges() {
66                assert currentPath != null;
67                removeSideNote(currentPath, treeAtFrame.getUserChangesKey());
68                pullValuesFromLocalToUser(bindAccess(currentPath));
69        }
70
71        @Override
72        public void pullValuesFromLocalToUser(Access access) {
73                assert currentPath != null;
74                log.debug("refreshing components");
75
76                UserChanges userChanges = getSideNote(currentPath, treeAtFrame.getUserChangesKey());
77
78
79                for (Map.Entry<String, ValueControl> e : valueControls.entrySet()) {
80                        String id = e.getKey();
81                        Object value;
82                        if (userChanges != null && userChanges.changes.containsKey(id)) {
83                                value = userChanges.changes.get(id);
84                        } else {
85                                value = access.get(id, Object.class);
86                        }
87
88                        e.getValue().pushValueToUserInterface(value);
89                }
90
91                for (Map.Entry<String, Control> e : controls.entrySet()) {
92                        e.getValue().refreshState();
93                }
94
95                refreshControlButtons();
96                // ObjectPanel.this.revalidate();
97        }
98
99        @Override
100        public String getTitle() {
101                return "Properties";
102        }
103
104        @Override
105        public void handle(FramsticksException exception) {
106                frame.handle(exception);
107        }
108
109        @Override
110        public Path getCurrentPath() {
111                return super.getCurrentPath();
112        }
113
114        @Override
115        public boolean onValueChange(ValueControl control, Object newValue) {
116                if (currentPath == null) {
117                        return true;
118                }
119                boolean result = treeAtFrame.changeValue(currentPath.assureResolved().getTopObject(), control, newValue);
120                refreshControlButtons();
121                return result;
122        }
123
124}
Note: See TracBrowser for help on using the repository browser.