source: java/main/src/main/java/com/framsticks/gui/controls/ProcedureControl.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.0 KB
Line 
1package com.framsticks.gui.controls;
2
3import com.framsticks.core.Tree;
4import com.framsticks.core.Path;
5import com.framsticks.gui.Frame;
6import com.framsticks.gui.Gui;
7import com.framsticks.params.Param;
8import com.framsticks.params.ValueParam;
9import com.framsticks.params.types.ProcedureParam;
10import com.framsticks.util.dispatching.ExceptionResultHandler;
11import com.framsticks.util.dispatching.FutureHandler;
12import com.framsticks.util.dispatching.RunAt;
13import com.framsticks.util.dispatching.ThrowExceptionHandler;
14
15import javax.swing.*;
16import javax.swing.border.BevelBorder;
17import javax.swing.tree.TreePath;
18
19import org.apache.log4j.Logger;
20
21import java.awt.event.ActionEvent;
22import java.awt.event.ActionListener;
23import java.util.IdentityHashMap;
24import java.util.LinkedList;
25import java.util.List;
26import java.util.Map;
27
28@SuppressWarnings("serial")
29public class ProcedureControl extends Control implements ControlOwner {
30
31        private static final Logger log = Logger.getLogger(ProcedureControl.class);
32
33        protected final JButton procedureButton;
34
35        final protected Map<ValueParam, ValueControl> components = new IdentityHashMap<>();
36
37        public ProcedureControl(ProcedureParam procedureParam) {
38                super(procedureParam);
39
40                procedureButton = new JButton("Call");
41                procedureButton.setName("call");
42
43                this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
44
45                Gui.fillWithControls(this, procedureParam.getArgumentsType(), components, ValueControl.class);
46
47                if (components.size() != procedureParam.getArgumentsType().size()) {
48                        procedureButton.setEnabled(false);
49                }
50                if (!components.isEmpty()) {
51                        this.setBorder(new BevelBorder(BevelBorder.RAISED));
52                }
53
54                procedureButton.addActionListener(new ActionListener() {
55                        @Override
56                        public void actionPerformed(ActionEvent e) {
57
58                                final Path path = getFrame().getTreeModel().convertToPath(getCurrentTreePath());
59
60                                final List<Object> arguments = new LinkedList<Object>();
61                                for (Param arg : getParam().getArgumentsType()) {
62                                        Object value = components.get(arg).getCurrentValue();
63                                        arguments.add(value);
64                                        log.debug("argument " + arg + ": " + value);
65                                }
66                                //TODO FEH: make it show dialog
67                                final ExceptionResultHandler handler = ThrowExceptionHandler.getInstance();
68
69                                path.getTree().dispatch(new RunAt<Tree>(handler) {
70                                        @Override
71                                        protected void runAt() {
72                                                path.getTree().call(path, getParam(), arguments.toArray(), new FutureHandler<Object>(handler) {
73
74                                                        @Override
75                                                        public void result(Object result) {
76
77                                                        }
78                                                });
79                                        }
80                                });
81                        }
82                });
83                this.add(procedureButton);
84
85        }
86
87        @Override
88        public JPanel getPanel() {
89                return this;
90        }
91
92        @Override
93        public ProcedureParam getParam() {
94                return (ProcedureParam) param;
95        }
96
97        @Override
98        protected void updateEnabled(boolean enabled) {
99                procedureButton.setEnabled(enabled);
100                for (ValueControl vc : components.values()) {
101                        vc.setUserEnabled(enabled);
102                }
103        }
104
105        @Override
106        public Frame getFrame() {
107                return owner.getFrame();
108        }
109
110        @Override
111        public TreePath getCurrentTreePath() {
112                return owner.getCurrentTreePath();
113        }
114
115}
Note: See TracBrowser for help on using the repository browser.