source: java/main/src/main/java/com/framsticks/gui/Browser.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: 7.2 KB
Line 
1package com.framsticks.gui;
2
3import com.framsticks.core.*;
4import com.framsticks.gui.console.Console;
5import com.framsticks.gui.console.TrackConsole;
6import com.framsticks.gui.table.ColumnsConfig;
7import com.framsticks.gui.table.ListPanelProvider;
8import com.framsticks.params.annotations.AutoAppendAnnotation;
9import com.framsticks.params.annotations.FramsClassAnnotation;
10import com.framsticks.params.annotations.ParamAnnotation;
11import com.framsticks.remote.RemoteTree;
12import com.framsticks.util.FramsticksException;
13import com.framsticks.util.dispatching.AbstractJoinable;
14import com.framsticks.util.dispatching.Dispatcher;
15import com.framsticks.util.dispatching.Dispatching;
16import com.framsticks.util.dispatching.ExceptionResultHandler;
17import com.framsticks.util.dispatching.Future;
18import com.framsticks.util.dispatching.Joinable;
19import com.framsticks.util.dispatching.JoinableCollection;
20import com.framsticks.util.dispatching.JoinableParent;
21import com.framsticks.util.dispatching.JoinableState;
22
23import javax.swing.*;
24
25import org.apache.logging.log4j.Logger;
26import org.apache.logging.log4j.LogManager;
27
28import java.awt.Dimension;
29import java.awt.Toolkit;
30import java.awt.datatransfer.StringSelection;
31import java.awt.event.ActionEvent;
32import java.util.ArrayList;
33import java.util.LinkedList;
34import java.util.List;
35import com.framsticks.util.dispatching.RunAt;
36
37/**
38 * @author Piotr Sniegowski
39 */
40@FramsClassAnnotation
41public class Browser extends AbstractJoinable implements Dispatcher<Browser>, JoinableParent, ExceptionResultHandler {
42
43        private static final Logger log = LogManager.getLogger(Browser.class);
44
45        protected final JoinableCollection<Frame> frames = new JoinableCollection<Frame>().setObservableName("frames");
46        protected final JoinableCollection<Tree> trees = new JoinableCollection<Tree>().setObservableName("trees");
47        protected final JoinableCollection<Console> consoles = new JoinableCollection<Console>().setObservableName("consoles");
48
49        protected final List<PopupMenuEntryProvider> popupMenuEntryProviders = new LinkedList<>();
50        // protected final SwingDispatcher
51
52        protected final MainFrame mainFrame;
53        protected final List<PanelProvider> panelProviders = new ArrayList<PanelProvider>();
54        protected Dimension defaultFrameDimension;
55
56        String name;
57
58        public void addFrame(Frame frame) {
59                frames.add(frame);
60        }
61
62        protected final StandardPanelProvider standardPanelProvider;
63        protected final ListPanelProvider listPanelProvider;
64
65        public Browser() {
66                setName("browser");
67                JPopupMenu.setDefaultLightWeightPopupEnabled(false);
68                addPanelProvider(standardPanelProvider = new StandardPanelProvider());
69                addPanelProvider(listPanelProvider = new ListPanelProvider());
70
71                mainFrame = new MainFrame(Browser.this);
72
73                // mainFrame.getStatusBar().setExceptionHandler(ThrowExceptionHandler.getInstance());
74
75                addFrame(mainFrame);
76
77                addPopupMenuEntryProvider(new PopupMenuEntryProvider() {
78                        @Override
79                        public void provide(JPopupMenu menu, Path path) {
80                                menu.add(new JMenuItem(path.getFullTextual()));
81                                menu.addSeparator();
82                        }
83                });
84
85                addPopupMenuEntryProvider(new PopupMenuEntryProvider() {
86                        @SuppressWarnings("serial")
87                        @Override
88                        public void provide(JPopupMenu menu, final Path path) {
89                                menu.add(new AbstractAction("Copy path to clipboard") {
90                                        @Override
91                                        public void actionPerformed(ActionEvent e) {
92                                                Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(path.getFullTextual()), null);
93                                        }
94                                });
95                        }
96                });
97
98                addPopupMenuEntryProvider(new PopupMenuEntryProvider() {
99                        @SuppressWarnings("serial")
100                        @Override
101                        public void provide(JPopupMenu menu, final Path path) {
102                                if (!(path.getTree() instanceof RemoteTree)) {
103                                        return;
104                                }
105                                final RemoteTree remoteTree = (RemoteTree) path.getTree();
106                                menu.add(new AbstractAction("Open tracking console") {
107                                        @Override
108                                        public void actionPerformed(ActionEvent e) {
109                                                consoles.add(new TrackConsole().setConnection(remoteTree.getConnection()));
110                                        }
111                                });
112                        }
113                });
114                // addNodeActionToTreePopupMenu("", new NodeAction() )
115
116        }
117
118        @AutoAppendAnnotation
119        public void addPanelProvider(PanelProvider panelProvider) {
120                log.debug("added panel provider of type: {}", panelProvider.getClass().getCanonicalName());
121                panelProviders.add(panelProvider);
122        }
123
124        @AutoAppendAnnotation
125        public void addColumnsConfig(ColumnsConfig columnsConfig) {
126                listPanelProvider.addColumnsConfig(columnsConfig);
127        }
128
129        @AutoAppendAnnotation
130        public void addPopupMenuEntryProvider(PopupMenuEntryProvider popupMenuEntryProvider) {
131                popupMenuEntryProviders.add(popupMenuEntryProvider);
132        }
133
134        @AutoAppendAnnotation
135        public void addTree(Tree tree) {
136                log.debug("adding tree: {}", tree);
137                tree.setDispatcher(new SwingDispatcher<Tree>());
138                tree.setExceptionHandler(this);
139                trees.add(tree);
140        }
141
142        public void autoResolvePath(final String path, final Future<Path> future) {
143                // final Tree i = trees.get("localhost");
144                // i.dispatch(new RunAt<Tree>(future) {
145                //      @Override
146                //      protected void runAt() {
147                //              TreeOperations.tryGet(i, path, new FutureHandler<Path>(future) {
148                //                      @Override
149                //                      protected void result(final Path p) {
150                //                              future.pass(p);
151                //                              mainFrame.dispatch(new RunAt<Frame>(future) {
152                //                                      @Override
153                //                                      protected void runAt() {
154                //                                              mainFrame.goTo(p);
155                //                                      }
156                //                              });
157                //                      }
158                //              });
159                //      }
160                // });
161        }
162
163        public void clear() {
164                assert isActive();
165                for (Frame f : frames) {
166                        f.clear();
167                }
168        }
169
170        @Override
171        protected void joinableStart() {
172                Dispatching.use(frames, this);
173                Dispatching.use(trees, this);
174                Dispatching.use(consoles, this);
175
176                dispatch(new RunAt<Browser>(this) {
177                        @Override
178                        protected void runAt() {
179
180                                for (final Tree i : trees) {
181                                        i.dispatch(new RunAt<Tree>(this) {
182                                                @Override
183                                                protected void runAt() {
184                                                        final Path p = Path.to(i, "/");
185                                                        dispatch(new RunAt<Browser>(this) {
186                                                                @Override
187                                                                protected void runAt() {
188                                                                        mainFrame.addRootPath(p);
189                                                                }
190                                                        });
191                                                }
192                                        });
193                                }
194                        }
195                });
196        }
197
198        /**
199         * @return the tree
200         */
201        public JoinableCollection<Tree> getTrees() {
202                return trees;
203        }
204
205        /**
206         * @return the mainFrame
207         */
208        public MainFrame getMainFrame() {
209                return mainFrame;
210        }
211
212        /**
213         * @return the name
214         */
215        @ParamAnnotation
216        public String getName() {
217                return name;
218        }
219
220        /**
221         * @param name the name to set
222         */
223        @ParamAnnotation
224        public void setName(String name) {
225                this.name = name;
226        }
227
228        @Override
229        public boolean isActive() {
230                return SwingDispatcher.getInstance().isActive();
231        }
232
233        @Override
234        public void dispatch(RunAt<? extends Browser> runnable) {
235                SwingDispatcher.getInstance().dispatch(runnable);
236        }
237
238        @Override
239        protected void joinableJoin() throws InterruptedException {
240                Dispatching.join(frames);
241                Dispatching.join(trees);
242                Dispatching.join(consoles);
243                // super.join();
244        }
245
246        @Override
247        protected void joinableInterrupt() {
248                Dispatching.drop(consoles, this);
249                Dispatching.drop(frames, this);
250                Dispatching.drop(trees, this);
251        }
252
253        @Override
254        public void childChangedState(Joinable joinable, JoinableState state) {
255                if (joinable == frames) {
256                        proceedToState(state);
257                }
258
259        }
260
261        @Override
262        protected void joinableFinish() {
263
264        }
265
266        @Override
267        public String toString() {
268                return getName();
269        }
270
271        @Override
272        public void handle(FramsticksException exception) {
273                mainFrame.handle(exception);
274        }
275
276}
Note: See TracBrowser for help on using the repository browser.