Skip to content

Commit ef8d8e1

Browse files
committed
v2.1
1 parent 5432d95 commit ef8d8e1

File tree

10 files changed

+243
-45
lines changed

10 files changed

+243
-45
lines changed

release/ReactClient-2.1.exe

442 KB
Binary file not shown.

release/ReactClient-2.1.jar

49.1 KB
Binary file not shown.
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
package org.cyberpwn.react;
2+
3+
import java.awt.BorderLayout;
4+
import java.awt.FlowLayout;
5+
import java.awt.Font;
6+
import java.awt.Toolkit;
7+
import java.awt.event.MouseAdapter;
8+
import java.awt.event.MouseEvent;
9+
10+
import javax.swing.JButton;
11+
import javax.swing.JDialog;
12+
import javax.swing.JLabel;
13+
import javax.swing.JPanel;
14+
import javax.swing.JPasswordField;
15+
import javax.swing.JTextField;
16+
import javax.swing.border.EmptyBorder;
17+
18+
import org.cyberpwn.react.network.NetworkedServer;
19+
import org.cyberpwn.react.ui.PortJTextField;
20+
21+
import net.miginfocom.swing.MigLayout;
22+
23+
public class EditConnection extends JDialog
24+
{
25+
private static final long serialVersionUID = 801014377635942783L;
26+
private final JPanel contentPanel = new JPanel();
27+
private JTextField txtLocalhost;
28+
private JTextField textField_1;
29+
private JTextField txtCyberpwn;
30+
private JTextField txtReactisawesome;
31+
private JTextField txtFancyServer;
32+
33+
public static void editConnection(NetworkedServer ns)
34+
{
35+
try
36+
{
37+
EditConnection dialog = new EditConnection(ns);
38+
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
39+
dialog.setVisible(true);
40+
}
41+
42+
catch(Exception e)
43+
{
44+
e.printStackTrace();
45+
}
46+
}
47+
48+
public EditConnection(final NetworkedServer ns)
49+
{
50+
setIconImage(Toolkit.getDefaultToolkit().getImage(EditConnection.class.getResource("/org/cyberpwn/react/ui/server-low.png")));
51+
setTitle("Add a Connection");
52+
setBounds(100, 100, 450, 397);
53+
getContentPane().setLayout(new BorderLayout());
54+
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
55+
56+
getContentPane().add(contentPanel, BorderLayout.CENTER);
57+
contentPanel.setLayout(new MigLayout("", "[grow][grow]", "[][][][][][][][]"));
58+
{
59+
JLabel lblName = new JLabel("Name");
60+
lblName.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
61+
contentPanel.add(lblName, "cell 0 0");
62+
}
63+
{
64+
txtFancyServer = new JTextField();
65+
txtFancyServer.setText(ns.getName());
66+
txtFancyServer.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
67+
txtFancyServer.setColumns(10);
68+
contentPanel.add(txtFancyServer, "cell 0 1,growx");
69+
}
70+
{
71+
JLabel lblAddress = new JLabel("Address");
72+
lblAddress.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
73+
contentPanel.add(lblAddress, "cell 0 2");
74+
}
75+
{
76+
JLabel lblPort = new JLabel("Port");
77+
lblPort.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
78+
contentPanel.add(lblPort, "cell 1 2");
79+
}
80+
{
81+
txtLocalhost = new JTextField();
82+
txtLocalhost.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
83+
txtLocalhost.setText(ns.getAddress());
84+
contentPanel.add(txtLocalhost, "cell 0 3,growx");
85+
txtLocalhost.setColumns(10);
86+
}
87+
{
88+
textField_1 = new PortJTextField();
89+
textField_1.setText(ns.getPort().toString());
90+
textField_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
91+
textField_1.setColumns(10);
92+
contentPanel.add(textField_1, "cell 1 3,alignx left");
93+
}
94+
{
95+
JLabel lblUsername = new JLabel("Username");
96+
lblUsername.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
97+
contentPanel.add(lblUsername, "cell 0 4");
98+
}
99+
{
100+
txtCyberpwn = new JTextField();
101+
txtCyberpwn.setText(ns.getUsername());
102+
txtCyberpwn.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
103+
txtCyberpwn.setColumns(10);
104+
contentPanel.add(txtCyberpwn, "cell 0 5,growx");
105+
}
106+
{
107+
JLabel lblPassword = new JLabel("Password");
108+
lblPassword.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
109+
contentPanel.add(lblPassword, "cell 0 6");
110+
}
111+
{
112+
txtReactisawesome = new JPasswordField();
113+
txtReactisawesome.setText(ns.getPassword());
114+
txtReactisawesome.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
115+
txtReactisawesome.setColumns(10);
116+
117+
contentPanel.add(txtReactisawesome, "cell 0 7,growx");
118+
}
119+
{
120+
JPanel buttonPane = new JPanel();
121+
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
122+
123+
getContentPane().add(buttonPane, BorderLayout.SOUTH);
124+
{
125+
JButton okButton = new JButton("Edit Connection");
126+
okButton.addMouseListener(new MouseAdapter()
127+
{
128+
@Override
129+
public void mouseReleased(MouseEvent e)
130+
{
131+
editServer(txtFancyServer.getText(), txtLocalhost.getText(), Integer.valueOf(textField_1.getText()), txtCyberpwn.getText(), txtReactisawesome.getText(), ns);
132+
setVisible(false);
133+
dispose();
134+
}
135+
});
136+
okButton.setActionCommand("OK");
137+
buttonPane.add(okButton);
138+
getRootPane().setDefaultButton(okButton);
139+
}
140+
141+
{
142+
JButton cancelButton = new JButton("Cancel");
143+
cancelButton.addMouseListener(new MouseAdapter() {
144+
@Override
145+
public void mouseReleased(MouseEvent e)
146+
{
147+
setVisible(false);
148+
dispose();
149+
}
150+
});
151+
cancelButton.setActionCommand("Cancel");
152+
buttonPane.add(cancelButton);
153+
}
154+
}
155+
}
156+
157+
public void editServer(String name, String address, int port, String username, String password, NetworkedServer ns)
158+
{
159+
ReactClient.getInstance().validateConnectionEdit(name, address, port, username, password, ns);
160+
}
161+
}

src/org/cyberpwn/react/ReactClient.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,29 @@ public void deleteConnection(NetworkedServer ns)
248248

249249
restart();
250250
}
251+
252+
public void editConnection(NetworkedServer ns)
253+
{
254+
EditConnection.editConnection(ns);
255+
}
256+
257+
public void validateConnectionEdit(String name, String address, int port, String username, String password, NetworkedServer ns)
258+
{
259+
network.rename(name, ns);
260+
ns.setPort(port);
261+
ns.setAddress(address);
262+
ns.setPassword(password);
263+
ns.setUsername(username);
264+
265+
try
266+
{
267+
network.save();
268+
}
269+
270+
catch(IOException e)
271+
{
272+
e.printStackTrace();
273+
}
274+
restart();
275+
}
251276
}

src/org/cyberpwn/react/network/Network.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,23 @@ public void fromJson(JSONObject network)
135135
}
136136
}
137137

138+
public void rename(String newName, NetworkedServer ns)
139+
{
140+
servers.remove(ns.getName());
141+
servers.put(newName, ns);
142+
ns.setName(newName);
143+
144+
try
145+
{
146+
save();
147+
}
148+
149+
catch(IOException e)
150+
{
151+
e.printStackTrace();
152+
}
153+
}
154+
138155
public JSONObject toJson()
139156
{
140157
JSONObject js = new JSONObject();

src/org/cyberpwn/react/network/NetworkedServer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public void run()
8686
{
8787
sample = getData();
8888
tab.push(sample);
89+
8990
}
9091
}
9192
});

src/org/cyberpwn/react/network/Request.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import java.io.DataInputStream;
44
import java.io.DataOutputStream;
5-
import java.io.IOException;
65
import java.net.Socket;
7-
import java.net.SocketTimeoutException;
8-
import java.net.UnknownHostException;
96

107
import org.cyberpwn.react.util.GMap;
118
import org.cyberpwn.react.util.JSONObject;
@@ -63,19 +60,9 @@ public void run()
6360
callback.run(data, false);
6461
}
6562

66-
catch(UnknownHostException e)
63+
catch(Exception e)
6764
{
68-
e.printStackTrace();
69-
}
70-
71-
catch(SocketTimeoutException e)
72-
{
73-
e.printStackTrace();
74-
}
75-
76-
catch(IOException e)
77-
{
78-
e.printStackTrace();
65+
7966
}
8067
}
8168
}

src/org/cyberpwn/react/network/RequestBasic.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import java.io.DataInputStream;
44
import java.io.DataOutputStream;
5-
import java.io.IOException;
65
import java.net.Socket;
7-
import java.net.SocketTimeoutException;
8-
import java.net.UnknownHostException;
96

107
import org.cyberpwn.react.util.GMap;
118
import org.cyberpwn.react.util.JSONObject;
@@ -63,19 +60,9 @@ public void run()
6360
callback.run(data, false);
6461
}
6562

66-
catch(UnknownHostException e)
63+
catch(Exception e)
6764
{
68-
e.printStackTrace();
69-
}
70-
71-
catch(SocketTimeoutException e)
72-
{
73-
e.printStackTrace();
74-
}
75-
76-
catch(IOException e)
77-
{
78-
e.printStackTrace();
65+
7966
}
8067
}
8168
}

0 commit comments

Comments
 (0)