[jbosstools-commits] JBoss Tools SVN: r24126 - in trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui: src/org/jboss/tools/deltacloud/ui/views and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Thu Aug 12 17:01:42 EDT 2010
Author: jjohnstn
Date: 2010-08-12 17:01:42 -0400 (Thu, 12 Aug 2010)
New Revision: 24126
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.java
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/InstanceView.java
Log:
2010-08-12 Jeff Johnston <jjohnstn at redhat.com>
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.java (getFormattedString): New method.
* src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add new messages.
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (PerformDestroyInstanceActionThread.run):
Rewrite as Job run method.
(PerformInstanceActionThread.run): Ditto.
(PerformInstanceActionThread): Rewrite to inherit from Job.
(PerformDestroyInstanceActionThread): Ditto.
(PerformDestroyInstanceActionThread.PerformDestroyInstanceActionThread): Change constructor to
take title and task name.
(PerformInstanceActionThread.PerformInstanceActionThread): Ditto.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-12 20:52:22 UTC (rev 24125)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-08-12 21:01:42 UTC (rev 24126)
@@ -1,5 +1,18 @@
2010-08-12 Jeff Johnston <jjohnstn at redhat.com>
+ * src/org/jboss/tools/deltacloud/ui/views/CVMessages.java (getFormattedString): New method.
+ * src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties: Add new messages.
+ * src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (PerformDestroyInstanceActionThread.run):
+ Rewrite as Job run method.
+ (PerformInstanceActionThread.run): Ditto.
+ (PerformInstanceActionThread): Rewrite to inherit from Job.
+ (PerformDestroyInstanceActionThread): Ditto.
+ (PerformDestroyInstanceActionThread.PerformDestroyInstanceActionThread): Change constructor to
+ take title and task name.
+ (PerformInstanceActionThread.PerformInstanceActionThread): Ditto.
+
+2010-08-12 Jeff Johnston <jjohnstn at redhat.com>
+
* src/org/jboss/tools/deltacloud/ui/views/InstanceView.java (changeEvent): Don't
mark as override.
(listChanged): Ditto.
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.java 2010-08-12 20:52:22 UTC (rev 24125)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.java 2010-08-12 21:01:42 UTC (rev 24126)
@@ -1,5 +1,6 @@
package org.jboss.tools.deltacloud.ui.views;
+import java.text.MessageFormat;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
@@ -16,5 +17,12 @@
return '#' + key + '#';
}
}
+
+ public static String getFormattedString(String key, String arg) {
+ return MessageFormat.format(getString(key), new Object[] { arg });
+ }
+ public static String getFormattedString(String key, String[] args) {
+ return MessageFormat.format(getString(key), (Object[])args);
+ }
}
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-08-12 20:52:22 UTC (rev 24125)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/CVMessages.properties 2010-08-12 21:01:42 UTC (rev 24126)
@@ -28,6 +28,13 @@
Reboot.label=Reboot
Destroy.label=Destroy
+StartingInstance.title=Starting Instance
+StartingInstance.msg=Starting Instance: {0}
+StoppingInstance.title=Stopping Instance
+StoppingInstance.msg=Stopping Instance: {0}
+RebootingInstance.title=Rebooting Instance
+RebootingInstance.msg=Rebooting Instance: {0}
+
NAME=Name
ID=ID
HOSTNAME=Public Hostname
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-08-12 20:52:22 UTC (rev 24125)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/InstanceView.java 2010-08-12 21:01:42 UTC (rev 24126)
@@ -4,6 +4,10 @@
import java.util.List;
import java.util.Map;
+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.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -54,7 +58,16 @@
private final static String STOP_LABEL = "Stop.label"; //$NON-NLS-1$
private final static String REBOOT_LABEL = "Reboot.label"; //$NON-NLS-1$
private final static String DESTROY_LABEL = "Destroy.label"; //$NON-NLS-1$
+ private final static String STARTING_INSTANCE_TITLE = "StartingInstance.title"; //$NON-NLS-1$
+ private final static String STARTING_INSTANCE_MSG = "StartingInstance.msg"; //$NON-NLS-1$
+ private final static String STOPPING_INSTANCE_TITLE = "StoppingInstance.title"; //$NON-NLS-1$
+ private final static String STOPPING_INSTANCE_MSG = "StoppingInstance.msg"; //$NON-NLS-1$
+ 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 DESTROYING_INSTANCE_TITLE = "DestroyingInstance.title"; //$NON-NLS-1$
+ private final static String DESTROYING_INSTANCE_MSG = "DestroyingInstance.msg"; //$NON-NLS-1$
+
private TableViewer viewer;
private Composite container;
private Combo cloudSelector;
@@ -252,50 +265,69 @@
//TODO
}
- private class PerformInstanceActionThread extends Thread {
+ private class PerformInstanceActionThread extends Job {
private DeltaCloud cloud;
private DeltaCloudInstance instance;
private String action;
+ private String taskName;
- public PerformInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance instance, String action) {
- super();
+ public PerformInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance instance,
+ String action, String title, String taskName) {
+ super(title);
this.cloud = cloud;
this.instance = instance;
this.action = action;
+ this.taskName = taskName;
}
@Override
- public void run() {
- cloud.performInstanceAction(instance.getId(), action);
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- refreshInstance(instance);
- }
- });
-
+ public IStatus run(IProgressMonitor pm) {
+ try {
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ pm.worked(1);
+ cloud.performInstanceAction(instance.getId(), action);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ refreshInstance(instance);
+ }
+ });
+ } finally {
+ pm.done();
+ }
+ return Status.OK_STATUS;
}
}
- private class PerformDestroyInstanceActionThread extends Thread {
+ private class PerformDestroyInstanceActionThread extends Job {
private DeltaCloud cloud;
private DeltaCloudInstance instance;
+ private String taskName;
- public PerformDestroyInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance instance) {
- super();
+ public PerformDestroyInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance instance,
+ String title, String taskName) {
+ super(title);
this.cloud = cloud;
this.instance = instance;
+ this.taskName = taskName;
}
- @Override
- public void run() {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- cloud.destroyInstance(instance.getId());
- }
- });
- }
+ @Override
+ public IStatus run(IProgressMonitor pm) {
+ try {
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ pm.worked(1);
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ cloud.destroyInstance(instance.getId());
+ }
+ });
+ } finally {
+ pm.done();
+ }
+ return Status.OK_STATUS;
+ }
}
private void makeActions() {
@@ -310,8 +342,11 @@
public void run() {
ISelection selection = viewer.getSelection();
DeltaCloudInstance instance = (DeltaCloudInstance)((IStructuredSelection)selection).getFirstElement();
- PerformInstanceActionThread t = new PerformInstanceActionThread(currCloud, instance, DeltaCloudInstance.START);
- t.start();
+ PerformInstanceActionThread t = new PerformInstanceActionThread(currCloud, instance, DeltaCloudInstance.START,
+ CVMessages.getString(STARTING_INSTANCE_TITLE),
+ CVMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[]{instance.getName()}));
+ t.setUser(true);
+ t.schedule();
}
};
startAction.setText(CVMessages.getString(START_LABEL));
@@ -321,8 +356,11 @@
public void run() {
ISelection selection = viewer.getSelection();
DeltaCloudInstance instance = (DeltaCloudInstance)((IStructuredSelection)selection).getFirstElement();
- PerformInstanceActionThread t = new PerformInstanceActionThread(currCloud, instance, DeltaCloudInstance.STOP);
- t.start();
+ PerformInstanceActionThread t = new PerformInstanceActionThread(currCloud, instance, DeltaCloudInstance.STOP,
+ CVMessages.getString(STOPPING_INSTANCE_TITLE),
+ CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[]{instance.getName()}));
+ t.setUser(true);
+ t.schedule();
}
};
stopAction.setText(CVMessages.getString(STOP_LABEL));
@@ -332,8 +370,11 @@
public void run() {
ISelection selection = viewer.getSelection();
DeltaCloudInstance instance = (DeltaCloudInstance)((IStructuredSelection)selection).getFirstElement();
- PerformInstanceActionThread t = new PerformInstanceActionThread(currCloud, instance, DeltaCloudInstance.REBOOT);
- t.start();
+ PerformInstanceActionThread t = new PerformInstanceActionThread(currCloud, instance, DeltaCloudInstance.REBOOT,
+ CVMessages.getString(REBOOTING_INSTANCE_TITLE),
+ CVMessages.getFormattedString(REBOOTING_INSTANCE_MSG, new String[]{instance.getName()}));
+ t.setUser(true);
+ t.schedule();
}
};
rebootAction.setText(CVMessages.getString(REBOOT_LABEL));
@@ -343,8 +384,11 @@
public void run() {
ISelection selection = viewer.getSelection();
DeltaCloudInstance instance = (DeltaCloudInstance)((IStructuredSelection)selection).getFirstElement();
- PerformDestroyInstanceActionThread t = new PerformDestroyInstanceActionThread(currCloud, instance);
- t.start();
+ PerformDestroyInstanceActionThread t = new PerformDestroyInstanceActionThread(currCloud, instance,
+ CVMessages.getString(DESTROYING_INSTANCE_TITLE),
+ CVMessages.getFormattedString(DESTROYING_INSTANCE_MSG, new String[]{instance.getName()}));
+ t.setUser(true);
+ t.schedule();
}
};
destroyAction.setText(CVMessages.getString(DESTROY_LABEL));
More information about the jbosstools-commits
mailing list