Author: xcoulon
Date: 2012-05-11 11:53:49 -0400 (Fri, 11 May 2012)
New Revision: 40956
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshElementAction.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/RefreshElementActionProvider.java
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
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/messages/OpenShiftExpressUIMessages.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
Log:
Fixed - JBIDE-11680
OpenShift Explorer is noticebly slower since b2
JBIDE-11791
Add a 'refresh' action at the user level in the OpenShift Explorer
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2012-05-11
15:45:49 UTC (rev 40955)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.client/.classpath 2012-05-11
15:53:49 UTC (rev 40956)
@@ -3,7 +3,7 @@
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib"
path="openshift-java-client-2.0.0-SNAPSHOT.jar"/>
+ <classpathentry exported="true" kind="lib"
path="openshift-java-client-2.0.0-SNAPSHOT.jar"
sourcepath="/openshift-java-client"/>
<classpathentry kind="lib" path="jboss-dmr-1.0.0.Final.jar"/>
<classpathentry kind="lib" path="log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="slf4j-api-1.6.1.jar"/>
Modified: trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml
===================================================================
--- trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-05-11
15:45:49 UTC (rev 40955)
+++ trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/plugin.xml 2012-05-11
15:53:49 UTC (rev 40956)
@@ -386,6 +386,20 @@
</enablement>
</actionProvider>
<actionProvider
+
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.RefreshElementActionProvider"
+
id="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.RefreshElementActionProvider">
+ <enablement>
+ <or>
+ <instanceof
+
value="org.jboss.tools.openshift.express.internal.core.console.UserDelegate">
+ </instanceof>
+ <instanceof
+ value="com.openshift.client.IApplication">
+ </instanceof>
+ </or>
+ </enablement>
+ </actionProvider>
+ <actionProvider
class="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.DeleteConnectionActionProvider"
id="org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider.DeleteConnectionActionProvider">
<enablement>
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-11
15:45:49 UTC (rev 40955)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/core/console/UserDelegate.java 2012-05-11
15:53:49 UTC (rev 40956)
@@ -216,7 +216,7 @@
return false;
}
- public void refresh() throws OpenShiftException {
+ public void refresh() throws OpenShiftException, SocketTimeoutException {
if(checkForPassword()) {
delegate.refresh();
}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshElementAction.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshElementAction.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshElementAction.java 2012-05-11
15:53:49 UTC (rev 40956)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.action;
+
+import java.net.SocketTimeoutException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.swt.widgets.Display;
+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 com.openshift.client.IOpenShiftResource;
+import com.openshift.client.OpenShiftException;
+
+/**
+ * @author Xavier Coulon
+ */
+public class RefreshElementAction extends AbstractAction {
+
+ public RefreshElementAction() {
+ super(OpenShiftExpressUIMessages.REFRESH_USER_ACTION, true);
+ setImageDescriptor(OpenShiftUIActivator.getDefault().createImageDescriptor("refresh.gif"));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (selection != null && selection instanceof ITreeSelection
+ && ((ITreeSelection) selection).getFirstElement() instanceof
IOpenShiftResource) {
+ refresh((IOpenShiftResource) ((ITreeSelection) selection).getFirstElement());
+ }
+ }
+
+ private void refresh(final IOpenShiftResource element) {
+ Job job = new Job("Loading OpenShift information...") {
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ monitor.beginTask("Loading OpenShift information...",
IProgressMonitor.UNKNOWN);
+ element.refresh();
+ //List<IApplication> applications = user.getApplications();
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ viewer.refresh(element);
+ }
+ });
+ } catch (OpenShiftException e) {
+ Logger.error("Failed to refresh element", e);
+ } catch (SocketTimeoutException e) {
+ Logger.error("Failed to refresh element", e);
+ } finally {
+ monitor.done();
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.setPriority(Job.LONG);
+ job.schedule();
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/action/RefreshElementAction.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java 2012-05-11
15:45:49 UTC (rev 40955)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.java 2012-05-11
15:53:49 UTC (rev 40956)
@@ -45,6 +45,8 @@
public static String REFRESH_VIEWER_ACTION;
+ public static String REFRESH_USER_ACTION;
+
public static String DELETE_CONNECTION_ACTION;
public static String USER_NOT_CONNECTED_LABEL;
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties 2012-05-11
15:45:49 UTC (rev 40955)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/messages/OpenShiftExpressUIMessages.properties 2012-05-11
15:53:49 UTC (rev 40956)
@@ -16,6 +16,7 @@
SHOW_PROPERTIES_VIEW_ACTION=Properties
REFRESH_VIEWER_ACTION=Refresh
+REFRESH_USER_ACTION=Refresh
SHOW_ENVIRONMENT_ACTION=Show Environment Variables
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-05-11
15:45:49 UTC (rev 40955)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/OpenShiftExpressConsoleContentProvider.java 2012-05-11
15:53:49 UTC (rev 40956)
@@ -13,6 +13,8 @@
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -25,7 +27,6 @@
import org.eclipse.swt.widgets.Display;
import org.jboss.tools.openshift.express.internal.core.console.UserDelegate;
import org.jboss.tools.openshift.express.internal.core.console.UserModel;
-import org.jboss.tools.openshift.express.internal.ui.utils.Logger;
import com.openshift.client.IApplication;
import com.openshift.client.OpenShiftException;
@@ -60,15 +61,19 @@
}
// Keep track of what's loading and what's finished
- private ArrayList<UserDelegate> loadedUsers = new
ArrayList<UserDelegate>();
- private ArrayList<UserDelegate> loadingUsers = new
ArrayList<UserDelegate>();
- private HashMap<UserDelegate, Exception> errors = new HashMap<UserDelegate,
Exception>();
+ private List<Object> loadedElements = new ArrayList<Object>();
+ private List<Object> loadingElements = new ArrayList<Object>();
+
+ private Map<Object, Exception> errors = new HashMap<Object, Exception>();
+ /**
+ * Called to obtain the root elements of the tree viewer, ie, the Users
+ */
@Override
public Object[] getElements(final Object parentElement) {
// A refresh on the whole model... clear our cache
- loadedUsers.clear();
- loadingUsers.clear();
+ loadedElements.clear();
+ loadingElements.clear();
errors.clear();
if (parentElement instanceof IWorkspaceRoot) {
return UserModel.getDefault().getUsers();
@@ -80,6 +85,9 @@
return new Object[0];
}
+ /**
+ * Called to obtain the children of any element in the tree viewer, ie, from a user or
an application
+ */
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof UserDelegate) {
@@ -87,45 +95,39 @@
if(!user.isConnected() && !user.canPromptForPassword()) {
return new Object[]{new NotConnectedUserStub()};
}
- if (!loadedUsers.contains(parentElement)) {
- if (!loadingUsers.contains(parentElement)) {
- // Load the data
- launchLoadingUserJob((UserDelegate) parentElement);
- }
- // return a stub object that says loading...
- return new Object[] { new LoadingStub() };
- }
- Exception ose = errors.get((UserDelegate)parentElement);
- if( ose != null ) {
- return new Object[]{ose};
- }
+ return loadChildren(parentElement);
+ } else if(parentElement instanceof IApplication) {
+ return loadChildren(parentElement);
}
- return getChildrenForElement_LogException(parentElement, false);
+ return getChildrenForElement(parentElement);
}
- // Force the children to load completely
- private void getChildrenFor(Object[] parentElements) {
- for (int i = 0; i < parentElements.length; i++) {
- getChildrenForElement_LogException(parentElements[i], true);
+ /**
+ * @param parentElement
+ * @return
+ */
+ private Object[] loadChildren(Object parentElement) {
+ if (!loadedElements.contains(parentElement)) {
+ if (!loadingElements.contains(parentElement)) {
+ // Load the data
+ launchLoadingJob(parentElement);
+ }
+ // return a stub object that says loading...
+ return new Object[] { new LoadingStub() };
}
- }
-
- // Get the children without the protection of a "loading..." situation
- private Object[] getChildrenForElement_LogException(Object parentElement, boolean
recurse) {
- try {
- return getChildrenForElement(parentElement, recurse);
- } catch (OpenShiftException e) {
- Logger.error("Unable to retrieve OpenShift information", e);
- } catch (SocketTimeoutException e) {
- Logger.error("Unable to retrieve OpenShift information", e);
+ Exception ose = errors.get(parentElement);
+ if( ose != null ) {
+ return new Object[]{ose};
}
- return new Object[0];
+ return getChildrenForElement(parentElement);
}
+
- private Object[] getChildrenForElement(Object parentElement, boolean recurse) throws
OpenShiftException, SocketTimeoutException {
+
+ private Object[] getChildrenForElement(Object parentElement) {
// .... the actual work is done here...
Object[] children = new Object[0];
-// try {
+ try {
if (parentElement instanceof OpenShiftExpressConsoleContentCategory) {
UserDelegate user = ((OpenShiftExpressConsoleContentCategory)
parentElement).getUser();
children = new Object[] { user };
@@ -137,36 +139,28 @@
} else if (parentElement instanceof IApplication) {
children = ((IApplication) parentElement).getEmbeddedCartridges().toArray();
}
+ } catch(OpenShiftException e) {
+ errors.put(parentElement, e);
+ } catch(SocketTimeoutException e) {
+ errors.put(parentElement, e);
+ }
- if (recurse) {
- getChildrenFor(children);
- }
-// } catch (OpenShiftException e) {
-// Logger.error("Unable to retrieve OpenShift information", e);
-// }
return children;
}
- private void launchLoadingUserJob(final UserDelegate user) {
- Job job = new Job("Loading OpenShift User information...") {
+ private void launchLoadingJob(final Object element) {
+ Job job = new Job("Loading OpenShift information...") {
@Override
protected IStatus run(IProgressMonitor monitor) {
monitor.beginTask("Loading OpenShift information...",
IProgressMonitor.UNKNOWN);
monitor.worked(1);
// Get the actual children, with the delay
- loadingUsers.add(user);
- try {
- getChildrenForElement(user,
Boolean.valueOf(System.getProperty("org.jboss.tools.openshift.express.ui.eagerloading",
"true"))); // JBIDE-11680 false = fast, but blocks ui while loading cartridges,
true = slow, but no blocking since cartridges is forced loaded.
-
- } catch(OpenShiftException e) {
- errors.put(user, e);
- } catch(SocketTimeoutException e) {
- errors.put(user, e);
- }
- loadedUsers.add(user);
- loadingUsers.remove(user);
- refreshViewerObject(user);
+ loadingElements.add(element);
+ getChildrenForElement(element);
//Boolean.valueOf(System.getProperty("org.jboss.tools.openshift.express.ui.eagerloading",
"true"))); // JBIDE-11680 false = fast, but blocks ui while loading cartridges,
true = slow, but no blocking since cartridges is forced loaded.
+ loadedElements.add(element);
+ loadingElements.remove(element);
+ refreshViewerObject(element);
monitor.done();
return Status.OK_STATUS;
}
Added:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/RefreshElementActionProvider.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/RefreshElementActionProvider.java
(rev 0)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/RefreshElementActionProvider.java 2012-05-11
15:53:49 UTC (rev 40956)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.openshift.express.internal.ui.viewer.actionProvider;
+
+import org.jboss.tools.openshift.express.internal.ui.action.RefreshElementAction;
+
+/**
+ * @author Xavier Coulon
+ */
+public class RefreshElementActionProvider extends AbstractActionProvider {
+
+ public RefreshElementActionProvider() {
+ super(new RefreshElementAction(), "group.properties");
+ }
+
+}
Property changes on:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/viewer/actionProvider/RefreshElementActionProvider.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-05-11
15:45:49 UTC (rev 40955)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/ApplicationSelectionDialogModel.java 2012-05-11
15:53:49 UTC (rev 40956)
@@ -44,6 +44,8 @@
getUser().refresh();
} catch (OpenShiftException e) {
Logger.error("Failed to refresh User's account", e);
+ } catch (SocketTimeoutException e) {
+ Logger.error("Failed to refresh User's account", e);
}
}