Author: adietish
Date: 2010-12-22 10:56:30 -0500 (Wed, 22 Dec 2010)
New Revision: 27672
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudObjectLabelUtils.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java
Log:
[JBIDE-7980] extracted image label construction to central class, displaying now
"image name [image id]"
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudObjectLabelUtils.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudObjectLabelUtils.java 2010-12-22
15:35:02 UTC (rev 27671)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/utils/DeltaCloudObjectLabelUtils.java 2010-12-22
15:56:30 UTC (rev 27672)
@@ -45,4 +45,20 @@
}
return sb.toString();
}
+
+ public static String getId(String imageLabel) {
+ if (imageLabel == null) {
+ return null;
+ }
+ int idStart = imageLabel.indexOf('[');
+ if (idStart == -1) {
+ return imageLabel;
+ }
+ int idStop = imageLabel.indexOf(']');
+ if (idStop == -1) {
+ return imageLabel.substring(idStart + 1);
+ }
+ return imageLabel.substring(idStart + 1, idStop);
+ }
+
}
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-22
15:35:02 UTC (rev 27671)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstancePage.java 2010-12-22
15:56:30 UTC (rev 27672)
@@ -13,8 +13,6 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.core.databinding.Binding;
import org.eclipse.core.databinding.DataBindingContext;
@@ -453,8 +451,6 @@
private class ImageLabel2DeltaCloudImageConverter extends Converter {
- private final Pattern IMAGE_ID_PATTERN =
Pattern.compile("[^\\[]*\\[(.*)\\]");
-
private WritableValue imageObservable = new WritableValue();
public ImageLabel2DeltaCloudImageConverter() {
@@ -464,8 +460,8 @@
@Override
public Object convert(Object fromObject) {
Assert.isLegal(fromObject instanceof String);
- String id = getId((String) fromObject);
DeltaCloudImage image = null;
+ String id = DeltaCloudObjectLabelUtils.getId((String) fromObject);
if (id != null) {
image = getImage(id);
}
@@ -473,13 +469,6 @@
return image;
}
- private String getId(String imageLabel) {
- Matcher matcher = IMAGE_ID_PATTERN.matcher(imageLabel);
- if (matcher.find()) {
- return matcher.group(1);
- }
- return null;
- }
private DeltaCloudImage getImage(String id) {
try {