DlgMainConfig.java
6.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
package org.emercit.components;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
import java.awt.event.KeyEvent;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JLabel;
import java.awt.ComponentOrientation;
import java.awt.Font;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.SystemColor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.SwingWorker;
import java.util.ArrayList;
import java.io.File;
import com.google.gson.Gson;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import org.emercit.model.*;
import org.emercit.service.SData;
import org.emercit.szsterminal.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JCheckBox;
import javax.swing.JTextField;
import javax.swing.JFormattedTextField;
import javax.swing.text.MaskFormatter;
import org.emercit.config.*;
public class DlgMainConfig extends JDialog {
private final JPanel contentPanel = new JPanel();
private JButton ApplyButton = new JButton("ПРИМЕНИТЬ");
private JLabel lblGUID=new JLabel("GUID:");
private JLabel lblProxyServer=new JLabel("Server:");
private JLabel lblProxyPort=new JLabel("Port:");
private JLabel lblPassword=new JLabel("Password:");
public static JCheckBox chkUseProxy=new JCheckBox();
public static JTextField txtGUID=new JTextField();
public static JFormattedTextField txtProxyServer;
public static JFormattedTextField txtProxyPort;
private void setIsOpen(boolean visible) {
this.setVisible(visible);
}
public void setValue(Config config) {
this.txtGUID.setText(config.getRegKey());
this.txtProxyServer.setText(config.getProxyServer());
this.txtProxyPort.setText(String.valueOf(config.getProxyPort()));
this.chkUseProxy.setSelected(config.getProxyEnabled());
}
private void setVisibleFalse() {
this.setVisible(false);
}
public DlgMainConfig() {
try {
contentPanel.setLayout(null);
contentPanel.setBorder(new LineBorder(new Color(100, 149, 237), 10));
this.setTitle("Настройка программы");
//this.setUndecorated(true);
this.setForeground(UIManager.getColor("activeCaption"));
this.setBackground(Color.BLUE);
this.setLayout(null);
this.setSize(500, 400);
this.setLocationRelativeTo(null); // CENTER
this.setAlwaysOnTop(true);
this.setModal(true);
contentPanel.setForeground(Color.BLUE);
this.setBackground(Color.BLUE);
// GUID
this.lblGUID.setFont(new Font(null, Font.BOLD, 18));
this.lblGUID.setBounds(15, 20, 110, 35);
contentPanel.add(lblGUID);
this.txtGUID.setFont(new Font(null, Font.BOLD, 18));
this.txtGUID.setBounds(80, 20, 370, 35);
contentPanel.add(txtGUID);
// use Proxy
this.chkUseProxy.setFont(new Font(null, Font.BOLD, 18));
this.chkUseProxy.setBounds(15, 57, 370, 35);
this.chkUseProxy.setText("Proxy");
contentPanel.add(chkUseProxy);
//Server
this.lblProxyServer.setFont(new Font(null, Font.BOLD, 18));
this.lblProxyServer.setBounds(15, 100, 110, 35);
contentPanel.add(lblProxyServer);
MaskFormatter formatteIp = new MaskFormatter("###.###.###.###");
this.txtProxyServer = new JFormattedTextField(formatteIp);
this.txtProxyServer.setFont(new Font(null, Font.BOLD, 18));
this.txtProxyServer.setBounds(90, 100, 350, 35);
contentPanel.add(txtProxyServer);
// Port
this.lblProxyPort.setFont(new Font(null, Font.BOLD, 18));
this.lblProxyPort.setBounds(15, 143, 110, 35);
contentPanel.add(lblProxyPort);
MaskFormatter formattePort = new MaskFormatter("####");
this.txtProxyPort = new JFormattedTextField(formattePort);
this.txtProxyPort.setFont(new Font(null, Font.BOLD, 18));
this.txtProxyPort.setBounds(90, 143, 350, 35);
contentPanel.add(txtProxyPort);
contentPanel.setBounds(5, 5, 490, 280);
add(contentPanel);
ApplyButton.setBorder(new LineBorder(new Color(100, 149, 237), 7));
ApplyButton.setFont(new Font("Tahoma", Font.PLAIN, 24));
ApplyButton.setPreferredSize(new Dimension(320, 80));
ApplyButton.setMinimumSize(new Dimension(220, 80));
ApplyButton.setMaximumSize(new Dimension(220, 80));
ApplyButton.setMnemonic(KeyEvent.VK_COMPOSE);
ApplyButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
setVisibleFalse();
try
{
Config config=SData.INSTANCE.getConfig();
config.setRegkey(DlgMainConfig.txtGUID.getText());
config.setProxyServer(DlgMainConfig.txtProxyServer.getText());
config.setProxyPort(Integer.valueOf(DlgMainConfig.txtProxyPort.getText()));
config.setProxyEnabled(DlgMainConfig.chkUseProxy.isSelected());
config.Save();
SData.INSTANCE.SetConfig(config);
//configmain.setServer(DlgMainConfig.txtProxyServer.getText());
//configmain.setPort(Integer.valueOf(DlgMainConfig.txtProxyPort.getText()));
// String inputpassword=DlgMainConfig.txtPassword.getText();
// String pass=SZSTerminal.configmain.getPassword();
// if (inputpassword.trim().equals(pass.trim())) {
// SZSTerminal.configmain.Save();
// }
}
catch (Exception e) {
}
}
});
}
});
ApplyButton.setBounds(5, 290, 488, 75);
add(ApplyButton);
}
catch(Exception e) {
}
}
}