1 |
51 |
nyawn |
package advancedWatchpointControl;
|
2 |
|
|
import java.text.SimpleDateFormat;
|
3 |
|
|
|
4 |
|
|
import org.eclipse.swt.SWT;
|
5 |
|
|
import org.eclipse.swt.graphics.FontMetrics;
|
6 |
|
|
import org.eclipse.swt.graphics.GC;
|
7 |
|
|
import org.eclipse.swt.layout.GridData;
|
8 |
|
|
import org.eclipse.swt.layout.GridLayout;
|
9 |
|
|
import org.eclipse.swt.widgets.Button;
|
10 |
|
|
import org.eclipse.swt.widgets.Composite;
|
11 |
|
|
import org.eclipse.swt.widgets.Group;
|
12 |
|
|
import org.eclipse.swt.widgets.Text;
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
public class guiControlGroup implements LogMessageObserver {
|
17 |
|
|
|
18 |
|
|
private Group miscGroup = null;
|
19 |
|
|
private Button applyButton = null;
|
20 |
|
|
private Button rereadButton = null;
|
21 |
|
|
private Group messagesGroup = null;
|
22 |
|
|
private Text notifyMessageLabel = null;
|
23 |
|
|
private mainControl mCtrl = null;
|
24 |
|
|
|
25 |
|
|
public guiControlGroup(Composite parent, mainControl mc) {
|
26 |
|
|
mCtrl = mc;
|
27 |
|
|
GridLayout gridLayout2 = new GridLayout();
|
28 |
|
|
gridLayout2.numColumns = 2;
|
29 |
|
|
gridLayout2.horizontalSpacing = 10;
|
30 |
|
|
gridLayout2.makeColumnsEqualWidth = false;
|
31 |
|
|
miscGroup = new Group(parent, SWT.NONE);
|
32 |
|
|
miscGroup.setText("Control");
|
33 |
|
|
applyButton = new Button(miscGroup, SWT.NONE);
|
34 |
|
|
applyButton.setText("Write Registers");
|
35 |
|
|
applyButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
36 |
|
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
37 |
|
|
mCtrl.doWriteAllRegisters();
|
38 |
|
|
}
|
39 |
|
|
});
|
40 |
|
|
createMessagesGroup();
|
41 |
|
|
rereadButton = new Button(miscGroup, SWT.NONE);
|
42 |
|
|
rereadButton.setText("Read Registers");
|
43 |
|
|
rereadButton.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
|
44 |
|
|
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) {
|
45 |
|
|
mCtrl.doReadAllRegisters();
|
46 |
|
|
}
|
47 |
|
|
});
|
48 |
|
|
miscGroup.setLayout(gridLayout2);
|
49 |
|
|
mCtrl.registerForLogMessages(this);
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
private void createMessagesGroup() {
|
54 |
|
|
GridData gridData6 = new GridData();
|
55 |
|
|
gridData6.verticalSpan = 2;
|
56 |
|
|
gridData6.grabExcessHorizontalSpace = true;
|
57 |
|
|
gridData6.horizontalAlignment = GridData.FILL;
|
58 |
|
|
gridData6.verticalAlignment = GridData.FILL;
|
59 |
|
|
gridData6.grabExcessVerticalSpace = true;
|
60 |
|
|
messagesGroup = new Group(miscGroup, SWT.NONE);
|
61 |
|
|
messagesGroup.setLayout(new GridLayout());
|
62 |
|
|
messagesGroup.setLayoutData(gridData6);
|
63 |
|
|
messagesGroup.setText("Messages");
|
64 |
|
|
|
65 |
|
|
notifyMessageLabel = new Text(messagesGroup, SWT.MULTI|SWT.READ_ONLY);
|
66 |
|
|
java.util.Date today = new java.util.Date();
|
67 |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS ");
|
68 |
|
|
notifyMessageLabel.setText(sdf.format(today) + "Ready");
|
69 |
|
|
|
70 |
|
|
int columns = 100;
|
71 |
|
|
int rows = 4;
|
72 |
|
|
GC gc = new GC (notifyMessageLabel);
|
73 |
|
|
FontMetrics fm = gc.getFontMetrics ();
|
74 |
|
|
int width = columns * fm.getAverageCharWidth ();
|
75 |
|
|
int height = rows * fm.getHeight ();
|
76 |
|
|
gc.dispose ();
|
77 |
|
|
|
78 |
|
|
gridData6 = new GridData();
|
79 |
|
|
gridData6.widthHint = width;
|
80 |
|
|
gridData6.heightHint = height;
|
81 |
|
|
notifyMessageLabel.setLayoutData(gridData6);
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
public void notifyLogMessage() {
|
85 |
|
|
String msg = mCtrl.getLogMessage();
|
86 |
|
|
java.util.Date today = new java.util.Date();
|
87 |
|
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS ");
|
88 |
|
|
notifyMessageLabel.append("\n" + sdf.format(today) + msg);
|
89 |
|
|
System.out.print(sdf.format(today) + msg + "\n");
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
}
|