diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te')
10 files changed, 306 insertions, 44 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java index fa60f79a5..51fd51b7c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/ScannerRunnable.java @@ -139,10 +139,13 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { return; } - // Don't scan command server peers - boolean isCommandServer = peer.getName() != null - && peer.getName().endsWith("Command Server"); //$NON-NLS-1$ - if (isCommandServer) { + // Don't scan "CLI" peers + boolean isCLI = peer.getName() != null + && (peer.getName().startsWith("Eclipse CLI") //$NON-NLS-1$ + || peer.getName().startsWith("Eclipse Command Server") //$NON-NLS-1$ + || peer.getName().endsWith("CLI Server") //$NON-NLS-1$ + || peer.getName().endsWith("CLI Client")); //$NON-NLS-1$ + if (isCLI) { if (callback != null) callback.done(this, Status.OK_STATUS); return; } @@ -342,13 +345,17 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { String remoteIP = channel.getRemotePeer().getAttributes().get(IPeer.ATTR_IP_HOST); boolean isLocal = remoteIP != null && IPAddressUtil.getInstance().isLocalHost(remoteIP); - boolean isCommandServer = channel.getRemotePeer().getName() != null - && channel.getRemotePeer().getName().endsWith("Command Server"); //$NON-NLS-1$ + boolean isCLI = channel.getRemotePeer().getName() != null + && (channel.getRemotePeer().getName().startsWith("Eclipse CLI") //$NON-NLS-1$ + || channel.getRemotePeer().getName().endsWith("CLI Server") //$NON-NLS-1$ + || channel.getRemotePeer().getName().endsWith("CLI Client")); //$NON-NLS-1$ - isCommandServer |= channel.getLocalPeer().getName() != null - && channel.getLocalPeer().getName().endsWith("Command Server"); //$NON-NLS-1$ + isCLI |= channel.getLocalPeer().getName() != null + && (channel.getLocalPeer().getName().startsWith("Eclipse CLI") //$NON-NLS-1$ + || channel.getLocalPeer().getName().endsWith("CLI Server") //$NON-NLS-1$ + || channel.getLocalPeer().getName().endsWith("CLI Client")); //$NON-NLS-1$ - return !isLocal && !isCommandServer; + return !isLocal && !isCLI; } /** @@ -407,11 +414,14 @@ public class ScannerRunnable implements Runnable, IChannel.IChannelListener { String value = attributes.get("ValueAdd"); //$NON-NLS-1$ boolean isValueAdd = value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim())); //$NON-NLS-1$ - // Don't process command server service server or clients + // Don't process CLI service or clients String name = attributes.get(IPeer.ATTR_NAME); - boolean isCommandServer = name != null && name.endsWith("Command Server"); //$NON-NLS-1$ + boolean isCLI = name != null + && (name.startsWith("Eclipse CLI") //$NON-NLS-1$ + || name.endsWith("CLI Server") //$NON-NLS-1$ + || name.endsWith("CLI Client")); //$NON-NLS-1$ - if (isValueAdd || isCommandServer) continue; + if (isValueAdd || isCLI) continue; // Get the peer id String peerId = attributes.get(IPeer.ATTR_ID); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java index 0a811c602..d20d9ce0e 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/nodes/IPeerModelProperties.java @@ -113,11 +113,21 @@ public interface IPeerModelProperties { public static final String PROP_SIM_TYPE = "SimulatorType"; //$NON-NLS-1$ /** + * Property: Discovered target for a static peer + */ + public static final String PROP_TARGET = "Target"; //$NON-NLS-1$ + + /** * Property: Auto-start the debugger after the agent launch. */ public static final String PROP_AUTO_START_DEBUGGER = "autoStartDebugger"; //$NON-NLS-1$ /** + * Property: Connect after the configuration has been created. + */ + public static final String PROP_AUTO_CONNECT = "autoConnect"; //$NON-NLS-1$ + + /** * Property: Exclude from scanner process. If set to <code>true</code>, the node will not be scanned * by the scanner. */ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IStepperServiceOperations.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IStepperServiceOperations.java index 667c58cd4..419d372f1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IStepperServiceOperations.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/interfaces/services/IStepperServiceOperations.java @@ -17,5 +17,4 @@ public interface IStepperServiceOperations { public static final String CONNECT = "connect"; //$NON-NLS-1$ public static final String DISCONNECT = "disconnect"; //$NON-NLS-1$ - public static final String ATTACH_DEBUGGER = "attachDebugger"; //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java index 6fe13635e..5f698a49d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java @@ -16,6 +16,7 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IAdapterFactory; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.model.factory.Factory; import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; @@ -33,7 +34,7 @@ public class AdapterFactory implements IAdapterFactory { private final IPersistableURIProvider peerModelPersistableURIProvider = new PeerPersistableURIProvider(); private static final Class<?>[] CLASSES = new Class[] { - IPersistableURIProvider.class, IPeerModel.class + IPersistableURIProvider.class, IPeerModel.class, IConnectable.class, ILocatorModel.class }; /* (non-Javadoc) @@ -46,6 +47,11 @@ public class AdapterFactory implements IAdapterFactory { Assert.isTrue(false); } } + if (IConnectable.class.isAssignableFrom(adapterType)) { + if (adaptableObject instanceof IConnectable) { + return adaptableObject; + } + } if (ILocatorModel.class.isAssignableFrom(adapterType)) { if (adaptableObject instanceof IPeerModel) { return ((IPeerModel)adaptableObject).getModel(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties index 098df3289..4a1439bb5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nls/Messages.properties @@ -9,5 +9,5 @@ ############################################################################### WaitForReadyStep_error_timeout=Failed to connect to ''{0}''.\n\n\ -The connection attempt timed out. Please check that the connection properties are\n\ +The configuration attempt timed out. Please check that the configuration properties are\n\ valid. Verify also that no firewall is blocking the communication. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java new file mode 100644 index 000000000..95b1e989d --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/nodes/ConnectablePeerModel.java @@ -0,0 +1,179 @@ +/******************************************************************************* + * 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.tcf.locator.nodes; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; +import org.eclipse.tcf.te.core.utils.ConnectStateHelper; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService; +import org.eclipse.tcf.te.runtime.stepper.utils.StepperHelper; +import org.eclipse.tcf.te.runtime.utils.StatusHelper; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.ILocatorModel; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; + +/** + * ConnectablePeerModel + */ +public class ConnectablePeerModel extends PeerModel implements IConnectable { + + public static final String PROPERTY_CONNECT_STATE = "connectState"; //$NON-NLS-1$ + + /** + * Constructor. + * @param model + * @param peer + */ + public ConnectablePeerModel(ILocatorModel model, IPeer peer) { + super(model, peer); + setConnectState(STATE_DISCONNECTED); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.core.interfaces.IConnectable#getConnectState() + */ + @Override + public int getConnectState() { + final AtomicInteger state = new AtomicInteger(STATE_UNKNOWN); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + if (getProperty(PROPERTY_CONNECT_STATE) != null) { + state.set(getIntProperty(PROPERTY_CONNECT_STATE)); + } + } + }); + return state.get(); + } + + @Override + public boolean setConnectState(final int newState) { + final AtomicBoolean result = new AtomicBoolean(false); + if (isConnectStateChangeAllowed(newState)) { + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + result.set(setProperty(PROPERTY_CONNECT_STATE, newState)); + } + }); + } + return result.get(); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.locator.nodes.PeerModel#postSetProperty(java.lang.String, java.lang.Object, java.lang.Object) + */ + @Override + public void postSetProperty(String key, Object value, Object oldValue) { + if (getConnectState() == STATE_CONNECTED && IPeerModelProperties.PROP_STATE.equals(key)) { + int state = value instanceof Integer ? ((Integer)value).intValue() : IPeerModelProperties.STATE_UNKNOWN; + if (state != IPeerModelProperties.STATE_CONNECTED && state != IPeerModelProperties.STATE_REACHABLE) { + changeConnectState(STATE_DISCONNECTED, null, null); + } + } + + super.postSetProperty(key, value, oldValue); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.core.interfaces.IConnectable#changeConnectState(int, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void changeConnectState(final int action, ICallback callback, IProgressMonitor monitor) throws IllegalArgumentException { + final int oldState = getConnectState(); + if (!isConnectStateChangeActionAllowed(action)) { + IllegalArgumentException e = new IllegalArgumentException("Cannot change state from '" + ConnectStateHelper.getConnectState(oldState) + "' using action '" + ConnectStateHelper.getConnectState(action) + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + if (callback != null) { + callback.done(this, StatusHelper.getStatus(e)); + } + else { + throw e; + } + } + + String operation = null; + int intermediateState = 0; + + switch (action) { + case ACTION_CONNECT: + operation = IStepperServiceOperations.CONNECT; + intermediateState = STATE_CONNECT_SCHEDULED; + break; + case ACTION_DISCONNECT: + operation = IStepperServiceOperations.DISCONNECT; + intermediateState = STATE_DISCONNECT_SCHEDULED; + break; + } + + IStepperOperationService service = StepperHelper.getService(this, operation); + if (service != null) { + setConnectState(intermediateState); + StepperHelper.scheduleStepperJob(this, operation, service, callback, monitor); + } + else if (callback != null) { + callback.done(this, StatusHelper.getStatus(new NullPointerException("Missing stepper operation service for " + getName() + "."))); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + @Override + public boolean isConnectStateChangeActionAllowed(int action) { + int state = getConnectState(); + switch (state) { + case STATE_CONNECTED: + case STATE_CONNECT_SCHEDULED: + case STATE_CONNECTING: + return isAllowedState(action, ACTION_DISCONNECT); + case STATE_DISCONNECTED: + return isAllowedState(action, ACTION_CONNECT); + } + return false; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.core.interfaces.IConnectable#isConnectStateChangeAllowed(int) + */ + @Override + public boolean isConnectStateChangeAllowed(int newState) { + int state = getConnectState(); + switch (state) { + case STATE_CONNECTED: + return isAllowedState(newState, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING); + case STATE_CONNECT_SCHEDULED: + return isAllowedState(newState, STATE_CONNECTING, STATE_CONNECTED, STATE_DISCONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING); + case STATE_CONNECTING: + return isAllowedState(newState, STATE_CONNECTED, STATE_DISCONNECT_SCHEDULED, STATE_DISCONNECTING, STATE_DISCONNECTED); + case STATE_DISCONNECTED: + return isAllowedState(newState, STATE_CONNECTED, STATE_CONNECT_SCHEDULED, STATE_CONNECTING); + case STATE_DISCONNECT_SCHEDULED: + return isAllowedState(newState, STATE_DISCONNECTING, STATE_DISCONNECTED); + case STATE_DISCONNECTING: + return isAllowedState(newState, STATE_DISCONNECTED); + case STATE_UNKNOWN: + return isAllowedState(newState, STATE_DISCONNECTED); + } + return false; + } + + private boolean isAllowedState(int state, int... allowedStates) { + for (int allowedState : allowedStates) { + if (state == allowedState) { + return true; + } + } + return false; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java index 71c3c4ed9..2894548ce 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/LocatorModelRefreshService.java @@ -52,6 +52,7 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupSer import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelUpdateService; import org.eclipse.tcf.te.tcf.locator.model.ModelLocationUtil; +import org.eclipse.tcf.te.tcf.locator.nodes.ConnectablePeerModel; import org.eclipse.tcf.te.tcf.locator.nodes.LocatorModel; import org.eclipse.tcf.te.tcf.locator.nodes.PeerModel; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; @@ -158,7 +159,13 @@ public class LocatorModelRefreshService extends AbstractLocatorModelService impl IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(entry.getKey()); // And create a new one if we cannot find it if (peerNode == null) { - peerNode = new PeerModel(model, peer); + String value = peer.getAttributes().get("static.transient"); //$NON-NLS-1$ + if (value != null && Boolean.parseBoolean(value.trim())) { + peerNode = new ConnectablePeerModel(model, peer); + } + else { + peerNode = new PeerModel(model, peer); + } } else { oldChildren.remove(peerNode); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractStepperOperationService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java index fff476206..70fabdaaf 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractStepperOperationService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/StepperOperationService.java @@ -1,5 +1,5 @@ /** - * AbstractStepperOperationService.java + * StepperOperationService.java * Created on Apr 10, 2013 * * Copyright (c) 2013 Wind River Systems, Inc. @@ -11,18 +11,19 @@ package org.eclipse.tcf.te.tcf.locator.services; import org.eclipse.core.runtime.Assert; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; /** - * Abstract connect/disconnect stepper service implementation. + * Connect/disconnect stepper operation service implementation. */ -public abstract class AbstractStepperOperationService extends org.eclipse.tcf.te.runtime.stepper.services.AbstractStepperOperationService { +public class StepperOperationService extends org.eclipse.tcf.te.runtime.stepper.services.AbstractStepperOperationService { /** * Constructor. */ - public AbstractStepperOperationService() { + public StepperOperationService() { } /* (non-Javadoc) @@ -31,8 +32,7 @@ public abstract class AbstractStepperOperationService extends org.eclipse.tcf.te @Override public boolean isHandledOperation(Object context, String operation) { return IStepperServiceOperations.CONNECT.equals(operation) || - IStepperServiceOperations.DISCONNECT.equals(operation) || - IStepperServiceOperations.ATTACH_DEBUGGER.equals(operation); + IStepperServiceOperations.DISCONNECT.equals(operation); } /* (non-Javadoc) @@ -42,7 +42,7 @@ public abstract class AbstractStepperOperationService extends org.eclipse.tcf.te public String getStepGroupId(Object context, String operation) { Assert.isTrue(context instanceof IPeerModel); - if (IStepperServiceOperations.CONNECT.equals(operation) || IStepperServiceOperations.ATTACH_DEBUGGER.equals(operation)) { + if (IStepperServiceOperations.CONNECT.equals(operation)) { return "org.eclipse.tcf.te.tcf.locator.connectStepGroup"; //$NON-NLS-1$ } if (IStepperServiceOperations.DISCONNECT.equals(operation)) { @@ -65,18 +65,32 @@ public abstract class AbstractStepperOperationService extends org.eclipse.tcf.te if (IStepperServiceOperations.DISCONNECT.equals(operation)) { return "Disconnect "+((IPeerModel)context).getName(); //$NON-NLS-1$ } - if (IStepperServiceOperations.ATTACH_DEBUGGER.equals(operation)) { - return "Attach Debugger to "+((IPeerModel)context).getName(); //$NON-NLS-1$ - } return null; } /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService#isEnabled(java.lang.Object, java.lang.String) + */ + @Override + public boolean isEnabled(Object context, String operation) { + if (context instanceof IConnectable) { + if (IStepperServiceOperations.CONNECT.equals(operation)) { + return ((IConnectable)context).isConnectStateChangeActionAllowed(IConnectable.ACTION_CONNECT); + } + if (IStepperServiceOperations.DISCONNECT.equals(operation)) { + return ((IConnectable)context).isConnectStateChangeActionAllowed(IConnectable.ACTION_DISCONNECT); + } + } + + return false; + } + + /* (non-Javadoc) * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperOperationService#isCancelable(java.lang.Object, java.lang.String) */ @Override public boolean isCancelable(Object context, String operation) { - return IStepperServiceOperations.CONNECT.equals(operation) || IStepperServiceOperations.ATTACH_DEBUGGER.equals(operation); + return IStepperServiceOperations.CONNECT.equals(operation); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java new file mode 100644 index 000000000..023622795 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/SetAsDefaultContextStep.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.tcf.locator.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Status; +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.ServiceManager; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; + +/** + * Set the active context as default context. + */ +public class SetAsDefaultContextStep extends AbstractPeerModelStep { + + /** + * Constructor. + */ + public SetAsDefaultContextStep() { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#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) { + IDefaultContextService selService = ServiceManager.getInstance().getService(IDefaultContextService.class); + if (selService != null) { + selService.setDefaultContext(getActivePeerModelContext(context, data, fullQualifiedId)); + } + + callback.done(this, Status.OK_STATUS); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java index 8fe7af841..cde08c7d6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/steps/StartSimulatorStep.java @@ -12,14 +12,10 @@ package org.eclipse.tcf.te.tcf.locator.steps; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -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.services.ServiceManager; 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.ProgressHelper; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; /** @@ -45,19 +41,7 @@ public class StartSimulatorStep extends AbstractPeerModelStep { */ @Override public void execute(final IStepContext context, final IPropertiesContainer data, final IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, final ICallback callback) { - SimulatorUtils.start(getActivePeerModelContext(context, data, fullQualifiedId), monitor, new Callback(callback) { - /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.callback.Callback#internalDone(java.lang.Object, org.eclipse.core.runtime.IStatus) - */ - @Override - protected void internalDone(Object caller, IStatus status) { - if (!ProgressHelper.isCancelOrError(caller, status, monitor, null)) { - IDefaultContextService service = ServiceManager.getInstance().getService(IDefaultContextService.class); - if (service != null) service.setDefaultContext(getActivePeerModelContext(context, data, fullQualifiedId)); - } - super.internalDone(caller, status); - } - }); + SimulatorUtils.start(getActivePeerModelContext(context, data, fullQualifiedId), monitor, callback); } /* (non-Javadoc) |