Author: adietish
Date: 2010-12-13 06:37:47 -0500 (Mon, 13 Dec 2010)
New Revision: 27404
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
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/AbstractInstanceHandler.java
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/StartInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
Log:
[JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-13 10:43:38
UTC (rev 27403)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/ChangeLog 2010-12-13 11:37:47
UTC (rev 27404)
@@ -1,5 +1,15 @@
2010-12-13 André Dietisheim <adietish(a)redhat.com>
+ * src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
(performFinish):
+ *
src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
(getStatusIcon):
+ * src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java (run):
+ * src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java
(PerformInstanceActionJob):
+ (run):
+ * src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java (stopInstance):
+ * src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java (startInstance):
+ * src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java
(rebootInstance):
+ * src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
(executeInstanceAction):
+ [JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
* plugin.xml:
[JBIDE-7864] added hasImages property tester, rename CreateInstanceHandler2 to
CreateInstanceFromAnyImage,
renamed CreateInstanceHandler to CreateInstanceFromSpecificImage
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/AbstractInstanceHandler.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -15,7 +15,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionThread;
+import org.jboss.tools.deltacloud.ui.views.PerformInstanceActionJob;
import org.jboss.tools.internal.deltacloud.ui.utils.StringUtils;
import org.jboss.tools.internal.deltacloud.ui.utils.StringUtils.IElementFormatter;
import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
@@ -27,13 +27,13 @@
*/
public abstract class AbstractInstanceHandler extends AbstractHandler implements IHandler
{
- protected void executeInstanceAction(DeltaCloudInstance instance, String actionId,
String expectedState,
+ protected void executeInstanceAction(DeltaCloudInstance instance,
DeltaCloudInstance.Action action, DeltaCloudInstance.State expectedState,
String title, String message) {
if (instance != null) {
- PerformInstanceActionThread t = new PerformInstanceActionThread(
+ PerformInstanceActionJob t = new PerformInstanceActionJob(
instance.getDeltaCloud(),
instance,
- actionId,
+ action,
title,
message,
expectedState);
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-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/RebootInstanceHandler.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -81,8 +81,8 @@
if (instance != null) {
executeInstanceAction(
instance
- , DeltaCloudInstance.REBOOT
- , DeltaCloudInstance.RUNNING
+ , DeltaCloudInstance.Action.REBOOT
+ , DeltaCloudInstance.State.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/commands/StartInstanceHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StartInstanceHandler.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -83,8 +83,8 @@
if (instance != null) {
executeInstanceAction(
instance
- , DeltaCloudInstance.START
- , DeltaCloudInstance.RUNNING
+ , DeltaCloudInstance.Action.START
+ , DeltaCloudInstance.State.RUNNING
, CVMessages.getString(STARTING_INSTANCE_TITLE)
, CVMessages.getFormattedString(STARTING_INSTANCE_MSG, new String[] {
instance.getName() }));
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/commands/StopInstanceHandler.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -81,8 +81,8 @@
if (instance != null) {
executeInstanceAction(
instance
- , DeltaCloudInstance.STOP
- , DeltaCloudInstance.STOPPED
+ , DeltaCloudInstance.Action.STOP
+ , DeltaCloudInstance.State.STOPPED
, CVMessages.getString(STOPPING_INSTANCE_TITLE)
, CVMessages.getFormattedString(STOPPING_INSTANCE_MSG, new String[] {
instance.getName() }));
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformDestroyInstanceActionThread.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -48,7 +48,7 @@
@Override
public void run() {
try {
- cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.DESTROY);
+ cloud.performInstanceAction(instance.getId(), DeltaCloudInstance.Action.DESTROY);
} catch (DeltaCloudException e) {
// TODO internationalize strings
ErrorUtils.handleError("Error",
Copied:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java
(from rev 27367,
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java)
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionJob.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2010 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.deltacloud.ui.views;
+
+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.dialogs.ErrorDialog;
+import org.eclipse.swt.widgets.Display;
+import org.jboss.tools.common.log.StatusFactory;
+import org.jboss.tools.deltacloud.core.DeltaCloud;
+import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
+import org.jboss.tools.deltacloud.ui.Activator;
+import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
+
+public class PerformInstanceActionJob extends Job {
+
+ private static final String INSTANCEACTION_ERROR_TITLE =
"InstanceActionError.title"; //$NON-NLS-1$
+ private static final String INSTANCEACTION_ERROR_MESSAGE =
"InstanceActionError.msg"; //$NON-NLS-1$
+
+ private DeltaCloud cloud;
+ private DeltaCloudInstance instance;
+ private DeltaCloudInstance.Action action;
+ private String taskName;
+ private DeltaCloudInstance.State expectedState;
+
+ public PerformInstanceActionJob(DeltaCloud cloud, DeltaCloudInstance instance,
+ DeltaCloudInstance.Action action, String title, String taskName,
DeltaCloudInstance.State expectedState) {
+ super(title);
+ this.cloud = cloud;
+ this.instance = instance;
+ this.action = action;
+ this.taskName = taskName;
+ this.expectedState = expectedState;
+ }
+
+ @Override
+ public IStatus run(IProgressMonitor pm) {
+ String id = instance.getId();
+ try {
+ pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
+ pm.worked(1);
+ // To handle the user starting a new action when we haven't
+ // confirmed the last one yet,
+ // cancel the previous job and then go on performing this action
+ cancelPreviousJob(id);
+ cloud.performInstanceAction(id, action);
+ cloud.waitForState(id, expectedState, pm);
+ } catch (Exception e) {
+ final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ ErrorDialog.openError(
+ UIUtils.getActiveShell(),
+ CVMessages.getString(INSTANCEACTION_ERROR_TITLE),
+ CVMessages.getFormattedString(INSTANCEACTION_ERROR_MESSAGE, action.getName(),
instance.getName()),
+ status);
+ }
+ });
+
+ } finally {
+ cloud.removeInstanceJob(id, this);
+ pm.done();
+ }
+ return Status.OK_STATUS;
+ }
+
+ private void cancelPreviousJob(String id) {
+ Job job = cloud.getInstanceJob(id);
+ if (job != null) {
+ job.cancel();
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // do nothing, this is ok
+ }
+ }
+ }
+}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/PerformInstanceActionThread.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 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.deltacloud.ui.views;
-
-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.dialogs.ErrorDialog;
-import org.eclipse.swt.widgets.Display;
-import org.jboss.tools.common.log.StatusFactory;
-import org.jboss.tools.deltacloud.core.DeltaCloud;
-import org.jboss.tools.deltacloud.core.DeltaCloudInstance;
-import org.jboss.tools.deltacloud.ui.Activator;
-import org.jboss.tools.internal.deltacloud.ui.utils.UIUtils;
-
-public class PerformInstanceActionThread extends Job {
-
- private static final String INSTANCEACTION_ERROR_TITLE =
"InstanceActionError.title"; //$NON-NLS-1$
- private static final String INSTANCEACTION_ERROR_MESSAGE =
"InstanceActionError.msg"; //$NON-NLS-1$
-
- private DeltaCloud cloud;
- private DeltaCloudInstance instance;
- private String action;
- private String taskName;
- private String expectedState;
-
- public PerformInstanceActionThread(DeltaCloud cloud, DeltaCloudInstance instance,
- String action, String title, String taskName, String expectedState) {
- super(title);
- this.cloud = cloud;
- this.instance = instance;
- this.action = action;
- this.taskName = taskName;
- this.expectedState = expectedState;
- }
-
- @Override
- public IStatus run(IProgressMonitor pm) {
- String id = instance.getId();
- try {
- pm.beginTask(taskName, IProgressMonitor.UNKNOWN);
- pm.worked(1);
- // To handle the user starting a new action when we haven't
- // confirmed the last one yet,
- // cancel the previous job and then go on performing this action
- cancelPreviousJob(id);
- cloud.performInstanceAction(id, action);
- cloud.waitForState(id, expectedState, pm);
- } catch (Exception e) {
- final IStatus status = StatusFactory.getInstance(IStatus.ERROR, Activator.PLUGIN_ID,
e.getMessage(), e);
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ErrorDialog.openError(
- UIUtils.getActiveShell(),
- CVMessages.getString(INSTANCEACTION_ERROR_TITLE),
- CVMessages.getFormattedString(INSTANCEACTION_ERROR_MESSAGE, action,
instance.getName()),
- status);
- }
- });
-
- } finally {
- cloud.removeInstanceJob(id, this);
- pm.done();
- }
- return Status.OK_STATUS;
- }
-
- private void cancelPreviousJob(String id) {
- Job job = cloud.getInstanceJob(id);
- if (job != null) {
- job.cancel();
- try {
- job.join();
- } catch (InterruptedException e) {
- // do nothing, this is ok
- }
- }
- }
-}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/deltacloud/ui/views/cloudelements/InstanceViewLabelAndContentProvider.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -86,12 +86,12 @@
}
}
- private Image getStatusIcon(String status) {
- if (DeltaCloudInstance.STOPPED.equals(status)) {
+ private Image getStatusIcon(DeltaCloudInstance.State status) {
+ if (DeltaCloudInstance.State.STOPPED.equals(status)) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_STOPPED);
- } else if (DeltaCloudInstance.RUNNING.equals(status)) {
+ } else if (DeltaCloudInstance.State.RUNNING.equals(status)) {
return SWTImagesFactory.get(SWTImagesFactory.IMG_RUNNING);
- } else if (DeltaCloudInstance.BOGUS.equals(status)) {
+ } else if (DeltaCloudInstance.State.BOGUS.equals(status)) {
return PlatformUI.getWorkbench().getSharedImages().
getImage(ISharedImages.IMG_DEC_FIELD_WARNING);
} else {
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-13
10:43:38 UTC (rev 27403)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/NewInstanceWizard.java 2010-12-13
11:37:47 UTC (rev 27404)
@@ -175,7 +175,7 @@
if (instance != null) {
result = true;
}
- if (instance != null &&
instance.getState().equals(DeltaCloudInstance.PENDING)) {
+ if (instance != null &&
instance.getState().equals(DeltaCloudInstance.State.PENDING)) {
final String instanceId = instance.getId();
final String instanceName = name;
Job job = new WatchCreateJob(WizardMessages.getString(STARTING_INSTANCE_TITLE),