Author: adietish
Date: 2010-11-04 15:06:31 -0400 (Thu, 04 Nov 2010)
New Revision: 26269
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/RebootInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
Log:
[JBIDE-7499] added dialog to reboot several instances at once
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-04 19:01:58
UTC (rev 26268)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-11-04 19:06:31
UTC (rev 26269)
@@ -1,5 +1,7 @@
2010-11-04 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java:
+ [JBIDE-7501] added dialog to reboot several instances at once
* src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java:
[JBIDE-7499] extracted base handler for instances
* src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java:
@@ -7,6 +9,7 @@
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties:
[JBIDE-7496] added texts for dialog to stop several instances at once
[JBIDE-7499] added texts for dialog to start several instances at once
+ [JBIDE-7501] added texts for dialog to reboot several instances at once
* src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
(StopInstanceDialog):
[JBIDE-7496] added dialog to stop several instances at once
* src/org/jboss/tools/deltacloud/ui/views/ImageView.java (.modifyText):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2010-11-04
19:01:58 UTC (rev 26268)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2010-11-04
19:06:31 UTC (rev 26269)
@@ -10,57 +10,74 @@
******************************************************************************/
package org.jboss.tools.deltacloud.ui.commands;
-import org.eclipse.core.commands.AbstractHandler;
+import java.util.List;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
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.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.CVCloudElement;
import org.jboss.tools.deltacloud.ui.views.CVInstanceElement;
import org.jboss.tools.deltacloud.ui.views.CVMessages;
-import org.jboss.tools.deltacloud.ui.views.CloudViewElement;
-import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionThread;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
/**
* @author Andre Dietisheim
*/
-public class RebootInstanceHandler extends AbstractHandler implements IHandler {
+public class RebootInstanceHandler extends AbstractInstanceHandler implements IHandler {
private final static String REBOOTING_INSTANCE_TITLE =
"RebootingInstance.title"; //$NON-NLS-1$
private final static String REBOOTING_INSTANCE_MSG = "RebootingInstance.msg";
//$NON-NLS-1$
+ private final static String REBOOT_INSTANCE_TITLE =
"RebootInstancesDialog.title"; //$NON-NLS-1$
+ private final static String REBOOT_INSTANCE_MSG = "RebootInstancesDialog.msg";
//$NON-NLS-1$
+
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelection(event);
if (selection instanceof IStructuredSelection) {
- CVInstanceElement cvInstance = UIUtils.getFirstElement(selection,
CVInstanceElement.class);
- rebootInstance(cvInstance);
+ if (isSingleInstanceSelected(selection)) {
+ CVInstanceElement cvInstance = UIUtils.getFirstElement(selection,
CVInstanceElement.class);
+ rebootInstance(cvInstance);
+ } else {
+ rebootWithDialog((IStructuredSelection)selection);
+ }
}
return Status.OK_STATUS;
}
+ @SuppressWarnings("unchecked")
+ private void rebootWithDialog(IStructuredSelection selection) {
+ CVInstanceElementsSelectionDialog dialog = new CVInstanceElementsSelectionDialog(
+ UIUtils.getActiveShell()
+ , (List<CVInstanceElement>) selection.toList()
+ , CVMessages.getString(REBOOT_INSTANCE_TITLE)
+ , CVMessages.getString(REBOOT_INSTANCE_MSG));
+ if (Dialog.OK == dialog.open()) {
+ rebootInstances(dialog.getResult());
+ }
+ }
+
+ private void rebootInstances(Object[] cvInstances) {
+ for (int i = 0; i < cvInstances.length; i++) {
+ rebootInstance((CVInstanceElement) cvInstances[i]);
+ }
+ }
+
private void rebootInstance(CVInstanceElement cvInstance) {
if (cvInstance != null) {
DeltaCloudInstance instance = (DeltaCloudInstance) cvInstance.getElement();
- CloudViewElement element = cvInstance;
- while (!(element instanceof CVCloudElement))
- element = (CloudViewElement) element.getParent();
- CVCloudElement cvcloud = (CVCloudElement) element;
- DeltaCloud cloud = (DeltaCloud) cvcloud.getElement();
- PerformInstanceActionThread t = new PerformInstanceActionThread(cloud, instance,
- DeltaCloudInstance.REBOOT,
- CVMessages.getString(REBOOTING_INSTANCE_TITLE),
- CVMessages.getFormattedString(REBOOTING_INSTANCE_MSG, new String[] {
instance.getName() }),
- DeltaCloudInstance.RUNNING);
- t.setUser(true);
- t.schedule();
+ executeInstanceAction(
+ cvInstance
+ , DeltaCloudInstance.REBOOT
+ , DeltaCloudInstance.RUNNING
+ , CVMessages.getString(REBOOTING_INSTANCE_TITLE)
+ , CVMessages.getFormattedString(REBOOTING_INSTANCE_MSG, new String[] {
instance.getName() }));
}
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-11-04
19:01:58 UTC (rev 26268)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-11-04
19:06:31 UTC (rev 26269)
@@ -55,6 +55,8 @@
StopInstancesDialog.msg=Please choose the instances that shall be stopped by checking
them:
RebootingInstance.title=Rebooting Instance
RebootingInstance.msg=Rebooting Instance: {0}
+RebootInstancesDialog.title=Reboot Instances
+RebootInstancesDialog.msg=Please choose the clouds that shall be rebooted by checking
them:
DestroyingInstance.title=Destroying Instance
DestroyingInstance.msg=Destroying Instance: {0}
ConnectingRSE.msg=Connecting instance as: {0}
Show replies by date