Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-04-18 08:48:40 +0000
committerTobias Schwarz2013-04-18 08:48:40 +0000
commit773760c2e4fc02b53aec96d442db27c504bc4566 (patch)
tree6e8db62d7c7c504e014bb636d0f4e055ac52229f /target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper
parent6746d40b333df5d5b47ceab98dfa3868eda412e8 (diff)
downloadorg.eclipse.tcf-773760c2e4fc02b53aec96d442db27c504bc4566.tar.gz
org.eclipse.tcf-773760c2e4fc02b53aec96d442db27c504bc4566.tar.xz
org.eclipse.tcf-773760c2e4fc02b53aec96d442db27c504bc4566.zip
Target Explorer: add support for not cancelable stepper jobs
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/job/StepperJob.java72
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java28
4 files changed, 105 insertions, 4 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/META-INF/MANIFEST.MF
index 3267cdd8b..a50610791 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/META-INF/MANIFEST.MF
@@ -25,5 +25,6 @@ Export-Package: org.eclipse.tcf.te.runtime.stepper,
org.eclipse.tcf.te.runtime.stepper.iterators,
org.eclipse.tcf.te.runtime.stepper.job,
org.eclipse.tcf.te.runtime.stepper.nls;x-internal:=true,
+ org.eclipse.tcf.te.runtime.stepper.services,
org.eclipse.tcf.te.runtime.stepper.stepper,
org.eclipse.tcf.te.runtime.stepper.steps
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java
index 02d1b7af3..0073d7994 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java
@@ -58,4 +58,12 @@ public interface IStepperService extends IService {
* @return <code>true</code> if the operation is enabled.
*/
public boolean isEnabled(Object context, String operation);
+
+ /**
+ * Returns <code>true</code> if the given operation can be canceled.
+ * @param context The context. Must not be <code>null</code>.
+ * @param operation The operation. Must not be <code>null</code>.
+ * @return <code>true</code> if the operation can be canceled.
+ */
+ public boolean isCancelable(Object context, String operation);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/job/StepperJob.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/job/StepperJob.java
index 520ee27e4..bd388b989 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/job/StepperJob.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/job/StepperJob.java
@@ -37,6 +37,56 @@ public class StepperJob extends Job {
private ICallback jobCallback = null;
private boolean isFinished = false;
private boolean isCanceled = false;
+ private final boolean isCancelable;
+
+ private class NotCancelableProgressMonitor implements IProgressMonitor {
+
+ private final IProgressMonitor monitor;
+
+ public NotCancelableProgressMonitor(IProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ @Override
+ public void beginTask(String name, int totalWork) {
+ monitor.beginTask(name, totalWork);
+ }
+
+ @Override
+ public void done() {
+ monitor.done();
+ }
+
+ @Override
+ public void internalWorked(double work) {
+ monitor.internalWorked(work);
+ }
+
+ @Override
+ public boolean isCanceled() {
+ return false;
+ }
+
+ @Override
+ public void setCanceled(boolean value) {
+ monitor.setCanceled(false);
+ }
+
+ @Override
+ public void setTaskName(String name) {
+ monitor.setTaskName(name);
+ }
+
+ @Override
+ public void subTask(String name) {
+ monitor.subTask(name);
+ }
+
+ @Override
+ public void worked(int work) {
+ monitor.worked(work);
+ }
+ }
/**
* Constructor.
@@ -47,7 +97,7 @@ public class StepperJob extends Job {
* @param stepGroupId The step group id to execute.
* @param operation The operation to execute.
*/
- public StepperJob(String name, IStepContext stepContext, IPropertiesContainer data, String stepGroupId, String operation) {
+ public StepperJob(String name, IStepContext stepContext, IPropertiesContainer data, String stepGroupId, String operation, boolean isCancelable) {
super(name);
setPriority(Job.INTERACTIVE);
@@ -60,6 +110,7 @@ public class StepperJob extends Job {
this.data = data;
this.stepGroupId = stepGroupId;
this.operation = operation;
+ this.isCancelable = isCancelable;
if (stepContext.getContextObject() instanceof ISchedulingRule) {
setRule((ISchedulingRule)stepContext.getContextObject());
@@ -92,12 +143,23 @@ public class StepperJob extends Job {
return jobCallback;
}
+ /**
+ * Return <code>true</code> if thsi job is cancelable.
+ */
+ public boolean isCancelable() {
+ return isCancelable;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
protected final IStatus run(IProgressMonitor monitor) {
+ if (!isCancelable) {
+ monitor = new NotCancelableProgressMonitor(monitor);
+ }
+
// The stepper instance to be used
IStepper stepper = new Stepper(getName());
IStatus status = Status.OK_STATUS;
@@ -134,7 +196,7 @@ public class StepperJob extends Job {
}
public boolean isCanceled() {
- return isCanceled;
+ return isCanceled && isCancelable;
}
/* (non-Javadoc)
@@ -142,7 +204,9 @@ public class StepperJob extends Job {
*/
@Override
protected void canceling() {
- super.canceling();
- isCanceled = true;
+ if (isCancelable) {
+ super.canceling();
+ isCanceled = true;
+ }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java
new file mode 100644
index 000000000..49af424b1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.runtime.stepper.services;
+
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
+
+/**
+ * AbstractStepperService
+ */
+public abstract class AbstractStepperService extends AbstractService implements IStepperService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService#isCancelable(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isCancelable(Object context, String operation) {
+ return OPERATION_CONNECT.equals(operation);
+ }
+}

Back to the top