Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 247282
Collapse All | Expand All

(-)src/org/eclipse/rse/internal/remotecdt/Activator.java (-3 / +46 lines)
Lines 1-17 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2006 PalmSource, Inc.
2
 * Copyright (c) 2006, 2008 PalmSource, Inc.
3
 * All rights reserved. This program and the accompanying materials 
3
 * All rights reserved. This program and the accompanying materials 
4
 * are made available under the terms of the Eclipse Public License v1.0 
4
 * are made available under the terms of the Eclipse Public License v1.0 
5
 * which accompanies this distribution, and is available at 
5
 * which accompanies this distribution, and is available at 
6
 * http://www.eclipse.org/legal/epl-v10.html 
6
 * http://www.eclipse.org/legal/epl-v10.html 
7
 * 
7
 * 
8
 * Contributors: 
8
 * Contributors: 
9
 * Ewa Matejska (PalmSource)
9
 * Ewa Matejska    (PalmSource) - initial implementation
10
 * Anna Dushistova (MontaVista) - [247282][remotecdt] Make remotecdt work over any subsystem that has service which can be adapted to IShellService
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.rse.internal.remotecdt;
13
package org.eclipse.rse.internal.remotecdt;
13
14
15
import java.util.ArrayList;
16
14
import org.eclipse.core.runtime.Plugin;
17
import org.eclipse.core.runtime.Plugin;
18
import org.eclipse.rse.core.model.IHost;
19
import org.eclipse.rse.core.model.SystemStartHere;
20
import org.eclipse.rse.core.subsystems.ISubSystem;
21
import org.eclipse.rse.services.IService;
22
import org.eclipse.rse.services.shells.IShellService;
15
import org.osgi.framework.BundleContext;
23
import org.osgi.framework.BundleContext;
16
24
17
/**
25
/**
Lines 54-58 Link Here
54
	public static Activator getDefault() {
62
	public static Activator getDefault() {
55
		return plugin;
63
		return plugin;
56
	}
64
	}
57
65
	
66
	public static IHost[] getSuitableHosts()
67
	{
68
		IHost[] connections = SystemStartHere.getConnections();
69
		ArrayList result=new ArrayList();
70
		for(int i=0; i<connections.length;i++)
71
		{
72
			if(getSuitableSubSystem(connections[i])!=null)
73
				result.add(connections[i]);
74
		}
75
        return (IHost[]) result.toArray(new IHost[result.size()]);
76
	}
77
	
78
    /**
79
     * Find the first ISubSystem with service which adapts to IShellService
80
     *  associated with the host.
81
     * 
82
     * @param host the connection 
83
     * @return ISubSystem with service which adapts to IShellService, or <code>null</code> if not found.
84
     */
85
    public static ISubSystem getSuitableSubSystem(IHost host) {
86
        if (host == null)
87
            return null;
88
        ISubSystem[] subSystems = host.getSubSystems();
89
        IShellService ssvc = null;
90
        for (int i = 0; subSystems != null && i < subSystems.length; i++) {
91
        	IService svc = subSystems[i].getSubSystemConfiguration().getService(host);
92
        	if (svc!=null) {
93
        		ssvc = (IShellService)svc.getAdapter(IShellService.class);
94
        		if (ssvc != null) {
95
        		    return subSystems[i];	
96
        		}	
97
        	}
98
        }
99
        return null;
100
    }
58
}
101
}
(-)src/org/eclipse/rse/internal/remotecdt/RemoteCMainTab.java (-6 / +7 lines)
Lines 6-18 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * Ewa Matejska (PalmSource) - initial API and implementation
9
 * Ewa Matejska (PalmSource)          - initial API and implementation
10
 * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
10
 * Martin Oberhuber (Wind River)      - [186773] split ISystemRegistryUI from ISystemRegistry
11
 * Martin Oberhuber (Wind River) - [196934] hide disabled system types in remotecdt combo
11
 * Martin Oberhuber (Wind River)      - [196934] hide disabled system types in remotecdt combo
12
 * Yu-Fen Kuo (MontaVista) - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
12
 * Yu-Fen Kuo (MontaVista)            - [190613] Fix NPE in Remotecdt when RSEUIPlugin has not been loaded
13
 * Martin Oberhuber (Wind River) - [cleanup] Avoid using SystemStartHere in production code
13
 * Martin Oberhuber (Wind River)      - [cleanup] Avoid using SystemStartHere in production code
14
 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
14
 * Johann Draschwandtner (Wind River) - [231827][remotecdt]Auto-compute default for Remote path
15
 * Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
15
 * Johann Draschwandtner (Wind River) - [233057][remotecdt]Fix button enablement
16
 * Anna Dushistova (MontaVista)       - [247282][remotecdt] Make remotecdt work over any subsystem that has service which can be adapted to IShellService
16
 *******************************************************************************/
17
 *******************************************************************************/
17
18
18
package org.eclipse.rse.internal.remotecdt;
19
package org.eclipse.rse.internal.remotecdt;
Lines 475-481 Link Here
475
		} else {
476
		} else {
476
			//already initialized
477
			//already initialized
477
		    connectionCombo.removeAll();
478
		    connectionCombo.removeAll();
478
			IHost[] connections = RSECorePlugin.getTheSystemRegistry().getHostsBySubSystemConfigurationCategory("shells"); //$NON-NLS-1$
479
			IHost[] connections = Activator.getSuitableHosts();
479
			for(int i = 0; i < connections.length; i++) {
480
			for(int i = 0; i < connections.length; i++) {
480
				IRSESystemType sysType = connections[i].getSystemType();
481
				IRSESystemType sysType = connections[i].getSystemType();
481
				if (sysType!=null && sysType.isEnabled()) {
482
				if (sysType!=null && sysType.isEnabled()) {
(-)src/org/eclipse/rse/internal/remotecdt/RemoteRunLaunchDelegate.java (-5 / +74 lines)
Lines 6-17 Link Here
6
 * http://www.eclipse.org/legal/epl-v10.html
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 * Ewa Matejska (PalmSource) - Adapted from LocalRunLaunchDelegate
9
 * Ewa Matejska     (PalmSource) - Adapted from LocalRunLaunchDelegate
10
 * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
10
 * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
11
 * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
11
 * Martin Oberhuber (Wind River) - [186773] split ISystemRegistryUI from ISystemRegistry
12
 * Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error
12
 * Martin Oberhuber (Wind River) - [226301][api] IShellService should throw SystemMessageException on error
13
 * Anna Dushistova  (MontaVista) - [234490][remotecdt] Launching with disconnected target fails
13
 * Anna Dushistova  (MontaVista) - [234490][remotecdt] Launching with disconnected target fails
14
 * Anna Dushistova  (MontaVista) - [235298][remotecdt] Further improve progress reporting and cancellation of Remote CDT Launch
14
 * Anna Dushistova  (MontaVista) - [235298][remotecdt] Further improve progress reporting and cancellation of Remote CDT Launch
15
 * Anna Dushistova  (MontaVista) - [247282][remotecdt] Make remotecdt work over any subsystem that has service which can be adapted to IShellService
15
 *******************************************************************************/
16
 *******************************************************************************/
16
17
17
18
Lines 262-268 Link Here
262
			// Nothing to do.  Download is skipped.
263
			// Nothing to do.  Download is skipped.
263
			return null;
264
			return null;
264
		monitor.beginTask("Downloading remote file", 100); //$NON-NLS-1$
265
		monitor.beginTask("Downloading remote file", 100); //$NON-NLS-1$
265
		IFileService fileService = (IFileService) getConnectedRemoteService(config, FILE_SERVICE, new SubProgressMonitor(monitor, 10));
266
		IFileService fileService = getConnectedRemoteFileService(config,
267
				new SubProgressMonitor(monitor, 10));
266
		File file = new File(localExePath);
268
		File file = new File(localExePath);
267
		Path remotePath = new Path(remoteExePath);
269
		Path remotePath = new Path(remoteExePath);
268
		try {
270
		try {
Lines 282-288 Link Here
282
		return null;
284
		return null;
283
	}
285
	}
284
286
285
	protected String getRemoteHostname(ILaunchConfiguration config) throws CoreException {
287
	private IFileService getConnectedRemoteFileService(
288
			ILaunchConfiguration config, SubProgressMonitor monitor)
289
			throws CoreException {
290
291
		IHost currentConnection = getCurrentConnection(config);
292
293
		ISubSystem[] subSystems = currentConnection.getSubSystems();
294
		int i = 0;
295
		for (i = 0; i < subSystems.length; i++) {
296
			if (subSystems[i] instanceof IFileServiceSubSystem)
297
				break;
298
		}
299
300
		if (i >= subSystems.length)
301
			abort(Messages.RemoteRunLaunchDelegate_4, null,
302
					ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
303
304
		final IFileServiceSubSystem subsystem = (IFileServiceSubSystem) subSystems[i];
305
306
		try {
307
			subsystem.connect(monitor, false);
308
		} catch (CoreException e) {
309
			throw e;
310
		} catch (OperationCanceledException e) {
311
			throw new CoreException(Status.CANCEL_STATUS);
312
		} catch (Exception e) {
313
			throw new CoreException(new Status(IStatus.ERROR, getPluginID(),
314
					IStatus.OK, e.getLocalizedMessage(), e));
315
		}
316
317
		if (!subsystem.isConnected())
318
			abort(Messages.RemoteRunLaunchDelegate_5, null,
319
					ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
320
		return subsystem.getFileService();
321
	}
322
323
	protected String getRemoteHostname(ILaunchConfiguration config)
324
			throws CoreException {
286
		IHost currentConnection = getCurrentConnection(config);
325
		IHost currentConnection = getCurrentConnection(config);
287
		return currentConnection.getHostName();
326
		return currentConnection.getHostName();
288
	}
327
	}
Lines 297-304 Link Here
297
												    spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
336
												    spaceEscapify(remoteCommandPath) + " " + arguments; //$NON-NLS-1$
298
		String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
337
		String remote_command = real_remote_command + CMD_DELIMITER + EXIT_CMD;
299
338
300
		
339
		IShellService shellService = getConnectedRemoteShellService(config,
301
		IShellService shellService = (IShellService) getConnectedRemoteService(config, SHELL_SERVICE, new SubProgressMonitor(monitor,7));
340
				new SubProgressMonitor(monitor, 7));
302
341
303
		// This is necessary because runCommand does not actually run the command right now.
342
		// This is necessary because runCommand does not actually run the command right now.
304
		String env[] = new String[0];
343
		String env[] = new String[0];
Lines 318-323 Link Here
318
357
319
	}
358
	}
320
359
360
	private IShellService getConnectedRemoteShellService(
361
			ILaunchConfiguration config, SubProgressMonitor monitor)
362
			throws CoreException {
363
364
		IHost currentConnection = getCurrentConnection(config);
365
366
		ISubSystem subsystem = Activator
367
				.getSuitableSubSystem(currentConnection);
368
		if (subsystem == null)
369
			abort(Messages.RemoteRunLaunchDelegate_4, null,
370
					ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
371
		try {
372
			subsystem.connect(monitor, false);
373
		} catch (CoreException e) {
374
			throw e;
375
		} catch (OperationCanceledException e) {
376
			throw new CoreException(Status.CANCEL_STATUS);
377
		} catch (Exception e) {
378
			throw new CoreException(new Status(IStatus.ERROR, getPluginID(),
379
					IStatus.OK, e.getLocalizedMessage(), e));
380
		}
381
382
		if (!subsystem.isConnected())
383
			abort(Messages.RemoteRunLaunchDelegate_5, null,
384
					ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
385
386
		return (IShellService) subsystem.getSubSystemConfiguration()
387
				.getService(currentConnection).getAdapter(IShellService.class);
388
	}
389
321
	protected String getPluginID() {
390
	protected String getPluginID() {
322
		return "org.eclipse.rse.internal.remotecdt"; //$NON-NLS-1$
391
		return "org.eclipse.rse.internal.remotecdt"; //$NON-NLS-1$
323
	}
392
	}

Return to bug 247282