[jbosstools-commits] JBoss Tools SVN: r42703 - in trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal: ui/viewer/property and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jul 25 05:35:02 EDT 2012


Author: rob.stryker at jboss.com
Date: 2012-07-25 05:35:02 -0400 (Wed, 25 Jul 2012)
New Revision: 42703

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/viewer/property/UserPropertySource.java
Log:
UI freeze to trunk JBIDE-10997

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-07-25 09:32:55 UTC (rev 42702)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java	2012-07-25 09:35:02 UTC (rev 42703)
@@ -38,6 +38,7 @@
 	private String username;
 	private String password;
 	private IUser delegate;
+	private boolean isDomainLoaded = false;
 	private boolean rememberPassword;
 	private boolean connected;
 	private boolean alreadyPromptedForPassword;
@@ -233,11 +234,17 @@
 	
 	public IDomain getDefaultDomain() throws OpenShiftException {
 		if(checkForPassword()) {
-			return delegate.getDefaultDomain();
+			IDomain d = delegate.getDefaultDomain();
+			isDomainLoaded = true;
+			return d;
 		} 
 		return null;
 	}
-	
+
+	public boolean isDomainLoaded() throws OpenShiftException {
+		return isDomainLoaded;
+	}
+
 	public List<IEmbeddableCartridge> getEmbeddableCartridges()
 			throws OpenShiftException {
 		if(checkForPassword()) {
@@ -275,6 +282,7 @@
 	}
 	
 	public void refresh() throws OpenShiftException {
+		isDomainLoaded = false;
 		if(checkForPassword()) {
 			delegate.refresh();
 		} 

Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java	2012-07-25 09:32:55 UTC (rev 42702)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/property/UserPropertySource.java	2012-07-25 09:35:02 UTC (rev 42703)
@@ -10,6 +10,13 @@
  ******************************************************************************/
 package org.jboss.tools.openshift.express.internal.ui.viewer.property;
 
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 import org.eclipse.ui.views.properties.IPropertySource;
 import org.eclipse.ui.views.properties.PropertyDescriptor;
@@ -50,8 +57,10 @@
 			if(!user.isConnected() && !user.canPromptForPassword()) {
 				return OpenShiftExpressUIMessages.USER_NOT_CONNECTED_LABEL;
 			}
-			if(!user.isConnected() && user.canPromptForPassword()) {
-				user.checkForPassword();
+				
+			boolean requiresConnect = !user.isConnected() && user.canPromptForPassword();
+			if( requiresConnect || !user.isDomainLoaded()) {
+				loadRemoteDetails();
 			}
 			
 			if (id.equals(PROPERTY_USERNAME)) {
@@ -66,6 +75,33 @@
 		return null;
 	}
 
+	private void loadRemoteDetails() throws OpenShiftException  {
+		IRunnableWithProgress longRunning = new IRunnableWithProgress() {
+			public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException  {
+				monitor.beginTask("Checking Remote Details", 200);
+				try {
+					if( !user.isConnected() && user.canPromptForPassword())
+						user.checkForPassword();
+					monitor.worked(100);
+					if( user.isConnected())
+						user.getDefaultDomain();
+					monitor.worked(100);
+				} catch(OpenShiftException ose) {
+					throw new InvocationTargetException(ose);
+				} finally {
+					monitor.done();
+				}
+			}
+		};
+		try {
+			PlatformUI.getWorkbench().getProgressService().busyCursorWhile(longRunning);
+		} catch( InvocationTargetException ite ) {
+			Throwable t = ite.getCause();
+			throw (OpenShiftException)t;
+		} catch( InterruptedException ie ) {
+		}
+	}
+	
 	@Override
 	public void resetPropertyValue(Object id) {
 		// TODO Auto-generated method stub



More information about the jbosstools-commits mailing list