Author: adietish
Date: 2010-12-10 12:02:53 -0500 (Fri, 10 Dec 2010)
New Revision: 27370
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
Log:
[JBIDE-7738]
* made ImageView and InstanceView adaptable, so that RefreshImageHandler and
RefreshInstanceHandler may pick the cloud it shows
* added #getDeltaCloud so that it may be used by subclasses: RefreshImagesHandler,
RefreshInstancesHandler
* RefreshImagesHandler and RefreshInstancesHandler are now subclasses of
RefreshCloudHandler that only refresh images / instances
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-10 16:55:28
UTC (rev 27369)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-10 17:02:53
UTC (rev 27370)
@@ -1,5 +1,15 @@
2010-12-10 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java:
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java:
+ [JBIDE-7738] RefreshImagesHandler and RefreshInstancesHandler are now subclasses of
+ RefreshCloudHandler that only refresh images / instances
+ * src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java (getDeltaCloud):
+ [JBIDE-7738] added #getDeltaCloud so that it may be used by subclasses:
RefreshImagesHandler, RefreshInstancesHandler
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java
+ (getAdapter):
+ [JBIDE-7738] made ImageView and InstanceView adaptable, so that RefreshImageHandler and
+ RefreshInstanceHandler may pick the cloud it shows
*
src/org/jboss/tools/deltacloud/ui/views/cloudelements/AbstractCloudElementTableView.java:
(updateCloudSelector):
[JBIDE-7862] layouting the combo's parent as soon as the cloud name gets edited
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-10
16:55:28 UTC (rev 27369)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshCloudHandler.java 2010-12-10
17:02:53 UTC (rev 27370)
@@ -17,8 +17,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
@@ -34,32 +32,40 @@
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- DeltaCloud cloud = UIUtils.getFirstAdaptedElement(selection, DeltaCloud.class);
+ DeltaCloud cloud = getDeltaCloud(event);
+ if (cloud != null) {
refresh(cloud);
}
return Status.OK_STATUS;
}
- private void refresh(final DeltaCloud cloud) {
- if (cloud != null) {
- // TODO: internationalize strings
- new AbstractCloudJob("Refreshing images and instances on " +
cloud.getName(), cloud) {
-
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- try {
- monitor.worked(1);
- cloud.loadChildren();
- monitor.done();
- } catch (DeltaCloudMultiException e) {
- return ErrorUtils.createMultiStatus(e);
- }
- return Status.OK_STATUS;
- }
- }.schedule();
+ private DeltaCloud getDeltaCloud(ExecutionEvent event) {
+ DeltaCloud cloud = null;
+ // first try selected item
+ cloud = UIUtils.getFirstAdaptedElement(HandlerUtil.getCurrentSelection(event),
DeltaCloud.class);
+ if (cloud == null) {
+ // no item selected: try active part
+ cloud = UIUtils.adapt(HandlerUtil.getActivePart(event), DeltaCloud.class);
}
+ return cloud;
}
+
+ protected void refresh(final DeltaCloud cloud) {
+ // TODO: internationalize strings
+ new AbstractCloudJob("Refreshing images and instances on " + cloud.getName(),
cloud) {
+
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ try {
+ monitor.worked(1);
+ cloud.loadChildren();
+ monitor.done();
+ } catch (DeltaCloudMultiException e) {
+ return ErrorUtils.createMultiStatus(e);
+ }
+ return Status.OK_STATUS;
+ }
+ }.schedule();
+ }
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-12-10
16:55:28 UTC (rev 27369)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshImagesHandler.java 2010-12-10
17:02:53 UTC (rev 27370)
@@ -10,54 +10,29 @@
******************************************************************************/
package org.jboss.tools.deltacloud.ui.commands;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.DeltaCloudImage;
import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Andre Dietisheim
*/
-public class RefreshImagesHandler extends AbstractHandler implements IHandler {
+public class RefreshImagesHandler extends RefreshCloudHandler {
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- DeltaCloudImage deltaCloudImage = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudImage.class);
- refresh(deltaCloudImage);
- }
+ protected void refresh(final DeltaCloud cloud) {
+ // TODO: internationalize strings
+ new AbstractCloudJob("Refreshing images on cloud " + cloud.getName(), cloud)
{
- return Status.OK_STATUS;
- }
-
- private void refresh(DeltaCloudImage deltaCloudImage) {
- if (deltaCloudImage != null) {
- final DeltaCloud cloud = deltaCloudImage.getDeltaCloud();
- if (cloud != null) {
- // TODO: internationalize strings
- new AbstractCloudJob("Refreshing images on cloud " + cloud.getName(),
cloud) {
-
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- monitor.worked(1);
- cloud.loadChildren();
- monitor.done();
- return Status.OK_STATUS;
- }
- }.schedule();
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ monitor.worked(1);
+ cloud.loadImages();
+ monitor.done();
+ return Status.OK_STATUS;
}
- }
+ }.schedule();
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-12-10
16:55:28 UTC (rev 27369)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RefreshInstancesHandler.java 2010-12-10
17:02:53 UTC (rev 27370)
@@ -10,55 +10,32 @@
******************************************************************************/
package org.jboss.tools.deltacloud.ui.commands;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
import org.jboss.tools.deltacloud.core.DeltaCloud;
import org.jboss.tools.deltacloud.core.DeltaCloudException;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
import org.jboss.tools.deltacloud.core.job.AbstractCloudJob;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Andre Dietisheim
*/
-public class RefreshInstancesHandler extends AbstractHandler implements IHandler {
+public class RefreshInstancesHandler extends RefreshCloudHandler {
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection instanceof IStructuredSelection) {
- DeltaCloudInstance deltaCloudInstance = UIUtils.getFirstAdaptedElement(selection,
DeltaCloudInstance.class);
- refresh(deltaCloudInstance);
- }
+ protected void refresh(final DeltaCloud cloud) {
+ if (cloud != null) {
+ // TODO: internationalize strings
+ new AbstractCloudJob("Refreshing instances on cloud " + cloud.getName(),
cloud) {
- return Status.OK_STATUS;
- }
+ @Override
+ protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
+ monitor.worked(1);
+ cloud.loadInstances();
+ monitor.done();
+ return Status.OK_STATUS;
+ }
- private void refresh(final DeltaCloudInstance deltaCloudInstance) {
- if (deltaCloudInstance != null) {
- final DeltaCloud cloud = deltaCloudInstance.getDeltaCloud();
- if (cloud != null) {
- // TODO: internationalize strings
- new AbstractCloudJob("Refreshing instances on cloud " + cloud.getName(),
cloud) {
-
- @Override
- protected IStatus doRun(IProgressMonitor monitor) throws DeltaCloudException {
- monitor.worked(1);
- cloud.loadChildren();
- monitor.done();
- return Status.OK_STATUS;
- }
-
- }.setUser(true);
- }
+ }.setUser(true);
}
}
}
Show replies by date