Author: adietish
Date: 2012-05-31 14:24:48 -0400 (Thu, 31 May 2012)
New Revision: 41586
Modified:
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java
Log:
[JBIDE-12034] avoiding NPE when displaying embedded cartridges that dont have an URL
Modified:
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java
===================================================================
---
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java 2012-05-31
17:13:54 UTC (rev 41585)
+++
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/propertytable/PropertyValueCellLabelProvider.java 2012-05-31
18:24:48 UTC (rev 41586)
@@ -22,6 +22,7 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.jboss.tools.common.ui.BrowserUtil;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
+import org.jboss.tools.openshift.express.internal.ui.utils.StringUtils;
import org.jboss.tools.openshift.express.internal.ui.utils.TreeUtils;
/**
@@ -41,6 +42,9 @@
}
protected void createLink(IProperty property, final ViewerCell cell) {
+ if (StringUtils.isEmpty(property.getValue())) {
+ return;
+ }
final Hyperlink link = new Hyperlink((Tree) cell.getControl(),SWT.NONE);
//SWT.NO_BACKGROUND
link.setBackground(cell.getBackground());
link.setForeground(JFaceResources.getColorRegistry().get(JFacePreferences.ACTIVE_HYPERLINK_COLOR));
Modified:
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java
===================================================================
---
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java 2012-05-31
17:13:54 UTC (rev 41585)
+++
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/StringUtils.java 2012-05-31
18:24:48 UTC (rev 41586)
@@ -26,6 +26,13 @@
return "";
}
+ public static String toStringOrNull(Object value) {
+ if (value == null) {
+ return null;
+ }
+ return String.valueOf(value);
+ }
+
public static boolean isEmpty(String value) {
return value == null
|| value.length() == 0;
Modified:
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java
===================================================================
---
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java 2012-05-31
17:13:54 UTC (rev 41585)
+++
branches/jbosstools-3.3.x/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationDetailsContentProvider.java 2012-05-31
18:24:48 UTC (rev 41586)
@@ -3,6 +3,8 @@
*/
package org.jboss.tools.openshift.express.internal.ui.wizard;
+import static
org.jboss.tools.openshift.express.internal.ui.utils.StringUtils.toStringOrNull;
+
import java.net.SocketTimeoutException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -54,10 +56,10 @@
private ContainerElement createCartridges(IApplication application)
throws OpenShiftException, SocketTimeoutException {
ContainerElement cartridgesContainer = new ContainerElement("Cartridges");
- for (IEmbeddedCartridge cartridge : application.getEmbeddedCartridges()) {
+ for (IEmbeddedCartridge cartridge : application.getEmbeddedCartridges()) {
cartridgesContainer.add(
- new StringElement(cartridge.getName(), cartridge.getUrl().toString(), true,
- cartridgesContainer));
+ new StringElement(
+ cartridge.getName(), toStringOrNull(cartridge.getUrl()), true,
cartridgesContainer));
}
return cartridgesContainer;
}