private final String levelNumber = "8\n";
private final String batteryLevel = "Level : ";
private final String batteryCharger = "Charger : ";
- private int sendData = 100;
+ private int sendData = 100, preSendData = -1;
private Button radioButton[];
private int sensorOn;
private IDevice currentDevice;
InjectorView.getDefault().addSelectionListener(this);
sensorOn = 0;
- Composite mainComposite = formUtil.createComposite(parent, 3);
+ Composite mainComposite = formUtil.createComposite(parent, 4);
formUtil.createLabel(mainComposite, batteryLevel);
slider = formUtil.createSlider(mainComposite, SWT.HORIZONTAL);
slider.setValues(100, 1, 101, 1, 1, 1);
slider.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- sliderText = formUtil.createText(mainComposite, Integer.toString(slider.getSelection()));
- sliderText.setEditable(false);
- GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
+ sliderText = new Text(mainComposite, SWT.COLOR_BLACK);
+ sliderText.setText(String.format("%d", slider.getSelection()));
+ sliderText.setEnabled(false);
+
+ GridData gd = new GridData(GridData.CENTER, GridData.CENTER, false, false);
gd.widthHint = 24;
sliderText.setLayoutData(gd);
sendData = slider.getSelection();
}
});
- slider.addMouseListener(new MouseListener() {
+ Button sendButton = formUtil.createButton(mainComposite, "Send", SWT.PUSH);
+ gd = new GridData(SWT.NONE, SWT.FILL, false, true);
+ gd.widthHint = 50;
+ sendButton.setLayoutData(gd);
+
+ sendButton.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
+ // TODO Auto-generated method stub
}
@Override
public void mouseDown(MouseEvent e) {
+ // TODO Auto-generated method stub
}
@Override
public void mouseUp(MouseEvent e) {
+ // TODO Auto-generated method stub
sendMessage(sendData, sensorOn);
}
});
- slider.addKeyListener(new KeyListener() {
+ sendButton.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
- sendMessage(sendData, sensorOn);
+ if(e.keyCode == 13) // enter
+ {
+ radioButton[0].setFocus();
+ }
}
});
-
+
Composite secondComposite = formUtil.createComposite(parent, 5);
formUtil.createLabel(secondComposite, batteryCharger);
radioButton = new Button[2];
}
public void sendMessage(int level, int charger) {
+ if(preSendData == sendData)
+ return;
+
TestSensorMessage msg = new TestSensorMessage(level, charger);
try {
// sensorSocket.send(levelNumber + msg.getMessage());
// TODO Auto-generated catch block
e1.printStackTrace();
}
+ preSendData = sendData;
}
// @Override
slider = formUtil.createSlider(mainComposite, SWT.HORIZONTAL);
slider.setValues(5, 0, 6, 1, 1, 1);
slider.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
- sliderText = formUtil.createText(mainComposite, Integer.toString(slider.getSelection()));
- sliderText.setEditable(false);
+ sliderText = new Text(mainComposite, SWT.COLOR_BLACK);
+ sliderText.setText(String.format("%d", slider.getSelection()));
+ sliderText.setEnabled(false);
GridData gd = new GridData(GridData.BEGINNING, GridData.CENTER, false, false);
gd.widthHint = 10;
sliderText.setLayoutData(gd);