[openrtm-commit:00620] r251 - in trunk/rtmtools/jp.go.aist.rtm.systemeditor: src/jp/go/aist/rtm/systemeditor/ui/dialog src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 1月 30日 (月) 01:00:52 JST
Author: sakamoto
Date: 2012-01-30 01:00:52 +0900 (Mon, 30 Jan 2012)
New Revision: 251
Modified:
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ConfigurationDialog.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidget.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ComponentConfigurationWrapperTest.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidgetTest.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/NamedValueConfigurationWrapperTest.java
trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java
Log:
Add checkBox and ordered list in Configuration Dialog #2290
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ConfigurationDialog.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ConfigurationDialog.java 2012-01-29 15:43:45 UTC (rev 250)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/dialog/ConfigurationDialog.java 2012-01-29 16:00:52 UTC (rev 251)
@@ -15,6 +15,12 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.FocusEvent;
@@ -468,6 +474,14 @@
}
}
+ } else if (widget != null && widget.isCheckbox()) {
+ // widget種別がcheckboxの場合
+ Checkbox.create(parent, key, this, widget);
+
+ } else if (widget != null && widget.isOrderedList()) {
+ // widget種別がordered_listの場合
+ OrderedList.create(parent, this, widget);
+
} else {
createKeyLabel(key, parent);
@@ -486,6 +500,347 @@
}
}
+ /**
+ * チェックボックスのコントロール
+ */
+ public static class Checkbox {
+
+ List<Button> checkButtons;
+
+ String keyLabel;
+ ConfigurationDialog dialog;
+ ConfigurationWidget widget;
+
+ public static Checkbox create(Composite parent, String keyLabel,
+ ConfigurationDialog dialog, ConfigurationWidget widget) {
+ Checkbox cb = new Checkbox(keyLabel, dialog, widget);
+ cb.createComposite(parent);
+ //
+ cb.refreshCheck();
+ return cb;
+ }
+
+ Checkbox(String keyLabel, ConfigurationDialog dialog,
+ ConfigurationWidget widget) {
+ this.keyLabel = keyLabel;
+ this.dialog = dialog;
+ this.widget = widget;
+ }
+
+ void createComposite(Composite parent) {
+ GridLayout gl;
+ GridData gd;
+
+ Group group = new Group(parent, SWT.NONE);
+ gl = new GridLayout(3, false);
+ gl.marginHeight = 1;
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ group.setLayout(gl);
+ group.setLayoutData(gd);
+
+ if (keyLabel != null) {
+ // ハッシュキーのある場合
+ group.setText(keyLabel);
+ }
+
+ // 列挙型制約条件から選択リスト作成
+ List<String> enumList = widget.getCondition().getEnumList();
+ checkButtons = new ArrayList<Button>();
+ for (String s : enumList) {
+ Button vb = new Button(group, SWT.CHECK);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ vb.setLayoutData(gd);
+ vb.setText(s);
+ vb.addSelectionListener(new SelectionListener() {
+ ConfigurationWidget wd = widget;
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ List<String> values = new ArrayList<String>();
+ for (Button b : checkButtons) {
+ if (b.getSelection()) {
+ values.add(b.getText());
+ }
+ }
+ wd.setValueByArray(values.toArray(new String[0]));
+ doModify();
+ }
+ });
+ checkButtons.add(vb);
+ }
+ }
+
+ void doModify() {
+ if (dialog != null) {
+ dialog.doModify(null);
+ }
+ }
+
+ public void refreshCheck() {
+ for (Button vb : checkButtons) {
+ for (String v : widget.getValueAsArray()) {
+ if (vb.getText().equals(v)) {
+ vb.setSelection(true);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * 順序付きリストのコントロール
+ */
+ public static class OrderedList {
+
+ TableViewer enumViewer;
+ TableViewer valueViewer;
+ Button addButton;
+ Button deleteButton;
+ Button upButton;
+ Button downButton;
+
+ String selectedEnum;
+ int selectedValueIndex = -1;
+
+ ConfigurationDialog dialog;
+ ConfigurationWidget widget;
+ List<String> valueList;
+
+ public static OrderedList create(Composite parent,
+ ConfigurationDialog dialog, ConfigurationWidget widget) {
+ OrderedList ol = new OrderedList(dialog, widget);
+ ol.createComposite(parent);
+ //
+ ol.refreshEnumList();
+ ol.refreshValueList();
+ ol.refreshButton();
+ return ol;
+ }
+
+ OrderedList(ConfigurationDialog dialog, ConfigurationWidget widget) {
+ this.dialog = dialog;
+ this.widget = widget;
+ this.valueList = new ArrayList<String>();
+ }
+
+ void createComposite(Composite parent) {
+ GridLayout gl;
+ GridData gd;
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ gl = new GridLayout(4, false);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.grabExcessHorizontalSpace = true;
+
+ composite.setLayout(gl);
+ composite.setLayoutData(gd);
+
+ enumViewer = new TableViewer(composite, SWT.BORDER);
+ gl = new GridLayout(1, false);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.grabExcessHorizontalSpace = true;
+ enumViewer.getTable().setLayout(gl);
+ enumViewer.getTable().setLayoutData(gd);
+ enumViewer.setContentProvider(new ArrayContentProvider());
+ enumViewer.setLabelProvider(new LabelProvider());
+ enumViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ selectedEnum = null;
+ selectedValueIndex = -1;
+ StructuredSelection s = (StructuredSelection) event
+ .getSelection();
+ selectedEnum = (String) s.getFirstElement();
+ refreshButton();
+ }
+ });
+
+ Composite bc1 = new Composite(composite, SWT.NONE);
+ gl = new GridLayout(1, false);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.CENTER;
+ gd.verticalAlignment = GridData.CENTER;
+ gd.grabExcessVerticalSpace = false;
+ gd.grabExcessHorizontalSpace = false;
+ bc1.setLayout(gl);
+ bc1.setLayoutData(gd);
+
+ addButton = new Button(bc1, SWT.ARROW | SWT.RIGHT);
+ gd = new GridData();
+ gd.widthHint = 30;
+ addButton.setLayoutData(gd);
+ addButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (selectedEnum == null || widget == null) {
+ return;
+ }
+ valueList.add(selectedEnum);
+ widget.setValueByArray(valueList.toArray(new String[0]));
+ doModify();
+ refreshValueList();
+ }
+ });
+
+ deleteButton = new Button(bc1, SWT.ARROW | SWT.LEFT);
+ gd = new GridData();
+ gd.widthHint = 30;
+ deleteButton.setLayoutData(gd);
+ deleteButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (selectedValueIndex == -1 || widget == null) {
+ return;
+ }
+ valueList.remove(selectedValueIndex);
+ widget.setValueByArray(valueList.toArray(new String[0]));
+ doModify();
+ refreshValueList();
+ }
+ });
+
+ valueViewer = new TableViewer(composite, SWT.BORDER);
+ gl = new GridLayout(1, false);
+ gd = new GridData();
+ gd.verticalAlignment = SWT.FILL;
+ gd.horizontalAlignment = SWT.FILL;
+ gd.grabExcessVerticalSpace = true;
+ gd.grabExcessHorizontalSpace = true;
+ valueViewer.getTable().setLayout(gl);
+ valueViewer.getTable().setLayoutData(gd);
+ valueViewer.setContentProvider(new ArrayContentProvider());
+ valueViewer.setLabelProvider(new LabelProvider());
+ valueViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ selectedEnum = null;
+ selectedValueIndex = valueViewer.getTable()
+ .getSelectionIndex();
+ refreshButton();
+ }
+ });
+
+ Composite bc2 = new Composite(composite, SWT.NONE);
+ gl = new GridLayout(1, false);
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.CENTER;
+ gd.verticalAlignment = GridData.CENTER;
+ gd.grabExcessVerticalSpace = false;
+ gd.grabExcessHorizontalSpace = false;
+ bc2.setLayout(gl);
+ bc2.setLayoutData(gd);
+
+ upButton = new Button(bc2, SWT.ARROW | SWT.UP);
+ gd = new GridData();
+ gd.widthHint = 30;
+ upButton.setLayoutData(gd);
+ upButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = selectedValueIndex;
+ String s = valueList.remove(index);
+ valueList.add(index - 1, s);
+ selectedValueIndex = index - 1;
+ //
+ widget.setValueByArray(valueList.toArray(new String[0]));
+ doModify();
+ refreshValueList();
+ refreshButton();
+ }
+ });
+
+ downButton = new Button(bc2, SWT.ARROW | SWT.DOWN);
+ gd = new GridData();
+ gd.widthHint = 30;
+ downButton.setLayoutData(gd);
+ downButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = selectedValueIndex;
+ String s = valueList.remove(index);
+ valueList.add(index + 1, s);
+ selectedValueIndex = index + 1;
+ //
+ widget.setValueByArray(valueList.toArray(new String[0]));
+ doModify();
+ refreshValueList();
+ refreshButton();
+ }
+ });
+ }
+
+ void doModify() {
+ if (dialog != null) {
+ dialog.doModify(null);
+ }
+ }
+
+ public void refreshEnumList() {
+ if (widget == null) {
+ return;
+ }
+ enumViewer.setInput(widget.getCondition().getEnumList());
+ }
+
+ public void refreshValueList() {
+ valueList.clear();
+ valueViewer.getTable().setBackground(
+ colorRegistry.get(NORMAL_COLOR));
+ if (widget != null) {
+ for (String v : widget.getValueAsArray()) {
+ if (widget.getCondition().getEnumList().contains(v)) {
+ valueList.add(v);
+ }
+ }
+ if (widget.isValueModified()) {
+ valueViewer.getTable().setBackground(
+ colorRegistry.get(MODIFY_COLOR));
+ }
+ }
+ valueViewer.setInput(valueList);
+ valueViewer.refresh();
+ if (selectedValueIndex != -1) {
+ valueViewer.getTable().setSelection(selectedValueIndex);
+ }
+ }
+
+ public void refreshButton() {
+ addButton.setEnabled(false);
+ deleteButton.setEnabled(false);
+ upButton.setEnabled(false);
+ downButton.setEnabled(false);
+ if (selectedEnum != null) {
+ addButton.setEnabled(true);
+ }
+ if (selectedValueIndex != -1) {
+ deleteButton.setEnabled(true);
+ }
+ if (selectedValueIndex > 0 && selectedValueIndex < valueList.size()) {
+ upButton.setEnabled(true);
+ }
+ if (selectedValueIndex >= 0
+ && selectedValueIndex < valueList.size() - 1) {
+ downButton.setEnabled(true);
+ }
+ }
+ }
+
private FocusListener createFocusListner(final Text valueText) {
return new FocusListener(){
public void focusGained(FocusEvent e) {
@@ -522,7 +877,7 @@
}
/** Applyが押されていたら即時更新する */
- private void doModify(Control control) {
+ void doModify(Control control) {
if (control != null)
control.setBackground(colorRegistry.get(MODIFY_COLOR));
isValueModified = true;
@@ -801,9 +1156,17 @@
// Configurationダイアログで保存時の制約条件チェックによるエラーメッセージで、 パラメータ名、制約条件、エラーになった値を表示したい 2008.12.18
private void validateParam(List<String> validateErrors, ConfigurationWidget wd, String paramName) {
ConfigurationCondition cc = wd.getCondition();
- String value = wd.getValue();
- if (!cc.validate(value)) {
- validateErrors.add(paramName + "(" + cc + ":" + value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (wd.isCheckbox() || wd.isOrderedList()) {
+ for (String value : wd.getValueAsArray()) {
+ if (!cc.validate(value)) {
+ validateErrors.add(paramName + "(" + cc + ":" + value + ")");
+ }
+ }
+ } else {
+ String value = wd.getValue();
+ if (!cc.validate(value)) {
+ validateErrors.add(paramName + "(" + cc + ":" + value + ")");
+ }
}
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidget.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidget.java 2012-01-29 15:43:45 UTC (rev 250)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/src/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidget.java 2012-01-29 16:00:52 UTC (rev 251)
@@ -13,6 +13,8 @@
public static final String SLIDER = "slider";
public static final String SPIN = "spin";
public static final String RADIO = "radio";
+ public static final String CHECKBOX = "checkbox";
+ public static final String ORDERED_LIST = "ordered_list";
private String type;
private ConfigurationCondition condition;
@@ -98,7 +100,8 @@
// slider、spinnerで最大、最小値がなければテキスト
this.type = TEXT;
}
- } else if (this.isRadio()) {
+ } else if (this.isRadio() || this.isCheckbox()
+ || this.isOrderedList()) {
if (!condition.hasEnumList()) {
// radioは列挙設定がなければテキスト
this.type = TEXT;
@@ -119,8 +122,15 @@
setSpinStep(type);
return SPIN;
}
- if (type.equals(RADIO))
+ if (type.equals(RADIO)) {
return RADIO;
+ }
+ if (type.equals(CHECKBOX)) {
+ return CHECKBOX;
+ }
+ if (type.equals(ORDERED_LIST)) {
+ return ORDERED_LIST;
+ }
return TEXT;
}
@@ -162,8 +172,17 @@
return this.type.equals(RADIO);
}
+ public boolean isCheckbox() {
+ return this.type.equals(CHECKBOX);
+ }
+
+ public boolean isOrderedList() {
+ return this.type.equals(ORDERED_LIST);
+ }
+
public boolean isText() {
- return !(this.isSlider() || this.isSpinner() || this.isRadio());
+ return !(this.isSlider() || this.isSpinner() || this.isRadio()
+ || this.isCheckbox() || this.isOrderedList());
}
public boolean hasCondition() {
@@ -184,10 +203,32 @@
this.valueModified = true;
}
+ public void setValueByArray(String[] values) {
+ if (values == null) {
+ return;
+ }
+ String val = "";
+ for (String s : values) {
+ if (!val.isEmpty()) {
+ val += ",";
+ }
+ val += s;
+ }
+ setValue(val);
+ }
+
public String getValue() {
return this.value;
}
+ public String[] getValueAsArray() {
+ String[] values = new String[0];
+ if (this.value != null && !this.value.isEmpty()) {
+ values = this.value.split(",");
+ }
+ return values;
+ }
+
public void clearValueModified() {
this.valueModified = false;
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ComponentConfigurationWrapperTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ComponentConfigurationWrapperTest.java 2012-01-29 15:43:45 UTC (rev 250)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ComponentConfigurationWrapperTest.java 2012-01-29 16:00:52 UTC (rev 251)
@@ -32,6 +32,16 @@
assertEquals("(test1,test2,test3,test4,test5)", nv
.widget().getCondition().toString());
} else if (nv.getKey() == "str_param2") {
+ assertEquals("top", this.getNamedValueString(nv));
+ assertEquals("checkbox", nv.widget().getType());
+ assertEquals("(top,left,bottom,right)", nv.widget()
+ .getCondition().toString());
+ } else if (nv.getKey() == "str_param3") {
+ assertEquals("bottom", this.getNamedValueString(nv));
+ assertEquals("ordered_list", nv.widget().getType());
+ assertEquals("(top,left,bottom,right)", nv.widget()
+ .getCondition().toString());
+ } else if (nv.getKey() == "str_param4") {
assertEquals("case1", this.getNamedValueString(nv));
assertEquals("text", nv.widget().getType());
assertEquals("null", nv.widget().getCondition().toString());
@@ -70,6 +80,16 @@
assertEquals("(test1,test2,test3)", nv.widget()
.getCondition().toString());
} else if (nv.getKey() == "str_param2") {
+ assertEquals("right", this.getNamedValueString(nv));
+ assertEquals("checkbox", nv.widget().getType());
+ assertEquals("(top,left,bottom,right)", nv.widget()
+ .getCondition().toString());
+ } else if (nv.getKey() == "str_param3") {
+ assertEquals("top,left", this.getNamedValueString(nv));
+ assertEquals("ordered_list", nv.widget().getType());
+ assertEquals("(top,left,bottom,right)", nv.widget()
+ .getCondition().toString());
+ } else if (nv.getKey() == "str_param4") {
assertEquals("case2", this.getNamedValueString(nv));
assertEquals("text", nv.widget().getType());
assertEquals("null", nv.widget().getCondition().toString());
@@ -108,6 +128,16 @@
assertEquals("(test1,test2,test3,test4,test5)", nv
.widget().getCondition().toString());
} else if (nv.getKey() == "str_param2") {
+ assertEquals("left", this.getNamedValueString(nv));
+ assertEquals("checkbox", nv.widget().getType());
+ assertEquals("(top,left,bottom,right)", nv.widget()
+ .getCondition().toString());
+ } else if (nv.getKey() == "str_param3") {
+ assertEquals("bottom,right,right", this.getNamedValueString(nv));
+ assertEquals("ordered_list", nv.widget().getType());
+ assertEquals("(top,left,bottom,right)", nv.widget()
+ .getCondition().toString());
+ } else if (nv.getKey() == "str_param4") {
assertEquals("case3", this.getNamedValueString(nv));
assertEquals("text", nv.widget().getType());
assertEquals("null", nv.widget().getCondition().toString());
@@ -142,6 +172,8 @@
assertEquals(true, names.contains("double_param1"));
assertEquals(true, names.contains("str_param1"));
assertEquals(true, names.contains("str_param2"));
+ assertEquals(true, names.contains("str_param3"));
+ assertEquals(true, names.contains("str_param4"));
assertEquals(true, names.contains("vector_param1"));
assertEquals(false, names.contains("unknown_param1"));
}
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidgetTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidgetTest.java 2012-01-29 15:43:45 UTC (rev 250)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/ConfigurationWidgetTest.java 2012-01-29 16:00:52 UTC (rev 251)
@@ -47,7 +47,21 @@
verifyWidget(result.get("key0"), ConfigurationWidget.SLIDER, "0.0<x<10.0");
verifyWidget(result.get("key1"), ConfigurationWidget.SLIDER, "0.1<x<10.0");
}
-
+
+ public void testParseHashWidget3() throws Exception {
+ ConfigurationCondition cc = ConfigurationCondition.parse("{key0:(top,left,bottom,right), key1:0.0<x<10.0 }");
+ Map<String, ConfigurationWidget> result = ConfigurationWidget.parseHashWidget("{key0:checkbox, key1:spin}", cc);
+ verifyWidget(result.get("key0"), ConfigurationWidget.CHECKBOX, "(top,left,bottom,right)");
+ verifyWidget(result.get("key1"), ConfigurationWidget.SPIN, "0.0<x<10.0");
+ }
+
+ public void testParseHashWidget4() throws Exception {
+ ConfigurationCondition cc = ConfigurationCondition.parse("{key0:(top,left,bottom,right), key1:0.0<x<10.0 }");
+ Map<String, ConfigurationWidget> result = ConfigurationWidget.parseHashWidget("{key0:ordered_list, key1:spin}", cc);
+ verifyWidget(result.get("key0"), ConfigurationWidget.ORDERED_LIST, "(top,left,bottom,right)");
+ verifyWidget(result.get("key1"), ConfigurationWidget.SPIN, "0.0<x<10.0");
+ }
+
public void testSimpleWidget() throws Exception {
ConfigurationCondition cc = ConfigurationCondition.parse(" 0.0<x<10.0 ");
List<ConfigurationWidget> result = ConfigurationWidget.parseSimpleWidget(" slider ", cc);
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/NamedValueConfigurationWrapperTest.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/NamedValueConfigurationWrapperTest.java 2012-01-29 15:43:45 UTC (rev 250)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/configurationwrapper/NamedValueConfigurationWrapperTest.java 2012-01-29 16:00:52 UTC (rev 251)
@@ -65,6 +65,42 @@
assertEquals(true, nv.widget().isText());
assertEquals(true, nv.widget().getCondition().isNull());
+ // checkboxは列挙設定が必要
+ nv.setWidgetAndCondition("checkbox", "(top,left,bottom,right)");
+ assertEquals(true, nv.widget().isCheckbox());
+ assertEquals(true, nv.widget().getCondition().hasEnumList());
+ assertEquals(4, nv.widget().getCondition().getEnumList().size());
+
+ nv.setWidgetAndCondition("checkbox", "x<100");
+ assertEquals(false, nv.widget().isCheckbox());
+ assertEquals(true, nv.widget().isText());
+ assertEquals(false, nv.widget().getCondition().hasEnumList());
+ assertEquals(null, nv.widget().getCondition().getMin());
+ assertEquals("100", nv.widget().getCondition().getMax());
+
+ nv.setWidgetAndCondition("checkbox", "");
+ assertEquals(false, nv.widget().isCheckbox());
+ assertEquals(true, nv.widget().isText());
+ assertEquals(true, nv.widget().getCondition().isNull());
+
+ // ordered_listは列挙設定が必要
+ nv.setWidgetAndCondition("ordered_list", "(top,left,bottom,right)");
+ assertEquals(true, nv.widget().isOrderedList());
+ assertEquals(true, nv.widget().getCondition().hasEnumList());
+ assertEquals(4, nv.widget().getCondition().getEnumList().size());
+
+ nv.setWidgetAndCondition("ordered_list", "x<100");
+ assertEquals(false, nv.widget().isOrderedList());
+ assertEquals(true, nv.widget().isText());
+ assertEquals(false, nv.widget().getCondition().hasEnumList());
+ assertEquals(null, nv.widget().getCondition().getMin());
+ assertEquals("100", nv.widget().getCondition().getMax());
+
+ nv.setWidgetAndCondition("ordered_list", "");
+ assertEquals(false, nv.widget().isOrderedList());
+ assertEquals(true, nv.widget().isText());
+ assertEquals(true, nv.widget().getCondition().isNull());
+
// 制約条件エラーの場合はtext
nv.setWidgetAndCondition("radio", "(100,200"); // 列挙閉じ括弧なし
assertEquals(false, nv.widget().isRadio());
Modified: trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java
===================================================================
--- trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java 2012-01-29 15:43:45 UTC (rev 250)
+++ trunk/rtmtools/jp.go.aist.rtm.systemeditor/test/jp/go/aist/rtm/systemeditor/ui/views/configurationview/mock/ComponentMock.java 2012-01-29 16:00:52 UTC (rev 251)
@@ -53,8 +53,12 @@
cs.configurationData.add(nv);
nv = createNameValue("str_param1", "test1");
cs.configurationData.add(nv);
- nv = createNameValue("str_param2", "case1");
+ nv = createNameValue("str_param2", "top");
cs.configurationData.add(nv);
+ nv = createNameValue("str_param3", "bottom");
+ cs.configurationData.add(nv);
+ nv = createNameValue("str_param4", "case1");
+ cs.configurationData.add(nv);
nv = createNameValue("vector_param1", "0.01, 0.11, 0.22");
cs.configurationData.add(nv);
mock1.configurationSets.add(cs);
@@ -67,8 +71,12 @@
cs.configurationData.add(nv);
nv = createNameValue("str_param1", "test2");
cs.configurationData.add(nv);
- nv = createNameValue("str_param2", "case2");
+ nv = createNameValue("str_param2", "right");
cs.configurationData.add(nv);
+ nv = createNameValue("str_param3", "top,left");
+ cs.configurationData.add(nv);
+ nv = createNameValue("str_param4", "case2");
+ cs.configurationData.add(nv);
nv = createNameValue("vector_param1", "5.5, 10.5, 15.5");
cs.configurationData.add(nv);
mock1.configurationSets.add(cs);
@@ -81,8 +89,12 @@
cs.configurationData.add(nv);
nv = createNameValue("str_param1", "test3");
cs.configurationData.add(nv);
- nv = createNameValue("str_param2", "case3");
+ nv = createNameValue("str_param2", "left");
cs.configurationData.add(nv);
+ nv = createNameValue("str_param3", "bottom,right,right");
+ cs.configurationData.add(nv);
+ nv = createNameValue("str_param4", "case3");
+ cs.configurationData.add(nv);
nv = createNameValue("vector_param1", "0.05, 0.15, 0.25");
cs.configurationData.add(nv);
mock1.configurationSets.add(cs);
@@ -95,8 +107,12 @@
cs.configurationData.add(nv);
nv = createNameValue("str_param1", "radio");
cs.configurationData.add(nv);
- nv = createNameValue("str_param2", "hoge"); // 不明なwidget種別
+ nv = createNameValue("str_param2", "checkbox");
cs.configurationData.add(nv);
+ nv = createNameValue("str_param3", "ordered_list");
+ cs.configurationData.add(nv);
+ nv = createNameValue("str_param4", "hoge"); // 不明なwidget種別
+ cs.configurationData.add(nv);
nv = createNameValue("vector_param1", "spin"); // TODO 配列表記
cs.configurationData.add(nv);
mock1.configurationSets.add(cs);
@@ -109,6 +125,10 @@
cs.configurationData.add(nv);
nv = createNameValue("str_param1", "(test1,test2,test3,test4,test5)");
cs.configurationData.add(nv);
+ nv = createNameValue("str_param2", "(top,left,bottom,right)");
+ cs.configurationData.add(nv);
+ nv = createNameValue("str_param3", "(top,left,bottom,right)");
+ cs.configurationData.add(nv);
nv = createNameValue("vector_param1", "0.0<x<1.0, 1.0<x<2.0, 2.0<x<3.0");
cs.configurationData.add(nv);
mock1.configurationSets.add(cs);
@@ -121,6 +141,10 @@
cs.configurationData.add(nv);
nv = createNameValue("str_param1", "(test1,test2,test3)");
cs.configurationData.add(nv);
+ nv = createNameValue("str_param2", "(top,left,bottom,right)");
+ cs.configurationData.add(nv);
+ nv = createNameValue("str_param3", "(top,left,bottom,right)");
+ cs.configurationData.add(nv);
nv = createNameValue("vector_param1", "5.0<x<10.0, 10.0<x<15.0, 15.0<x<20.0");
cs.configurationData.add(nv);
mock1.configurationSets.add(cs);
openrtm-commit メーリングリストの案内