1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.displayers.info;
24
25 import java.awt.BorderLayout;
26 import java.awt.GridBagConstraints;
27 import java.awt.GridBagLayout;
28 import java.awt.Insets;
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31
32 import javax.swing.BorderFactory;
33 import javax.swing.JCheckBox;
34 import javax.swing.JPanel;
35 import javax.swing.JTextArea;
36
37 import de.desy.acop.displayers.tools.AcopInfoDialog;
38 import de.desy.acop.transport.ConnectionParameters;
39 import de.desy.tine.client.TLinkFactory;
40 import de.desy.tine.queryUtils.TQuery;
41
42
43
44
45
46
47
48
49
50 public class AcopDebugPanel extends JPanel {
51
52 private static final long serialVersionUID = -1597262900075362868L;
53 private JTextArea textArea;
54 private ConnectionParameters connectionParameters;
55 private JCheckBox debugCheckBox;
56 private boolean showDebug = true;
57
58
59
60
61
62 public AcopDebugPanel() {
63 super();
64 initialize();
65 }
66
67 private void initialize() {
68 this.setLayout(new BorderLayout());
69 textArea = new JTextArea();
70 textArea.setBorder(BorderFactory.createTitledBorder("Fec Information"));
71 this.add(textArea, BorderLayout.CENTER);
72 JPanel southPanel = new JPanel(new GridBagLayout());
73 debugCheckBox = new JCheckBox("Debug");
74 debugCheckBox.addActionListener(new ActionListener() {
75 public void actionPerformed(ActionEvent e) {
76 TLinkFactory.getInstance().setDebugLevel(debugCheckBox.isSelected() ? 2 : 0);
77 }
78 });
79 southPanel.add(debugCheckBox, new GridBagConstraints(0,0,1,1,1,1,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,0,0,0),0,0));
80 this.add(southPanel, BorderLayout.NORTH);
81 }
82
83
84
85
86
87
88
89 public void setConnectionParameters(ConnectionParameters param) {
90 if (this.connectionParameters != null && this.connectionParameters.equals(param)) return;
91 this.connectionParameters = param;
92 if (connectionParameters != null){
93 textArea.setText("Updating ... Please wait.");
94 new Thread(new Runnable() {
95 public void run() {
96 String srv = connectionParameters.getDeviceGroup();
97 String con = connectionParameters.getDeviceContext();
98 StringBuffer s = new StringBuffer(TQuery.getModuleAddressInfo(srv, con) +"\n");
99 s.append(TQuery.getTineVersion(con, srv) + "\n");
100 s.append(TQuery.getAppVersion(con, srv) + "\n");
101 s.append(TQuery.getAppDate(con, srv) + "\n");
102 textArea.setText(s.substring(0));
103 }
104 }).start();
105 } else {
106 textArea.setText("");
107 }
108 }
109
110
111
112
113
114
115
116 public ConnectionParameters getConnectionParameters() {
117 return connectionParameters;
118 }
119
120
121
122
123
124
125
126 public void setDebug(int debug) {
127 if (debug > 0) {
128 debugCheckBox.setSelected(true);
129 } else {
130 debugCheckBox.setSelected(false);
131 }
132 }
133
134
135
136
137
138
139 public int isDebug() {
140 return debugCheckBox.isSelected() ? 2 : 0;
141 }
142
143
144
145
146
147
148 public void setShowDebug(boolean showDebug) {
149 if (this.showDebug == showDebug) return;
150 this.showDebug = showDebug;
151 debugCheckBox.setVisible(showDebug);
152 firePropertyChange("showDebug", !showDebug, showDebug);
153 }
154
155
156
157
158
159 public boolean isShowDebug() {
160 return showDebug;
161 }
162 }