[cooja] plugins/VariableWatcher: Added 'line break' for byte text fields
Adds new line each 8 text fields
This commit is contained in:
parent
a638bd5b01
commit
72dcd323a3
@ -36,12 +36,8 @@ import java.awt.Color;
|
|||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.FocusAdapter;
|
|
||||||
import java.awt.event.FocusEvent;
|
|
||||||
import java.awt.event.FocusListener;
|
|
||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemEvent;
|
||||||
import java.awt.event.ItemListener;
|
import java.awt.event.ItemListener;
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -101,13 +97,13 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
|||||||
private final static int LABEL_HEIGHT = 15;
|
private final static int LABEL_HEIGHT = 15;
|
||||||
|
|
||||||
private JPanel lengthPane;
|
private JPanel lengthPane;
|
||||||
private JPanel valuePane;
|
|
||||||
private JComboBox varNameCombo;
|
private JComboBox varNameCombo;
|
||||||
private JComboBox varTypeCombo;
|
private JComboBox varTypeCombo;
|
||||||
private JComboBox varFormatCombo;
|
private JComboBox varFormatCombo;
|
||||||
private JPanel infoPane;
|
private JPanel infoPane;
|
||||||
private JTextField varAddressField;
|
private JTextField varAddressField;
|
||||||
private JTextField varSizeField;
|
private JTextField varSizeField;
|
||||||
|
private JPanel valuePane;
|
||||||
private JFormattedTextField[] varValues;
|
private JFormattedTextField[] varValues;
|
||||||
private byte[] bufferedBytes;
|
private byte[] bufferedBytes;
|
||||||
private JButton readButton;
|
private JButton readButton;
|
||||||
@ -115,11 +111,10 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
|||||||
private JFormattedTextField varLength;
|
private JFormattedTextField varLength;
|
||||||
private JButton writeButton;
|
private JButton writeButton;
|
||||||
private JLabel debuglbl;
|
private JLabel debuglbl;
|
||||||
private FocusListener charValueFocusListener;
|
|
||||||
private VarMemory moteMemory;
|
private VarMemory moteMemory;
|
||||||
|
|
||||||
MemoryInterface.SegmentMonitor memMonitor;
|
MemoryInterface.SegmentMonitor memMonitor;
|
||||||
int monitorAddr;
|
long monitorAddr;
|
||||||
int monitorSize;
|
int monitorSize;
|
||||||
|
|
||||||
private NumberFormat integerFormat;
|
private NumberFormat integerFormat;
|
||||||
@ -374,19 +369,6 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
|||||||
varValues[0].setColumns(3);
|
varValues[0].setColumns(3);
|
||||||
varValues[0].setText("?");
|
varValues[0].setText("?");
|
||||||
|
|
||||||
charValueFocusListener = new FocusListener() {
|
|
||||||
@Override
|
|
||||||
public void focusGained(FocusEvent arg0) {
|
|
||||||
JTextField jtxt = (JTextField)arg0.getComponent();
|
|
||||||
jtxt.selectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void focusLost(FocusEvent arg0) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mainPane.add(valuePane);
|
mainPane.add(valuePane);
|
||||||
mainPane.add(Box.createRigidArea(new Dimension(0,5)));
|
mainPane.add(Box.createRigidArea(new Dimension(0,5)));
|
||||||
|
|
||||||
@ -678,6 +660,9 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
|||||||
|
|
||||||
valuePane.removeAll();
|
valuePane.removeAll();
|
||||||
|
|
||||||
|
JPanel linePane = new JPanel();
|
||||||
|
linePane.setLayout(new BoxLayout(linePane, BoxLayout.X_AXIS));
|
||||||
|
|
||||||
DefaultFormatterFactory defac = new DefaultFormatterFactory(hf);
|
DefaultFormatterFactory defac = new DefaultFormatterFactory(hf);
|
||||||
long address = moteMemory.getVariableAddress((String) varNameCombo.getSelectedItem());
|
long address = moteMemory.getVariableAddress((String) varNameCombo.getSelectedItem());
|
||||||
int bytes = moteMemory.getVariableSize((String) varNameCombo.getSelectedItem());
|
int bytes = moteMemory.getVariableSize((String) varNameCombo.getSelectedItem());
|
||||||
@ -688,8 +673,16 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
|||||||
varValues = new JFormattedTextField[elements];
|
varValues = new JFormattedTextField[elements];
|
||||||
for (int i = 0; i < elements; i++) {
|
for (int i = 0; i < elements; i++) {
|
||||||
varValues[i] = new JFormattedTextField(defac);
|
varValues[i] = new JFormattedTextField(defac);
|
||||||
valuePane.add(varValues[i]);
|
varValues[i].setColumns(6);
|
||||||
|
linePane.add(varValues[i]);
|
||||||
|
/* After 8 Elements, break line */
|
||||||
|
if ((i + 1) % 8 == 0) {
|
||||||
|
valuePane.add(linePane);
|
||||||
|
linePane = new JPanel();
|
||||||
|
linePane.setLayout(new BoxLayout(linePane, BoxLayout.X_AXIS));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
valuePane.add(linePane);
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshValues();
|
refreshValues();
|
||||||
|
Loading…
Reference in New Issue
Block a user