source: java/main/src/main/java/com/framsticks/gui/StatusBar.java @ 105

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

HIGHLIGHTS:

  • import refactorization: move Tree, Path, etc.

from core to structure package

  • initial serialization implementation
  • improve PrimeExperiment? test
  • many organizational changes and convenience improvements

CHANGELOG:
Make registry in AbstractTree? final.

Move most classes from core to structure package.

Minor changes.

Switch names of Future and FutureHandler?.

Rename ExceptionResultHandler? to ExceptionHandler?.

Rename ExceptionHandler? to ExceptionDispatcherHandler?.

Fix bug in ParamCandidate? cache.

Add missing synchronization to the BufferedDispatcher?.

Develop @Serialized support.

Rework serialization further.

Add serialization/deserialization interface to ValueParam?.

Move getStorageType and isNumeric from Param down to params hierarchy.

Minor changes.

Improve param type induction.

Add TestSerializedClass? for testing new serialization.

Add info files gor GenePool? and Population.

Add standard.expt exemplary netfile.

Add type name field to PropertiesObject?.

Use PropertiesObject? for PropertiesAccess? instead of ordinary map.

Hide getFramsClass is several more places.

More unification accross FramsClass?, Access and Path.

Add ParamCollection?.

Simplify interface for getting params from FramsClass?, Access
or Path.

Make Access.call() interface variadic.

Add arguments(args) convenience wrapper around new Object[] {args}.

Upgrade to apache.commons.lang version 3.1

Minor improvement with Response constructors.

Develop proper result printing in ClientAtServer?.

Add experimentNetsave to PrimeExperiment?.

File size: 2.3 KB
Line 
1package com.framsticks.gui;
2
3
4import java.awt.BorderLayout;
5import java.awt.Dimension;
6// import java.awt.Dimension;
7
8import javax.swing.JPanel;
9import javax.swing.JTextField;
10
11import org.apache.logging.log4j.Logger;
12import org.apache.logging.log4j.LogManager;
13
14import com.framsticks.gui.controls.Control;
15import com.framsticks.util.ExceptionHandler;
16import com.framsticks.util.FramsticksException;
17import com.framsticks.util.dispatching.Dispatcher;
18import com.framsticks.util.dispatching.Dispatching;
19import com.framsticks.util.dispatching.RunAt;
20
21public class StatusBar implements ExceptionHandler {
22        private static final Logger log = LogManager.getLogger(StatusBar.class);
23
24        protected JTextField statusBar;
25        protected JPanel swing;
26        protected ExceptionHandler exceptionHandler;
27        protected final Dispatcher<?> dispatcher;
28
29        /**
30         *
31         */
32        public StatusBar(Dispatcher<?> dispatcher) {
33                this.dispatcher = dispatcher;
34        }
35
36        @SuppressWarnings({"rawtypes", "unchecked"})
37        public void showInfo(final Object value) {
38                Dispatching.dispatchIfNotActive(dispatcher, new RunAt(this) {
39
40                        @Override
41                        protected void runAt() {
42                                String text = value.toString();
43                                log.info("info: {}", text);
44                                statusBar.setText(text);
45
46                        }
47                });
48        }
49
50        @Override
51        @SuppressWarnings({"rawtypes", "unchecked"})
52        public void handle(final FramsticksException exception) {
53                dispatcher.dispatch(new RunAt(this) {
54
55                        @Override
56                        protected void runAt() {
57                                log.error("error: {}", exception.getMessage());
58                                statusBar.setText(exception.getShortMessage(new StringBuilder()).toString());
59                                if (exceptionHandler != null) {
60                                        exceptionHandler.handle(exception);
61                                }
62                        }
63                });
64        }
65
66        public void initializeGui() {
67                statusBar = new JTextField();
68                statusBar.setEditable(false);
69
70                swing = new JPanel();
71                swing.setMaximumSize(new Dimension(Integer.MAX_VALUE, Control.LINE_HEIGHT));
72
73                swing.setLayout(new BorderLayout());
74                swing.add(statusBar, BorderLayout.CENTER);
75                // swing.add(statusBar);
76        }
77
78        /**
79         * @return the swing
80         */
81        public JPanel getSwing() {
82                return swing;
83        }
84
85        /**
86         * @return the exceptionHandler
87         */
88        public ExceptionHandler getExceptionHandler() {
89                return exceptionHandler;
90        }
91
92        /**
93         * @param exceptionHandler the exceptionHandler to set
94         */
95        public void setExceptionHandler(ExceptionHandler exceptionHandler) {
96                this.exceptionHandler = exceptionHandler;
97        }
98
99}
Note: See TracBrowser for help on using the repository browser.