[cooja] plugins/VariableWatcher: Fixed xml config save/load
This commit is contained in:
parent
16d94780e9
commit
e77c01d586
|
@ -558,7 +558,7 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
||||||
@Override
|
@Override
|
||||||
public Collection<Element> getConfigXML() {
|
public Collection<Element> getConfigXML() {
|
||||||
// Return currently watched variable and type
|
// Return currently watched variable and type
|
||||||
Vector<Element> config = new Vector<Element>();
|
Vector<Element> config = new Vector<>();
|
||||||
|
|
||||||
Element element;
|
Element element;
|
||||||
|
|
||||||
|
@ -568,56 +568,33 @@ public class VariableWatcher extends VisPlugin implements MotePlugin {
|
||||||
config.add(element);
|
config.add(element);
|
||||||
|
|
||||||
// Selected variable type
|
// Selected variable type
|
||||||
if (varTypeCombo.getSelectedIndex() == BYTE_INDEX) {
|
|
||||||
element = new Element("vartype");
|
element = new Element("vartype");
|
||||||
element.setText("byte");
|
element.setText(String.valueOf(varTypeCombo.getSelectedIndex()));
|
||||||
config.add(element);
|
config.add(element);
|
||||||
} else if (varTypeCombo.getSelectedIndex() == INT_INDEX) {
|
|
||||||
element = new Element("vartype");
|
|
||||||
element.setText("int");
|
|
||||||
config.add(element);
|
|
||||||
} else if (varTypeCombo.getSelectedIndex() == ARRAY_INDEX) {
|
|
||||||
element = new Element("vartype");
|
|
||||||
element.setText("array");
|
|
||||||
config.add(element);
|
|
||||||
element = new Element("array_length");
|
|
||||||
element.setText(varLength.getValue().toString());
|
|
||||||
config.add(element);
|
|
||||||
} else if (varTypeCombo.getSelectedIndex() == CHAR_ARRAY_INDEX) {
|
|
||||||
element = new Element("vartype");
|
|
||||||
element.setText("chararray");
|
|
||||||
config.add(element);
|
|
||||||
element = new Element("array_length");
|
|
||||||
element.setText(varLength.getValue().toString());
|
|
||||||
config.add(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Selected output format
|
||||||
|
element = new Element("varformat");
|
||||||
|
element.setText(String.valueOf(varDispCombo.getSelectedIndex()));
|
||||||
|
config.add(element);
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||||
updateNumberOfValues();
|
|
||||||
|
|
||||||
for (Element element : configXML) {
|
for (Element element : configXML) {
|
||||||
if (element.getName().equals("varname")) {
|
switch (element.getName()) {
|
||||||
|
case "varname":
|
||||||
varNameCombo.setSelectedItem(element.getText());
|
varNameCombo.setSelectedItem(element.getText());
|
||||||
} else if (element.getName().equals("vartype")) {
|
break;
|
||||||
if (element.getText().equals("byte")) {
|
case "vartype":
|
||||||
varTypeCombo.setSelectedIndex(BYTE_INDEX);
|
varTypeCombo.setSelectedIndex(Integer.parseInt(element.getText()));
|
||||||
} else if (element.getText().equals("int")) {
|
break;
|
||||||
varTypeCombo.setSelectedIndex(INT_INDEX);
|
case "varformat":
|
||||||
} else if (element.getText().equals("array")) {
|
varDispCombo.setSelectedIndex(Integer.parseInt(element.getText()));
|
||||||
varTypeCombo.setSelectedIndex(ARRAY_INDEX);
|
break;
|
||||||
} else if (element.getText().equals("chararray")) {
|
}
|
||||||
varTypeCombo.setSelectedIndex(CHAR_ARRAY_INDEX);
|
|
||||||
lengthPane.setVisible(true);
|
|
||||||
}
|
}
|
||||||
} else if (element.getName().equals("array_length")) {
|
|
||||||
int nrValues = Integer.parseInt(element.getText());
|
|
||||||
updateNumberOfValues();
|
updateNumberOfValues();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue