Author: adietish
Date: 2010-12-08 12:00:00 -0500 (Wed, 08 Dec 2010)
New Revision: 27242
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
Log:
[JBIDE-7834] simplified binding, fixed find image by id (moved implementation to
DeltaCloud)
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-08
16:50:08 UTC (rev 27241)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-08
17:00:00 UTC (rev 27242)
@@ -476,18 +476,30 @@
}
private IObservableValue bindImage(Text imageText, DataBindingContext dbc) {
- UpdateValueStrategy imageUpdateStrategy = new UpdateValueStrategy();
+ UpdateValueStrategy widgetToModelUpdateStrategy = new UpdateValueStrategy();
ImageConverter imageConverter = new ImageConverter();
- imageUpdateStrategy.setConverter(imageConverter);
- imageUpdateStrategy.setAfterGetValidator(
+ widgetToModelUpdateStrategy.setConverter(imageConverter);
+ widgetToModelUpdateStrategy.setAfterGetValidator(
new MandatoryStringValidator(WizardMessages.getString(MUST_ENTER_IMAGE_ID)));
- imageUpdateStrategy.setAfterConvertValidator(new ImageValidator());
+ widgetToModelUpdateStrategy.setAfterConvertValidator(new ImageValidator());
+ UpdateValueStrategy modelToTextUpdateStrategy = new UpdateValueStrategy();
+ modelToTextUpdateStrategy.setConverter(new Converter(DeltaCloudImage.class,
String.class) {
+ @Override
+ public Object convert(Object fromObject) {
+ if (fromObject instanceof DeltaCloudImage) {
+ return ((DeltaCloudImage) fromObject).getName();
+ } else {
+ return "";
+ }
+ }
+ });
+
Binding imageBinding = dbc.bindValue(
WidgetProperties.text(SWT.Modify).observeDelayed(IMAGE_CHECK_DELAY, imageText),
BeanProperties.value(NewInstanceModel.class,
NewInstanceModel.PROPERTY_IMAGE).observe(model),
- imageUpdateStrategy,
- null);
+ widgetToModelUpdateStrategy,
+ modelToTextUpdateStrategy);
ControlDecorationSupport.create(imageBinding, SWT.LEFT | SWT.TOP);
return imageConverter.getImageObservable();
}