source: java/main/src/main/java/com/framsticks/gui/windows/ServerLogFrame.java @ 84

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

HIGHLIGHTS:

  • simplification of entities management model
  • cleanup around params (improve hierarchy)
  • migrate from JUnit to TestNG
  • introduce FEST to automatically test GUI
  • improve slider control
  • loosen synchronization between gui tree and backend representation
  • and many other bug fixes

NOTICE:

  • a great many of lines is changed only because of substituting spaces with tabs

CHANGELOG (oldest changes at the bottom):

Some cleaning after fix found.

Fix bug with tree.

More changes with TreeNodes?.

Finally fix issue with tree.

Improve gui tree management.

Decouple update of values from fetch request in gui.

Minor changes.

Minor changes.

Minor change.

Change Path construction wording.

More fixes to SliderControl?.

Fix SliderControl?.

Fix SliderControl?.

Minor improvement.

Several changes.

Make NumberParam? a generic class.

Add robot to the gui test.

Setup common testing logging configuration.

Remove Parameters class.

Remove entityOwner from Parameters.

Move name out from Parameters class.

Move configuration to after the construction.

Simplify observers and endpoints.

Remove superfluous configureEntity overrides.

Add dependency on fest-swing-testng.

Use FEST for final print test.

Use FEST for more concise and readable assertions.

Divide test of F0Parser into multiple methods.

Migrate to TestNG

Minor change.

Change convention from LOGGER to log.

Fix reporting of errors during controls filling.

Bound maximal height of SliderControl?.

Minor improvements.

Improve tooltips for controls.

Also use Delimeted in more places.

Move static control utilities to Gui.

Rename package gui.components to controls.

Some cleaning in controls.

Improve Param classes placing.

Move ValueParam?, PrimitiveParam? and CompositeParam? one package up.

Improve ParamBuilder?.

Move getDef to ValueParam? and PrimitiveParam?.

Move getMax and getDef to ValueParam?.

Move getMin to ValueParam?.

Upgrade to laters apache commons versions.

Use filterInstanceof extensively.

Add instanceof filters.

Make ValueParam? in many places of Param.

Place assertions about ValueParam?.

Add ValueParam?

Rename ValueParam? to PrimitiveParam?

Minor changes.

Several improvements to params types.

Add NumberParam?.

Add TextControl? component.

Add .swp files to .gitignore

Greatly improved slider component.

Some improvements.

Make Param.reassign return also a state.

Add IterableIterator?.

Several changes.

  • Move util classes to better packages.
  • Remove warnings from eclim.

Several improvements.

Fix bug with BooleanParam?.

Some experiments with visualization.

Another fix to panel management.

Improve panel management.

Some refactorization around panels.

Add root class for panel.

File size: 3.1 KB
Line 
1package com.framsticks.gui.windows;
2
3import com.framsticks.gui.ImageProvider;
4import org.apache.log4j.Logger;
5
6import javax.swing.*;
7import java.awt.*;
8import java.awt.event.ActionEvent;
9import java.awt.event.ActionListener;
10
11/**
12 * Frame displaying manager logs.
13 */
14@SuppressWarnings("serial")
15public class ServerLogFrame extends JFrame {
16        public JTextArea logText;
17        private int levelReporting = -1;
18        private boolean popUp = true;
19
20        private final static String[] STR_ = {"DEBUG", "INFO", "WARNING", "ERROR",
21                        "CRITICAL"};
22
23
24        public ServerLogFrame() {
25
26                super("FNC - Manager Log");
27                Dimension size = new Dimension(440, 400);
28                this.setSize(size);
29                this.setMinimumSize(size);
30                this.setIconImage(ImageProvider.loadImage(ImageProvider.LOGO).getImage());
31                JFrame.setDefaultLookAndFeelDecorated(true);
32                /*
33                try {
34                        UIManager
35                                        .setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
36                } catch (Exception ex) {
37                }
38                */
39                this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
40                logText = new JTextArea();
41                //logText.setFont(Control.FONT);
42                logText.setEditable(false);
43                logText.setWrapStyleWord(true);
44                logText.setLineWrap(true);
45                JComboBox levelBox = new JComboBox();
46                for (String i : STR_) {
47                        levelBox.addItem(i);
48                }
49                levelBox.addActionListener(new ActionListener() {
50                        public void actionPerformed(ActionEvent e) {
51                                levelReporting = ((JComboBox) e.getSource()).getSelectedIndex();
52                        }
53                });
54                JCheckBox logPopup = new JCheckBox();
55                logPopup.addActionListener(new ActionListener() {
56                        public void actionPerformed(ActionEvent e) {
57                                popUp = ((JCheckBox) e.getSource()).isSelected();
58                        }
59                });
60                logPopup.setSelected(true);
61                JLabel levelLabel = new JLabel("Select reporting level ");
62                JLabel popupLabel = new JLabel("Window popup ? ");
63                JPanel panel = new JPanel();
64                panel.setLayout(new FlowLayout());
65                panel.add(levelLabel);
66                panel.add(levelBox);
67                panel.add(logPopup);
68                panel.add(popupLabel);
69                JScrollPane scrollPane = new JScrollPane(logText);
70                scrollPane.setBorder(BorderFactory.createEtchedBorder());
71                Container contentPane = this.getContentPane();
72                contentPane.setLayout(new BorderLayout());
73                contentPane.add(scrollPane, BorderLayout.CENTER);
74                contentPane.add(panel, BorderLayout.SOUTH);
75                levelReporting = 0;
76        }
77
78        public void setLevelReporting(int level) {
79                levelReporting = level;
80        }
81
82        public void log(int level, String clazz, String function,
83                        String message) {
84                if (level >= levelReporting) {
85                        if (popUp && !this.isVisible())
86                                this.setVisible(true);
87                        Logger.getLogger(ServerLogFrame.class).error(
88                                        "level " + level + " class " + clazz + " function "
89                                                        + function + " msg " + message);
90                        logText.append("[" + STR_[level] + "] " + clazz + "::"
91                                        + function + " - " + message + "\n");
92                }
93        }
94
95        /**
96         * Shows frame sets location relative to parent.
97         *
98         * @param parent Frame relative to which console window will be localized.
99         */
100        public void show(final JFrame parent) {
101                if (parent != null) {
102                        final Point parentLocation = parent.getLocation();
103                        final Point location = new Point(parentLocation.x + 20,
104                                        parentLocation.y + 20);
105                        this.setLocation(location);
106                }
107                this.setVisible(true);
108        }
109}
Note: See TracBrowser for help on using the repository browser.