From a638bd5b011d7483e6a655d0aa24fb003ff91e1d Mon Sep 17 00:00:00 2001 From: Enrico Joerns Date: Wed, 27 Aug 2014 19:30:10 +0200 Subject: [PATCH] [cooja] plugins/VariableWatcher: Added address and and size labels to display information about currently selected variable --- .../cooja/plugins/VariableWatcher.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tools/cooja/java/org/contikios/cooja/plugins/VariableWatcher.java b/tools/cooja/java/org/contikios/cooja/plugins/VariableWatcher.java index e67a3001a..b073e1f04 100644 --- a/tools/cooja/java/org/contikios/cooja/plugins/VariableWatcher.java +++ b/tools/cooja/java/org/contikios/cooja/plugins/VariableWatcher.java @@ -105,6 +105,9 @@ public class VariableWatcher extends VisPlugin implements MotePlugin { private JComboBox varNameCombo; private JComboBox varTypeCombo; private JComboBox varFormatCombo; + private JPanel infoPane; + private JTextField varAddressField; + private JTextField varSizeField; private JFormattedTextField[] varValues; private byte[] bufferedBytes; private JButton readButton; @@ -265,6 +268,8 @@ public class VariableWatcher extends VisPlugin implements MotePlugin { bufferedBytes = null; /* calculate number of elements required to show the value in the given size */ updateNumberOfValues(); + varAddressField.setText(String.format("0x%04x", moteMemory.getVariableAddress((String) e.getItem()))); + varSizeField.setText(String.valueOf(moteMemory.getVariableSize((String) e.getItem()))); } catch (UnknownVariableException ex) { ((JTextField) varNameCombo.getEditor().getEditorComponent()).setForeground(Color.RED); @@ -322,6 +327,33 @@ public class VariableWatcher extends VisPlugin implements MotePlugin { mainPane.add(Box.createRigidArea(new Dimension(0,5))); + infoPane = new JPanel(); + infoPane.setLayout(new BoxLayout(infoPane, BoxLayout.Y_AXIS)); + + JPanel addrInfoPane = new JPanel(new BorderLayout()); + JPanel sizeInfoPane = new JPanel(new BorderLayout()); + + label = new JLabel("Address"); + addrInfoPane.add(BorderLayout.CENTER, label); + varAddressField = new JTextField("?"); + varAddressField.setEditable(false); + varAddressField.setEnabled(false); + varAddressField.setColumns(6); + addrInfoPane.add(BorderLayout.EAST, varAddressField); + + infoPane.add(addrInfoPane); + + label = new JLabel("Size"); + sizeInfoPane.add(BorderLayout.WEST, label); + varSizeField = new JTextField("?"); + varSizeField.setEditable(false); + varSizeField.setEnabled(false); + varSizeField.setColumns(6); + sizeInfoPane.add(BorderLayout.EAST, varSizeField); + + infoPane.add(sizeInfoPane); + mainPane.add(infoPane); + // Variable value label label = new JLabel("Variable value"); label.setAlignmentX(JLabel.CENTER_ALIGNMENT);