1 |
51 |
nyawn |
package advancedWatchpointControl;
|
2 |
|
|
import org.eclipse.swt.SWT;
|
3 |
|
|
import org.eclipse.swt.graphics.FontMetrics;
|
4 |
|
|
import org.eclipse.swt.graphics.GC;
|
5 |
|
|
import org.eclipse.swt.layout.GridData;
|
6 |
|
|
import org.eclipse.swt.layout.GridLayout;
|
7 |
|
|
import org.eclipse.swt.widgets.Button;
|
8 |
|
|
import org.eclipse.swt.widgets.Composite;
|
9 |
|
|
import org.eclipse.swt.widgets.Group;
|
10 |
|
|
import org.eclipse.swt.widgets.Label;
|
11 |
|
|
import org.eclipse.swt.widgets.Text;
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
public class guiServerGroup implements NetworkStatusObserver {
|
16 |
|
|
|
17 |
|
|
private Group serverGroup = null;
|
18 |
|
|
private GridLayout serverGroupLayout = null;
|
19 |
|
|
private Button serverConnectButton = null;
|
20 |
|
|
private Group serverHostnameGroup = null;
|
21 |
|
|
private Text serverHostnameText = null;
|
22 |
|
|
private Group tcpPortGroup = null;
|
23 |
|
|
private Text tcpPortText = null;
|
24 |
|
|
private Group networkStatusGroup = null;
|
25 |
|
|
private Label connectionStatusLabel = null;
|
26 |
|
|
private mainControl mCtrl = null;
|
27 |
|
|
|
28 |
|
|
public guiServerGroup(Composite parent, mainControl mc) {
|
29 |
|
|
mCtrl = mc;
|
30 |
|
|
serverGroup = new Group(parent, SWT.NONE);
|
31 |
|
|
serverGroupLayout = new GridLayout();
|
32 |
|
|
|
33 |
|
|
serverGroupLayout.numColumns = 4;
|
34 |
|
|
|
35 |
|
|
serverGroup.setLayout(serverGroupLayout);
|
36 |
|
|
serverGroup.setText("Server Connection");
|
37 |
|
|
|
38 |
|
|
createServerHostnameGroup();
|
39 |
|
|
createTcpPortGroup();
|
40 |
|
|
serverConnectButton = new Button(serverGroup, SWT.NONE);
|
41 |
|
|
serverConnectButton.setText("Connect");
|
42 |
|
|
serverConnectButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
43 |
|
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
44 |
|
|
int port = Integer.parseInt(tcpPortText.getText());
|
45 |
|
|
if(mCtrl != null) {
|
46 |
|
|
mCtrl.doNetworkConnect(serverHostnameText.getText(), port);
|
47 |
|
|
}
|
48 |
|
|
}
|
49 |
|
|
});
|
50 |
|
|
createNetworkStatusGroup();
|
51 |
|
|
|
52 |
|
|
mCtrl.registerForNetworkStatusUpdates(this);
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
private void createServerHostnameGroup() {
|
56 |
|
|
serverHostnameGroup = new Group(serverGroup, SWT.NONE);
|
57 |
|
|
serverHostnameGroup.setLayout(new GridLayout());
|
58 |
|
|
serverHostnameGroup.setText("Server Hostname");
|
59 |
|
|
serverHostnameText = new Text(serverHostnameGroup, SWT.BORDER);
|
60 |
|
|
serverHostnameText.setText("localhost");
|
61 |
|
|
|
62 |
|
|
// Make the Text box a bit bigger than default
|
63 |
|
|
int columns = 20;
|
64 |
|
|
GC gc = new GC (serverHostnameText);
|
65 |
|
|
FontMetrics fm = gc.getFontMetrics ();
|
66 |
|
|
int width = columns * fm.getAverageCharWidth ();
|
67 |
|
|
int height = fm.getHeight ();
|
68 |
|
|
gc.dispose ();
|
69 |
|
|
// This doesn't seem to work, need to use gd.widthHint/heightHint below
|
70 |
|
|
|
71 |
|
|
GridData gd = new GridData();
|
72 |
|
|
gd.grabExcessHorizontalSpace = true;
|
73 |
|
|
gd.verticalAlignment = GridData.CENTER;
|
74 |
|
|
gd.horizontalAlignment = GridData.FILL;
|
75 |
|
|
gd.widthHint = width;
|
76 |
|
|
gd.heightHint = height;
|
77 |
|
|
serverHostnameText.setLayoutData(gd);
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
private void createTcpPortGroup() {
|
81 |
|
|
tcpPortGroup = new Group(serverGroup, SWT.NONE);
|
82 |
|
|
tcpPortGroup.setLayout(new GridLayout());
|
83 |
|
|
tcpPortGroup.setText("Server Port");
|
84 |
|
|
tcpPortText = new Text(tcpPortGroup, SWT.BORDER);
|
85 |
|
|
tcpPortText.setText("9928");
|
86 |
|
|
GridData gd = new GridData();
|
87 |
|
|
gd.horizontalAlignment = GridData.FILL;
|
88 |
|
|
gd.grabExcessHorizontalSpace = true;
|
89 |
|
|
gd.verticalAlignment = GridData.CENTER;
|
90 |
|
|
tcpPortText.setLayoutData(gd);
|
91 |
|
|
}
|
92 |
|
|
|
93 |
|
|
private void createNetworkStatusGroup() {
|
94 |
|
|
networkStatusGroup = new Group(serverGroup, SWT.NONE);
|
95 |
|
|
networkStatusGroup.setText("Connection Status");
|
96 |
|
|
GridLayout gl = new GridLayout();
|
97 |
|
|
gl.makeColumnsEqualWidth = false;
|
98 |
|
|
networkStatusGroup.setLayout(gl);
|
99 |
|
|
|
100 |
|
|
GridData gd = new GridData();
|
101 |
|
|
gd.horizontalAlignment = GridData.FILL;
|
102 |
|
|
gd.grabExcessHorizontalSpace = true;
|
103 |
|
|
networkStatusGroup.setLayoutData(gd);
|
104 |
|
|
|
105 |
|
|
connectionStatusLabel = new Label(networkStatusGroup, SWT.NONE);
|
106 |
|
|
connectionStatusLabel.setText("Not Connected"); // cheating - doesn't through mainControl
|
107 |
|
|
gd = new GridData();
|
108 |
|
|
gd.grabExcessHorizontalSpace = true;
|
109 |
|
|
gd.verticalAlignment = GridData.CENTER;
|
110 |
|
|
gd.horizontalAlignment = GridData.FILL;
|
111 |
|
|
connectionStatusLabel.setLayoutData(gd);
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
public void notifyNetworkStatus() {
|
115 |
|
|
// *** Limit length?
|
116 |
|
|
connectionStatusLabel.setText(mCtrl.getNetworkStatus());
|
117 |
|
|
}
|
118 |
|
|
}
|