1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.cosylab.gui.infopanel;
21
22 import java.awt.Dimension;
23 import java.awt.GridBagConstraints;
24 import java.awt.GridBagLayout;
25 import java.awt.Insets;
26 import java.util.Date;
27
28 import javax.swing.JLabel;
29 import javax.swing.JPanel;
30
31 import com.cosylab.gui.displayers.DataState;
32
33
34
35
36
37
38
39
40
41 public class DebugPanel extends JPanel {
42
43 private static final long serialVersionUID = -1976156943972439878L;
44 private DataState dataState;
45
46 private JLabel stateLabel;
47 private JLabel errorLabel;
48 private JLabel timeLabel;
49
50 private JLabel state;
51 private JLabel error;
52 private JLabel time;
53
54 public DebugPanel() {
55 super();
56 initialize();
57 }
58
59 private void initialize() {
60 this.setLayout(new GridBagLayout());
61 stateLabel = new JLabel("State: ");
62 stateLabel.setMaximumSize(new Dimension(100,21));
63 stateLabel.setMinimumSize(new Dimension(100,21));
64 stateLabel.setPreferredSize(new Dimension(100,21));
65 this.add(stateLabel, new GridBagConstraints(0,0,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(11,11,1,1),0,0));
66 state = new JLabel();
67 this.add(state, new GridBagConstraints(1,0,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(11,1,1,11),0,0));
68
69 errorLabel = new JLabel("Description: ");
70 errorLabel.setMaximumSize(new Dimension(100,21));
71 errorLabel.setMinimumSize(new Dimension(100,21));
72 errorLabel.setPreferredSize(new Dimension(100,21));
73 this.add(errorLabel, new GridBagConstraints(0,1,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1,11,1,1),0,0));
74 error = new JLabel();
75 this.add(error, new GridBagConstraints(1,1,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(1,1,1,11),0,0));
76
77 timeLabel = new JLabel("Time: ");
78 timeLabel.setMaximumSize(new Dimension(100,21));
79 timeLabel.setMinimumSize(new Dimension(100,21));
80 timeLabel.setPreferredSize(new Dimension(100,21));
81 this.add(timeLabel, new GridBagConstraints(0,2,1,1,0,0,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1,11,11,1),0,0));
82 time = new JLabel();
83 this.add(time, new GridBagConstraints(1,2,1,1,1,0,GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(1,1,11,11),0,0));
84 }
85
86
87
88
89
90
91 public void setDataState(DataState dataState) {
92 this.dataState = dataState;
93 if (this.dataState != null) {
94 state.setText(dataState.type);
95 error.setText(dataState.description);
96 time.setText(String.valueOf(new Date(dataState.timestamp)));
97 } else {
98 state.setText("< NONE >");
99 error.setText("< NONE >");
100 time.setText(String.valueOf(new Date(System.currentTimeMillis())));
101 }
102
103 }
104
105
106
107
108
109 public DataState getDataState() {
110 return dataState;
111 }
112
113 }