Author: xcoulon
Date: 2012-05-16 17:35:31 -0400 (Wed, 16 May 2012)
New Revision: 41092
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java
Log:
Fixed - JBIDE-11890
OpenShift Explorer: NPE when launching "New OpenShift Application"
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-16
21:35:14 UTC (rev 41091)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-16
21:35:31 UTC (rev 41092)
@@ -146,7 +146,7 @@
return null;
}
public List<IApplication> getApplications() throws OpenShiftException,
SocketTimeoutException {
- if(checkForPassword()) {
+ if(checkForPassword() && delegate.hasDomain()) {
return delegate.getDefaultDomain().getApplications();
}
return null;
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-16
21:35:14 UTC (rev 41091)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-16
21:35:31 UTC (rev 41092)
@@ -10,19 +10,24 @@
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.action;
+import java.net.SocketTimeoutException;
+
import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.ui.OpenShiftUIActivator;
import
org.jboss.tools.openshift.express.internal.ui.messages.OpenShiftExpressUIMessages;
+import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import
org.jboss.tools.openshift.express.internal.ui.wizard.NewOpenShiftExpressApplicationWizard;
import
org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard;
+import com.openshift.client.OpenShiftException;
+
/**
* @author Xavier Coulon
*/
-public class CreateApplicationAction extends AbstractAction {
+public class CreateApplicationAction extends AbstractAction {
/**
* Constructor
@@ -37,10 +42,10 @@
* created, otherwise, it is displayed. {@inheritDoc}
*/
@Override
- public void run() {
- if (selection != null && selection instanceof ITreeSelection ) {
- Object sel = ((ITreeSelection)selection).getFirstElement();
- if( sel instanceof UserDelegate) {
+ public void run() {
+ if (selection != null && selection instanceof ITreeSelection) {
+ Object sel = ((ITreeSelection) selection).getFirstElement();
+ if (sel instanceof UserDelegate) {
UserDelegate user = (UserDelegate) sel;
OpenShiftExpressApplicationWizard wizard = new
NewOpenShiftExpressApplicationWizard(user);
new WizardDialog(new Shell(), wizard).open();
@@ -48,5 +53,26 @@
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ if (selection != null && selection instanceof ITreeSelection) {
+ Object sel = ((ITreeSelection) selection).getFirstElement();
+ if (sel instanceof UserDelegate) {
+ UserDelegate user = (UserDelegate) sel;
+ try {
+ return user.getDefaultDomain() != null;
+ } catch (SocketTimeoutException e) {
+ Logger.error("Failed to check if selected user has a domain", e);
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to check if selected user has a domain", e);
+ }
+ }
+ }
+ return false;
+ }
}
Show replies by date