Author: xcoulon
Date: 2012-05-18 09:14:09 -0400 (Fri, 18 May 2012)
New Revision: 41150
Modified:
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/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-18
12:52:10 UTC (rev 41149)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/CreateApplicationAction.java 2012-05-18
13:14:09 UTC (rev 41150)
@@ -12,9 +12,12 @@
import java.net.SocketTimeoutException;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.navigator.CommonViewer;
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;
@@ -22,6 +25,7 @@
import
org.jboss.tools.openshift.express.internal.ui.wizard.NewOpenShiftExpressApplicationWizard;
import
org.jboss.tools.openshift.express.internal.ui.wizard.OpenShiftExpressApplicationWizard;
+import com.openshift.client.IDomain;
import com.openshift.client.OpenShiftException;
/**
@@ -53,18 +57,29 @@
}
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.action.Action#isEnabled()
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ super.selectionChanged(event);
+ enableWhenDomainExists();
+ }
+
+ @Override
+ public void setSelection(ISelection selection) {
+ super.setSelection(selection);
+ enableWhenDomainExists();
+ }
+
+ /**
+ * Enables the current action if the selected User has a default domain. Otherwise, the
action is disabled.
*/
- @Override
- public boolean isEnabled() {
+ private void enableWhenDomainExists() {
if (selection != null && selection instanceof ITreeSelection) {
Object sel = ((ITreeSelection) selection).getFirstElement();
if (sel instanceof UserDelegate) {
UserDelegate user = (UserDelegate) sel;
try {
- return user.getDefaultDomain() != null;
+ final IDomain defaultDomain = user.getDefaultDomain();
+ setEnabled(defaultDomain != null);
} catch (SocketTimeoutException e) {
Logger.error("Failed to check if selected user has a domain", e);
} catch (OpenShiftException e) {
@@ -72,7 +87,7 @@
}
}
}
- return false;
}
+
}
Show replies by date