diff options
author | Tobias Schwarz | 2012-06-20 07:42:33 +0000 |
---|---|---|
committer | Uwe Stieber | 2012-06-20 07:42:33 +0000 |
commit | f040254c9a2a5c017060cad50f3a6df8bbe09c63 (patch) | |
tree | 1e1cd7a55956e45ecd51c6e847e4c8bc63fa455e /target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core | |
parent | 7c9d807ca9a3a0186cd275fe26ea5af329c673de (diff) | |
download | org.eclipse.tcf-f040254c9a2a5c017060cad50f3a6df8bbe09c63.tar.gz org.eclipse.tcf-f040254c9a2a5c017060cad50f3a6df8bbe09c63.tar.xz org.eclipse.tcf-f040254c9a2a5c017060cad50f3a6df8bbe09c63.zip |
Target Explorer: REWORK stepper api
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core')
8 files changed, 579 insertions, 570 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml index a38edc29f..385a0c26e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/plugin.xml @@ -107,7 +107,7 @@ <stepGroup id="org.eclipse.tcf.te.tcf.launch.type.remote.app.stepGroup" label="%LaunchStepGroup.Remote.App.name" - locked="false"> + iterator="org.eclipse.tcf.te.launch.core.steps.iterators.LaunchContextIterator"> <references> <reference id="org.eclipse.tcf.te.tcf.launch.core.openChannelStep"/> <reference id="org.eclipse.tcf.te.tcf.launch.core.fileTransferStepGroup"/> @@ -141,8 +141,7 @@ <stepGroup id="org.eclipse.tcf.te.tcf.launch.core.fileTransferStepGroup" label="%LaunchStepGroup.FileTransfer.name" - iterator="org.eclipse.tcf.te.tcf.launch.core.steps.iterators.FileTransferIterator" - locked="false"> + iterator="org.eclipse.tcf.te.tcf.launch.core.steps.iterators.FileTransferIterator"> <references> <reference id="org.eclipse.tcf.te.tcf.launch.core.fileTransferStep"/> </references> @@ -150,7 +149,7 @@ <stepGroup id="org.eclipse.tcf.te.tcf.launch.type.attach.stepGroup" label="%LaunchStepGroup.Attach.name" - locked="false"> + iterator="org.eclipse.tcf.te.launch.core.steps.iterators.LaunchContextIterator"> <references> <reference id="org.eclipse.tcf.te.tcf.launch.core.attachDebuggerStep"> <enablement> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java index b077a9f2b..fe207d802 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/internal/adapters/StepContextAdapter.java @@ -1,159 +1,167 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.internal.adapters;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-
-/**
- * Peer model step context adapter implementation.
- */
-public class StepContextAdapter extends PlatformObject implements IStepContext {
- // Reference to the launch
- private final ILaunch launch;
-
- /**
- * Constructor.
- *
- * @param launch The launch. Must not be <code>null</code>.
- */
- public StepContextAdapter(ILaunch launch) {
- super();
- Assert.isNotNull(launch);
- this.launch = launch;
- }
-
- /**
- * Returns the launch.
- * @return The launch.
- */
- public ILaunch getLaunch() {
- return launch;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getId()
- */
- @Override
- public String getId() {
- return launch != null && launch.getLaunchConfiguration() != null ? launch.getLaunchConfiguration().getName() : null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getName()
- */
- @Override
- public String getName() {
- final AtomicReference<String> name = new AtomicReference<String>();
-
- if (launch != null) {
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- name.set(getId());
- }
- };
-
- if (Protocol.isDispatchThread()) {
- runnable.run();
- }
- else {
- Protocol.invokeAndWait(runnable);
- }
- }
-
- return name.get();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getContextObject()
- */
- @Override
- public Object getContextObject() {
- return launch;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getInfo(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
- */
- @Override
- public String getInfo(IPropertiesContainer data) {
- try {
- return getName() + "(" + launch.getLaunchMode() + ") - " + launch.getLaunchConfiguration().getType().getName(); //$NON-NLS-1$ //$NON-NLS-2$
- }
- catch (CoreException e) {
- }
- return getName() + "(" + launch.getLaunchMode() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(final Class adapter) {
- // NOTE: The getAdapter(...) method can be invoked from many place and
- // many threads where we cannot control the calls. Therefore, this
- // method is allowed be called from any thread.
- final AtomicReference<Object> object = new AtomicReference<Object>();
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- object.set(doGetAdapter(adapter));
- }
- };
-
- if (Protocol.isDispatchThread()) {
- runnable.run();
- }
- else {
- Protocol.invokeAndWait(runnable);
- }
-
- return object.get() != null ? object.get() : super.getAdapter(adapter);
- }
-
- /**
- * Returns an object which is an instance of the given class associated with this object.
- * Returns <code>null</code> if no such object can be found.
- * <p>
- * This method must be called within the TCF dispatch thread!
- *
- * @param adapter The adapter class to look up.
- * @return The adapter or <code>null</code>.
- */
- protected Object doGetAdapter(Class<?> adapter) {
- if (ILaunch.class.equals(adapter)) {
- return launch;
- }
-
- if (ILaunchConfiguration.class.equals(adapter)) {
- return launch.getLaunchConfiguration();
- }
-
- if (ILaunchConfigurationType.class.equals(adapter)) {
- try {
- return launch.getLaunchConfiguration().getType();
- }
- catch (CoreException e) {
- }
- }
-
- return null;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.internal.adapters; + +import java.util.concurrent.atomic.AtomicReference; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; + +/** + * Peer model step context adapter implementation. + */ +public class StepContextAdapter extends PlatformObject implements IStepContext { + // Reference to the launch + private final ILaunch launch; + + /** + * Constructor. + * + * @param launch The launch. Must not be <code>null</code>. + */ + public StepContextAdapter(ILaunch launch) { + super(); + Assert.isNotNull(launch); + this.launch = launch; + } + + /** + * Returns the launch. + * @return The launch. + */ + public ILaunch getLaunch() { + return launch; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getId() + */ + @Override + public String getId() { + return launch != null && launch.getLaunchConfiguration() != null ? launch.getLaunchConfiguration().getName() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getSecondaryId() + */ + @Override + public String getSecondaryId() { + return launch != null ? launch.getLaunchMode() : null; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getName() + */ + @Override + public String getName() { + final AtomicReference<String> name = new AtomicReference<String>(); + + if (launch != null) { + Runnable runnable = new Runnable() { + @Override + public void run() { + name.set(getId()); + } + }; + + if (Protocol.isDispatchThread()) { + runnable.run(); + } + else { + Protocol.invokeAndWait(runnable); + } + } + + return name.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getContextObject() + */ + @Override + public Object getContextObject() { + return launch; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext#getInfo(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer) + */ + @Override + public String getInfo(IPropertiesContainer data) { + try { + return getName() + "(" + launch.getLaunchMode() + ") - " + launch.getLaunchConfiguration().getType().getName(); //$NON-NLS-1$ //$NON-NLS-2$ + } + catch (CoreException e) { + } + return getName() + "(" + launch.getLaunchMode() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + /* (non-Javadoc) + * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class) + */ + @Override + public Object getAdapter(final Class adapter) { + // NOTE: The getAdapter(...) method can be invoked from many place and + // many threads where we cannot control the calls. Therefore, this + // method is allowed be called from any thread. + final AtomicReference<Object> object = new AtomicReference<Object>(); + Runnable runnable = new Runnable() { + @Override + public void run() { + object.set(doGetAdapter(adapter)); + } + }; + + if (Protocol.isDispatchThread()) { + runnable.run(); + } + else { + Protocol.invokeAndWait(runnable); + } + + return object.get() != null ? object.get() : super.getAdapter(adapter); + } + + /** + * Returns an object which is an instance of the given class associated with this object. + * Returns <code>null</code> if no such object can be found. + * <p> + * This method must be called within the TCF dispatch thread! + * + * @param adapter The adapter class to look up. + * @return The adapter or <code>null</code>. + */ + protected Object doGetAdapter(Class<?> adapter) { + if (ILaunch.class.equals(adapter)) { + return launch; + } + + if (ILaunchConfiguration.class.equals(adapter)) { + return launch.getLaunchConfiguration(); + } + + if (ILaunchConfigurationType.class.equals(adapter)) { + try { + return launch.getLaunchConfiguration().getType(); + } + catch (CoreException e) { + } + } + + return null; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java index 4031c9d6a..48f1b0892 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AbstractTcfLaunchStep.java @@ -1,34 +1,35 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.steps;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.launch.core.steps.AbstractLaunchStep;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-
-/**
- * Abstract TCF launch step implementation.
- */
-public abstract class AbstractTcfLaunchStep extends AbstractLaunchStep {
-
- /**
- * Returns the active peer model that is currently used.
- *
- * @param data The data giving object. Must not be <code>null</code>.
- * @return The active peer model.
- */
- protected IPeerModel getActivePeerModel(IPropertiesContainer data) {
- IModelNode node = getActiveLaunchContext(data);
- Assert.isTrue(node instanceof IPeerModel);
- return (IPeerModel)node;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.steps; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.te.launch.core.steps.AbstractLaunchStep; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; + +/** + * Abstract TCF launch step implementation. + */ +public abstract class AbstractTcfLaunchStep extends AbstractLaunchStep { + + /** + * Returns the active peer model that is currently used. + * + * @param data The data giving object. Must not be <code>null</code>. + * @return The active peer model. + */ + protected IPeerModel getActivePeerModel(IFullQualifiedId fullQualifiedId, IPropertiesContainer data) { + IModelNode node = getActiveLaunchContext(fullQualifiedId, data); + Assert.isTrue(node instanceof IPeerModel); + return (IPeerModel)node; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java index b5eae0bb1..5c96a5d2b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/AttachDebuggerStep.java @@ -1,73 +1,73 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.tcf.protocol.Protocol;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.utils.StatusHelper;
-import org.eclipse.tcf.te.tcf.launch.core.delegates.Launch;
-
-/**
- * Attach debugger step implementation.
- */
-public class AttachDebuggerStep extends AbstractTcfLaunchStep {
-
- /**
- * Constructor.
- */
- public AttachDebuggerStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- if (Protocol.isDispatchThread()) {
- internalExecute(context, data, fullQualifiedId, monitor, callback);
- }
- else {
- Protocol.invokeLater(new Runnable() {
- @Override
- public void run() {
- internalExecute(context, data, fullQualifiedId, monitor, callback);
- }
- });
- }
- }
-
- protected void internalExecute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) {
- ILaunch launch = getLaunch(context);
- if (launch instanceof Launch) {
- Launch tcfLaunch = (Launch)launch;
- try {
- tcfLaunch.attachDebugger(getActivePeerModel(data).getPeerId());
- callback.done(this, Status.OK_STATUS);
- }
- catch (Exception e) {
- callback.done(this, StatusHelper.getStatus(e));
- }
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.runtime.utils.StatusHelper; +import org.eclipse.tcf.te.tcf.launch.core.delegates.Launch; + +/** + * Attach debugger step implementation. + */ +public class AttachDebuggerStep extends AbstractTcfLaunchStep { + + /** + * Constructor. + */ + public AttachDebuggerStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { + if (Protocol.isDispatchThread()) { + internalExecute(context, data, fullQualifiedId, monitor, callback); + } + else { + Protocol.invokeLater(new Runnable() { + @Override + public void run() { + internalExecute(context, data, fullQualifiedId, monitor, callback); + } + }); + } + } + + protected void internalExecute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { + ILaunch launch = getLaunch(context); + if (launch instanceof Launch) { + Launch tcfLaunch = (Launch)launch; + try { + tcfLaunch.attachDebugger(getActivePeerModel(fullQualifiedId, data).getPeerId()); + callback.done(this, Status.OK_STATUS); + } + catch (Exception e) { + callback.done(this, StatusHelper.getStatus(e)); + } + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java index 44c77e502..6b3a997de 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/FileTransferStep.java @@ -1,78 +1,78 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.IFileTransferLaunchAttributes;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
-import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.filesystem.core.services.FileTransferService;
-import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes;
-
-/**
- * Launch process step implementation.
- */
-public class FileTransferStep extends AbstractTcfLaunchStep {
-
- /**
- * Constructor.
- */
- public FileTransferStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
- if (channel == null || channel.getState() != IChannel.STATE_OPEN) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing or closed channel")); //$NON-NLS-1$
- }
-
- Object item = StepperAttributeUtil.getProperty(IFileTransferLaunchAttributes.ATTR_ACTIVE_FILE_TRANSFER, fullQualifiedId, data);
- if (!(item instanceof IFileTransferItem)) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing file transfer item")); //$NON-NLS-1$
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
- final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
- final IFileTransferItem item = (IFileTransferItem)StepperAttributeUtil.getProperty(IFileTransferLaunchAttributes.ATTR_ACTIVE_FILE_TRANSFER, fullQualifiedId, data);
-
- if (item.isEnabled()) {
- FileTransferService.transfer(getActivePeerModel(data).getPeer(), channel, item, monitor, callback);
- }
- else {
- callback.done(this, Status.OK_STATUS);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStep#getTotalWork(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
- */
- @Override
- public int getTotalWork(IStepContext context, IPropertiesContainer data) {
- return 1000;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.te.launch.core.lm.interfaces.IFileTransferLaunchAttributes; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem; +import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.filesystem.core.services.FileTransferService; +import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes; + +/** + * Launch process step implementation. + */ +public class FileTransferStep extends AbstractTcfLaunchStep { + + /** + * Constructor. + */ + public FileTransferStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data); + if (channel == null || channel.getState() != IChannel.STATE_OPEN) { + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing or closed channel")); //$NON-NLS-1$ + } + + Object item = StepperAttributeUtil.getProperty(IFileTransferLaunchAttributes.ATTR_ACTIVE_FILE_TRANSFER, fullQualifiedId, data); + if (!(item instanceof IFileTransferItem)) { + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing file transfer item")); //$NON-NLS-1$ + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data); + final IFileTransferItem item = (IFileTransferItem)StepperAttributeUtil.getProperty(IFileTransferLaunchAttributes.ATTR_ACTIVE_FILE_TRANSFER, fullQualifiedId, data); + + if (item.isEnabled()) { + FileTransferService.transfer(getActivePeerModel(fullQualifiedId, data).getPeer(), channel, item, monitor, callback); + } + else { + callback.done(this, Status.OK_STATUS); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.extensions.AbstractStep#getTotalWork(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer) + */ + @Override + public int getTotalWork(IStepContext context, IPropertiesContainer data) { + return 1000; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java index fe75075a9..b7454f9e8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/LaunchProcessStep.java @@ -1,120 +1,120 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.steps;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.services.IProcesses;
-import org.eclipse.tcf.te.core.utils.text.StringUtil;
-import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
-import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants;
-import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes;
-import org.eclipse.tcf.te.tcf.processes.core.interfaces.launcher.IProcessLauncher;
-import org.eclipse.tcf.te.tcf.processes.core.launcher.ProcessLauncher;
-
-/**
- * Launch process step implementation.
- */
-public class LaunchProcessStep extends AbstractTcfLaunchStep {
-
- /**
- * Constructor.
- */
- public LaunchProcessStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- String processImage = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null);
- if (processImage != null && processImage.trim().length() > 0) {
- StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, fullQualifiedId, data, processImage);
- }
- else {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing process image name")); //$NON-NLS-1$
- }
-
- IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
- if (channel == null || channel.getState() != IChannel.STATE_OPEN) {
- throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing or closed channel")); //$NON-NLS-1$
- }
-
- String processArguments = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null);
- StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, fullQualifiedId, data, processArguments);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
- final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
- Assert.isTrue(channel != null && channel.getState() == IChannel.STATE_OPEN, "channel is missing or closed"); //$NON-NLS-1$
- // Construct the launcher object
- ProcessLauncher launcher = new ProcessLauncher();
-
- Map<String, Object> launchAttributes = new HashMap<String, Object>();
-
- launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, StepperAttributeUtil.getStringProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, fullQualifiedId, data));
-
- String arguments = StepperAttributeUtil.getStringProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, fullQualifiedId, data);
- String[] args = arguments != null && !"".equals(arguments.trim()) ? StringUtil.tokenize(arguments, 0, true) : null; //$NON-NLS-1$
- launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args);
-
- launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE);
-
- boolean outputConsole = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), "org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", true); //$NON-NLS-1$
- if (outputConsole) {
- launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE);
- }
- String outputFile = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), "org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE", (String)null); //$NON-NLS-1$
- if (outputFile != null) {
- launchAttributes.put(IProcessLauncher.PROP_PROCESS_OUTPUT_REDIRECT_TO_FILE, outputFile);
- }
-
- if (ILaunchManager.DEBUG_MODE.equals(getLaunchMode(context))) {
- launchAttributes.put(IProcessLauncher.PROP_PROCESS_ATTACH, Boolean.TRUE);
- }
-
- // Launch the process
- IPropertiesContainer container = new PropertiesContainer();
- container.setProperties(launchAttributes);
- launcher.launch(getActivePeerModel(data).getPeer(), container, new Callback(callback) {
- @Override
- protected void internalDone(Object caller, IStatus status) {
- Object result = getResult();
- if (status.isOK() && result instanceof IProcesses.ProcessContext) {
- StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId.getParentId(), data, result);
- }
- Assert.isTrue(channel.getState() == IChannel.STATE_OPEN, "channel is closed"); //$NON-NLS-1$
- super.internalDone(caller, status);
- }
- });
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.steps; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.services.IProcesses; +import org.eclipse.tcf.te.core.utils.text.StringUtil; +import org.eclipse.tcf.te.launch.core.persistence.DefaultPersistenceDelegate; +import org.eclipse.tcf.te.runtime.callback.Callback; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; +import org.eclipse.tcf.te.runtime.services.interfaces.constants.ITerminalsConnectorConstants; +import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.launch.core.activator.CoreBundleActivator; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.IRemoteAppLaunchAttributes; +import org.eclipse.tcf.te.tcf.processes.core.interfaces.launcher.IProcessLauncher; +import org.eclipse.tcf.te.tcf.processes.core.launcher.ProcessLauncher; + +/** + * Launch process step implementation. + */ +public class LaunchProcessStep extends AbstractTcfLaunchStep { + + /** + * Constructor. + */ + public LaunchProcessStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + String processImage = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, (String)null); + if (processImage != null && processImage.trim().length() > 0) { + StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, fullQualifiedId, data, processImage); + } + else { + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing process image name")); //$NON-NLS-1$ + } + + IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data); + if (channel == null || channel.getState() != IChannel.STATE_OPEN) { + throw new CoreException(new Status(IStatus.ERROR, CoreBundleActivator.getUniqueIdentifier(), "missing or closed channel")); //$NON-NLS-1$ + } + + String processArguments = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, (String)null); + StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, fullQualifiedId, data, processArguments); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + final IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data); + Assert.isTrue(channel != null && channel.getState() == IChannel.STATE_OPEN, "channel is missing or closed"); //$NON-NLS-1$ + // Construct the launcher object + ProcessLauncher launcher = new ProcessLauncher(); + + Map<String, Object> launchAttributes = new HashMap<String, Object>(); + + launchAttributes.put(IProcessLauncher.PROP_PROCESS_PATH, StepperAttributeUtil.getStringProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_IMAGE, fullQualifiedId, data)); + + String arguments = StepperAttributeUtil.getStringProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_ARGUMENTS, fullQualifiedId, data); + String[] args = arguments != null && !"".equals(arguments.trim()) ? StringUtil.tokenize(arguments, 0, true) : null; //$NON-NLS-1$ + launchAttributes.put(IProcessLauncher.PROP_PROCESS_ARGS, args); + + launchAttributes.put(ITerminalsConnectorConstants.PROP_LOCAL_ECHO, Boolean.FALSE); + + boolean outputConsole = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), "org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", true); //$NON-NLS-1$ + if (outputConsole) { + launchAttributes.put(IProcessLauncher.PROP_PROCESS_ASSOCIATE_CONSOLE, Boolean.TRUE); + } + String outputFile = DefaultPersistenceDelegate.getAttribute(getLaunchConfiguration(context), "org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE", (String)null); //$NON-NLS-1$ + if (outputFile != null) { + launchAttributes.put(IProcessLauncher.PROP_PROCESS_OUTPUT_REDIRECT_TO_FILE, outputFile); + } + + if (ILaunchManager.DEBUG_MODE.equals(getLaunchMode(context))) { + launchAttributes.put(IProcessLauncher.PROP_PROCESS_ATTACH, Boolean.TRUE); + } + + // Launch the process + IPropertiesContainer container = new PropertiesContainer(); + container.setProperties(launchAttributes); + launcher.launch(getActivePeerModel(fullQualifiedId, data).getPeer(), container, new Callback(callback) { + @Override + protected void internalDone(Object caller, IStatus status) { + Object result = getResult(); + if (status.isOK() && result instanceof IProcesses.ProcessContext) { + StepperAttributeUtil.setProperty(IRemoteAppLaunchAttributes.ATTR_PROCESS_CONTEXT, fullQualifiedId.getParentId(), data, result); + } + Assert.isTrue(channel.getState() == IChannel.STATE_OPEN, "channel is closed"); //$NON-NLS-1$ + super.internalDone(caller, status); + } + }); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java index 995aaab70..10702102a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/OpenChannelStep.java @@ -1,66 +1,66 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.tcf.protocol.IChannel;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.utils.StatusHelper;
-import org.eclipse.tcf.te.tcf.core.Tcf;
-import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes;
-
-/**
- * Open channel step implementation.
- */
-public class OpenChannelStep extends AbstractTcfLaunchStep {
-
- /**
- * Constructor.
- */
- public OpenChannelStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) {
- Tcf.getChannelManager().openChannel(getActivePeerModel(data).getPeer(), null, new IChannelManager.DoneOpenChannel() {
- @Override
- public void doneOpenChannel(final Throwable error, final IChannel channel) {
- StepperAttributeUtil.setProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId.getParentId(), data, channel);
- callback.done(OpenChannelStep.this, StatusHelper.getStatus(error));
- }
- });
- }
-
- @Override
- public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
- IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data);
- if (channel != null && channel.getState() != IChannel.STATE_CLOSED) {
- Tcf.getChannelManager().closeChannel(channel);
- }
- super.rollback(context, data, status, fullQualifiedId, monitor, callback);
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.runtime.utils.StatusHelper; +import org.eclipse.tcf.te.tcf.core.Tcf; +import org.eclipse.tcf.te.tcf.core.interfaces.IChannelManager; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ICommonTCFLaunchAttributes; + +/** + * Open channel step implementation. + */ +public class OpenChannelStep extends AbstractTcfLaunchStep { + + /** + * Constructor. + */ + public OpenChannelStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, final ICallback callback) { + Tcf.getChannelManager().openChannel(getActivePeerModel(fullQualifiedId, data).getPeer(), null, new IChannelManager.DoneOpenChannel() { + @Override + public void doneOpenChannel(final Throwable error, final IChannel channel) { + StepperAttributeUtil.setProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId.getParentId(), data, channel); + callback.done(OpenChannelStep.this, StatusHelper.getStatus(error)); + } + }); + } + + @Override + public void rollback(IStepContext context, IPropertiesContainer data, IStatus status, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { + IChannel channel = (IChannel)StepperAttributeUtil.getProperty(ICommonTCFLaunchAttributes.ATTR_CHANNEL, fullQualifiedId, data); + if (channel != null && channel.getState() != IChannel.STATE_CLOSED) { + Tcf.getChannelManager().closeChannel(channel); + } + super.rollback(context, data, status, fullQualifiedId, monitor, callback); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java index 0660b2575..0f20eb626 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.core/src/org/eclipse/tcf/te/tcf/launch/core/steps/iterators/AbstractTcfLaunchStepGroupIterator.java @@ -1,36 +1,37 @@ -/*******************************************************************************
- * Copyright (c) 2012 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.tcf.launch.core.steps.iterators;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.tcf.te.launch.core.steps.iterators.AbstractLaunchStepGroupIterator;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
-
-
-/**
- * AbstractTcfLaunchStepGroupIterator
- */
-public abstract class AbstractTcfLaunchStepGroupIterator extends AbstractLaunchStepGroupIterator {
-
- /**
- * Returns the active peer model that is currently used.
- *
- * @param data The data giving object. Must not be <code>null</code>.
- * @return The active peer model.
- */
- protected IPeerModel getActivePeerModel(IPropertiesContainer data) {
- IModelNode node = getActiveLaunchContext(data);
- Assert.isTrue(node instanceof IPeerModel);
- return (IPeerModel)node;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 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.tcf.launch.core.steps.iterators; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.te.launch.core.steps.iterators.AbstractLaunchStepGroupIterator; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; + + +/** + * AbstractTcfLaunchStepGroupIterator + */ +public abstract class AbstractTcfLaunchStepGroupIterator extends AbstractLaunchStepGroupIterator { + + /** + * Returns the active peer model that is currently used. + * + * @param data The data giving object. Must not be <code>null</code>. + * @return The active peer model. + */ + protected IPeerModel getActivePeerModel(IFullQualifiedId fullQualifiedId, IPropertiesContainer data) { + IModelNode node = getActiveLaunchContext(fullQualifiedId, data); + Assert.isTrue(node instanceof IPeerModel); + return (IPeerModel)node; + } +} |