mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 458583 Remote Services v2 API with UI, Local, and JSch updated.
v2 of Remote API. New Services architecture. Connections are now stored in preferences and loaded by the framework. Attributes are stored in the preferences. Secure attributes are stored in the secure preferences. Remote services renamed to connection types. Remote connections broken up into services. JSch and Local connection types have been updated to new architecture. Also moved the tests from core.tests to jsch.core.tests since they are actually JSch tests and need to reference attribute names from the jsch.core plug-in. This is just phase one. Many more changes are expected to clean up and to fix bugs this introduces. Change-Id: I62ad2567b0c5ca7d277649879a8d16bec7058d5f Signed-off-by: Doug Schaefer <dschaefer@qnx.com>
This commit is contained in:
parent
391b74f0a1
commit
e97eb96c5d
124 changed files with 3864 additions and 4130 deletions
|
@ -2,20 +2,20 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.remote.core;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Version: 2.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.remote.internal.core.RemoteCorePlugin
|
||||
Bundle-Vendor: %pluginProvider
|
||||
Require-Bundle: org.eclipse.core.runtime,
|
||||
org.eclipse.core.filesystem,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.core.variables
|
||||
org.eclipse.core.variables,
|
||||
org.eclipse.debug.core
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.remote.core,
|
||||
org.eclipse.remote.core.exception,
|
||||
org.eclipse.remote.core.launch,
|
||||
org.eclipse.remote.internal.core;x-friends:="org.eclipse.remote.ui,org.eclipse.remote.jsch.core",
|
||||
org.eclipse.remote.internal.core.messages;x-internal:=true,
|
||||
org.eclipse.remote.internal.core.preferences;x-friends:="org.eclipse.remote.ui",
|
||||
org.eclipse.remote.internal.core.services.local;x-internal:=true
|
||||
org.eclipse.remote.internal.core.preferences;x-friends:="org.eclipse.remote.ui"
|
||||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Import-Package: org.eclipse.equinox.security.storage
|
||||
|
|
|
@ -7,12 +7,22 @@
|
|||
<extension-point id="authenticator" name="User Authenticator" schema="schema/authenticator.exsd"/>
|
||||
<extension
|
||||
point="org.eclipse.remote.core.remoteServices">
|
||||
<remoteServices
|
||||
class="org.eclipse.remote.internal.core.services.local.LocalServicesFactory"
|
||||
<connectionType
|
||||
capabilities="0"
|
||||
id="org.eclipse.remote.LocalServices"
|
||||
name="Local"
|
||||
scheme="file">
|
||||
</remoteServices>
|
||||
</connectionType>
|
||||
<connectionTypeService
|
||||
factory="org.eclipse.remote.internal.core.services.local.LocalConnectionProviderService$Factory"
|
||||
connectionTypeId="org.eclipse.remote.LocalServices"
|
||||
service="org.eclipse.remote.core.IRemoteConnectionProviderService">
|
||||
</connectionTypeService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.LocalServices"
|
||||
factory="org.eclipse.remote.internal.core.services.local.LocalConnectionPropertyService$Factory"
|
||||
service="org.eclipse.remote.core.IRemoteConnectionPropertyService">
|
||||
</connectionService>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.adapters">
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.remote.core</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
</appInfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="remoteServices"/>
|
||||
<sequence minOccurs="1" maxOccurs="unbounded">
|
||||
<element ref="connectionType" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<element ref="connectionTypeService" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<element ref="connectionService" minOccurs="0" maxOccurs="unbounded"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
|
@ -47,11 +49,14 @@
|
|||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="remoteServices">
|
||||
<element name="connectionType">
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.element labelAttribute="name"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
A connection type.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="id" type="string" use="required">
|
||||
|
@ -71,35 +76,103 @@
|
|||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="scheme" type="string" use="required">
|
||||
<attribute name="scheme" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
An EFS scheme name for this service
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<attribute name="capabilities" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The fully qualified name of the Java class implementing <samp>org.eclipse.remote.core.IRemoteServicesFactory</samp>.
|
||||
The capabilities of this connection. This an integer created by ORing the applicable capabilities as listed in IRemoteServices.
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="connectionTypeService">
|
||||
<annotation>
|
||||
<documentation>
|
||||
This is a service that implements the given service interface for a given connection type.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="connectionTypeId" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The remote services that this service applies to.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.remote.core.IRemoteServicesFactory"/>
|
||||
<meta.attribute kind="identifier" basedOn="org.eclipse.remote.core.remoteServices/connectionType/@id"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="service" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The interface class that this service implements. The service is found by calling the getService() method on the IRemoteServices object with this interface class as the parameter.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="factory" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The factory class used to instantiate the service.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.remote.core.IRemoteServices$Service$Factory"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="connectionService">
|
||||
<annotation>
|
||||
<documentation>
|
||||
This is a service that implements the given service interface for connections of a given connection type.
|
||||
</documentation>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="connectionTypeId" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The connection type for the connections that this service applies to.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="identifier" basedOn="org.eclipse.remote.core.remoteServices/connectionType/@id"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="service" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The interface class that this service implements. The service is found by calling the getService() method on the IRemoteConnection object with this interface class as the parameter.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="factory" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
The factory class used to instantiate the service.
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.remote.core.IRemoteConnection$Service$Factory"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
The value of the class attribute must implement <samp>org.eclipse.remote.core.IRemoteServicesFactory</samp>.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
|
@ -120,6 +193,15 @@
|
|||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appInfo>
|
||||
<documentation>
|
||||
The value of the class attribute must implement <samp>org.eclipse.remote.core.IRemoteServicesFactory</samp>.
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appInfo>
|
||||
<meta.section type="implementation"/>
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2014 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
|
||||
/**
|
||||
* Abstract base class for remote connection managers.
|
||||
*
|
||||
* @since 8.0
|
||||
*/
|
||||
public abstract class AbstractRemoteConnectionManager implements IRemoteConnectionManager {
|
||||
private static final String AUTHENTICATOR_EXTENSION_POINT_ID = "authenticator"; //$NON-NLS-1$
|
||||
private static final String ID_ATTR = "id"; //$NON-NLS-1$
|
||||
private static final String CLASS_ATTR = "class"; //$NON-NLS-1$
|
||||
private static final String PRIORITY_ATTR = "priority"; //$NON-NLS-1$
|
||||
|
||||
private final IRemoteServices fRemoteServices;
|
||||
private boolean fLoaded;
|
||||
private Constructor<?> fUserAuthenticatorConstructor;
|
||||
|
||||
public AbstractRemoteConnectionManager(IRemoteServices services) {
|
||||
fRemoteServices = services;
|
||||
}
|
||||
|
||||
protected IRemoteServices getRemoteServices() {
|
||||
return fRemoteServices;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionManager#getUserAuthenticator()
|
||||
*/
|
||||
@Override
|
||||
public IUserAuthenticator getUserAuthenticator(IRemoteConnection connection) {
|
||||
if (!fLoaded) {
|
||||
int currPriority = -1;
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(),
|
||||
AUTHENTICATOR_EXTENSION_POINT_ID);
|
||||
final IExtension[] extensions = extensionPoint.getExtensions();
|
||||
|
||||
for (IExtension ext : extensions) {
|
||||
final IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||
|
||||
for (IConfigurationElement ce : elements) {
|
||||
String id = ce.getAttribute(ID_ATTR);
|
||||
if (id.equals(getRemoteServices().getId())) {
|
||||
int priority = 0;
|
||||
String priorityAttr = ce.getAttribute(PRIORITY_ATTR);
|
||||
if (priorityAttr != null) {
|
||||
try {
|
||||
priority = Integer.parseInt(priorityAttr);
|
||||
} catch (NumberFormatException e) {
|
||||
// Assume default
|
||||
}
|
||||
}
|
||||
if (priority > currPriority) {
|
||||
try {
|
||||
String widgetClass = ce.getAttribute(CLASS_ATTR);
|
||||
Class<?> cls = Platform.getBundle(ce.getDeclaringExtension().getContributor().getName()).loadClass(
|
||||
widgetClass);
|
||||
if (cls != null) {
|
||||
fUserAuthenticatorConstructor = cls.getConstructor(IRemoteConnection.class);
|
||||
currPriority = priority;
|
||||
}
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
RemoteCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fLoaded = true;
|
||||
}
|
||||
if (fUserAuthenticatorConstructor != null) {
|
||||
try {
|
||||
return (IUserAuthenticator) fUserAuthenticatorConstructor.newInstance(connection);
|
||||
} catch (Exception e) {
|
||||
RemoteCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
/**
|
||||
* Abstract base class for remote services. Implementors can use this class to provide a default implementation of a remote
|
||||
* services provider.
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public abstract class AbstractRemoteServices implements IRemoteServices {
|
||||
|
||||
protected final IRemoteServicesDescriptor fDescriptor;
|
||||
|
||||
public AbstractRemoteServices(IRemoteServicesDescriptor descriptor) {
|
||||
fDescriptor = descriptor;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(IRemoteServicesDescriptor o) {
|
||||
return fDescriptor.compareTo(o);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServicesDescriptor#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return fDescriptor.getId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServicesDescriptor#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fDescriptor.getName();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServicesDescriptor#getScheme()
|
||||
*/
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return fDescriptor.getScheme();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A service that provides a command shell on a remote. This is mainly used by
|
||||
* Terminal views.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteCommandShellService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* Get a remote process that runs a command shell on the remote system. The shell will be the user's default shell on the remote
|
||||
* system. The flags may be used to modify behavior of the remote process. These flags may only be supported by specific types
|
||||
* of remote service providers. Clients can use {@link IRemoteProcessBuilder#getSupportedFlags()} to find out the flags
|
||||
* supported by the service provider.
|
||||
*
|
||||
* <pre>
|
||||
* Current flags are:
|
||||
* {@link IRemoteProcessBuilder#NONE} - disable any flags
|
||||
* {@link IRemoteProcessBuilder#ALLOCATE_PTY} - allocate a pseudo-terminal for the process (RFC-4254 Sec. 6.2)
|
||||
* {@link IRemoteProcessBuilder#FORWARD_X11} - enable X11 forwarding (RFC-4254 Sec. 6.3)
|
||||
* </pre>
|
||||
*
|
||||
* @param flags
|
||||
* bitwise-or of flags
|
||||
* @return remote process object
|
||||
* @throws IOException
|
||||
* @since 7.0
|
||||
*/
|
||||
public IRemoteProcess getCommandShell(int flags) throws IOException;
|
||||
|
||||
}
|
|
@ -10,177 +10,48 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Abstraction of a connection to a remote system. Clients should use the set methods to provide information on the remote system,
|
||||
* then call the {{@link #open(IProgressMonitor)} method. Once the connection is completed, call the {@link #close()} method to
|
||||
* terminate the connection.
|
||||
* Represents a connection to a remote system. Use the getService method to get at connection
|
||||
* specific services. Connections have state, open or closed. Some connection types are always
|
||||
* open in which case the close does nothing. Connections have properties which are values that
|
||||
* describe the connection and are discovered. Connections also have attributes which are
|
||||
* client specified values that control the connection.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface IRemoteConnection extends Comparable<IRemoteConnection> {
|
||||
public final static String OS_NAME_PROPERTY = "os.name"; //$NON-NLS-1$
|
||||
public final static String OS_VERSION_PROPERTY = "os.version"; //$NON-NLS-1$
|
||||
public final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
|
||||
public interface IRemoteConnection {
|
||||
/**
|
||||
* @since 6.0
|
||||
* The interface that is extend by services provided for this remote connection.
|
||||
* @since 2.0
|
||||
*/
|
||||
public final static String FILE_SEPARATOR_PROPERTY = "file.separator"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 6.0
|
||||
*/
|
||||
public final static String PATH_SEPARATOR_PROPERTY = "path.separator"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 6.0
|
||||
*/
|
||||
public final static String LINE_SEPARATOR_PROPERTY = "line.separator"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
public final static String USER_HOME_PROPERTY = "user.home"; //$NON-NLS-1$
|
||||
interface Service {
|
||||
IRemoteConnection getRemoteConnection();
|
||||
|
||||
interface Factory {
|
||||
<T extends Service> T getService(IRemoteConnection remoteConnection, Class<T> service);
|
||||
}
|
||||
}
|
||||
|
||||
// Common properties
|
||||
final static String OS_NAME_PROPERTY = "os.name"; //$NON-NLS-1$
|
||||
final static String OS_VERSION_PROPERTY = "os.version"; //$NON-NLS-1$
|
||||
final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
|
||||
final static String FILE_SEPARATOR_PROPERTY = "file.separator"; //$NON-NLS-1$
|
||||
final static String PATH_SEPARATOR_PROPERTY = "path.separator"; //$NON-NLS-1$
|
||||
final static String LINE_SEPARATOR_PROPERTY = "line.separator"; //$NON-NLS-1$
|
||||
final static String USER_HOME_PROPERTY = "user.home"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Register a listener that will be notified when this connection's status changes.
|
||||
* Get the connection type of this connection
|
||||
*
|
||||
* @param listener
|
||||
* @return connection type
|
||||
* @since 2.0
|
||||
*/
|
||||
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener);
|
||||
|
||||
/**
|
||||
* Close the connection. Must be called to terminate the connection.
|
||||
*/
|
||||
public void close();
|
||||
|
||||
/**
|
||||
* Notify all listeners when this connection's status changes. See {{@link IRemoteConnectionChangeEvent} for a list of event
|
||||
* types.
|
||||
*
|
||||
* @param event
|
||||
* event type indicating the nature of the event
|
||||
*/
|
||||
public void fireConnectionChangeEvent(int type);
|
||||
|
||||
/**
|
||||
* Forward local port localPort to remote port fwdPort on remote machine fwdAddress. If this IRemoteConnection is not to
|
||||
* fwdAddress, the port will be routed via the connection machine to fwdAddress.
|
||||
*
|
||||
* @param localPort
|
||||
* local port to forward
|
||||
* @param fwdAddress
|
||||
* address of remote machine
|
||||
* @param fwdPort
|
||||
* remote port on remote machine
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Forward a local port to remote port fwdPort on remote machine fwdAddress. The local port is chosen dynamically and returned
|
||||
* by the method. If this IRemoteConnection is not to fwdAddress, the port will be routed via the connection machine to
|
||||
* fwdAddress.
|
||||
*
|
||||
* @param fwdAddress
|
||||
* @param fwdPort
|
||||
* @param monitor
|
||||
* @return local port number
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Forward remote port remotePort to port fwdPort on machine fwdAddress. When a connection is made to remotePort on the remote
|
||||
* machine, it is forwarded via this IRemoteConnection to fwdPort on machine fwdAddress.
|
||||
*
|
||||
* @param remotePort
|
||||
* remote port to forward
|
||||
* @param fwdAddress
|
||||
* address of recipient machine
|
||||
* @param fwdPort
|
||||
* port on recipient machine
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Forward a remote port to port fwdPort on remote machine fwdAddress. The remote port is chosen dynamically and returned by the
|
||||
* method. When a connection is made to this port on the remote machine, it is forwarded via this IRemoteConnection to fwdPort
|
||||
* on machine fwdAddress.
|
||||
*
|
||||
* If fwdAddress is the empty string ("") then the fwdPort will be bound to any address on all interfaces. Note that this
|
||||
* requires enabling the GatewayPort sshd option on some systems.
|
||||
*
|
||||
* @param fwdAddress
|
||||
* @param fwdPort
|
||||
* @param monitor
|
||||
* @return remote port number
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Gets the implementation dependent address for this connection
|
||||
*
|
||||
* return address
|
||||
*/
|
||||
public String getAddress();
|
||||
|
||||
/**
|
||||
* Get the implementation specific attributes for the connection.
|
||||
*
|
||||
* NOTE: the attributes do not include any security related information (e.g. passwords, keys, etc.)
|
||||
*
|
||||
* @return a map containing the connection attribute keys and values
|
||||
*/
|
||||
public Map<String, String> getAttributes();
|
||||
|
||||
/**
|
||||
* Get a remote process that runs a command shell on the remote system. The shell will be the user's default shell on the remote
|
||||
* system. The flags may be used to modify behavior of the remote process. These flags may only be supported by specific types
|
||||
* of remote service providers. Clients can use {@link IRemoteProcessBuilder#getSupportedFlags()} to find out the flags
|
||||
* supported by the service provider.
|
||||
*
|
||||
* <pre>
|
||||
* Current flags are:
|
||||
* {@link IRemoteProcessBuilder#NONE} - disable any flags
|
||||
* {@link IRemoteProcessBuilder#ALLOCATE_PTY} - allocate a pseudo-terminal for the process (RFC-4254 Sec. 6.2)
|
||||
* {@link IRemoteProcessBuilder#FORWARD_X11} - enable X11 forwarding (RFC-4254 Sec. 6.3)
|
||||
* </pre>
|
||||
*
|
||||
* @param flags
|
||||
* bitwise-or of flags
|
||||
* @return remote process object
|
||||
* @throws IOException
|
||||
* @since 7.0
|
||||
*/
|
||||
public IRemoteProcess getCommandShell(int flags) throws IOException;
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable string map view of the remote environment. The connection must be open prior to calling this method.
|
||||
*
|
||||
* @return the remote environment
|
||||
* @since 5.0
|
||||
*/
|
||||
public Map<String, String> getEnv();
|
||||
|
||||
/**
|
||||
* Returns the value of an environment variable. The connection must be open prior to calling this method.
|
||||
*
|
||||
* @param name
|
||||
* name of the environment variable
|
||||
* @return value of the environment variable or null if the variable is not defined
|
||||
*/
|
||||
public String getEnv(String name);
|
||||
|
||||
/**
|
||||
* Get a file manager for managing remote files
|
||||
*
|
||||
* @return file manager or null if connection is not open
|
||||
*/
|
||||
public IRemoteFileManager getFileManager();
|
||||
public IRemoteConnectionType getConnectionType();
|
||||
|
||||
/**
|
||||
* Get unique name for this connection.
|
||||
|
@ -190,83 +61,23 @@ public interface IRemoteConnection extends Comparable<IRemoteConnection> {
|
|||
public String getName();
|
||||
|
||||
/**
|
||||
* Gets the port for this connection. Only valid if supported by the service provider.
|
||||
* Get the service for this remote connection that implements the given interface.
|
||||
*
|
||||
* return port number
|
||||
*
|
||||
* @since 5.0
|
||||
* @param service the interface the required service must implements
|
||||
* @return the desired service or null if there is no such service available
|
||||
* @throws CoreException
|
||||
* @since 2.0
|
||||
*/
|
||||
public int getPort();
|
||||
<T extends Service> T getService(Class<T> service);
|
||||
|
||||
/**
|
||||
* Get a process builder for creating remote processes
|
||||
* Does this connection support the given service.
|
||||
*
|
||||
* @return process builder or null if connection is not open
|
||||
* @param service The service to be tested
|
||||
* @return true if this connection supports the service
|
||||
* @since 2.0
|
||||
*/
|
||||
public IRemoteProcessBuilder getProcessBuilder(List<String> command);
|
||||
|
||||
/**
|
||||
* Get a process builder for creating remote processes
|
||||
*
|
||||
* @return process builder or null if connection is not open
|
||||
*/
|
||||
public IRemoteProcessBuilder getProcessBuilder(String... command);
|
||||
|
||||
/**
|
||||
* Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
|
||||
*
|
||||
* The following keys are supported:
|
||||
*
|
||||
* <pre>
|
||||
* os.name Operating system name
|
||||
* os.arch Operating system architecture
|
||||
* os.version Operating system version
|
||||
* file.separator File separator ("/" on UNIX)
|
||||
* path.separator Path separator (":" on UNIX)
|
||||
* line.separator Line separator ("\n" on UNIX)
|
||||
* user.home Home directory
|
||||
* </pre>
|
||||
*
|
||||
* @param key
|
||||
* the name of the property
|
||||
* @return the string value of the property, or null if no property has that key
|
||||
*/
|
||||
public String getProperty(String key);
|
||||
|
||||
/**
|
||||
* Get the remote services provider for this connection.
|
||||
*
|
||||
* @return remote services provider
|
||||
* @since 4.0
|
||||
*/
|
||||
public IRemoteServices getRemoteServices();
|
||||
|
||||
/**
|
||||
* Gets the username for this connection
|
||||
*
|
||||
* return username
|
||||
*/
|
||||
public String getUsername();
|
||||
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy();
|
||||
|
||||
/**
|
||||
* Get the working directory. Relative paths will be resolved using this path.
|
||||
*
|
||||
* The remote connection does not need to be open to use this method, however a default directory path, rather than the actual
|
||||
* working directory, may be returned in this case.
|
||||
*
|
||||
* @return String representing the current working directory
|
||||
* @since 4.0
|
||||
*/
|
||||
public String getWorkingDirectory();
|
||||
|
||||
/**
|
||||
* Test if the connection is open.
|
||||
*
|
||||
* @return true if connection is open.
|
||||
*/
|
||||
public boolean isOpen();
|
||||
<T extends Service> boolean hasService(Class<T> service);
|
||||
|
||||
/**
|
||||
* Open the connection. Must be called before the connection can be used.
|
||||
|
@ -279,6 +90,61 @@ public interface IRemoteConnection extends Comparable<IRemoteConnection> {
|
|||
*/
|
||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Close the connection. Must be called to terminate the connection.
|
||||
*/
|
||||
public void close();
|
||||
|
||||
/**
|
||||
* Test if the connection is open.
|
||||
*
|
||||
* @return true if connection is open.
|
||||
*/
|
||||
public boolean isOpen();
|
||||
|
||||
/**
|
||||
* Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
|
||||
*
|
||||
* @param key
|
||||
* the name of the property
|
||||
* @return the string value of the property, or null if no property has that key
|
||||
*/
|
||||
public String getProperty(String key);
|
||||
|
||||
/**
|
||||
* Get an attribute for a connection.
|
||||
*
|
||||
* NOTE: the attributes do not include any security related information (e.g. passwords, keys, etc.)
|
||||
*
|
||||
* @param key
|
||||
* @return the attribute value, or empty string if not defined.
|
||||
* @since 2.0
|
||||
*/
|
||||
public String getAttribute(String key);
|
||||
|
||||
/**
|
||||
* Get an attribute that is stored in secure storage, such as passwords.
|
||||
*
|
||||
* @param key
|
||||
* @return the attribute value, or empty string if not defined.
|
||||
* @since 2.0
|
||||
*/
|
||||
public String getSecureAttribute(String key);
|
||||
|
||||
/**
|
||||
* Return a working copy to allow setting and changing of attributes.
|
||||
*
|
||||
* @return working copy of remote
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy();
|
||||
|
||||
/**
|
||||
* Register a listener that will be notified when this connection's status changes.
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener);
|
||||
|
||||
/**
|
||||
* Remove a listener that will be notified when this connection's status changes.
|
||||
*
|
||||
|
@ -287,41 +153,12 @@ public interface IRemoteConnection extends Comparable<IRemoteConnection> {
|
|||
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener);
|
||||
|
||||
/**
|
||||
* Remove the local port forwarding associated with the given port.
|
||||
* Notify all listeners when this connection's status changes. See {{@link RemoteConnectionChangeEvent} for a list of event
|
||||
* types.
|
||||
*
|
||||
* @param port
|
||||
* forwarded port
|
||||
* @throws RemoteConnectionException
|
||||
* @since 7.0
|
||||
* @param event
|
||||
* event type indicating the nature of the event
|
||||
*/
|
||||
public void removeLocalPortForwarding(int port) throws RemoteConnectionException;
|
||||
public void fireConnectionChangeEvent(int type);
|
||||
|
||||
/**
|
||||
* Remove the remote port forwarding associated with the given port.
|
||||
*
|
||||
* @param port
|
||||
* forwarded port
|
||||
* @throws RemoteConnectionException
|
||||
* @since 7.0
|
||||
*/
|
||||
public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Set the working directory while the connection is open. The working directory will revert to the default when the connection
|
||||
* is closed then subsequently reopened.
|
||||
*
|
||||
* Relative paths will be resolved using this path. The path must be valid and absolute for any changes to be made.
|
||||
*
|
||||
* @param path
|
||||
* String representing the current working directory
|
||||
* @since 4.0
|
||||
*/
|
||||
public void setWorkingDirectory(String path);
|
||||
|
||||
/**
|
||||
* Test if this connection supports forwarding of TCP connections
|
||||
*
|
||||
* @return true if TCP port forwarding is supported
|
||||
*/
|
||||
public boolean supportsTCPPortForwarding();
|
||||
}
|
||||
|
|
|
@ -13,8 +13,11 @@ package org.eclipse.remote.core;
|
|||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* Listener used to register for notification of connection status changes. Clients should register a listener using the
|
||||
* {@link IRemoteConnection#addConnectionChangeListener(IRemoteConnectionChangeListener)} method.
|
||||
* Listener used to register for notification of connection status changes.
|
||||
* Listeners can be registered on individual connections using
|
||||
* {@link IRemoteConnection#addConnectionChangeListener(IRemoteConnectionChangeListener)},
|
||||
* or globally for all connections using
|
||||
* {@link IRemoteServicesManager#addRemoteConnectionChangeListener(IRemoteConnectionChangeListener)}.
|
||||
*/
|
||||
public interface IRemoteConnectionChangeListener extends EventListener {
|
||||
|
||||
|
@ -23,7 +26,9 @@ public interface IRemoteConnectionChangeListener extends EventListener {
|
|||
*
|
||||
* @param event
|
||||
* the connection change event
|
||||
* @since 2.0
|
||||
*/
|
||||
|
||||
public void connectionChanged(IRemoteConnectionChangeEvent event);
|
||||
public void connectionChanged(RemoteConnectionChangeEvent event);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* A service to control and report on the state of a connection, open or closed.
|
||||
* Connections that do not provide this service are always assumed to be opened.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteConnectionControlService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* Open the connection. Must be called before the connection can be used.
|
||||
*
|
||||
* @param monitor
|
||||
* the progress monitor to use for reporting progress to the user. It is the caller's responsibility to call done()
|
||||
* on the given monitor. Accepts null, indicating that no progress should be reported and that the operation cannot
|
||||
* be cancelled.
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Close the connection. Must be called to terminate the connection.
|
||||
*/
|
||||
public void close();
|
||||
|
||||
/**
|
||||
* Test if the connection is open.
|
||||
*
|
||||
* @return true if connection is open.
|
||||
*/
|
||||
public boolean isOpen();
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
/**
|
||||
* A connection property is some descriptive information that's discovered about the connection.
|
||||
* This service provides property values for a connection.
|
||||
*
|
||||
* Examples include:
|
||||
* <pre>
|
||||
* os.name Operating system name
|
||||
* os.arch Operating system architecture
|
||||
* os.version Operating system version
|
||||
* file.separator File separator ("/" on UNIX)
|
||||
* path.separator Path separator (":" on UNIX)
|
||||
* line.separator Line separator ("\n" on UNIX)
|
||||
* user.home Home directory
|
||||
* </pre>
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteConnectionPropertyService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
|
||||
*
|
||||
* @param key
|
||||
* the name of the property
|
||||
* @return the string value of the property, or null if no property has that key
|
||||
*/
|
||||
public String getProperty(String key);
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
/**
|
||||
* A connection type service for connectiont types that have automatic means of adding
|
||||
* and removing services. For example, the Local connection type needs to be able
|
||||
* to ensure the Local connection is created, or adapters to other target management
|
||||
* systems may prefer to let those systems manage the connections.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteConnectionProviderService extends IRemoteConnectionType.Service {
|
||||
|
||||
/**
|
||||
* Initialize the service. Called after all existing connections are loaded.
|
||||
* This method typically will add the initial connections or start up a job to do it.
|
||||
* This method is called on startup, it's important that it be fast.
|
||||
*/
|
||||
void init();
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2013 IBM Corporation 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
|
||||
|
@ -13,18 +13,91 @@ package org.eclipse.remote.core;
|
|||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for managing connections to remote systems.
|
||||
* A remote connection type manages a list of connections that implement the same services.
|
||||
* Services may be registered on the individual connections, or at the connection type level
|
||||
* for service that apply to all connections of this type.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteConnectionManager {
|
||||
public interface IRemoteConnectionType {
|
||||
/**
|
||||
* The name of the connection for local services. There is only one connection for local services.
|
||||
*
|
||||
* @since 7.0
|
||||
* The interface that is extend by services provided for this remote services implementation.
|
||||
* @since 2.0
|
||||
*/
|
||||
public static String LOCAL_CONNECTION_NAME = "Local"; //$NON-NLS-1$
|
||||
interface Service {
|
||||
IRemoteConnectionType getConnectionType();
|
||||
|
||||
interface Factory {
|
||||
<T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service);
|
||||
}
|
||||
}
|
||||
|
||||
// Capabilities
|
||||
static final int CAPABILITY_ADD_CONNECTIONS = 0x01;
|
||||
static final int CAPABILITY_EDIT_CONNECTIONS = 0x02;
|
||||
static final int CAPABILITY_REMOVE_CONNECTIONS = 0x04;
|
||||
static final int CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING = 0x08;
|
||||
static final int CAPABILITY_SUPPORTS_X11_FORWARDING = 0x10;
|
||||
|
||||
/**
|
||||
* Get the remote services manager. This is a convenient way to get back
|
||||
* to the root.
|
||||
*
|
||||
* @return remote services manager
|
||||
*/
|
||||
IRemoteServicesManager getRemoteServicesManager();
|
||||
|
||||
/**
|
||||
* Get unique ID of this service. Can be used as a lookup key.
|
||||
*
|
||||
* @return unique ID
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Get display name of this service.
|
||||
*
|
||||
* @return display name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the EFS scheme provided by this service.
|
||||
*
|
||||
* @return display name
|
||||
*/
|
||||
String getScheme();
|
||||
|
||||
/**
|
||||
* Gets the capabilities of the remote service.
|
||||
*
|
||||
* @return bit-wise or of capability flag constants
|
||||
*/
|
||||
int getCapabilities();
|
||||
|
||||
/**
|
||||
* Get the service for this remote services implementation that implements the given interface.
|
||||
*
|
||||
* @param service the interface the required service must implements
|
||||
* @return the desired service or null if there is no such service available
|
||||
* @throws CoreException
|
||||
* @since 2.0
|
||||
*/
|
||||
<T extends Service> T getService(Class<T> service);
|
||||
|
||||
/**
|
||||
* Does this connection type support the given service.
|
||||
*
|
||||
* @param service the service to be tested
|
||||
* @return true if this connection type supports this service
|
||||
*/
|
||||
<T extends Service> boolean hasService(Class<T> service);
|
||||
|
||||
/**
|
||||
* Gets the remote connection corresponding to the supplied name.
|
||||
|
@ -53,16 +126,6 @@ public interface IRemoteConnectionManager {
|
|||
*/
|
||||
public List<IRemoteConnection> getConnections();
|
||||
|
||||
/**
|
||||
* Get the user authenticator that will be used when opening connections. The user authenticator is specified using the
|
||||
* org.eclipse.remote.core.authenticator extension point.
|
||||
*
|
||||
* @param connection
|
||||
* connection that will use this authenticator
|
||||
* @return user authenticator
|
||||
*/
|
||||
public IUserAuthenticator getUserAuthenticator(IRemoteConnection connection);
|
||||
|
||||
/**
|
||||
* Creates a new remote connection named with supplied name. The connection attributes will be the default for the
|
||||
* implementation.
|
||||
|
@ -88,4 +151,5 @@ public interface IRemoteConnectionManager {
|
|||
* if the connection could not be removed
|
||||
*/
|
||||
public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException;
|
||||
|
||||
}
|
|
@ -10,9 +10,18 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* A working copy of a remote connection used to change the name and/or
|
||||
* attributes of the connection. It is also used when creating a new
|
||||
* connection
|
||||
*/
|
||||
public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
|
||||
|
||||
/**
|
||||
* Returns the original connection this working copy was created from.
|
||||
* Returns null if this is a new connection.
|
||||
*
|
||||
* @return original connection
|
||||
*/
|
||||
|
@ -30,27 +39,9 @@ public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
|
|||
* connection does not need saving.
|
||||
*
|
||||
* @return saved connection
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public IRemoteConnection save();
|
||||
|
||||
/**
|
||||
* Set the address for this connection
|
||||
*
|
||||
* @param address
|
||||
*/
|
||||
public void setAddress(String address);
|
||||
|
||||
/**
|
||||
* Set an implementation dependent attribute for the connection. Attributes keys supported by the connection can be obtained
|
||||
* using {@link #getAttributes()}. Attributes are persisted along with connection information.
|
||||
*
|
||||
* @param key
|
||||
* attribute key
|
||||
* @param value
|
||||
* attribute value
|
||||
* @since 5.0
|
||||
*/
|
||||
public void setAttribute(String key, String value);
|
||||
public IRemoteConnection save() throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Set the name for this connection
|
||||
|
@ -60,26 +51,23 @@ public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
|
|||
public void setName(String name);
|
||||
|
||||
/**
|
||||
* Set the password for this connection
|
||||
* Set an implementation dependent attribute for the connection. Attributes keys supported by the connection can be obtained
|
||||
* using {@link #getAttributes()}. Attributes are persisted along with connection information.
|
||||
*
|
||||
* @param password
|
||||
* @since 5.0
|
||||
* @param key
|
||||
* attribute key
|
||||
* @param value
|
||||
* attribute value
|
||||
*/
|
||||
public void setPassword(String password);
|
||||
public void setAttribute(String key, String value);
|
||||
|
||||
/**
|
||||
* Set the port used for this connection. Only valid if supported by the underlying service provider.
|
||||
* Set an attribute such as a password that's stored in secure storage.
|
||||
*
|
||||
* @param port
|
||||
* port number for the connection
|
||||
* @since 5.0
|
||||
* @param key
|
||||
* @param value
|
||||
* @since 2.0
|
||||
*/
|
||||
public void setPort(int port);
|
||||
public void setSecureAttribute(String key, String value);
|
||||
|
||||
/**
|
||||
* Set the username for this connection
|
||||
*
|
||||
* @param username
|
||||
*/
|
||||
public void setUsername(String username);
|
||||
}
|
||||
|
|
|
@ -16,9 +16,12 @@ import org.eclipse.core.filesystem.IFileStore;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
/**
|
||||
* Interface for managing resources on a remote system.
|
||||
* Interface for managing files on a remote system.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteFileManager {
|
||||
public interface IRemoteFileService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* Get the resource associated with path. IFileStore can then be used to
|
||||
* perform operations on the file.
|
||||
|
@ -31,15 +34,28 @@ public interface IRemoteFileManager {
|
|||
* path to resource
|
||||
* @return the file store representing the remote path
|
||||
*/
|
||||
public IFileStore getResource(String path);
|
||||
IFileStore getResource(String path);
|
||||
|
||||
/**
|
||||
* Get the base directory to be used for relative paths.
|
||||
*
|
||||
* @return base directory
|
||||
*/
|
||||
String getBaseDirectory();
|
||||
|
||||
/**
|
||||
* Set the base directory to be used for relative paths..
|
||||
*
|
||||
* @param path new base directory
|
||||
*/
|
||||
void setBaseDirectory(String path);
|
||||
|
||||
/**
|
||||
* Gets the directory separator on the target system.
|
||||
*
|
||||
* @return String
|
||||
* @since 4.0
|
||||
*/
|
||||
public String getDirectorySeparator();
|
||||
String getDirectorySeparator();
|
||||
|
||||
/**
|
||||
* Convert URI to a remote path. This path is suitable for direct file
|
||||
|
@ -49,7 +65,7 @@ public interface IRemoteFileManager {
|
|||
*
|
||||
* @return IPath representing the remote path
|
||||
*/
|
||||
public String toPath(URI uri);
|
||||
String toPath(URI uri);
|
||||
|
||||
/**
|
||||
* Convert remote path to equivalent URI. This URI is suitable for EFS
|
||||
|
@ -62,7 +78,7 @@ public interface IRemoteFileManager {
|
|||
* @return URI representing path on remote system, or null if the path is
|
||||
* invalid
|
||||
*/
|
||||
public URI toURI(IPath path);
|
||||
URI toURI(IPath path);
|
||||
|
||||
/**
|
||||
* Convert string representation of a remote path to equivalent URI. This
|
||||
|
@ -75,5 +91,6 @@ public interface IRemoteFileManager {
|
|||
* @return URI representing path on remote system, or null if the path is
|
||||
* invalid
|
||||
*/
|
||||
public URI toURI(String path);
|
||||
URI toURI(String path);
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* A connection service for setting up port forwarding between the host and the remote.
|
||||
* This is a feature provided by SSH.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemotePortForwardingService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* Forward local port localPort to remote port fwdPort on remote machine fwdAddress. If this IRemoteConnection is not to
|
||||
* fwdAddress, the port will be routed via the connection machine to fwdAddress.
|
||||
*
|
||||
* @param localPort
|
||||
* local port to forward
|
||||
* @param fwdAddress
|
||||
* address of remote machine
|
||||
* @param fwdPort
|
||||
* remote port on remote machine
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Forward a local port to remote port fwdPort on remote machine fwdAddress. The local port is chosen dynamically and returned
|
||||
* by the method. If this IRemoteConnection is not to fwdAddress, the port will be routed via the connection machine to
|
||||
* fwdAddress.
|
||||
*
|
||||
* @param fwdAddress
|
||||
* @param fwdPort
|
||||
* @param monitor
|
||||
* @return local port number
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Forward remote port remotePort to port fwdPort on machine fwdAddress. When a connection is made to remotePort on the remote
|
||||
* machine, it is forwarded via this IRemoteConnection to fwdPort on machine fwdAddress.
|
||||
*
|
||||
* @param remotePort
|
||||
* remote port to forward
|
||||
* @param fwdAddress
|
||||
* address of recipient machine
|
||||
* @param fwdPort
|
||||
* port on recipient machine
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Forward a remote port to port fwdPort on remote machine fwdAddress. The remote port is chosen dynamically and returned by the
|
||||
* method. When a connection is made to this port on the remote machine, it is forwarded via this IRemoteConnection to fwdPort
|
||||
* on machine fwdAddress.
|
||||
*
|
||||
* If fwdAddress is the empty string ("") then the fwdPort will be bound to any address on all interfaces. Note that this
|
||||
* requires enabling the GatewayPort sshd option on some systems.
|
||||
*
|
||||
* @param fwdAddress
|
||||
* @param fwdPort
|
||||
* @param monitor
|
||||
* @return remote port number
|
||||
* @throws RemoteConnectionException
|
||||
*/
|
||||
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Remove the local port forwarding associated with the given port.
|
||||
*
|
||||
* @param port
|
||||
* forwarded port
|
||||
* @throws RemoteConnectionException
|
||||
* @since 7.0
|
||||
*/
|
||||
public void removeLocalPortForwarding(int port) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Remove the remote port forwarding associated with the given port.
|
||||
*
|
||||
* @param port
|
||||
* forwarded port
|
||||
* @throws RemoteConnectionException
|
||||
* @since 7.0
|
||||
*/
|
||||
public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
|
||||
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A connection service for starting up processes on a remote.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteProcessService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable string map view of the remote environment. The connection must be open prior to calling this method.
|
||||
*
|
||||
* @return the remote environment
|
||||
*/
|
||||
public Map<String, String> getEnv();
|
||||
|
||||
/**
|
||||
* Returns the value of an environment variable. The connection must be open prior to calling this method.
|
||||
*
|
||||
* @param name
|
||||
* name of the environment variable
|
||||
* @return value of the environment variable or null if the variable is not defined
|
||||
*/
|
||||
public String getEnv(String name);
|
||||
|
||||
/**
|
||||
* Get a process builder for creating remote processes
|
||||
*
|
||||
* @return process builder or null if connection is not open
|
||||
*/
|
||||
public IRemoteProcessBuilder getProcessBuilder(List<String> command);
|
||||
|
||||
/**
|
||||
* Get a process builder for creating remote processes
|
||||
*
|
||||
* @return process builder or null if connection is not open
|
||||
*/
|
||||
public IRemoteProcessBuilder getProcessBuilder(String... command);
|
||||
|
||||
/**
|
||||
* Get the working directory. Relative paths will be resolved using this path.
|
||||
*
|
||||
* The remote connection does not need to be open to use this method, however a default directory path, rather than the actual
|
||||
* working directory, may be returned in this case.
|
||||
*
|
||||
* @return String representing the current working directory
|
||||
*/
|
||||
public String getWorkingDirectory();
|
||||
|
||||
/**
|
||||
* Set the working directory while the connection is open. The working directory will revert to the default when the connection
|
||||
* is closed then subsequently reopened.
|
||||
*
|
||||
* Relative paths will be resolved using this path. The path must be valid and absolute for any changes to be made.
|
||||
*
|
||||
* @param path
|
||||
* String representing the current working directory
|
||||
* @since 4.0
|
||||
*/
|
||||
public void setWorkingDirectory(String path);
|
||||
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* Abstraction of a remote services provider. Clients obtain this interface using one of the static methods in
|
||||
* {@link RemoteServices}. The methods on this interface can then be used to access the full range of remote services provided.
|
||||
*/
|
||||
public interface IRemoteServices extends IRemoteServicesDescriptor {
|
||||
public static final int CAPABILITY_ADD_CONNECTIONS = 0x01;
|
||||
public static final int CAPABILITY_EDIT_CONNECTIONS = 0x02;
|
||||
public static final int CAPABILITY_REMOVE_CONNECTIONS = 0x04;
|
||||
public static final int CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING = 0x08;
|
||||
public static final int CAPABILITY_SUPPORTS_X11_FORWARDING = 0x10;
|
||||
public static final int CAPABILITY_SUPPORTS_COMMAND_SHELL = 0x20;
|
||||
|
||||
/**
|
||||
* Get a connection manager for managing remote connections.
|
||||
*
|
||||
* @return connection manager or null if services are not initialized
|
||||
*/
|
||||
public IRemoteConnectionManager getConnectionManager();
|
||||
|
||||
/**
|
||||
* Initialize the remote service. Clients should not call this method (it is called internally.)
|
||||
*
|
||||
* @return true if the initialization was successful, false otherwise
|
||||
* @since 7.0
|
||||
*/
|
||||
public boolean initialize(IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* Gets the capabilities of the remote service.
|
||||
*
|
||||
* @return bit-wise or of capability flag constants
|
||||
*/
|
||||
public int getCapabilities();
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
/**
|
||||
* Interface representing a remote services provider extension. Clients can use this to find out information about the extension
|
||||
* without loading it.
|
||||
*/
|
||||
public interface IRemoteServicesDescriptor extends Comparable<IRemoteServicesDescriptor> {
|
||||
/**
|
||||
* Get unique ID of this service. Can be used as a lookup key.
|
||||
*
|
||||
* @return unique ID
|
||||
*/
|
||||
public String getId();
|
||||
|
||||
/**
|
||||
* Get display name of this service.
|
||||
*
|
||||
* @return display name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Get the EFS scheme provided by this service.
|
||||
*
|
||||
* @return display name
|
||||
*/
|
||||
public String getScheme();
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
/**
|
||||
* Factory for creating instances of a remote service provider. Implementors must provide a class implementing this interface when
|
||||
* supplying a new remote services provider extension.
|
||||
*/
|
||||
public interface IRemoteServicesFactory {
|
||||
/**
|
||||
* Return the remote services implementation for the given descriptor
|
||||
*
|
||||
* @param descriptor
|
||||
* descriptor for the remote services
|
||||
* @return the remote services implementation, or null if initialization failed
|
||||
*/
|
||||
public IRemoteServices getServices(IRemoteServicesDescriptor descriptor);
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The main entry point into the remote services system. The remote services manager
|
||||
* is an OSGi service. It provides a list of connection types and the global
|
||||
* list of all connections.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteServicesManager {
|
||||
|
||||
/**
|
||||
* Get the connection type identified by the id
|
||||
*
|
||||
* @param id id of the connection type
|
||||
* @return connection type or null if the service can not be found
|
||||
*/
|
||||
IRemoteConnectionType getConnectionType(String id);
|
||||
|
||||
/**
|
||||
* Get the connection type that provides connections to locations identified by
|
||||
* the URI.
|
||||
*
|
||||
* @param uri uri of locations to be accessed
|
||||
* @return the connection type that can be used to access the locations
|
||||
* or null if no connection type is available for the uri.
|
||||
*/
|
||||
IRemoteConnectionType getConnectionType(URI uri);
|
||||
|
||||
/**
|
||||
* Return the connection type used to access local resources.
|
||||
*
|
||||
* @return the local services
|
||||
*/
|
||||
IRemoteConnectionType getLocalConnectionType();
|
||||
|
||||
/**
|
||||
* Returns the list of all connection type including the local services.
|
||||
*
|
||||
* @return all remote services
|
||||
*/
|
||||
List<IRemoteConnectionType> getAllConnectionTypes();
|
||||
|
||||
/**
|
||||
* Returns the list of connection types except for the local services.
|
||||
*
|
||||
* @return all remote services that are really remote
|
||||
*/
|
||||
List<IRemoteConnectionType> getRemoteConnectionTypes();
|
||||
|
||||
/**
|
||||
* Returns the list of all known remote connections.
|
||||
*
|
||||
* @return all remote connections
|
||||
*/
|
||||
List<IRemoteConnection> getAllRemoteConnections();
|
||||
|
||||
/**
|
||||
* Add a global connection change listener that receives events for all connections.
|
||||
*
|
||||
* @param listener global connection change listener to be added
|
||||
*/
|
||||
void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener);
|
||||
|
||||
/**
|
||||
* Remove the global connection change listener.
|
||||
*
|
||||
* @param listener global connection change listener to be removed
|
||||
*/
|
||||
void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener);
|
||||
|
||||
/**
|
||||
* Used by connections and other components to notify the global connection
|
||||
* change listeners of events.
|
||||
*
|
||||
* @param event connection change event
|
||||
*/
|
||||
void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event);
|
||||
|
||||
}
|
|
@ -18,9 +18,9 @@ import java.net.PasswordAuthentication;
|
|||
/**
|
||||
* Allow clients to provide their own user interface for connection authentication.
|
||||
*
|
||||
* @since 7.0
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IUserAuthenticator {
|
||||
public interface IUserAuthenticatorService extends IRemoteConnection.Service {
|
||||
|
||||
/**
|
||||
* ID for an "Ok" response (value 0).
|
|
@ -13,8 +13,11 @@ package org.eclipse.remote.core;
|
|||
/**
|
||||
* Event representing a change in connection status. The {@link #getType()} method can be used to obtain information about the type
|
||||
* of event that occurred.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteConnectionChangeEvent {
|
||||
public class RemoteConnectionChangeEvent {
|
||||
|
||||
/**
|
||||
* Event indicating that the connection was closed.
|
||||
*/
|
||||
|
@ -35,12 +38,34 @@ public interface IRemoteConnectionChangeEvent {
|
|||
*/
|
||||
public static final int CONNECTION_RENAMED = 1 << 3;
|
||||
|
||||
/**
|
||||
* Event indicating the connection was added.
|
||||
* @since 2.0
|
||||
*/
|
||||
public static final int CONNECTION_ADDED = 1 << 4;
|
||||
|
||||
/**
|
||||
* Event indicating the connection is about to be removed.
|
||||
* @since 2.0
|
||||
*/
|
||||
public static final int CONNECTION_REMOVED = 1 << 5;
|
||||
|
||||
private final IRemoteConnection connection;
|
||||
private final int type;
|
||||
|
||||
public RemoteConnectionChangeEvent(IRemoteConnection connection, int type) {
|
||||
this.connection = connection;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connection that has changed.
|
||||
*
|
||||
* @return IRemoteConnection
|
||||
*/
|
||||
public IRemoteConnection getConnection();
|
||||
public IRemoteConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of event being reported. This type
|
||||
|
@ -50,5 +75,8 @@ public interface IRemoteConnectionChangeEvent {
|
|||
*
|
||||
* @return a bitwise OR of event type constants
|
||||
*/
|
||||
public int getType();
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesImpl;
|
||||
import org.eclipse.remote.internal.core.services.local.LocalServices;
|
||||
|
||||
/**
|
||||
* Main entry point for accessing remote services.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public class RemoteServices {
|
||||
/**
|
||||
* Retrieve the local services provider. Guaranteed to exist and be initialized.
|
||||
*
|
||||
* @return local services provider
|
||||
*/
|
||||
public static IRemoteServices getLocalServices() {
|
||||
return getRemoteServices(LocalServices.LocalServicesId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote service implementation identified by id and ensure that it is initialized.
|
||||
*
|
||||
* @param id
|
||||
* id of the remote service
|
||||
* @return remote service or null if the service cannot be found or failed to initialized
|
||||
*/
|
||||
public static IRemoteServices getRemoteServices(String id) {
|
||||
return getRemoteServices(id, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote service implementation identified by id and ensure that it is initialized. This method will present the user
|
||||
* with a dialog box that can be canceled.
|
||||
*
|
||||
* @param id
|
||||
* id of remote service to retrieve
|
||||
* @param monitor
|
||||
* progress monitor to allow user to cancel operation
|
||||
* @return remote service, or null if the service cannot be found or failed to initialized
|
||||
* @since 5.0
|
||||
*/
|
||||
public static IRemoteServices getRemoteServices(String id, IProgressMonitor monitor) {
|
||||
RemoteServicesDescriptor proxy = RemoteServicesImpl.getRemoteServiceDescriptorById(id);
|
||||
if (proxy != null) {
|
||||
IRemoteServices service = proxy.getServices();
|
||||
if (service.initialize(monitor)) {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote services identified by a URI.
|
||||
*
|
||||
* @param uri
|
||||
* URI of remote services to retrieve
|
||||
* @return remote service, or null if the service cannot be found or failed to initialized
|
||||
*/
|
||||
public static IRemoteServices getRemoteServices(URI uri) {
|
||||
return getRemoteServices(uri, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote services implementation identified by URI. This method will present the user
|
||||
* with a dialog box that can be canceled.
|
||||
*
|
||||
* @param uri
|
||||
* URI of remote services to retrieve
|
||||
* @param monitor
|
||||
* progress monitor to allow user to cancel operation
|
||||
* @return remote service, or null if the service cannot be found or failed to initialized
|
||||
* @since 5.0
|
||||
*/
|
||||
public static IRemoteServices getRemoteServices(URI uri, IProgressMonitor monitor) {
|
||||
RemoteServicesDescriptor proxy = RemoteServicesImpl.getRemoteServiceDescriptorByURI(uri);
|
||||
if (proxy != null) {
|
||||
IRemoteServices service = proxy.getServices();
|
||||
if (service.initialize(monitor)) {
|
||||
return service;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -13,76 +13,14 @@ package org.eclipse.remote.core;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesImpl;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
import org.eclipse.remote.internal.core.preferences.Preferences;
|
||||
|
||||
/**
|
||||
* Remote services utility methods.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public class RemoteServicesUtils {
|
||||
/**
|
||||
* Utility method to get a remote connection given a remote services ID and a connection name.
|
||||
*
|
||||
* @param remoteServicesId
|
||||
* ID of remote services providing the connection
|
||||
* @param connectionName
|
||||
* name of the connection to find
|
||||
* @param monitor
|
||||
* progress monitor
|
||||
* @return remote connection or null if the ID or connection name are invalid
|
||||
*/
|
||||
public static IRemoteConnection getConnectionWithProgress(String remoteServicesId, String connectionName,
|
||||
IProgressMonitor monitor) {
|
||||
SubMonitor progress = SubMonitor.convert(monitor, 10);
|
||||
IRemoteServices remoteServices = RemoteServices.getRemoteServices(remoteServicesId, progress.newChild(1));
|
||||
if (remoteServices != null) {
|
||||
IRemoteConnectionManager remoteConnectionManager = remoteServices.getConnectionManager();
|
||||
if (remoteConnectionManager != null) {
|
||||
return remoteConnectionManager.getConnection(connectionName);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to get a file store corresponding to the given path.
|
||||
*
|
||||
* @param remoteServicesId
|
||||
* ID of remote services providing the connection
|
||||
* @param connectionName
|
||||
* name of the remote connection to use
|
||||
* @param path
|
||||
* path of file on remote system
|
||||
* @param monitor
|
||||
* progress monitor
|
||||
* @return file store corresponding to the remote file or null if the ID or connection name are invalid
|
||||
*/
|
||||
public static IFileStore getRemoteFileWithProgress(String remoteServicesId, String connectionName, String path,
|
||||
IProgressMonitor monitor) {
|
||||
SubMonitor progress = SubMonitor.convert(monitor, 10);
|
||||
IRemoteServices remoteServices = RemoteServices.getRemoteServices(remoteServicesId, progress.newChild(10));
|
||||
if (remoteServices != null) {
|
||||
IRemoteConnectionManager remoteConnectionManager = remoteServices.getConnectionManager();
|
||||
if (remoteConnectionManager != null) {
|
||||
IRemoteConnection remoteConnection = remoteConnectionManager.getConnection(connectionName);
|
||||
if (remoteConnection != null) {
|
||||
IRemoteFileManager remoteFileManager = remoteConnection.getFileManager();
|
||||
if (remoteFileManager != null) {
|
||||
return remoteFileManager.getResource(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a UNC path to a URI
|
||||
*
|
||||
|
@ -97,19 +35,20 @@ public class RemoteServicesUtils {
|
|||
*/
|
||||
public static URI toURI(IPath path) {
|
||||
if (path.isUNC()) {
|
||||
IRemoteServicesManager manager = RemoteCorePlugin.getService(IRemoteServicesManager.class);
|
||||
/*
|
||||
* Split the server component if possible.
|
||||
*/
|
||||
String[] parts = path.segment(0).split(":"); //$NON-NLS-1$
|
||||
IRemoteServices services = null;
|
||||
IRemoteConnectionType services = null;
|
||||
String connName = null;
|
||||
if (parts.length == 2) {
|
||||
services = RemoteServices.getRemoteServices(parts[0]);
|
||||
services = manager.getConnectionType(parts[0]);
|
||||
connName = parts[1];
|
||||
} else if (parts.length == 1) {
|
||||
String id = Preferences.getString(IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
|
||||
if (id != null) {
|
||||
services = RemoteServices.getRemoteServices(id);
|
||||
services = manager.getConnectionType(id);
|
||||
}
|
||||
connName = parts[0];
|
||||
}
|
||||
|
@ -120,17 +59,13 @@ public class RemoteServicesUtils {
|
|||
*/
|
||||
IRemoteConnection conn = null;
|
||||
if (services != null) {
|
||||
conn = services.getConnectionManager().getConnection(connName);
|
||||
conn = services.getConnection(connName);
|
||||
} else if (connName != null) {
|
||||
for (RemoteServicesDescriptor proxy : RemoteServicesImpl.getRemoteServiceDescriptors()) {
|
||||
services = proxy.getServices();
|
||||
if (services != null) {
|
||||
IRemoteConnectionManager connMgr = services.getConnectionManager();
|
||||
if (connMgr != null) {
|
||||
conn = connMgr.getConnection(connName);
|
||||
if (conn != null) {
|
||||
break;
|
||||
}
|
||||
for (IRemoteConnectionType s : manager.getAllConnectionTypes()) {
|
||||
if (s != null) {
|
||||
conn = s.getConnection(connName);
|
||||
if (conn != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,7 +75,7 @@ public class RemoteServicesUtils {
|
|||
* If a connection was found then convert it to a URI.
|
||||
*/
|
||||
if (conn != null) {
|
||||
String scheme = conn.getRemoteServices().getScheme();
|
||||
String scheme = conn.getConnectionType().getScheme();
|
||||
String filePath = path.removeFirstSegments(1).makeAbsolute().toString();
|
||||
try {
|
||||
return new URI(scheme, connName, filePath, null, null);
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core.exception;
|
||||
|
||||
/**
|
||||
* Thrown when trying to add a connection with the same name as an existing
|
||||
* connection, or when trying to rename a connection to the same name as an
|
||||
* existing connection.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class ConnectionExistsException extends RemoteConnectionException {
|
||||
|
||||
private static final long serialVersionUID = -1591235868439783613L;
|
||||
|
||||
public ConnectionExistsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.core.launch;
|
||||
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
|
||||
/**
|
||||
* Manages and persists the mapping between launch configurations and
|
||||
* remote connections that they run on. Each launch configuration has an
|
||||
* active remote connection.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteLaunchConfigService {
|
||||
|
||||
/**
|
||||
* Sets the active remote connection for the given launch configuration.
|
||||
*
|
||||
* @param launchConfig launch configuration
|
||||
* @param connection active remote connection
|
||||
*/
|
||||
void setActiveConnection(ILaunchConfiguration launchConfig, IRemoteConnection connection);
|
||||
|
||||
/**
|
||||
* Gets the active remote connection for the given launch configuration
|
||||
* @param launchConfig launch configuration
|
||||
* @return active remote connection
|
||||
*/
|
||||
IRemoteConnection getActiveConnection(ILaunchConfiguration launchConfig);
|
||||
|
||||
/**
|
||||
* For a given launch configuration type, get the remote connection that was last
|
||||
* used by a launch configuration of that type.
|
||||
*
|
||||
* This is used for new launch configurations with the assumption that the user
|
||||
* will want to use the same remote connection.
|
||||
*
|
||||
* @param launchConfigType launch configuration type
|
||||
* @return last active remote configuration
|
||||
*/
|
||||
IRemoteConnection getLastActiveConnection(ILaunchConfigurationType launchConfigType);
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.equinox.security.storage.ISecurePreferences;
|
||||
import org.eclipse.equinox.security.storage.StorageException;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteConnectionControlService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionPropertyService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.exception.ConnectionExistsException;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* The standard root class for remote connections. Implements common hook up
|
||||
* with the remote services and the remote services manager as well as handling
|
||||
* for services.
|
||||
*/
|
||||
public class RemoteConnection implements IRemoteConnection {
|
||||
|
||||
private final RemoteConnectionType connectionType;
|
||||
private String name;
|
||||
|
||||
private Map<String, Object> servicesMap = new HashMap<>();
|
||||
|
||||
private final List<IRemoteConnectionChangeListener> fListeners = new ArrayList<>();
|
||||
|
||||
final static String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||
|
||||
public RemoteConnection(RemoteConnectionType connectionType, String name) {
|
||||
this.connectionType = connectionType;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType() {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(Class<T> service) {
|
||||
String serviceName = service.getName();
|
||||
Object obj = servicesMap.get(serviceName);
|
||||
if (obj == null) {
|
||||
obj = connectionType.getConnectionService(this, service);
|
||||
if (obj != null) {
|
||||
servicesMap.put(serviceName, obj);
|
||||
}
|
||||
}
|
||||
|
||||
return (T) obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Service> boolean hasService(Class<T> service) {
|
||||
return servicesMap.get(service.getName()) != null || connectionType.hasConnectionService(this, service);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from working copy when name has changed.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
void rename(String newName) throws ConnectionExistsException {
|
||||
try {
|
||||
// Copy the old preferences over and remove the old node
|
||||
if (connectionType.getPreferenceNode().nodeExists(newName)) {
|
||||
throw new ConnectionExistsException(newName);
|
||||
}
|
||||
|
||||
Preferences newPrefs = connectionType.getPreferenceNode().node(newName);
|
||||
Preferences oldPrefs = getPreferences();
|
||||
for (String key : oldPrefs.keys()) {
|
||||
newPrefs.put(key, oldPrefs.get(key, null));
|
||||
}
|
||||
|
||||
oldPrefs.removeNode();
|
||||
} catch (BackingStoreException e) {
|
||||
RemoteCorePlugin.log(e);
|
||||
}
|
||||
|
||||
this.name = newName;
|
||||
}
|
||||
|
||||
Preferences getPreferences() {
|
||||
return connectionType.getPreferenceNode().node(name);
|
||||
}
|
||||
|
||||
ISecurePreferences getSecurePreferences() {
|
||||
return connectionType.getSecurePreferencesNode().node(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute(String key) {
|
||||
return getPreferences().get(key, EMPTY_STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSecureAttribute(String key) {
|
||||
try {
|
||||
return getSecurePreferences().get(key, EMPTY_STRING);
|
||||
} catch (StorageException e) {
|
||||
RemoteCorePlugin.log(e);
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||
return new RemoteConnectionWorkingCopy(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
IRemoteConnectionPropertyService propertyService = getService(IRemoteConnectionPropertyService.class);
|
||||
if (propertyService != null) {
|
||||
return propertyService.getProperty(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
|
||||
if (controlService != null) {
|
||||
controlService.open(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
|
||||
if (controlService != null) {
|
||||
controlService.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
|
||||
if (controlService != null) {
|
||||
return controlService.isOpen();
|
||||
} else {
|
||||
// default is always open
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
fListeners.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
fListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireConnectionChangeEvent(final int type) {
|
||||
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type);
|
||||
for (IRemoteConnectionChangeListener listener : fListeners) {
|
||||
listener.connectionChanged(event);
|
||||
}
|
||||
// fire to the global listeners too
|
||||
connectionType.getRemoteServicesManager().fireRemoteConnectionChangeEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " - " + connectionType.getName(); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.equinox.security.storage.ISecurePreferences;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.exception.ConnectionExistsException;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* The implementation for a given remote services collection.n
|
||||
*/
|
||||
public class RemoteConnectionType implements IRemoteConnectionType {
|
||||
|
||||
private final RemoteServicesManager remoteServicesManager;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private final String scheme;
|
||||
private final int capabilities;
|
||||
|
||||
private final Map<String, Object> serviceMap = new HashMap<>();
|
||||
private final Map<String, IConfigurationElement> serviceDefinitionMap = new HashMap<>();
|
||||
|
||||
private final Map<String, RemoteConnection> connections = new HashMap<>();
|
||||
|
||||
public RemoteConnectionType(IConfigurationElement ce, RemoteServicesManager manager) {
|
||||
this.remoteServicesManager = manager;
|
||||
id = ce.getAttribute("id"); //$NON-NLS-1$
|
||||
name = ce.getAttribute("name"); //$NON-NLS-1$
|
||||
scheme = ce.getAttribute("scheme"); //$NON-NLS-1$
|
||||
|
||||
String caps = ce.getAttribute("capabilities"); //$NON-NLS-1$
|
||||
if (caps != null) {
|
||||
capabilities = Integer.parseInt(caps);
|
||||
} else {
|
||||
capabilities = 0;
|
||||
}
|
||||
|
||||
// load up existing connections
|
||||
try {
|
||||
for (String connectionName : getPreferenceNode().childrenNames()) {
|
||||
connections.put(connectionName, new RemoteConnection(this, connectionName));
|
||||
}
|
||||
} catch (BackingStoreException e) {
|
||||
RemoteCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
Preferences getPreferenceNode() {
|
||||
return remoteServicesManager.getPreferenceNode().node(id);
|
||||
}
|
||||
|
||||
ISecurePreferences getSecurePreferencesNode() {
|
||||
return remoteServicesManager.getSecurePreferenceNode().node(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteServicesManager getRemoteServicesManager() {
|
||||
return remoteServicesManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return scheme;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Service> T getService(Class<T> service) {
|
||||
String serviceName = service.getName();
|
||||
@SuppressWarnings("unchecked")
|
||||
T obj = (T) serviceMap.get(serviceName);
|
||||
if (obj == null) {
|
||||
IConfigurationElement ce = serviceDefinitionMap.get(serviceName);
|
||||
if (ce != null) {
|
||||
try {
|
||||
Service.Factory factory = (Service.Factory) ce.createExecutableExtension("factory"); //$NON-NLS-1$
|
||||
if (factory != null) {
|
||||
obj = factory.getService(this, service);
|
||||
serviceMap.put(serviceName, obj);
|
||||
serviceDefinitionMap.remove(serviceName);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Service> boolean hasService(Class<T> service) {
|
||||
String serviceName = service.getName();
|
||||
return serviceMap.get(serviceName) != null || serviceDefinitionMap.get(service) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the connection to get a service object for that connection.
|
||||
*
|
||||
* @param connection the connection to which the service applies
|
||||
* @param service the interface the service must implement
|
||||
* @return the service object
|
||||
* @throws CoreException
|
||||
*/
|
||||
public <T extends IRemoteConnection.Service> T getConnectionService(IRemoteConnection connection, Class<T> service) {
|
||||
// Both top level and connection services are stored in the serviceDefinitionMap.
|
||||
// In theory the two sets of interfaces can't collide.
|
||||
IConfigurationElement ce = serviceDefinitionMap.get(service.getName());
|
||||
if (ce != null) {
|
||||
try {
|
||||
IRemoteConnection.Service.Factory factory = (IRemoteConnection.Service.Factory) ce.createExecutableExtension("factory"); //$NON-NLS-1$
|
||||
if (factory != null) {
|
||||
return factory.getService(connection, service);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public <T extends IRemoteConnection.Service> boolean hasConnectionService(IRemoteConnection connection, Class<T> service) {
|
||||
return serviceDefinitionMap.get(service.getName()) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from the remote service manager to register a service extension for
|
||||
* this remote services implementation
|
||||
*
|
||||
* @param ce the extension element defining the service
|
||||
*/
|
||||
public void addService(IConfigurationElement ce) {
|
||||
String service = ce.getAttribute("service"); //$NON-NLS-1$
|
||||
serviceDefinitionMap.put(service, ce);
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal connection has been added.
|
||||
* @since 2.0
|
||||
*/
|
||||
protected void connectionAdded(final IRemoteConnection connection) {
|
||||
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection, RemoteConnectionChangeEvent.CONNECTION_ADDED);
|
||||
remoteServicesManager.fireRemoteConnectionChangeEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Signal a connnection is about to be removed.
|
||||
* @since 2.0
|
||||
*/
|
||||
protected void connectionRemoved(final IRemoteConnection connection) {
|
||||
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection, RemoteConnectionChangeEvent.CONNECTION_ADDED);
|
||||
remoteServicesManager.fireRemoteConnectionChangeEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getConnection(String name) {
|
||||
return connections.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getConnection(URI uri) {
|
||||
return connections.get(uri.getAuthority());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IRemoteConnection> getConnections() {
|
||||
return new ArrayList<IRemoteConnection>(connections.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
|
||||
if (connections.containsKey(name)) {
|
||||
throw new ConnectionExistsException(name);
|
||||
}
|
||||
return new RemoteConnectionWorkingCopy(this, name);
|
||||
}
|
||||
|
||||
void addConnection(RemoteConnection remoteConnection) {
|
||||
connections.put(remoteConnection.getName(), remoteConnection);
|
||||
}
|
||||
|
||||
void removeConnection(String name) {
|
||||
connections.remove(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException {
|
||||
if (connection instanceof RemoteConnection) {
|
||||
connection.close();
|
||||
RemoteConnection conn = (RemoteConnection) connection;
|
||||
try {
|
||||
conn.getPreferences().removeNode();
|
||||
} catch (BackingStoreException e) {
|
||||
throw new RemoteConnectionException(e);
|
||||
}
|
||||
conn.getSecurePreferences().removeNode();
|
||||
connections.remove(conn.getName());
|
||||
connection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_REMOVED);
|
||||
} else {
|
||||
RemoteCorePlugin.log("Wrong class for " + connection.getName() + ", was " + connection.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.equinox.security.storage.ISecurePreferences;
|
||||
import org.eclipse.equinox.security.storage.StorageException;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteConnectionControlService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionPropertyService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy {
|
||||
|
||||
private RemoteConnection original;
|
||||
private RemoteConnectionType connectionType;
|
||||
private String newName;
|
||||
private Map<String, String> newAttributes = new HashMap<>();
|
||||
private Map<String, String> newSecureAttributes = new HashMap<>();
|
||||
private List<IRemoteConnectionChangeListener> newListeners = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* New Connection.
|
||||
*/
|
||||
public RemoteConnectionWorkingCopy(RemoteConnectionType connectionType, String name) {
|
||||
this.connectionType = connectionType;
|
||||
this.newName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit Connection
|
||||
*/
|
||||
public RemoteConnectionWorkingCopy(RemoteConnection original) {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (newName != null) {
|
||||
return newName;
|
||||
} else if (original != null) {
|
||||
return original.getName();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
// set if only if it's changed
|
||||
if (original == null || !name.equals(original.getName())) {
|
||||
newName = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttribute(String key) {
|
||||
String value = newAttributes.get(key);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (original != null) {
|
||||
return original.getAttribute(key);
|
||||
}
|
||||
|
||||
return RemoteConnection.EMPTY_STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key, String value) {
|
||||
// set only if it's changed or value is null
|
||||
if (original == null || value == null || !value.equals(original.getAttribute(key))) {
|
||||
newAttributes.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSecureAttribute(String key) {
|
||||
String value = newSecureAttributes.get(key);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (original != null) {
|
||||
return original.getSecureAttribute(key);
|
||||
}
|
||||
|
||||
return RemoteConnection.EMPTY_STRING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecureAttribute(String key, String value) {
|
||||
// set only if it's changed or value is null
|
||||
if (original == null || value == null || !value.equals(original.getSecureAttribute(key))) {
|
||||
newSecureAttributes.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
if (original != null) {
|
||||
original.addConnectionChangeListener(listener);
|
||||
} else {
|
||||
newListeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
if (original != null) {
|
||||
original.removeConnectionChangeListener(listener);
|
||||
} else {
|
||||
newListeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireConnectionChangeEvent(int type) {
|
||||
if (original != null) {
|
||||
original.fireConnectionChangeEvent(type);
|
||||
} else {
|
||||
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type);
|
||||
for (IRemoteConnectionChangeListener listener : newListeners) {
|
||||
listener.connectionChanged(event);
|
||||
}
|
||||
connectionType.getRemoteServicesManager().fireRemoteConnectionChangeEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType() {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Service> T getService(Class<T> service) {
|
||||
if (original != null) {
|
||||
return original.getService(service);
|
||||
} else {
|
||||
return connectionType.getConnectionService(this, service);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Service> boolean hasService(Class<T> service) {
|
||||
if (original != null) {
|
||||
return original.hasService(service);
|
||||
} else {
|
||||
return connectionType.hasConnectionService(this, service);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getOriginal() {
|
||||
return original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return newName != null || !newAttributes.isEmpty() || !newSecureAttributes.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection save() throws RemoteConnectionException {
|
||||
if (newName != null && original != null) {
|
||||
// rename, delete the old one
|
||||
original.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_RENAMED);
|
||||
connectionType.removeConnection(original.getName());
|
||||
original.rename(newName);
|
||||
}
|
||||
|
||||
boolean added = false;
|
||||
if (original == null) {
|
||||
original = new RemoteConnection(connectionType, newName);
|
||||
added = true;
|
||||
}
|
||||
|
||||
Preferences prefs = original.getPreferences();
|
||||
for (Map.Entry<String, String> entry : newAttributes.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
prefs.put(entry.getKey(), value);
|
||||
} else {
|
||||
prefs.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
try {
|
||||
prefs.flush();
|
||||
} catch (BackingStoreException e1) {
|
||||
throw new RemoteConnectionException(e1);
|
||||
}
|
||||
newAttributes.clear();
|
||||
|
||||
ISecurePreferences securePrefs = original.getSecurePreferences();
|
||||
for (Map.Entry<String, String> entry : newSecureAttributes.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
if (value != null && !value.isEmpty()) {
|
||||
try {
|
||||
securePrefs.put(entry.getKey(), value, true);
|
||||
} catch (StorageException e) {
|
||||
throw new RemoteConnectionException(e);
|
||||
}
|
||||
} else {
|
||||
securePrefs.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
try {
|
||||
securePrefs.flush();
|
||||
} catch (IOException e) {
|
||||
throw new RemoteConnectionException(e);
|
||||
}
|
||||
newSecureAttributes.clear();
|
||||
|
||||
connectionType.addConnection(original);
|
||||
if (added) {
|
||||
original.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_ADDED);
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
if (original != null) {
|
||||
original.open(monitor);
|
||||
} else {
|
||||
IRemoteConnectionControlService controlService =
|
||||
connectionType.getConnectionService(this, IRemoteConnectionControlService.class);
|
||||
if (controlService != null) {
|
||||
controlService.open(monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (original != null) {
|
||||
original.close();
|
||||
} else {
|
||||
IRemoteConnectionControlService controlService =
|
||||
connectionType.getConnectionService(this, IRemoteConnectionControlService.class);
|
||||
if (controlService != null) {
|
||||
controlService.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
if (original != null) {
|
||||
return original.isOpen();
|
||||
} else {
|
||||
IRemoteConnectionControlService controlService =
|
||||
connectionType.getConnectionService(this, IRemoteConnectionControlService.class);
|
||||
if (controlService != null) {
|
||||
return controlService.isOpen();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
if (original != null) {
|
||||
return original.getProperty(key);
|
||||
} else {
|
||||
IRemoteConnectionPropertyService propertyService =
|
||||
connectionType.getConnectionService(this, IRemoteConnectionPropertyService.class);
|
||||
if (propertyService != null) {
|
||||
return propertyService.getProperty(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,8 +17,12 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
|
||||
import org.eclipse.remote.internal.core.launch.RemoteLaunchConfigService;
|
||||
import org.eclipse.remote.internal.core.preferences.Preferences;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
|
@ -78,6 +82,18 @@ public class RemoteCorePlugin extends Plugin {
|
|||
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the OSGi service with the given service interface.
|
||||
*
|
||||
* @param service service interface
|
||||
* @return the specified service or null if it's not registered
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
BundleContext context = plugin.getBundle().getBundleContext();
|
||||
ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
|
@ -93,6 +109,8 @@ public class RemoteCorePlugin extends Plugin {
|
|||
public void start(BundleContext context) throws Exception {
|
||||
super.start(context);
|
||||
plugin = this;
|
||||
context.registerService(IRemoteServicesManager.class, new RemoteServicesManager(), null);
|
||||
context.registerService(IRemoteLaunchConfigService.class, new RemoteLaunchConfigService(), null);
|
||||
RemoteDebugOptions.configure(context);
|
||||
ResourcesPlugin.getWorkspace().addSaveParticipant(getUniqueIdentifier(), new ISaveParticipant() {
|
||||
@Override
|
||||
|
|
|
@ -1,134 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||
import org.eclipse.remote.core.IRemoteServicesFactory;
|
||||
import org.eclipse.remote.internal.core.messages.Messages;
|
||||
|
||||
public class RemoteServicesDescriptor implements IRemoteServicesDescriptor {
|
||||
private static final String ATTR_ID = "id"; //$NON-NLS-1$
|
||||
private static final String ATTR_NAME = "name"; //$NON-NLS-1$
|
||||
private static final String ATTR_SCHEME = "scheme"; //$NON-NLS-1$
|
||||
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
|
||||
|
||||
private static String getAttribute(IConfigurationElement configElement, String name, String defaultValue) {
|
||||
String value = configElement.getAttribute(name);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
if (defaultValue != null) {
|
||||
return defaultValue;
|
||||
}
|
||||
throw new IllegalArgumentException(NLS.bind(Messages.RemoteServicesProxy_0, name));
|
||||
}
|
||||
|
||||
private final IConfigurationElement fConfigElement;
|
||||
|
||||
private final String fId;
|
||||
private final String fName;
|
||||
private final String fScheme;
|
||||
private IRemoteServicesFactory fFactory;
|
||||
private IRemoteServices fDelegate = null;
|
||||
|
||||
public RemoteServicesDescriptor(IConfigurationElement configElement) {
|
||||
fConfigElement = configElement;
|
||||
fId = getAttribute(configElement, ATTR_ID, null);
|
||||
fName = getAttribute(configElement, ATTR_NAME, fId);
|
||||
fScheme = getAttribute(configElement, ATTR_SCHEME, null);
|
||||
getAttribute(configElement, ATTR_CLASS, null);
|
||||
fFactory = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(IRemoteServicesDescriptor arg0) {
|
||||
return getName().compareTo(arg0.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the factory from the plugin
|
||||
*
|
||||
* @return instance of the factory
|
||||
*/
|
||||
public IRemoteServicesFactory getFactory() {
|
||||
if (fFactory != null) {
|
||||
return fFactory;
|
||||
}
|
||||
try {
|
||||
fFactory = (IRemoteServicesFactory) fConfigElement.createExecutableExtension(ATTR_CLASS);
|
||||
} catch (Exception e) {
|
||||
RemoteCorePlugin.log(NLS.bind(Messages.RemoteServicesProxy_1, new Object[] { fConfigElement.getAttribute(ATTR_CLASS),
|
||||
fId, fConfigElement.getDeclaringExtension().getNamespaceIdentifier() }));
|
||||
}
|
||||
return fFactory;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return fId;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getScheme()
|
||||
*/
|
||||
@Override
|
||||
public String getScheme() {
|
||||
return fScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote services implementation for this descriptor. The service has not been initialized.
|
||||
*
|
||||
* @return the remote services implementation
|
||||
*/
|
||||
public IRemoteServices getServices() {
|
||||
loadServices();
|
||||
return fDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the remote services factory. Note that the services will not be
|
||||
* initialized.
|
||||
*/
|
||||
private void loadServices() {
|
||||
if (fDelegate == null) {
|
||||
IRemoteServicesFactory factory = getFactory();
|
||||
if (factory != null) {
|
||||
fDelegate = factory.getServices(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.internal.core.services.local.LocalServices;
|
||||
|
||||
/**
|
||||
* Main entry point for remote services
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public class RemoteServicesImpl {
|
||||
public static final String REMOTE_SERVICES_EXTENSION_POINT_ID = "remoteServices"; //$NON-NLS-1$
|
||||
|
||||
// Active remote services plugins (not necessarily loaded)
|
||||
private static final Map<String, RemoteServicesDescriptor> fRemoteServicesById = Collections
|
||||
.synchronizedMap(new HashMap<String, RemoteServicesDescriptor>());
|
||||
private static final Map<String, RemoteServicesDescriptor> fRemoteServicesByScheme = Collections
|
||||
.synchronizedMap(new HashMap<String, RemoteServicesDescriptor>());
|
||||
|
||||
private RemoteServicesImpl() {
|
||||
// Hide constructor
|
||||
}
|
||||
|
||||
public static RemoteServicesDescriptor getRemoteServiceDescriptorById(String id) {
|
||||
retrieveRemoteServices();
|
||||
return fRemoteServicesById.get(id);
|
||||
}
|
||||
|
||||
public static RemoteServicesDescriptor getRemoteServiceDescriptorByURI(URI uri) {
|
||||
String scheme = uri.getScheme();
|
||||
if (scheme != null) {
|
||||
retrieveRemoteServices();
|
||||
return fRemoteServicesByScheme.get(scheme);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a sorted list of remote service descriptors. Does not return the local service provider. This must be obtained
|
||||
* using the {@link RemoteServices#getLocalServices()} method.
|
||||
*
|
||||
* @return remote service descriptors
|
||||
*/
|
||||
public static List<RemoteServicesDescriptor> getRemoteServiceDescriptors() {
|
||||
retrieveRemoteServices();
|
||||
List<RemoteServicesDescriptor> descriptors = new ArrayList<RemoteServicesDescriptor>();
|
||||
for (RemoteServicesDescriptor descriptor : fRemoteServicesById.values()) {
|
||||
if (!descriptor.getId().equals(LocalServices.LocalServicesId)) {
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
}
|
||||
Collections.sort(descriptors);
|
||||
return descriptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find and load all remoteServices plugins.
|
||||
*/
|
||||
private static void retrieveRemoteServices() {
|
||||
if (fRemoteServicesById.isEmpty()) {
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(),
|
||||
REMOTE_SERVICES_EXTENSION_POINT_ID);
|
||||
final IExtension[] extensions = extensionPoint.getExtensions();
|
||||
|
||||
for (IExtension ext : extensions) {
|
||||
final IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||
|
||||
for (IConfigurationElement ce : elements) {
|
||||
RemoteServicesDescriptor proxy = new RemoteServicesDescriptor(ce);
|
||||
fRemoteServicesById.put(proxy.getId(), proxy);
|
||||
fRemoteServicesByScheme.put(proxy.getScheme(), proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,183 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.core.runtime.IExtension;
|
||||
import org.eclipse.core.runtime.IExtensionPoint;
|
||||
import org.eclipse.core.runtime.IExtensionRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.equinox.security.storage.ISecurePreferences;
|
||||
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteConnectionProviderService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
/**
|
||||
* The implementation for the remote services manager service.
|
||||
*/
|
||||
public class RemoteServicesManager implements IRemoteServicesManager {
|
||||
|
||||
private static final String LOCAL_SERVICES_ID = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
|
||||
|
||||
// Map from id to remote services
|
||||
private final Map<String, RemoteConnectionType> connectionTypeMap = new HashMap<>();
|
||||
|
||||
// Map from URI scheme to remote services
|
||||
private final Map<String, IRemoteConnectionType> schemeMap = new HashMap<>();
|
||||
|
||||
private final List<IRemoteConnectionChangeListener> listeners = new LinkedList<>();
|
||||
private boolean inited;
|
||||
|
||||
/**
|
||||
* Loads up the services extensions and then loads up the persisted connections.
|
||||
* This stuff can't be done from the constructor for the manager since that's done
|
||||
* in the bundle activator which is way too early. It also gives us the ability
|
||||
* to override the initialization in tests
|
||||
*/
|
||||
protected void init() {
|
||||
if (inited) {
|
||||
return;
|
||||
}
|
||||
inited = true;
|
||||
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint point = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(), "remoteServices"); //$NON-NLS-1$
|
||||
|
||||
// Load up the connection types
|
||||
for (IExtension ext : point.getExtensions()) {
|
||||
for (IConfigurationElement ce : ext.getConfigurationElements()) {
|
||||
if (ce.getName().equals("connectionType")) { //$NON-NLS-1$
|
||||
RemoteConnectionType services = new RemoteConnectionType(ce, this);
|
||||
connectionTypeMap.put(services.getId(), services);
|
||||
String scheme = services.getScheme();
|
||||
if (scheme != null) {
|
||||
schemeMap.put(scheme, services);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load up the services
|
||||
for (IExtension ext : point.getExtensions()) {
|
||||
for (IConfigurationElement ce : ext.getConfigurationElements()) {
|
||||
String name = ce.getName();
|
||||
if (name.equals("connectionTypeService") || name.equals("connectionService")) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String id = ce.getAttribute("connectionTypeId"); //$NON-NLS-1$
|
||||
RemoteConnectionType services = connectionTypeMap.get(id);
|
||||
if (services != null) {
|
||||
services.addService(ce);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init connection providers
|
||||
for (IRemoteConnectionType connectionType : connectionTypeMap.values()) {
|
||||
IRemoteConnectionProviderService providerService = connectionType.getService(IRemoteConnectionProviderService.class);
|
||||
if (providerService != null) {
|
||||
providerService.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Preferences getPreferenceNode() {
|
||||
return InstanceScope.INSTANCE.getNode(RemoteCorePlugin.getUniqueIdentifier()).node("connections"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public ISecurePreferences getSecurePreferenceNode() {
|
||||
return SecurePreferencesFactory.getDefault().node(RemoteCorePlugin.getUniqueIdentifier()).node("connections"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType(String id) {
|
||||
init();
|
||||
return connectionTypeMap.get(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType(URI uri) {
|
||||
init();
|
||||
return schemeMap.get(uri.getScheme());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getLocalConnectionType() {
|
||||
return getConnectionType(LOCAL_SERVICES_ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IRemoteConnectionType> getAllConnectionTypes() {
|
||||
init();
|
||||
return new ArrayList<IRemoteConnectionType>(connectionTypeMap.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IRemoteConnectionType> getRemoteConnectionTypes() {
|
||||
init();
|
||||
List<IRemoteConnectionType> services = new ArrayList<>(connectionTypeMap.values().size() - 1);
|
||||
IRemoteConnectionType localServices = getLocalConnectionType();
|
||||
for (IRemoteConnectionType s : connectionTypeMap.values()) {
|
||||
if (!s.equals(localServices)) {
|
||||
services.add(s);
|
||||
}
|
||||
}
|
||||
return services;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<IRemoteConnection> getAllRemoteConnections() {
|
||||
// TODO do this without getting the connection managers and force loading the plugins
|
||||
List<IRemoteConnection> connections = new ArrayList<>();
|
||||
for (IRemoteConnectionType services : getAllConnectionTypes()) {
|
||||
connections.addAll(services.getConnections());
|
||||
}
|
||||
return connections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event) {
|
||||
List<IRemoteConnectionChangeListener> iListeners;
|
||||
synchronized (listeners) {
|
||||
iListeners = new ArrayList<>(listeners);
|
||||
}
|
||||
for (IRemoteConnectionChangeListener listener : iListeners) {
|
||||
listener.connectionChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.eclipse.remote.internal.core.launch;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||
import org.eclipse.debug.core.ILaunchConfigurationType;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class RemoteLaunchConfigService implements IRemoteLaunchConfigService {
|
||||
|
||||
private static final String REMOTE_LAUNCH_CONFIG = "remoteLaunchConfig"; //$NON-NLS-1$
|
||||
private static final String REMOTE_LAUNCH_TYPE = "remoteLaunchType"; //$NON-NLS-1$
|
||||
|
||||
private Preferences getPreferences(String node) {
|
||||
return InstanceScope.INSTANCE.getNode(RemoteCorePlugin.getUniqueIdentifier()).node(node);
|
||||
}
|
||||
|
||||
private IRemoteConnection getRemoteConnection(String remoteId) {
|
||||
if (remoteId == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String[] ids = remoteId.split(":"); //$NON-NLS-1$
|
||||
if (ids.length < 2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IRemoteServicesManager manager = RemoteCorePlugin.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType connectionType = manager.getConnectionType(ids[0]);
|
||||
if (connectionType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return connectionType.getConnection(ids[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActiveConnection(ILaunchConfiguration launchConfig, IRemoteConnection connection) {
|
||||
String remoteId = connection.getConnectionType().getId() + ":" + connection.getName(); //$NON-NLS-1$
|
||||
getPreferences(REMOTE_LAUNCH_CONFIG).put(launchConfig.getName(), remoteId);
|
||||
try {
|
||||
getPreferences(REMOTE_LAUNCH_TYPE).put(launchConfig.getType().getIdentifier(), remoteId);
|
||||
} catch (CoreException e) {
|
||||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getActiveConnection(ILaunchConfiguration launchConfig) {
|
||||
String remoteId = getPreferences(REMOTE_LAUNCH_CONFIG).get(launchConfig.getName(), null);
|
||||
return getRemoteConnection(remoteId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getLastActiveConnection(ILaunchConfigurationType launchConfigType) {
|
||||
String remoteId = getPreferences(REMOTE_LAUNCH_TYPE).get(launchConfigType.getIdentifier(), null);
|
||||
return getRemoteConnection(remoteId);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,413 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteFileManager;
|
||||
import org.eclipse.remote.core.IRemoteProcess;
|
||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.core.exception.UnableToForwardPortException;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
import org.eclipse.remote.internal.core.messages.Messages;
|
||||
|
||||
public class LocalConnection implements IRemoteConnection {
|
||||
private final String fName = IRemoteConnectionManager.LOCAL_CONNECTION_NAME;
|
||||
private final String fAddress = Messages.LocalConnection_1;
|
||||
private final String fUsername = System.getProperty("user.name"); //$NON-NLS-1$
|
||||
private boolean fConnected = true;
|
||||
private IPath fWorkingDir = null;
|
||||
|
||||
private final IRemoteFileManager fFileMgr = new LocalFileManager();
|
||||
private final IRemoteConnection fConnection = this;
|
||||
private final IRemoteServices fRemoteServices;
|
||||
private final ListenerList fListeners = new ListenerList();
|
||||
|
||||
public LocalConnection(IRemoteServices services) {
|
||||
fRemoteServices = services;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#addConnectionChangeListener
|
||||
* (org.eclipse.remote.core.IRemoteConnectionChangeListener)
|
||||
*/
|
||||
@Override
|
||||
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
fListeners.add(listener);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#close()
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
if (fConnected) {
|
||||
fConnected = false;
|
||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(IRemoteConnection connection) {
|
||||
return getName().compareTo(connection.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all listeners when this connection's status changes.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void fireConnectionChangeEvent(final int type) {
|
||||
IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
|
||||
@Override
|
||||
public IRemoteConnection getConnection() {
|
||||
return fConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
for (Object listener : fListeners.getListeners()) {
|
||||
((IRemoteConnectionChangeListener) listener).connectionChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(int,
|
||||
* java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
|
||||
throw new UnableToForwardPortException(Messages.LocalConnection_2);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(java.lang
|
||||
* .String, int, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
throw new UnableToForwardPortException(Messages.LocalConnection_2);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(int,
|
||||
* java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
|
||||
throw new UnableToForwardPortException(Messages.LocalConnection_2);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(java.
|
||||
* lang.String, int, org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
throw new UnableToForwardPortException(Messages.LocalConnection_2);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getAddress()
|
||||
*/
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return fAddress;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getCommandShell(int)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcess getCommandShell(int flags) throws IOException {
|
||||
throw new IOException("Not currently implemented"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getEnv()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getEnv() {
|
||||
return System.getenv();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#getEnv(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getEnv(String name) {
|
||||
return System.getenv(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getFileManager(j)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteFileManager getFileManager() {
|
||||
return fFileMgr;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getPort()
|
||||
*/
|
||||
@Override
|
||||
public int getPort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcessBuilder getProcessBuilder(List<String> command) {
|
||||
return new LocalProcessBuilder(command);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcessBuilder getProcessBuilder(String... command) {
|
||||
return new LocalProcessBuilder(command);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#getProperty(java.lang.String
|
||||
* )
|
||||
*/
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
/*
|
||||
* Convert os.name and os.arch to framework properties so they make more sense
|
||||
*/
|
||||
switch (key) {
|
||||
case IRemoteConnection.OS_NAME_PROPERTY:
|
||||
return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.os"); //$NON-NLS-1$
|
||||
case IRemoteConnection.OS_ARCH_PROPERTY:
|
||||
return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.arch"); //$NON-NLS-1$
|
||||
}
|
||||
return System.getProperty(key);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getRemoteServices()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteServices getRemoteServices() {
|
||||
return fRemoteServices;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getUsername()
|
||||
*/
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return fUsername;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||
return new LocalConnectionWorkingCopy(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteFileManager#getWorkingDirectory(org
|
||||
* .eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public String getWorkingDirectory() {
|
||||
if (fWorkingDir == null) {
|
||||
String cwd = System.getProperty("user.home"); //$NON-NLS-1$
|
||||
if (cwd == null) {
|
||||
cwd = System.getProperty("user.dir"); //$NON-NLS-1$;
|
||||
}
|
||||
if (cwd == null) {
|
||||
fWorkingDir = Path.ROOT;
|
||||
} else {
|
||||
fWorkingDir = new Path(cwd);
|
||||
}
|
||||
}
|
||||
return fWorkingDir.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#isOpen()
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return fConnected;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#open()
|
||||
*/
|
||||
@Override
|
||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
if (!fConnected) {
|
||||
fConnected = true;
|
||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#removeConnectionChangeListener
|
||||
* (org.eclipse.remote.core.IRemoteConnectionChangeListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
fListeners.remove(listener);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#removeLocalPortForwarding(int)
|
||||
*/
|
||||
@Override
|
||||
public void removeLocalPortForwarding(int port) throws RemoteConnectionException {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#removeRemotePortForwarding(int)
|
||||
*/
|
||||
@Override
|
||||
public void removeRemotePortForwarding(int port) throws RemoteConnectionException {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteFileManager#setWorkingDirectory(java
|
||||
* .lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setWorkingDirectory(String pathStr) {
|
||||
IPath path = new Path(pathStr);
|
||||
if (path.isAbsolute()) {
|
||||
fWorkingDir = path;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnection#supportsTCPPortForwarding()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsTCPPortForwarding() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,99 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.remote.core.AbstractRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.core.messages.Messages;
|
||||
|
||||
public class LocalConnectionManager extends AbstractRemoteConnectionManager {
|
||||
private final IRemoteConnection fLocalConnection;
|
||||
|
||||
public LocalConnectionManager(IRemoteServices services) {
|
||||
super(services);
|
||||
fLocalConnection = new LocalConnection(services);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
|
||||
* .lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection getConnection(String name) {
|
||||
if (name.equals(fLocalConnection.getName())) {
|
||||
return fLocalConnection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
|
||||
* .net.URI)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection getConnection(URI uri) {
|
||||
if (uri.getScheme().equals(EFS.getLocalFileSystem().getScheme())) {
|
||||
return fLocalConnection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
|
||||
*/
|
||||
@Override
|
||||
public List<IRemoteConnection> getConnections() {
|
||||
List<IRemoteConnection> list = new ArrayList<IRemoteConnection>();
|
||||
list.add(fLocalConnection);
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#newConnection(java
|
||||
* .lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
|
||||
throw new RemoteConnectionException(Messages.Unable_to_create_new_local_connections);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#removeConnection
|
||||
* (org.eclipse.remote.core.IRemoteConnection)
|
||||
*/
|
||||
@Override
|
||||
public void removeConnection(IRemoteConnection connection) {
|
||||
// Nothing
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnection.Service;
|
||||
import org.eclipse.remote.core.IRemoteConnectionPropertyService;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
|
||||
public class LocalConnectionPropertyService implements IRemoteConnectionPropertyService {
|
||||
|
||||
private final IRemoteConnection connection;
|
||||
|
||||
public LocalConnectionPropertyService(IRemoteConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public static class Factory implements IRemoteConnectionPropertyService.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnection remoteConnection, Class<T> service) {
|
||||
if (service.equals(IRemoteConnectionPropertyService.class)) {
|
||||
return (T) new LocalConnectionPropertyService(remoteConnection);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getRemoteConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
switch (key) {
|
||||
case IRemoteConnection.OS_NAME_PROPERTY:
|
||||
return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.os"); //$NON-NLS-1$
|
||||
case IRemoteConnection.OS_ARCH_PROPERTY:
|
||||
return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.arch"); //$NON-NLS-1$
|
||||
}
|
||||
return System.getProperty(key);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnectionProviderService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType.Service;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.core.RemoteCorePlugin;
|
||||
|
||||
public class LocalConnectionProviderService implements IRemoteConnectionProviderService {
|
||||
|
||||
private static final String localConnectionName = Messages.LocalConnectionProviderService_LocalConnectionName;
|
||||
|
||||
private IRemoteConnectionType connectionType;
|
||||
|
||||
public static class Factory implements IRemoteConnectionType.Service.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service) {
|
||||
if (service.equals(IRemoteConnectionProviderService.class)) {
|
||||
return (T) new LocalConnectionProviderService(connectionType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public LocalConnectionProviderService(IRemoteConnectionType connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
if (connectionType.getConnections().isEmpty()) {
|
||||
try {
|
||||
connectionType.newConnection(localConnectionName).save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
RemoteCorePlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType() {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
||||
public class LocalConnectionWorkingCopy extends LocalConnection implements IRemoteConnectionWorkingCopy {
|
||||
|
||||
private final LocalConnection fOriginal;
|
||||
|
||||
public LocalConnectionWorkingCopy(LocalConnection connection) {
|
||||
super(connection.getRemoteServices());
|
||||
fOriginal = connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#getOriginal()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection getOriginal() {
|
||||
return fOriginal;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#isDirty()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection save() {
|
||||
return fOriginal;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAddress(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAddress(String address) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAttribute(String key, String value) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPassword(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPort(int)
|
||||
*/
|
||||
@Override
|
||||
public void setPort(int port) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setUsername(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setUsername(String username) {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
|
@ -17,56 +17,56 @@ import org.eclipse.core.filesystem.IFileStore;
|
|||
import org.eclipse.core.filesystem.URIUtil;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.remote.core.IRemoteFileManager;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteFileService;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
|
||||
public class LocalFileManager implements IRemoteFileService {
|
||||
|
||||
private final IRemoteConnection connection;
|
||||
|
||||
public LocalFileManager(IRemoteConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getRemoteConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
public class LocalFileManager implements IRemoteFileManager {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteFileManager#getDirectorySeparator()
|
||||
*/
|
||||
@Override
|
||||
public String getDirectorySeparator() {
|
||||
return System.getProperty("file.separator", "/"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteFileManager#getResource(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IFileStore getResource(String path) {
|
||||
return EFS.getLocalFileSystem().getStore(new Path(path));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteFileManager#toPath(java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public String getBaseDirectory() {
|
||||
return connection.getService(IRemoteProcessService.class).getWorkingDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseDirectory(String path) {
|
||||
connection.getService(IRemoteProcessService.class).setWorkingDirectory(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPath(URI uri) {
|
||||
return URIUtil.toPath(uri).toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteFileManager#toURI(org.eclipse.core.runtime.IPath)
|
||||
*/
|
||||
@Override
|
||||
public URI toURI(IPath path) {
|
||||
return URIUtil.toURI(path);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteFileManager#toURI(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public URI toURI(String path) {
|
||||
return URIUtil.toURI(path);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnection.Service;
|
||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
|
||||
public class LocalProcessService implements IRemoteProcessService {
|
||||
|
||||
private final IRemoteConnection remoteConnection;
|
||||
private String workingDirectory;
|
||||
|
||||
public LocalProcessService(IRemoteConnection remoteConnection) {
|
||||
this.remoteConnection = remoteConnection;
|
||||
}
|
||||
|
||||
public static class Factory implements IRemoteProcessService.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnection remoteConnection, Class<T> service) {
|
||||
if (IRemoteProcessService.class.equals(service)) {
|
||||
return (T) new LocalProcessService(remoteConnection);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getRemoteConnection() {
|
||||
return remoteConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getEnv() {
|
||||
return System.getenv();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEnv(String name) {
|
||||
return System.getenv(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteProcessBuilder getProcessBuilder(List<String> command) {
|
||||
return new LocalProcessBuilder(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteProcessBuilder getProcessBuilder(String... command) {
|
||||
return new LocalProcessBuilder(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorkingDirectory() {
|
||||
if (workingDirectory == null) {
|
||||
workingDirectory = System.getProperty("user.home"); //$NON-NLS-1$
|
||||
if (workingDirectory == null) {
|
||||
workingDirectory = System.getProperty("user.dir"); //$NON-NLS-1$
|
||||
if (workingDirectory == null) {
|
||||
workingDirectory = Path.ROOT.toOSString();
|
||||
}
|
||||
}
|
||||
}
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkingDirectory(String path) {
|
||||
workingDirectory = path;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.remote.core.AbstractRemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||
|
||||
public class LocalServices extends AbstractRemoteServices {
|
||||
public static final String LocalServicesId = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
|
||||
|
||||
private final IRemoteConnectionManager fConnMgr = new LocalConnectionManager(this);
|
||||
|
||||
public LocalServices(IRemoteServicesDescriptor descriptor) {
|
||||
super(descriptor);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getCapabilities()
|
||||
*/
|
||||
@Override
|
||||
public int getCapabilities() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteServicesDescriptor#getConnectionManager
|
||||
* ()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionManager getConnectionManager() {
|
||||
return fConnMgr;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#initialize(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public boolean initialize(IProgressMonitor monitor) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||
import org.eclipse.remote.core.IRemoteServicesFactory;
|
||||
|
||||
public class LocalServicesFactory implements IRemoteServicesFactory {
|
||||
private static LocalServices services = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.remote.core.IRemoteServicesFactory#getServices(org.eclipse.remote.core.IRemoteServicesDescriptor)
|
||||
*/
|
||||
public IRemoteServices getServices(IRemoteServicesDescriptor descriptor) {
|
||||
if (services == null) {
|
||||
services = new LocalServices(descriptor);
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package org.eclipse.remote.internal.core.services.local;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.remote.internal.core.services.local.messages"; //$NON-NLS-1$
|
||||
public static String LocalConnectionProviderService_LocalConnectionName;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
LocalConnectionProviderService_LocalConnectionName=Local
|
|
@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.core.runtime,
|
|||
com.jcraft.jsch,
|
||||
org.eclipse.equinox.security
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.remote.internal.jsch.core;x-friends:="org.eclipse.remote.jsch.ui",
|
||||
Export-Package: org.eclipse.remote.internal.jsch.core;x-friends:="org.eclipse.remote.jsch.ui,org.eclipse.remote.jsch.tests",
|
||||
org.eclipse.remote.internal.jsch.core.messages;x-internal:=true
|
||||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
|
|
|
@ -3,12 +3,42 @@
|
|||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.remote.core.remoteServices">
|
||||
<remoteServices
|
||||
class="org.eclipse.remote.internal.jsch.core.JSchServicesFactory"
|
||||
<connectionType
|
||||
capabilities="31"
|
||||
id="org.eclipse.remote.JSch"
|
||||
name="Built-in SSH"
|
||||
name="SSH"
|
||||
scheme="ssh">
|
||||
</remoteServices>
|
||||
</connectionType>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.core.JSchConnection$Factory"
|
||||
service="org.eclipse.remote.core.IRemoteConnectionControlService">
|
||||
</connectionService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.core.JSchConnection$Factory"
|
||||
service="org.eclipse.remote.core.IRemotePortForwardingService">
|
||||
</connectionService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.core.JSchConnection$Factory"
|
||||
service="org.eclipse.remote.core.IRemoteConnectionPropertyService">
|
||||
</connectionService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.core.JSchConnection$Factory"
|
||||
service="org.eclipse.remote.core.IRemoteProcessService">
|
||||
</connectionService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.core.JSchFileManager$Factory"
|
||||
service="org.eclipse.remote.core.IRemoteFileService">
|
||||
</connectionService>
|
||||
<connectionService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.core.JSchConnection$Factory"
|
||||
service="org.eclipse.remote.internal.jsch.core.JSchConnection">
|
||||
</connectionService>
|
||||
</extension>
|
||||
<extension
|
||||
id="org.eclipse.remote.jsch.filesystem"
|
||||
|
|
|
@ -78,6 +78,18 @@ public class Activator extends Plugin {
|
|||
public Activator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the OSGi service with the given service interface.
|
||||
*
|
||||
* @param service service interface
|
||||
* @return the specified service or null if it's not registered
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
BundleContext context = plugin.getBundle().getBundleContext();
|
||||
ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
|
||||
public IJSchService getService() {
|
||||
return fJSchService;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.PasswordAuthentication;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -19,20 +18,19 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.jsch.core.IJSchService;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteConnectionControlService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionPropertyService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteFileManager;
|
||||
import org.eclipse.remote.core.IRemoteProcess;
|
||||
import org.eclipse.remote.core.IRemotePortForwardingService;
|
||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.IUserAuthenticator;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
import org.eclipse.remote.core.IUserAuthenticatorService;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.exception.AddressInUseException;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.core.exception.UnableToForwardPortException;
|
||||
|
@ -50,17 +48,27 @@ import com.jcraft.jsch.UserInfo;
|
|||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
public class JSchConnection implements IRemoteConnection {
|
||||
public class JSchConnection implements IRemoteConnectionControlService, IRemoteConnectionPropertyService, IRemotePortForwardingService, IRemoteProcessService {
|
||||
// Connection Type ID
|
||||
public static final String JSCH_ID = "org.eclipse.remote.JSch"; //$NON-NLS-1$
|
||||
|
||||
// Attributes
|
||||
public static final String ADDRESS_ATTR = "JSCH_ADDRESS_ATTR"; //$NON-NLS-1$
|
||||
public static final String USERNAME_ATTR = "JSCH_USERNAME_ATTR"; //$NON-NLS-1$
|
||||
public static final String PASSWORD_ATTR = "JSCH_PASSWORD_ATTR"; //$NON-NLS-1$
|
||||
public static final String PORT_ATTR = "JSCH_PORT_ATTR"; //$NON-NLS-1$
|
||||
public static final String PROXYCONNECTION_ATTR = "JSCH_PROXYCONNECTION_ATTR"; //$NON-NLS-1$
|
||||
public static final String PROXYCOMMAND_ATTR = "JSCH_PROXYCOMMAND_ATTR"; //$NON-NLS-1$
|
||||
public static final String IS_PASSWORD_ATTR = "JSCH_IS_PASSWORD_ATTR"; //$NON-NLS-1$
|
||||
public static final String PASSPHRASE_ATTR = "JSCH_PASSPHRASE_ATTR"; //$NON-NLS-1$
|
||||
public static final String TIMEOUT_ATTR = "JSCH_TIMEOUT_ATTR"; //$NON-NLS-1$
|
||||
public static final String USE_LOGIN_SHELL_ATTR = "JSCH_USE_LOGIN_SHELL_ATTR"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Class to supply credentials from connection attributes without user interaction.
|
||||
*/
|
||||
private class JSchUserInfo implements UserInfo, UIKeyboardInteractive {
|
||||
private boolean firstTryPassphrase = true;
|
||||
private final IUserAuthenticator fAuthenticator;
|
||||
|
||||
public JSchUserInfo(IUserAuthenticator authenticator) {
|
||||
fAuthenticator = authenticator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassphrase() {
|
||||
|
@ -88,11 +96,18 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
if (fAuthenticator != null) {
|
||||
String[] result = fAuthenticator.prompt(destination, name, instruction, prompt, echo);
|
||||
IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
|
||||
if (authService != null) {
|
||||
String[] result = authService.prompt(destination, name, instruction, prompt, echo);
|
||||
if (result != null) {
|
||||
if (prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
|
||||
fAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, result[0]);
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||
wc.setSecureAttribute(PASSWORD_ATTR, result[0]);
|
||||
try {
|
||||
wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
Activator.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -109,13 +124,20 @@ public class JSchConnection implements IRemoteConnection {
|
|||
firstTryPassphrase = false;
|
||||
return true;
|
||||
}
|
||||
if (fAuthenticator != null) {
|
||||
PasswordAuthentication auth = fAuthenticator.prompt(getUsername(), message);
|
||||
IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
|
||||
if (authService != null) {
|
||||
PasswordAuthentication auth = authService.prompt(getUsername(), message);
|
||||
if (auth == null) {
|
||||
return false;
|
||||
}
|
||||
fAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, auth.getUserName());
|
||||
fAttributes.setSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, new String(auth.getPassword()));
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||
wc.setAttribute(USERNAME_ATTR, auth.getUserName());
|
||||
wc.setSecureAttribute(PASSPHRASE_ATTR, new String(auth.getPassword()));
|
||||
try {
|
||||
wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
Activator.log(e.getStatus());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -126,13 +148,20 @@ public class JSchConnection implements IRemoteConnection {
|
|||
if (logging) {
|
||||
System.out.println("promptPassword:" + message); //$NON-NLS-1$
|
||||
}
|
||||
if (fAuthenticator != null) {
|
||||
PasswordAuthentication auth = fAuthenticator.prompt(getUsername(), message);
|
||||
IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
|
||||
if (authService != null) {
|
||||
PasswordAuthentication auth = authService.prompt(getUsername(), message);
|
||||
if (auth == null) {
|
||||
return false;
|
||||
}
|
||||
fAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, auth.getUserName());
|
||||
fAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, new String(auth.getPassword()));
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||
wc.setAttribute(USERNAME_ATTR, auth.getUserName());
|
||||
wc.setSecureAttribute(PASSWORD_ATTR, new String(auth.getPassword()));
|
||||
try {
|
||||
wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
Activator.log(e.getStatus());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -143,10 +172,11 @@ public class JSchConnection implements IRemoteConnection {
|
|||
if (logging) {
|
||||
System.out.println("promptYesNo:" + message); //$NON-NLS-1$
|
||||
}
|
||||
if (fAuthenticator != null) {
|
||||
int prompt = fAuthenticator.prompt(IUserAuthenticator.QUESTION, Messages.AuthInfo_Authentication_message, message,
|
||||
new int[] { IUserAuthenticator.YES, IUserAuthenticator.NO }, IUserAuthenticator.YES);
|
||||
return prompt == IUserAuthenticator.YES;
|
||||
IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
|
||||
if (authService != null) {
|
||||
int prompt = authService.prompt(IUserAuthenticatorService.QUESTION, Messages.AuthInfo_Authentication_message, message,
|
||||
new int[] { IUserAuthenticatorService.YES, IUserAuthenticatorService.NO }, IUserAuthenticatorService.YES);
|
||||
return prompt == IUserAuthenticatorService.YES;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -156,9 +186,10 @@ public class JSchConnection implements IRemoteConnection {
|
|||
if (logging) {
|
||||
System.out.println("showMessage:" + message); //$NON-NLS-1$
|
||||
}
|
||||
if (fAuthenticator != null) {
|
||||
fAuthenticator.prompt(IUserAuthenticator.INFORMATION, Messages.AuthInfo_Authentication_message, message,
|
||||
new int[] { IUserAuthenticator.OK }, IUserAuthenticator.OK);
|
||||
IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
|
||||
if (authService != null) {
|
||||
authService.prompt(IUserAuthenticatorService.INFORMATION, Messages.AuthInfo_Authentication_message, message,
|
||||
new int[] { IUserAuthenticatorService.OK }, IUserAuthenticatorService.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,35 +204,46 @@ public class JSchConnection implements IRemoteConnection {
|
|||
|
||||
private String fWorkingDir;
|
||||
|
||||
private final IRemoteConnection fRemoteConnection;
|
||||
private final IJSchService fJSchService;
|
||||
|
||||
private final JSchConnectionAttributes fAttributes;
|
||||
private final JSchConnectionManager fManager;
|
||||
private final Map<String, String> fEnv = new HashMap<String, String>();
|
||||
private final Map<String, String> fProperties = new HashMap<String, String>();
|
||||
private final IRemoteServices fRemoteServices;
|
||||
private final ListenerList fListeners = new ListenerList();
|
||||
private final List<Session> fSessions = new ArrayList<Session>();
|
||||
|
||||
private ChannelSftp fSftpChannel;
|
||||
private boolean isFullySetup; // including sftp channel and environment
|
||||
|
||||
public JSchConnection(String name, IRemoteServices services) {
|
||||
fRemoteServices = services;
|
||||
fManager = (JSchConnectionManager) services.getConnectionManager();
|
||||
fAttributes = new JSchConnectionAttributes(name);
|
||||
public JSchConnection(IRemoteConnection connection) {
|
||||
fRemoteConnection = connection;
|
||||
fJSchService = Activator.getDefault().getService();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#addConnectionChangeListener
|
||||
* (org.eclipse.remote.core.IRemoteConnectionChangeListener)
|
||||
*/
|
||||
@Override
|
||||
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
fListeners.add(listener);
|
||||
public IRemoteConnection getRemoteConnection() {
|
||||
return fRemoteConnection;
|
||||
}
|
||||
|
||||
public static class Factory implements IRemoteConnection.Service.Factory {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends IRemoteConnection.Service> T getService(IRemoteConnection connection, Class<T> service) {
|
||||
// This little trick creates an instance of this class for a connection
|
||||
// then for each interface it implements, it returns the same object.
|
||||
// This works because the connection caches the service so only one gets created.
|
||||
// As a side effect, it makes this class a service too which can be used
|
||||
// by the this plug-in
|
||||
if (JSchConnection.class.equals(service)) {
|
||||
return (T) new JSchConnection(connection);
|
||||
} else if (IRemoteConnectionControlService.class.equals(service)
|
||||
|| IRemoteConnectionPropertyService.class.equals(service)
|
||||
|| IRemotePortForwardingService.class.equals(service)
|
||||
|| IRemoteProcessService.class.equals(service)) {
|
||||
return (T) connection.getService(JSchConnection.class);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkConfiguration(Session session, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
|
@ -237,19 +279,14 @@ public class JSchConnection implements IRemoteConnection {
|
|||
* @throws RemoteConnectionException
|
||||
*/
|
||||
private void checkIsConfigured() throws RemoteConnectionException {
|
||||
if (fAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, null) == null) {
|
||||
if (fRemoteConnection.getAttribute(ADDRESS_ATTR) == null) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnection_remote_address_must_be_set);
|
||||
}
|
||||
if (fAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, null) == null) {
|
||||
if (fRemoteConnection.getAttribute(USERNAME_ATTR) == null) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnection_username_must_be_set);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#close()
|
||||
*/
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (fSftpChannel != null) {
|
||||
|
@ -264,17 +301,7 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
fSessions.clear();
|
||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(IRemoteConnection o) {
|
||||
return getName().compareTo(o.getName());
|
||||
fRemoteConnection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -293,35 +320,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
return exec.setCommand(cmd).getResult(monitor).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify all fListeners when this connection's status changes.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@Override
|
||||
public void fireConnectionChangeEvent(final int type) {
|
||||
final IRemoteConnection connection = this;
|
||||
IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
|
||||
@Override
|
||||
public IRemoteConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
};
|
||||
for (Object listener : fListeners.getListeners()) {
|
||||
((IRemoteConnectionChangeListener) listener).connectionChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(int, java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
|
||||
if (!isOpen()) {
|
||||
|
@ -334,12 +332,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(java.lang .String, int,
|
||||
* org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
if (!isOpen()) {
|
||||
|
@ -370,11 +362,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(int, java.lang.String, int)
|
||||
*/
|
||||
@Override
|
||||
public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
|
||||
if (!isOpen()) {
|
||||
|
@ -387,12 +374,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(java.lang.String, int,
|
||||
* org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
if (!isOpen()) {
|
||||
|
@ -422,34 +403,8 @@ public class JSchConnection implements IRemoteConnection {
|
|||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getAddress()
|
||||
*/
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return fAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return Collections.unmodifiableMap(fAttributes.getAttributes());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getCommandShell(int)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcess getCommandShell(int flags) throws IOException {
|
||||
throw new IOException("Not currently implemented"); //$NON-NLS-1$
|
||||
return fRemoteConnection.getAttribute(ADDRESS_ATTR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -467,21 +422,11 @@ public class JSchConnection implements IRemoteConnection {
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getEnv()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getEnv() {
|
||||
return Collections.unmodifiableMap(fEnv);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getEnv(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public String getEnv(String name) {
|
||||
return getEnv().get(name);
|
||||
|
@ -503,89 +448,41 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getFileManager()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteFileManager getFileManager() {
|
||||
return new JSchFileManager(this);
|
||||
}
|
||||
|
||||
public JSchConnectionAttributes getInfo() {
|
||||
return fAttributes;
|
||||
}
|
||||
|
||||
public JSchConnectionManager getManager() {
|
||||
return fManager;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fAttributes.getName();
|
||||
}
|
||||
|
||||
public String getPassphrase() {
|
||||
return fAttributes.getSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, EMPTY_STRING);
|
||||
return fRemoteConnection.getSecureAttribute(PASSPHRASE_ATTR);
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return fAttributes.getSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, EMPTY_STRING);
|
||||
return fRemoteConnection.getSecureAttribute(PASSWORD_ATTR);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getPort()
|
||||
*/
|
||||
@Override
|
||||
public int getPort() {
|
||||
return fAttributes.getInt(JSchConnectionAttributes.PORT_ATTR, DEFAULT_PORT);
|
||||
String portStr = fRemoteConnection.getAttribute(PORT_ATTR);
|
||||
return portStr != null ? Integer.parseInt(portStr) : DEFAULT_PORT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.util.List)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcessBuilder getProcessBuilder(List<String> command) {
|
||||
return new JSchProcessBuilder(this, command);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcessBuilder getProcessBuilder(String... command) {
|
||||
return new JSchProcessBuilder(this, command);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getProperty(java.lang.String )
|
||||
*/
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
return fProperties.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the proxy command. For no proxy command an empty string is returned.
|
||||
* Gets the proxy command. For no proxy command null is returned.
|
||||
*
|
||||
* @return proxy command
|
||||
*/
|
||||
public String getProxyCommand() {
|
||||
return fAttributes.getAttribute(JSchConnectionAttributes.PROXYCOMMAND_ATTR, EMPTY_STRING);
|
||||
return fRemoteConnection.getAttribute(PROXYCOMMAND_ATTR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -595,29 +492,19 @@ public class JSchConnection implements IRemoteConnection {
|
|||
*/
|
||||
public JSchConnection getProxyConnection() {
|
||||
String proxyConnectionName = getProxyConnectionName();
|
||||
if (proxyConnectionName.equals(EMPTY_STRING)) {
|
||||
if (proxyConnectionName.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return (JSchConnection) fManager.getConnection(proxyConnectionName);
|
||||
return fRemoteConnection.getConnectionType().getConnection(proxyConnectionName).getService(JSchConnection.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the proxy connection name
|
||||
*
|
||||
* @return proxy connection name. If no proxy is used returns an empty string. Never returns null.
|
||||
* @return proxy connection name. If no proxy is used returns null.
|
||||
*/
|
||||
public String getProxyConnectionName() {
|
||||
return fAttributes.getAttribute(JSchConnectionAttributes.PROXYCONNECTION_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getRemoteServices()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteServices getRemoteServices() {
|
||||
return fRemoteServices;
|
||||
return fRemoteConnection.getAttribute(PROXYCONNECTION_ATTR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -641,11 +528,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
return fSftpChannel;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.jcraft.jsch.Session#getStreamForwarder(java.lang.String, int)
|
||||
*/
|
||||
public Channel getStreamForwarder(String host, int port) throws RemoteConnectionException
|
||||
{
|
||||
try {
|
||||
|
@ -658,34 +540,14 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
|
||||
public int getTimeout() {
|
||||
return fAttributes.getInt(JSchConnectionAttributes.TIMEOUT_ATTR, DEFAULT_TIMEOUT);
|
||||
String str = fRemoteConnection.getAttribute(TIMEOUT_ATTR);
|
||||
return str != null ? Integer.parseInt(str) : DEFAULT_TIMEOUT;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getUsername()
|
||||
*/
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return fAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, EMPTY_STRING);
|
||||
return fRemoteConnection.getAttribute(USERNAME_ATTR);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||
return new JSchConnectionWorkingCopy(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingDirectory()
|
||||
*/
|
||||
@Override
|
||||
public String getWorkingDirectory() {
|
||||
if (!isOpen()) {
|
||||
|
@ -715,18 +577,14 @@ public class JSchConnection implements IRemoteConnection {
|
|||
return hasOpenSession;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#isOpen()
|
||||
*/
|
||||
@Override
|
||||
public boolean isOpen() {
|
||||
return hasOpenSession() && isFullySetup;
|
||||
}
|
||||
|
||||
public boolean isPasswordAuth() {
|
||||
return fAttributes.getBoolean(JSchConnectionAttributes.IS_PASSWORD_ATTR, DEFAULT_IS_PASSWORD);
|
||||
String str = fRemoteConnection.getAttribute(IS_PASSWORD_ATTR);
|
||||
return str != null ? Boolean.parseBoolean(str) : DEFAULT_IS_PASSWORD;
|
||||
}
|
||||
|
||||
private void loadEnv(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
|
@ -793,10 +651,10 @@ public class JSchConnection implements IRemoteConnection {
|
|||
*/
|
||||
private void loadProperties(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
SubMonitor subMon = SubMonitor.convert(monitor, 100);
|
||||
fProperties.put(FILE_SEPARATOR_PROPERTY, "/"); //$NON-NLS-1$
|
||||
fProperties.put(PATH_SEPARATOR_PROPERTY, ":"); //$NON-NLS-1$
|
||||
fProperties.put(LINE_SEPARATOR_PROPERTY, "\n"); //$NON-NLS-1$
|
||||
fProperties.put(USER_HOME_PROPERTY, getWorkingDirectory());
|
||||
fProperties.put(IRemoteConnection.FILE_SEPARATOR_PROPERTY, "/"); //$NON-NLS-1$
|
||||
fProperties.put(IRemoteConnection.PATH_SEPARATOR_PROPERTY, ":"); //$NON-NLS-1$
|
||||
fProperties.put(IRemoteConnection.LINE_SEPARATOR_PROPERTY, "\n"); //$NON-NLS-1$
|
||||
fProperties.put(IRemoteConnection.USER_HOME_PROPERTY, getWorkingDirectory());
|
||||
|
||||
String osVersion;
|
||||
String osArch;
|
||||
|
@ -830,26 +688,26 @@ public class JSchConnection implements IRemoteConnection {
|
|||
osVersion = "unknown"; //$NON-NLS-1$
|
||||
osArch = "unknown"; //$NON-NLS-1$
|
||||
}
|
||||
fProperties.put(OS_NAME_PROPERTY, osName);
|
||||
fProperties.put(OS_VERSION_PROPERTY, osVersion);
|
||||
fProperties.put(OS_ARCH_PROPERTY, osArch);
|
||||
fProperties.put(IRemoteConnection.OS_NAME_PROPERTY, osName);
|
||||
fProperties.put(IRemoteConnection.OS_VERSION_PROPERTY, osVersion);
|
||||
fProperties.put(IRemoteConnection.OS_ARCH_PROPERTY, osArch);
|
||||
}
|
||||
|
||||
private Session newSession(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
private Session newSession(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
SubMonitor progress = SubMonitor.convert(monitor, 10);
|
||||
try {
|
||||
Session session = fJSchService.createSession(getAddress(), getPort(), getUsername());
|
||||
session.setUserInfo(new JSchUserInfo(authenticator));
|
||||
session.setUserInfo(new JSchUserInfo());
|
||||
if (isPasswordAuth()) {
|
||||
session.setConfig("PreferredAuthentications", "password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
session.setPassword(getPassword());
|
||||
} else {
|
||||
session.setConfig("PreferredAuthentications", "publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
if (getProxyCommand().equals(EMPTY_STRING) && getProxyConnectionName().equals(EMPTY_STRING)) {
|
||||
if (getProxyCommand().isEmpty() && getProxyConnectionName().isEmpty()) {
|
||||
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10)); // connect without proxy
|
||||
} else {
|
||||
if (getProxyCommand().equals(EMPTY_STRING)) {
|
||||
if (getProxyCommand().isEmpty()) {
|
||||
session.setProxy(JSchConnectionProxyFactory.createForwardProxy(getProxyConnection(),
|
||||
progress.newChild(10)));
|
||||
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10));
|
||||
|
@ -869,11 +727,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#open()
|
||||
*/
|
||||
@Override
|
||||
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
open(monitor, true);
|
||||
|
@ -903,7 +756,7 @@ public class JSchConnection implements IRemoteConnection {
|
|||
SubMonitor subMon = SubMonitor.convert(monitor, 60);
|
||||
if (!hasOpenSession()) {
|
||||
checkIsConfigured();
|
||||
newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
|
||||
newSession(subMon.newChild(10));
|
||||
if (subMon.isCanceled()) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled);
|
||||
}
|
||||
|
@ -914,11 +767,11 @@ public class JSchConnection implements IRemoteConnection {
|
|||
// getCwd checks the exec channel before checkConfiguration checks the sftp channel
|
||||
fWorkingDir = getCwd(subMon.newChild(10));
|
||||
if (!checkConfiguration(fSessions.get(0), subMon.newChild(20))) {
|
||||
newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
|
||||
newSession(subMon.newChild(10));
|
||||
loadEnv(subMon.newChild(10));
|
||||
}
|
||||
loadProperties(subMon.newChild(10));
|
||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
|
||||
fRemoteConnection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_OPENED);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -932,22 +785,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#removeConnectionChangeListener
|
||||
* (org.eclipse.remote.core.IRemoteConnectionChangeListener)
|
||||
*/
|
||||
@Override
|
||||
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
|
||||
fListeners.remove(listener);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#removeLocalPortForwarding(int)
|
||||
*/
|
||||
@Override
|
||||
public void removeLocalPortForwarding(int port) throws RemoteConnectionException {
|
||||
if (!isOpen()) {
|
||||
|
@ -960,11 +797,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#removeRemotePortForwarding(int)
|
||||
*/
|
||||
@Override
|
||||
public void removeRemotePortForwarding(int port) throws RemoteConnectionException {
|
||||
if (!isOpen()) {
|
||||
|
@ -977,11 +809,6 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#setWorkingDirectory(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setWorkingDirectory(String path) {
|
||||
if (new Path(path).isAbsolute()) {
|
||||
|
@ -989,31 +816,9 @@ public class JSchConnection implements IRemoteConnection {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#supportsTCPPortForwarding()
|
||||
*/
|
||||
@Override
|
||||
public boolean supportsTCPPortForwarding() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String str = getName() + " [" + getUsername() + "@" + getAddress(); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (getPort() >= 0) {
|
||||
str += ":" + getPort(); //$NON-NLS-1$
|
||||
}
|
||||
return str + "]"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public boolean useLoginShell() {
|
||||
return fAttributes.getBoolean(JSchConnectionAttributes.USE_LOGIN_SHELL_ATTR, DEFAULT_USE_LOGIN_SHELL);
|
||||
String str = fRemoteConnection.getAttribute(USE_LOGIN_SHELL_ATTR);
|
||||
return !str.isEmpty() ? Boolean.parseBoolean(str) : DEFAULT_USE_LOGIN_SHELL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,236 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013, 2014 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
* Markus Schorn - Bug 449306: Unnecessary access to secure storage.
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.equinox.security.storage.ISecurePreferences;
|
||||
import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
|
||||
import org.eclipse.equinox.security.storage.StorageException;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class JSchConnectionAttributes {
|
||||
public static final String CONNECTIONS_KEY = "connections"; //$NON-NLS-1$
|
||||
|
||||
public static final String ADDRESS_ATTR = "JSCH_ADDRESS_ATTR"; //$NON-NLS-1$
|
||||
public static final String USERNAME_ATTR = "JSCH_USERNAME_ATTR"; //$NON-NLS-1$
|
||||
public static final String PASSWORD_ATTR = "JSCH_PASSWORD_ATTR"; //$NON-NLS-1$
|
||||
public static final String PORT_ATTR = "JSCH_PORT_ATTR"; //$NON-NLS-1$
|
||||
public static final String PROXYCONNECTION_ATTR = "JSCH_PROXYCONNECTION_ATTR"; //$NON-NLS-1$
|
||||
public static final String PROXYCOMMAND_ATTR = "JSCH_PROXYCOMMAND_ATTR"; //$NON-NLS-1$
|
||||
public static final String IS_PASSWORD_ATTR = "JSCH_IS_PASSWORD_ATTR"; //$NON-NLS-1$
|
||||
public static final String PASSPHRASE_ATTR = "JSCH_PASSPHRASE_ATTR"; //$NON-NLS-1$
|
||||
public static final String TIMEOUT_ATTR = "JSCH_TIMEOUT_ATTR"; //$NON-NLS-1$
|
||||
public static final String USE_LOGIN_SHELL_ATTR = "JSCH_USE_LOGIN_SHELL_ATTR"; //$NON-NLS-1$
|
||||
|
||||
private String fName;
|
||||
private String fNewName;
|
||||
|
||||
private final Map<String, String> fAttributes = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
private final Map<String, String> fSecureAttributes = Collections.synchronizedMap(new HashMap<String, String>());
|
||||
|
||||
private boolean fSecureAttributesLoaded;
|
||||
|
||||
public JSchConnectionAttributes(String name) {
|
||||
fName = name;
|
||||
load();
|
||||
}
|
||||
|
||||
private void clearPreferences() {
|
||||
try {
|
||||
getPreferences().clear();
|
||||
} catch (BackingStoreException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
getSecurePreferences().clear();
|
||||
}
|
||||
|
||||
public JSchConnectionAttributes copy() {
|
||||
JSchConnectionAttributes copy = new JSchConnectionAttributes(fName);
|
||||
copy.getAttributes().putAll(fAttributes);
|
||||
copy.setSecureAttributes(getSecureAttributes());
|
||||
return copy;
|
||||
}
|
||||
|
||||
private void flushPreferences() {
|
||||
try {
|
||||
getPreferences().flush();
|
||||
} catch (BackingStoreException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
try {
|
||||
getSecurePreferences().flush();
|
||||
} catch (IOException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String getAttribute(String key, String def) {
|
||||
if (fAttributes.containsKey(key)) {
|
||||
return fAttributes.get(key);
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public Map<String, String> getAttributes() {
|
||||
return fAttributes;
|
||||
}
|
||||
|
||||
public boolean getBoolean(String key, boolean def) {
|
||||
if (fAttributes.containsKey(key)) {
|
||||
return Boolean.parseBoolean(fAttributes.get(key));
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public int getInt(String key, int def) {
|
||||
try {
|
||||
return Integer.parseInt(fAttributes.get(key));
|
||||
} catch (NumberFormatException e) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (fNewName == null) {
|
||||
return fName;
|
||||
}
|
||||
return fNewName;
|
||||
}
|
||||
|
||||
private Preferences getPreferences() {
|
||||
IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
|
||||
Preferences connections = root.node(CONNECTIONS_KEY);
|
||||
return connections.node(fName);
|
||||
}
|
||||
|
||||
public String getSecureAttribute(String key, String def) {
|
||||
loadSecureAttributes();
|
||||
if (fSecureAttributes.containsKey(key)) {
|
||||
return fSecureAttributes.get(key);
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
public Map<String, String> getSecureAttributes() {
|
||||
loadSecureAttributes();
|
||||
return fSecureAttributes;
|
||||
}
|
||||
|
||||
void setSecureAttributes(Map<String, String> secureAttributes) {
|
||||
fSecureAttributes.clear();
|
||||
fSecureAttributes.putAll(secureAttributes);
|
||||
fSecureAttributesLoaded = true;
|
||||
}
|
||||
|
||||
private ISecurePreferences getSecurePreferences() {
|
||||
ISecurePreferences secRoot = SecurePreferencesFactory.getDefault();
|
||||
ISecurePreferences secConnections = secRoot.node(CONNECTIONS_KEY);
|
||||
return secConnections.node(fName);
|
||||
}
|
||||
|
||||
private void load() {
|
||||
IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
|
||||
Preferences connections = root.node(CONNECTIONS_KEY);
|
||||
Preferences nodes = connections.node(fName);
|
||||
try {
|
||||
loadAttributes(nodes);
|
||||
} catch (BackingStoreException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
fSecureAttributesLoaded = false;
|
||||
}
|
||||
|
||||
private void loadAttributes(Preferences node) throws BackingStoreException {
|
||||
fAttributes.clear();
|
||||
for (String key : node.keys()) {
|
||||
fAttributes.put(key, node.get(key, null));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSecureAttributes() {
|
||||
if (fSecureAttributesLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
ISecurePreferences secNode = getSecurePreferences();
|
||||
try {
|
||||
fSecureAttributes.clear();
|
||||
for (String key : secNode.keys()) {
|
||||
fSecureAttributes.put(key, secNode.get(key, null));
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
fSecureAttributesLoaded = true;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
clearPreferences();
|
||||
flushPreferences();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
clearPreferences();
|
||||
if (fNewName != null) {
|
||||
fName = fNewName;
|
||||
fNewName = null;
|
||||
}
|
||||
savePreferences();
|
||||
flushPreferences();
|
||||
}
|
||||
|
||||
private void savePreferences() {
|
||||
Preferences node = getPreferences();
|
||||
synchronized (fAttributes) {
|
||||
for (Entry<String, String> entry : fAttributes.entrySet()) {
|
||||
if (entry.getValue() != null) {
|
||||
node.put(entry.getKey(), entry.getValue());
|
||||
} else {
|
||||
node.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fSecureAttributesLoaded) {
|
||||
try {
|
||||
ISecurePreferences secNode = getSecurePreferences();
|
||||
synchronized (fSecureAttributes) {
|
||||
for (Entry<String, String> entry : fSecureAttributes.entrySet()) {
|
||||
secNode.put(entry.getKey(), entry.getValue(), true);
|
||||
}
|
||||
}
|
||||
} catch (StorageException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setAttribute(String key, String value) {
|
||||
fAttributes.put(key, value);
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
fNewName = name;
|
||||
}
|
||||
|
||||
public void setSecureAttribute(String key, String value) {
|
||||
loadSecureAttributes();
|
||||
fSecureAttributes.put(key, value);
|
||||
}
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.core;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.AbstractRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.jsch.core.messages.Messages;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
import org.osgi.service.prefs.Preferences;
|
||||
|
||||
public class JSchConnectionManager extends AbstractRemoteConnectionManager {
|
||||
private Map<String, JSchConnection> fConnections;
|
||||
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
public JSchConnectionManager(IRemoteServices services) {
|
||||
super(services);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
|
||||
* .lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection getConnection(String name) {
|
||||
loadConnections();
|
||||
return fConnections.get(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
|
||||
* .net.URI)
|
||||
*/
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection getConnection(URI uri) {
|
||||
String connName = JSchFileSystem.getConnectionNameFor(uri);
|
||||
if (connName != null) {
|
||||
return getConnection(connName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public JSchConnection createConnection(String name) {
|
||||
return new JSchConnection(name, getRemoteServices());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
|
||||
*/
|
||||
@Override
|
||||
public List<IRemoteConnection> getConnections() {
|
||||
loadConnections();
|
||||
List<IRemoteConnection> conns = new ArrayList<IRemoteConnection>();
|
||||
conns.addAll(fConnections.values());
|
||||
return conns;
|
||||
}
|
||||
|
||||
private synchronized void loadConnections() {
|
||||
if (fConnections == null) {
|
||||
fConnections = Collections.synchronizedMap(new HashMap<String, JSchConnection>());
|
||||
IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
|
||||
Preferences connections = root.node(JSchConnectionAttributes.CONNECTIONS_KEY);
|
||||
try {
|
||||
for (String name : connections.childrenNames()) {
|
||||
JSchConnection connection = new JSchConnection(name, getRemoteServices());
|
||||
fConnections.put(name, connection);
|
||||
}
|
||||
} catch (BackingStoreException e) {
|
||||
Activator.log(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#newConnection(java
|
||||
* .lang.String, java.util.Map)
|
||||
*/
|
||||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
|
||||
if (getConnection(name) != null) {
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.JSchConnectionManager_connection_with_name_exists, name));
|
||||
}
|
||||
return createConnection(name).getWorkingCopy();
|
||||
}
|
||||
|
||||
public void add(JSchConnection conn) {
|
||||
if (!fConnections.containsKey(conn.getName())) {
|
||||
fConnections.put(conn.getName(), conn);
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(JSchConnection conn) {
|
||||
if (fConnections.containsKey(conn.getName())) {
|
||||
fConnections.remove(conn.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteConnectionManager#removeConnection
|
||||
* (org.eclipse.remote.core.IRemoteConnection)
|
||||
*/
|
||||
@Override
|
||||
public void removeConnection(IRemoteConnection conn) throws RemoteConnectionException {
|
||||
if (!(conn instanceof JSchConnection)) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnectionManager_invalidConnectionType);
|
||||
}
|
||||
if (conn.isOpen()) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnectionManager_cannotRemoveOpenConnection);
|
||||
}
|
||||
((JSchConnection) conn).getInfo().remove();
|
||||
fConnections.remove(conn.getName());
|
||||
}
|
||||
}
|
|
@ -24,9 +24,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteProcess;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.jsch.core.messages.Messages;
|
||||
|
||||
|
@ -113,8 +114,9 @@ public class JSchConnectionProxyFactory {
|
|||
}
|
||||
} else {
|
||||
List<String> cmd = new ArgumentParser(command).getTokenList();
|
||||
process = RemoteServices.getLocalServices().getConnectionManager().getConnection(
|
||||
IRemoteConnectionManager.LOCAL_CONNECTION_NAME).getProcessBuilder(cmd).start();
|
||||
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnection connection = manager.getLocalConnectionType().getConnections().get(0);
|
||||
process = connection.getService(IRemoteProcessService.class).getProcessBuilder(cmd).start();
|
||||
}
|
||||
|
||||
// Wait on command to produce stdout output
|
||||
|
|
|
@ -1,310 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2010, 2014 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
* Markus Schorn - Bug 449306: Unnecessary access to secure storage.
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.core;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
||||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
public class JSchConnectionWorkingCopy extends JSchConnection implements IRemoteConnectionWorkingCopy {
|
||||
private final JSchConnectionAttributes fWorkingAttributes;
|
||||
private final JSchConnection fOriginal;
|
||||
private boolean fIsDirty;
|
||||
|
||||
public JSchConnectionWorkingCopy(JSchConnection connection) {
|
||||
super(connection.getName(), connection.getRemoteServices());
|
||||
fWorkingAttributes = connection.getInfo().copy();
|
||||
fOriginal = connection;
|
||||
fIsDirty = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getAddress()
|
||||
*/
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return fWorkingAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return Collections.unmodifiableMap(fWorkingAttributes.getAttributes());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fWorkingAttributes.getName();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#getOriginal()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection getOriginal() {
|
||||
return fOriginal;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.internal.jsch.core.JSchConnection#getPassphrase()
|
||||
*/
|
||||
@Override
|
||||
public String getPassphrase() {
|
||||
return fWorkingAttributes.getSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.internal.jsch.core.JSchConnection#getPassword()
|
||||
*/
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return fWorkingAttributes.getSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getPort()
|
||||
*/
|
||||
@Override
|
||||
public int getPort() {
|
||||
return fWorkingAttributes.getInt(JSchConnectionAttributes.PORT_ATTR, DEFAULT_PORT);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.internal.jsch.core.JSchConnection#getProxyCommand()
|
||||
*/
|
||||
@Override
|
||||
public String getProxyCommand() {
|
||||
return fWorkingAttributes.getAttribute(JSchConnectionAttributes.PROXYCOMMAND_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.internal.jsch.core.JSchConnection#getProxyConnectionName()
|
||||
*/
|
||||
@Override
|
||||
public String getProxyConnectionName() {
|
||||
return fWorkingAttributes.getAttribute(JSchConnectionAttributes.PROXYCONNECTION_ATTR, EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.internal.jsch.core.JSchConnection#getTimeout()
|
||||
*/
|
||||
@Override
|
||||
public int getTimeout() {
|
||||
return fWorkingAttributes.getInt(JSchConnectionAttributes.TIMEOUT_ATTR, DEFAULT_TIMEOUT);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getUsername()
|
||||
*/
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return fWorkingAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, JSchConnection.EMPTY_STRING);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#isDirty()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return fIsDirty;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.internal.jsch.core.JSchConnection#isPasswordAuth()
|
||||
*/
|
||||
@Override
|
||||
public boolean isPasswordAuth() {
|
||||
return fWorkingAttributes.getBoolean(JSchConnectionAttributes.IS_PASSWORD_ATTR, DEFAULT_IS_PASSWORD);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection save() {
|
||||
JSchConnectionAttributes info = fOriginal.getInfo();
|
||||
info.getAttributes().clear();
|
||||
info.getAttributes().putAll(fWorkingAttributes.getAttributes());
|
||||
info.setSecureAttributes(fWorkingAttributes.getSecureAttributes());
|
||||
if (!getName().equals(info.getName())) {
|
||||
info.setName(getName());
|
||||
getManager().remove(fOriginal);
|
||||
fOriginal.fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_RENAMED);
|
||||
}
|
||||
info.save();
|
||||
getManager().add(fOriginal);
|
||||
fIsDirty = false;
|
||||
return fOriginal;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAddress(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAddress(String address) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.ADDRESS_ATTR, address);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setAttribute(String key, String value) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(key, value);
|
||||
}
|
||||
|
||||
public void setIsPasswordAuth(boolean flag) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.IS_PASSWORD_ATTR, Boolean.toString(flag));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setName(name);
|
||||
}
|
||||
|
||||
public void setPassphrase(String passphrase) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, passphrase);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPassword(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, password);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPort(int)
|
||||
*/
|
||||
@Override
|
||||
public void setPort(int port) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy command. Set to empty string for no command
|
||||
*
|
||||
* @param proxyCommand
|
||||
* proxy command
|
||||
*/
|
||||
public void setProxyCommand(String proxyCommand) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.PROXYCOMMAND_ATTR, proxyCommand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy connection name. Set to empty string for no proxy connection
|
||||
*
|
||||
* @param proxyCommand
|
||||
* proxy connection name
|
||||
*/
|
||||
public void setProxyConnectionName(String proxyConnectionName) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.PROXYCONNECTION_ATTR, proxyConnectionName);
|
||||
}
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.TIMEOUT_ATTR, Integer.toString(timeout));
|
||||
}
|
||||
|
||||
public void setUseLoginShell(boolean flag) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.USE_LOGIN_SHELL_ATTR, Boolean.toString(flag));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setUsername(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void setUsername(String userName) {
|
||||
fIsDirty = true;
|
||||
fWorkingAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, userName);
|
||||
}
|
||||
}
|
|
@ -15,62 +15,64 @@ import java.net.URI;
|
|||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.remote.core.IRemoteFileManager;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteFileService;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
import org.eclipse.remote.core.IRemoteConnection.Service;
|
||||
|
||||
public class JSchFileManager implements IRemoteFileManager {
|
||||
private final JSchConnection fConnection;
|
||||
public class JSchFileManager implements IRemoteFileService {
|
||||
|
||||
public JSchFileManager(JSchConnection connection) {
|
||||
private final IRemoteConnection fConnection;
|
||||
|
||||
public JSchFileManager(IRemoteConnection connection) {
|
||||
fConnection = connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteFileManager#getDirectorySeparator()
|
||||
*/
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
public static class Factory implements IRemoteFileService.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnection remoteConnection, Class<T> service) {
|
||||
if (IRemoteFileService.class.equals(service)) {
|
||||
return (T) new JSchFileManager(remoteConnection);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getRemoteConnection() {
|
||||
return fConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDirectorySeparator() {
|
||||
return "/"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteFileManager#getResource(java.lang.
|
||||
* String)
|
||||
*/
|
||||
@Override
|
||||
public IFileStore getResource(String pathStr) {
|
||||
IPath path = new Path(pathStr);
|
||||
if (!path.isAbsolute()) {
|
||||
path = new Path(fConnection.getWorkingDirectory()).append(path);
|
||||
path = new Path(getBaseDirectory()).append(path);
|
||||
}
|
||||
return JschFileStore.getInstance(JSchFileSystem.getURIFor(fConnection.getName(), path.toString()));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteFileManager#toPath(java.net.URI)
|
||||
*/
|
||||
@Override
|
||||
public String getBaseDirectory() {
|
||||
return fConnection.getService(IRemoteProcessService.class).getWorkingDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseDirectory(String path) {
|
||||
fConnection.getService(IRemoteProcessService.class).setWorkingDirectory(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toPath(URI uri) {
|
||||
return uri.getPath();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteFileManager#toURI(org.eclipse.core
|
||||
* .runtime.IPath)
|
||||
*/
|
||||
@Override
|
||||
public URI toURI(IPath path) {
|
||||
try {
|
||||
|
@ -80,14 +82,9 @@ public class JSchFileManager implements IRemoteFileManager {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteFileManager#toURI(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public URI toURI(String path) {
|
||||
return toURI(new Path(path));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.remote.core.AbstractRemoteProcessBuilder;
|
||||
import org.eclipse.remote.core.IRemoteFileManager;
|
||||
import org.eclipse.remote.core.IRemoteFileService;
|
||||
import org.eclipse.remote.core.IRemoteProcess;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.core.RemoteDebugOptions;
|
||||
|
@ -34,15 +34,13 @@ import com.jcraft.jsch.ChannelExec;
|
|||
import com.jcraft.jsch.JSchException;
|
||||
|
||||
public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
|
||||
|
||||
private final JSchConnection fConnection;
|
||||
private final Map<String, String> fRemoteEnv = new HashMap<String, String>();
|
||||
private final Set<Character> charSet = new HashSet<Character>();
|
||||
|
||||
private Map<String, String> fNewRemoteEnv = null;
|
||||
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
public JSchProcessBuilder(JSchConnection connection, List<String> command) {
|
||||
super(command);
|
||||
fConnection = connection;
|
||||
|
@ -58,34 +56,21 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.0
|
||||
*/
|
||||
public JSchProcessBuilder(JSchConnection connection, String... command) {
|
||||
this(connection, Arrays.asList(command));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.AbstractRemoteProcessBuilder#directory()
|
||||
*/
|
||||
@Override
|
||||
public IFileStore directory() {
|
||||
IFileStore dir = super.directory();
|
||||
IRemoteFileManager fileMgr = fConnection.getFileManager();
|
||||
if (dir == null && fileMgr != null) {
|
||||
dir = fileMgr.getResource(fConnection.getWorkingDirectory());
|
||||
IRemoteFileService fileService = fConnection.getRemoteConnection().getService(IRemoteFileService.class);
|
||||
if (dir == null && fileService != null) {
|
||||
dir = fileService.getResource(fConnection.getWorkingDirectory());
|
||||
directory(dir);
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.AbstractRemoteProcessBuilder#environment()
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> environment() {
|
||||
if (fNewRemoteEnv == null) {
|
||||
|
@ -95,21 +80,11 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
|
|||
return fNewRemoteEnv;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.AbstractRemoteProcessBuilder#getSupportedFlags ()
|
||||
*/
|
||||
@Override
|
||||
public int getSupportedFlags() {
|
||||
return ALLOCATE_PTY | FORWARD_X11;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteProcessBuilder#start(int)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteProcess start(int flags) throws IOException {
|
||||
if (!fConnection.isOpen()) {
|
||||
|
@ -234,4 +209,5 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
|
|||
inputString = newString.toString();
|
||||
return inputString;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.core;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.remote.core.AbstractRemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||
|
||||
public class JSchServices extends AbstractRemoteServices {
|
||||
public static final String JSCH_ID = "org.eclipse.remote.JSch"; //$NON-NLS-1$
|
||||
|
||||
private final JSchConnectionManager connMgr = new JSchConnectionManager(this);
|
||||
|
||||
public JSchServices(IRemoteServicesDescriptor descriptor) {
|
||||
super(descriptor);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteServicesDescriptor#getConnectionManager
|
||||
* ()
|
||||
*/
|
||||
public IRemoteConnectionManager getConnectionManager() {
|
||||
return connMgr;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#initialize(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public boolean initialize(IProgressMonitor monitor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCapabilities() {
|
||||
return CAPABILITY_ADD_CONNECTIONS | CAPABILITY_EDIT_CONNECTIONS | CAPABILITY_REMOVE_CONNECTIONS
|
||||
| CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING | CAPABILITY_SUPPORTS_X11_FORWARDING;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.core;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||
import org.eclipse.remote.core.IRemoteServicesFactory;
|
||||
|
||||
public class JSchServicesFactory implements IRemoteServicesFactory {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServicesFactory#getServices(org.eclipse.remote.core.IRemoteServicesDescriptor)
|
||||
*/
|
||||
public IRemoteServices getServices(IRemoteServicesDescriptor descriptor) {
|
||||
return new JSchServices(descriptor);
|
||||
}
|
||||
}
|
|
@ -30,9 +30,8 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.core.runtime.SubMonitor;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.jsch.core.commands.ChildInfosCommand;
|
||||
import org.eclipse.remote.internal.jsch.core.commands.DeleteCommand;
|
||||
|
@ -73,24 +72,27 @@ public class JschFileStore extends FileStore {
|
|||
}
|
||||
|
||||
private JSchConnection checkConnection(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||
IRemoteServices services = RemoteServices.getRemoteServices(fURI);
|
||||
assert (services instanceof JSchServices);
|
||||
if (services == null) {
|
||||
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType connectionType = manager.getConnectionType(fURI);
|
||||
if (connectionType == null) {
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_No_remote_services_found_for_URI, fURI));
|
||||
}
|
||||
IRemoteConnectionManager manager = services.getConnectionManager();
|
||||
assert (manager != null);
|
||||
IRemoteConnection connection = manager.getConnection(fURI);
|
||||
if (connection == null || !(connection instanceof JSchConnection)) {
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_Invalid_connection_for_URI, fURI));
|
||||
}
|
||||
if (!connection.isOpen()) {
|
||||
connection.open(monitor);
|
||||
if (!connection.isOpen()) {
|
||||
throw new RemoteConnectionException(Messages.JschFileStore_Connection_is_not_open);
|
||||
|
||||
try {
|
||||
IRemoteConnection connection = connectionType.getConnection(fURI);
|
||||
if (connection == null) {
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_Invalid_connection_for_URI, fURI));
|
||||
}
|
||||
if (!connection.isOpen()) {
|
||||
connection.open(monitor);
|
||||
if (!connection.isOpen()) {
|
||||
throw new RemoteConnectionException(Messages.JschFileStore_Connection_is_not_open);
|
||||
}
|
||||
}
|
||||
return connection.getService(JSchConnection.class);
|
||||
} catch (CoreException e) {
|
||||
throw new RemoteConnectionException(e);
|
||||
}
|
||||
return (JSchConnection) connection;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="org.eclipse.remote.ui.remoteUIServices">
|
||||
<remoteUIServices
|
||||
class="org.eclipse.remote.internal.jsch.ui.JSchUIServicesFactory"
|
||||
id="org.eclipse.remote.JSch"
|
||||
name="JSch">
|
||||
</remoteUIServices>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.ide.filesystemSupport">
|
||||
<filesystemContributor
|
||||
|
@ -42,5 +34,18 @@
|
|||
priority="0">
|
||||
</authenticator>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.remote.core.remoteServices">
|
||||
<connectionTypeService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.ui.JSchUIConnectionService$Factory"
|
||||
service="org.eclipse.remote.ui.IRemoteUIConnectionService">
|
||||
</connectionTypeService>
|
||||
<connectionTypeService
|
||||
connectionTypeId="org.eclipse.remote.JSch"
|
||||
factory="org.eclipse.remote.internal.jsch.ui.JSchUIFileService$Factory"
|
||||
service="org.eclipse.remote.ui.IRemoteUIFileService">
|
||||
</connectionTypeService>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -78,6 +78,18 @@ public class Activator extends Plugin {
|
|||
public Activator() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the OSGi service with the given service interface.
|
||||
*
|
||||
* @param service service interface
|
||||
* @return the specified service or null if it's not registered
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
BundleContext context = plugin.getBundle().getBundleContext();
|
||||
ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
|
||||
public IJSchService getService() {
|
||||
return fJSchService;
|
||||
}
|
||||
|
|
|
@ -27,14 +27,12 @@ import java.net.URI;
|
|||
import java.net.URISyntaxException;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchFileSystem;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchServices;
|
||||
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIServices;
|
||||
import org.eclipse.remote.ui.RemoteUIServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileService;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
|
||||
|
||||
|
@ -48,9 +46,9 @@ public class JSchFileSystemContributor extends FileSystemContributor {
|
|||
*/
|
||||
@Override
|
||||
public URI browseFileSystem(String initialPath, Shell shell) {
|
||||
IRemoteServices services = RemoteServices.getRemoteServices(JSchServices.JSCH_ID);
|
||||
IRemoteUIServices uiServices = RemoteUIServices.getRemoteUIServices(services);
|
||||
IRemoteUIFileManager uiFileMgr = uiServices.getUIFileManager();
|
||||
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
|
||||
IRemoteConnectionType connectionType = manager.getConnectionType(JSchConnection.JSCH_ID);
|
||||
IRemoteUIFileService uiFileMgr = connectionType.getService(IRemoteUIFileService.class);
|
||||
uiFileMgr.showConnections(true);
|
||||
String path = uiFileMgr.browseDirectory(shell, Messages.JSchFileSystemContributor_0, initialPath, 0);
|
||||
if (path != null) {
|
||||
|
|
|
@ -20,30 +20,43 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
|||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType.Service;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnectionManager;
|
||||
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
|
||||
import org.eclipse.remote.internal.jsch.ui.wizards.JSchConnectionWizard;
|
||||
import org.eclipse.remote.ui.AbstractRemoteUIConnectionManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionService;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class JSchUIConnectionManager extends AbstractRemoteUIConnectionManager {
|
||||
private final JSchConnectionManager fConnMgr;
|
||||
public class JSchUIConnectionService extends AbstractRemoteUIConnectionManager {
|
||||
|
||||
public JSchUIConnectionManager(IRemoteServices services) {
|
||||
fConnMgr = (JSchConnectionManager) services.getConnectionManager();
|
||||
private final IRemoteConnectionType fConnectionType;
|
||||
|
||||
public JSchUIConnectionService(IRemoteConnectionType connectionType) {
|
||||
fConnectionType = connectionType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#getConnectionWizard(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
public static class Factory implements IRemoteConnectionType.Service.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service) {
|
||||
if (IRemoteUIConnectionService.class.equals(service)) {
|
||||
return (T) new JSchUIConnectionService(connectionType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType() {
|
||||
return fConnectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteUIConnectionWizard getConnectionWizard(Shell shell) {
|
||||
return new JSchConnectionWizard(shell, fConnMgr);
|
||||
return new JSchConnectionWizard(shell, fConnectionType);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -16,15 +16,38 @@ import java.util.List;
|
|||
import org.eclipse.core.filesystem.IFileStore;
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType.Service;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileService;
|
||||
import org.eclipse.remote.ui.dialogs.RemoteResourceBrowser;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class JSchUIFileManager implements IRemoteUIFileManager {
|
||||
public class JSchUIFileService implements IRemoteUIFileService {
|
||||
private final IRemoteConnectionType connectionType;
|
||||
private IRemoteConnection connection = null;
|
||||
private boolean showConnections = false;
|
||||
|
||||
public JSchUIFileService(IRemoteConnectionType connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
}
|
||||
|
||||
public static class Factory implements IRemoteConnectionType.Service.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service) {
|
||||
if (IRemoteUIFileService.class.equals(service)) {
|
||||
return (T) new JSchUIFileService(connectionType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType() {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
|
@ -1,78 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.ui;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIServices;
|
||||
|
||||
public class JSchUIServices implements IRemoteUIServices {
|
||||
private static JSchUIServices fInstance = null;
|
||||
|
||||
/**
|
||||
* Get shared instance of this class
|
||||
*
|
||||
* @return instance
|
||||
*/
|
||||
public static JSchUIServices getInstance(IRemoteServices services) {
|
||||
if (fInstance == null) {
|
||||
fInstance = new JSchUIServices(services);
|
||||
}
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private final IRemoteServices fServices;
|
||||
|
||||
public JSchUIServices(IRemoteServices services) {
|
||||
fServices = services;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return fServices.getId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fServices.getName();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getUIConnectionManager()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteUIConnectionManager getUIConnectionManager() {
|
||||
return new JSchUIConnectionManager(fServices);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getUIFileManager()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteUIFileManager getUIFileManager() {
|
||||
return new JSchUIFileManager();
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.jsch.ui;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIServicesFactory;
|
||||
|
||||
public class JSchUIServicesFactory implements IRemoteUIServicesFactory {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesFactory#getServices(org.eclipse.ptp.remote.core.IRemoteServices)
|
||||
*/
|
||||
public IRemoteUIServices getServices(IRemoteServices services) {
|
||||
return JSchUIServices.getInstance(services);
|
||||
}
|
||||
}
|
|
@ -16,24 +16,35 @@ import org.eclipse.jface.dialogs.IDialogConstants;
|
|||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jsch.ui.UserInfoPrompter;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IUserAuthenticator;
|
||||
import org.eclipse.remote.core.IUserAuthenticatorService;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
|
||||
public class JSchUserAuthenticator implements IUserAuthenticator {
|
||||
public class JSchUserAuthenticator implements IUserAuthenticatorService {
|
||||
|
||||
private final IRemoteConnection remoteConnection;
|
||||
private UserInfoPrompter prompter;
|
||||
|
||||
public JSchUserAuthenticator(IRemoteConnection conn) {
|
||||
this.remoteConnection = conn;
|
||||
try {
|
||||
prompter = new UserInfoPrompter(new JSch().getSession(conn.getUsername(), conn.getAddress()));
|
||||
String username = conn.getAttribute(JSchConnection.USERNAME_ATTR);
|
||||
String address = conn.getAttribute(JSchConnection.ADDRESS_ATTR);
|
||||
prompter = new UserInfoPrompter(new JSch().getSession(username, address));
|
||||
} catch (JSchException e) {
|
||||
// Not allowed
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection getRemoteConnection() {
|
||||
return remoteConnection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordAuthentication prompt(String username, String message) {
|
||||
if (prompter.promptPassword(message)) {
|
||||
|
|
|
@ -15,16 +15,16 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.preference.PreferenceDialog;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.jsch.core.Activator;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnectionAttributes;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnectionWorkingCopy;
|
||||
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -51,6 +51,7 @@ import org.eclipse.ui.forms.events.IExpansionListener;
|
|||
import org.eclipse.ui.forms.widgets.ExpandableComposite;
|
||||
|
||||
public class JSchConnectionPage extends WizardPage {
|
||||
|
||||
private class DataModifyListener implements ModifyListener {
|
||||
@Override
|
||||
public synchronized void modifyText(ModifyEvent e) {
|
||||
|
@ -72,18 +73,18 @@ public class JSchConnectionPage extends WizardPage {
|
|||
private String fInitialName = "Remote Host"; //$NON-NLS-1$
|
||||
private Set<String> fInvalidConnectionNames;
|
||||
private final Map<String, String> fInitialAttributes = new HashMap<String, String>();
|
||||
private JSchConnectionWorkingCopy fConnection;
|
||||
private IRemoteConnectionWorkingCopy fConnection;
|
||||
|
||||
private final IRemoteConnectionManager fConnectionManager;
|
||||
private final IRemoteConnectionType fConnectionType;
|
||||
|
||||
private final DataModifyListener fDataModifyListener = new DataModifyListener();
|
||||
private RemoteConnectionWidget fProxyConnectionWidget;
|
||||
private Text fProxyCommandText;
|
||||
private static final String PREFS_PAGE_ID_NET_PROXY = "org.eclipse.ui.net.NetPreferences"; //$NON-NLS-1$
|
||||
|
||||
public JSchConnectionPage(IRemoteConnectionManager connMgr) {
|
||||
public JSchConnectionPage(IRemoteConnectionType connectionType) {
|
||||
super(Messages.JSchNewConnectionPage_New_Connection);
|
||||
fConnectionManager = connMgr;
|
||||
fConnectionType = connectionType;
|
||||
setPageComplete(false);
|
||||
}
|
||||
|
||||
|
@ -258,7 +259,12 @@ public class JSchConnectionPage extends WizardPage {
|
|||
createAuthControls(authGroup);
|
||||
createAdvancedControls(authGroup);
|
||||
|
||||
loadValues();
|
||||
try {
|
||||
loadValues();
|
||||
} catch (CoreException e) {
|
||||
Activator.log(e.getStatus());
|
||||
}
|
||||
|
||||
/*
|
||||
* Register listeners after loading values so we don't trigger listeners
|
||||
*/
|
||||
|
@ -312,7 +318,7 @@ public class JSchConnectionPage extends WizardPage {
|
|||
link.setText(Messages.JSchConnectionPage_Help);
|
||||
}
|
||||
|
||||
public JSchConnectionWorkingCopy getConnection() {
|
||||
public IRemoteConnectionWorkingCopy getConnection() {
|
||||
return fConnection;
|
||||
}
|
||||
|
||||
|
@ -326,67 +332,69 @@ public class JSchConnectionPage extends WizardPage {
|
|||
private boolean isInvalidName(String name) {
|
||||
if (fConnection == null) {
|
||||
if (fInvalidConnectionNames == null) {
|
||||
return fConnectionManager.getConnection(name) != null;
|
||||
return fConnectionType.getConnection(name) != null;
|
||||
}
|
||||
return fInvalidConnectionNames.contains(name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadValues() {
|
||||
private void loadValues() throws CoreException {
|
||||
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
|
||||
if (fConnection != null) {
|
||||
fConnectionName.setText(fConnection.getName());
|
||||
fHostText.setText(fConnection.getAddress());
|
||||
fUserText.setText(fConnection.getUsername());
|
||||
fPortText.setText(Integer.toString(fConnection.getPort()));
|
||||
fTimeoutText.setText(Integer.toString(fConnection.getTimeout()));
|
||||
boolean isPwd = fConnection.isPasswordAuth();
|
||||
fHostText.setText(fConnection.getAttribute(JSchConnection.ADDRESS_ATTR));
|
||||
fUserText.setText(fConnection.getAttribute(JSchConnection.USERNAME_ATTR));
|
||||
fPortText.setText(fConnection.getAttribute(JSchConnection.PORT_ATTR));
|
||||
fTimeoutText.setText(fConnection.getAttribute(JSchConnection.TIMEOUT_ATTR));
|
||||
String isPwdStr = fConnection.getAttribute(JSchConnection.IS_PASSWORD_ATTR);
|
||||
boolean isPwd = isPwdStr != null && Boolean.parseBoolean(isPwdStr);
|
||||
fPasswordButton.setSelection(isPwd);
|
||||
fPublicKeyButton.setSelection(!isPwd);
|
||||
if (isPwd) {
|
||||
fPasswordText.setText(fConnection.getPassword());
|
||||
fPasswordText.setText(fConnection.getSecureAttribute(JSchConnection.PASSWORD_ATTR));
|
||||
} else {
|
||||
fPassphraseText.setText(fConnection.getPassphrase());
|
||||
fPassphraseText.setText(fConnection.getSecureAttribute(JSchConnection.PASSPHRASE_ATTR));
|
||||
}
|
||||
fProxyCommandText.setText(fConnection.getProxyCommand());
|
||||
IRemoteConnection proxyConn = fConnection.getProxyConnection();
|
||||
fProxyCommandText.setText(fConnection.getAttribute(JSchConnection.PROXYCOMMAND_ATTR));
|
||||
JSchConnection proxyConn = fConnection.getService(JSchConnection.class).getProxyConnection();
|
||||
if (proxyConn == null) {
|
||||
proxyConn = RemoteServices.getLocalServices().getConnectionManager()
|
||||
.getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME);
|
||||
// Use local connection
|
||||
fProxyConnectionWidget.setConnection(manager.getLocalConnectionType().getConnections().get(0));
|
||||
} else {
|
||||
fProxyConnectionWidget.setConnection(proxyConn.getRemoteConnection());
|
||||
}
|
||||
fProxyConnectionWidget.setConnection(proxyConn);
|
||||
} else {
|
||||
fConnectionName.setText(fInitialName);
|
||||
String host = fInitialAttributes.get(JSchConnectionAttributes.ADDRESS_ATTR);
|
||||
String host = fInitialAttributes.get(JSchConnection.ADDRESS_ATTR);
|
||||
if (host != null) {
|
||||
fHostText.setText(host);
|
||||
}
|
||||
String username = fInitialAttributes.get(JSchConnectionAttributes.USERNAME_ATTR);
|
||||
String username = fInitialAttributes.get(JSchConnection.USERNAME_ATTR);
|
||||
if (username != null) {
|
||||
fUserText.setText(username);
|
||||
}
|
||||
String port = fInitialAttributes.get(JSchConnectionAttributes.PORT_ATTR);
|
||||
String port = fInitialAttributes.get(JSchConnection.PORT_ATTR);
|
||||
if (port != null) {
|
||||
fPortText.setText(port);
|
||||
}
|
||||
String timeout = fInitialAttributes.get(JSchConnectionAttributes.TIMEOUT_ATTR);
|
||||
String timeout = fInitialAttributes.get(JSchConnection.TIMEOUT_ATTR);
|
||||
if (timeout != null) {
|
||||
fTimeoutText.setText(timeout);
|
||||
}
|
||||
String isPwd = fInitialAttributes.get(JSchConnectionAttributes.IS_PASSWORD_ATTR);
|
||||
String isPwd = fInitialAttributes.get(JSchConnection.IS_PASSWORD_ATTR);
|
||||
if (isPwd != null) {
|
||||
fPasswordButton.setSelection(Boolean.parseBoolean(isPwd));
|
||||
}
|
||||
String password = fInitialAttributes.get(JSchConnectionAttributes.PASSWORD_ATTR);
|
||||
String password = fInitialAttributes.get(JSchConnection.PASSWORD_ATTR);
|
||||
if (password != null) {
|
||||
fPasswordText.setText(password);
|
||||
}
|
||||
String passphrase = fInitialAttributes.get(JSchConnectionAttributes.PASSPHRASE_ATTR);
|
||||
String passphrase = fInitialAttributes.get(JSchConnection.PASSPHRASE_ATTR);
|
||||
if (passphrase != null) {
|
||||
fPassphraseText.setText(passphrase);
|
||||
}
|
||||
fProxyConnectionWidget.setConnection(RemoteServices.getLocalServices().getConnectionManager()
|
||||
.getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME));
|
||||
fProxyConnectionWidget.setConnection(manager.getLocalConnectionType().getConnections().get(0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,14 +417,14 @@ public class JSchConnectionPage extends WizardPage {
|
|||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
fInitialAttributes.put(JSchConnectionAttributes.ADDRESS_ATTR, address);
|
||||
fInitialAttributes.put(JSchConnection.ADDRESS_ATTR, address);
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
fInitialAttributes.putAll(attributes);
|
||||
}
|
||||
|
||||
public void setConnection(JSchConnectionWorkingCopy connection) {
|
||||
public void setConnection(IRemoteConnectionWorkingCopy connection) {
|
||||
fConnection = connection;
|
||||
}
|
||||
|
||||
|
@ -437,7 +445,7 @@ public class JSchConnectionPage extends WizardPage {
|
|||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
fInitialAttributes.put(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
|
||||
fInitialAttributes.put(JSchConnection.PORT_ATTR, Integer.toString(port));
|
||||
}
|
||||
|
||||
private void setTextFieldWidthInChars(Text text, int chars) {
|
||||
|
@ -453,56 +461,34 @@ public class JSchConnectionPage extends WizardPage {
|
|||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
fInitialAttributes.put(JSchConnectionAttributes.USERNAME_ATTR, username);
|
||||
fInitialAttributes.put(JSchConnection.USERNAME_ATTR, username);
|
||||
}
|
||||
|
||||
private void storeValues() {
|
||||
if (fConnection == null) {
|
||||
try {
|
||||
JSchConnection conn = (JSchConnection) fConnectionManager.newConnection(fConnectionName.getText().trim());
|
||||
fConnection = (JSchConnectionWorkingCopy) conn.getWorkingCopy();
|
||||
fConnection = fConnectionType.newConnection(fConnectionName.getText().trim());
|
||||
} catch (RemoteConnectionException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
}
|
||||
if (fConnection != null) {
|
||||
if (!fConnection.getName().equals(fConnectionName.getText().trim())) {
|
||||
fConnection.setName(fConnectionName.getText().trim());
|
||||
}
|
||||
if (!fConnection.getAddress().equals(fHostText.getText().trim())) {
|
||||
fConnection.setAddress(fHostText.getText().trim());
|
||||
}
|
||||
if (!fConnection.getUsername().equals(fUserText.getText().trim())) {
|
||||
fConnection.setUsername(fUserText.getText().trim());
|
||||
}
|
||||
if (!fConnection.getPassword().equals(fPasswordText.getText().trim())) {
|
||||
fConnection.setPassword(fPasswordText.getText().trim());
|
||||
}
|
||||
if (!fConnection.getPassphrase().equals(fPassphraseText.getText().trim())) {
|
||||
fConnection.setPassphrase(fPassphraseText.getText().trim());
|
||||
}
|
||||
if (fConnection.isPasswordAuth() != fPasswordButton.getSelection()) {
|
||||
fConnection.setIsPasswordAuth(fPasswordButton.getSelection());
|
||||
}
|
||||
int timeout = Integer.parseInt(fTimeoutText.getText().trim());
|
||||
if (fConnection.getTimeout() != timeout) {
|
||||
fConnection.setTimeout(timeout);
|
||||
}
|
||||
int port = Integer.parseInt(fPortText.getText().trim());
|
||||
if (fConnection.getPort() != port) {
|
||||
fConnection.setPort(port);
|
||||
}
|
||||
if (!fConnection.getProxyCommand().equals(fProxyCommandText.getText().trim())) {
|
||||
fConnection.setProxyCommand(fProxyCommandText.getText().trim());
|
||||
}
|
||||
fConnection.setName(fConnectionName.getText().trim());
|
||||
fConnection.setAttribute(JSchConnection.ADDRESS_ATTR, fHostText.getText().trim());
|
||||
fConnection.setAttribute(JSchConnection.USERNAME_ATTR, fUserText.getText().trim());
|
||||
fConnection.setSecureAttribute(JSchConnection.PASSWORD_ATTR, fPasswordText.getText().trim());
|
||||
fConnection.setSecureAttribute(JSchConnection.PASSPHRASE_ATTR, fPassphraseText.getText().trim());
|
||||
fConnection.setAttribute(JSchConnection.IS_PASSWORD_ATTR, Boolean.toString(fPasswordButton.getSelection()));
|
||||
fConnection.setAttribute(JSchConnection.TIMEOUT_ATTR, fTimeoutText.getText().trim());
|
||||
fConnection.setAttribute(JSchConnection.PORT_ATTR, fPortText.getText().trim());
|
||||
fConnection.setAttribute(JSchConnection.PROXYCOMMAND_ATTR, fProxyCommandText.getText().trim());
|
||||
IRemoteConnection proxyConnection = fProxyConnectionWidget.getConnection();
|
||||
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
|
||||
String proxyConnectionName = ""; //$NON-NLS-1$
|
||||
if (proxyConnection != null && proxyConnection.getRemoteServices() != RemoteServices.getLocalServices()) {
|
||||
if (proxyConnection != null && proxyConnection.getConnectionType() != manager.getLocalConnectionType()) {
|
||||
proxyConnectionName = proxyConnection.getName();
|
||||
}
|
||||
if (!fConnection.getProxyConnectionName().equals(proxyConnectionName)) {
|
||||
fConnection.setProxyConnectionName(proxyConnectionName);
|
||||
}
|
||||
fConnection.setAttribute(JSchConnection.PROXYCONNECTION_ATTR, proxyConnectionName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,37 +15,27 @@ import java.util.Set;
|
|||
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.internal.jsch.core.JSchConnectionWorkingCopy;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class JSchConnectionWizard extends Wizard implements IRemoteUIConnectionWizard {
|
||||
|
||||
private final Shell fShell;
|
||||
private final JSchConnectionPage fPage;
|
||||
|
||||
public JSchConnectionWizard(Shell shell, IRemoteConnectionManager connMgr) {
|
||||
public JSchConnectionWizard(Shell shell, IRemoteConnectionType connectionType) {
|
||||
fShell = shell;
|
||||
fPage = new JSchConnectionPage(connMgr);
|
||||
fPage = new JSchConnectionPage(connectionType);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.wizard.Wizard#addPages()
|
||||
*/
|
||||
@Override
|
||||
public void addPages() {
|
||||
super.addPages();
|
||||
addPage(fPage);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#getWorkingCopy()
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy open() {
|
||||
WizardDialog dialog = new WizardDialog(fShell, this);
|
||||
dialog.setBlockOnOpen(true);
|
||||
|
@ -55,50 +45,31 @@ public class JSchConnectionWizard extends Wizard implements IRemoteUIConnectionW
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.wizard.Wizard#performCancel()
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getConnection() {
|
||||
return fPage.getConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCancel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.wizard.Wizard#performFinish()
|
||||
*/
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setConnection(org.eclipse.remote.core.IRemoteConnectionWorkingCopy)
|
||||
*/
|
||||
public void setConnection(IRemoteConnectionWorkingCopy connection) {
|
||||
fPage.setConnection((JSchConnectionWorkingCopy) connection);
|
||||
fPage.setConnection(connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setConnectionName(java.lang.String)
|
||||
*/
|
||||
public void setConnectionName(String name) {
|
||||
fPage.setConnectionName(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setInvalidConnectionNames(java.util.Set)
|
||||
*/
|
||||
public void setInvalidConnectionNames(Set<String> names) {
|
||||
fPage.setInvalidConnectionNames(names);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.remote.ui;singleton:=true
|
||||
Bundle-Version: 1.1.0.qualifier
|
||||
Bundle-Version: 2.0.0.qualifier
|
||||
Bundle-Activator: org.eclipse.remote.internal.ui.RemoteUIPlugin
|
||||
Bundle-Vendor: %pluginProvider
|
||||
Require-Bundle: org.eclipse.ui,
|
||||
|
@ -12,7 +12,9 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.remote.core,
|
||||
org.eclipse.core.filesystem,
|
||||
org.eclipse.core.resources,
|
||||
org.eclipse.ui.trace
|
||||
org.eclipse.ui.trace,
|
||||
org.eclipse.ui.navigator,
|
||||
org.eclipse.core.expressions
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.remote.internal.ui;x-internal:=true,
|
||||
|
|
BIN
bundles/org.eclipse.remote.ui/icons/new_wiz.gif
Normal file
BIN
bundles/org.eclipse.remote.ui/icons/new_wiz.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 612 B |
|
@ -10,4 +10,11 @@
|
|||
pluginName=Remote Services UI
|
||||
pluginProvider=Eclipse PTP
|
||||
RemoteDevPrefPage.name=Remote Development
|
||||
ConnectionsPreferencePage.name=Remote Connections
|
||||
ConnectionsPreferencePage.name=Remote Connections
|
||||
ConnectionsViewCategory.name=Connections
|
||||
ConnectionsView.name=Connections
|
||||
ConnectionsContent.name=Connections
|
||||
NewConnectionCommand.name=New Connection
|
||||
DeleteConnectionCommand.name=Delete Connection
|
||||
OpenTerminalCommand.name=Open Terminal
|
||||
ConnectionProperties.name=Connection
|
||||
|
|
|
@ -1,15 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.2"?>
|
||||
<plugin>
|
||||
<extension-point id="remoteUIServices" name="Remote UI Services" schema="schema/remoteUIServices.exsd"/>
|
||||
<extension
|
||||
point="org.eclipse.remote.ui.remoteUIServices">
|
||||
<remoteUIServices
|
||||
class="org.eclipse.remote.internal.ui.services.local.LocalUIServicesFactory"
|
||||
id="org.eclipse.remote.LocalServices"
|
||||
name="Local">
|
||||
</remoteUIServices>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.preferencePages">
|
||||
<page
|
||||
|
@ -38,5 +29,176 @@
|
|||
</bundle>
|
||||
</component>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.remote.core.remoteServices">
|
||||
<connectionTypeService
|
||||
connectionTypeId="org.eclipse.remote.LocalServices"
|
||||
factory="org.eclipse.remote.internal.ui.services.local.LocalUIFileService$Factory"
|
||||
service="org.eclipse.remote.ui.IRemoteUIFileService">
|
||||
</connectionTypeService>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.views">
|
||||
<category
|
||||
id="org.eclipse.remote.ui.view.category.connections"
|
||||
name="%ConnectionsViewCategory.name">
|
||||
</category>
|
||||
<view
|
||||
category="org.eclipse.remote.ui.view.category.connections"
|
||||
class="org.eclipse.remote.internal.ui.views.RemoteConnectionsView"
|
||||
id="org.eclipse.remote.ui.view.connections"
|
||||
name="%ConnectionsView.name"
|
||||
restorable="true">
|
||||
</view>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.navigator.navigatorContent">
|
||||
<navigatorContent
|
||||
activeByDefault="true"
|
||||
contentProvider="org.eclipse.remote.internal.ui.views.RemoteConnectionsContentProvider"
|
||||
id="org.eclipse.remote.ui.navigatorContent.connections"
|
||||
labelProvider="org.eclipse.remote.internal.ui.views.RemoteConnectionsLabelProvider"
|
||||
name="%ConnectionsContent.name">
|
||||
<triggerPoints>
|
||||
<instanceof
|
||||
value="org.eclipse.remote.core.IRemoteServicesManager">
|
||||
</instanceof>
|
||||
</triggerPoints>
|
||||
<possibleChildren>
|
||||
<instanceof
|
||||
value="org.eclipse.remote.core.IRemoteConnection">
|
||||
</instanceof>
|
||||
</possibleChildren>
|
||||
</navigatorContent>
|
||||
<actionProvider
|
||||
class="org.eclipse.remote.internal.ui.views.RemoteConnectionsActionProvider"
|
||||
id="org.eclipse.remote.ui.actionProvider.properties">
|
||||
<enablement>
|
||||
<instanceof
|
||||
value="org.eclipse.remote.core.IRemoteConnection">
|
||||
</instanceof>
|
||||
</enablement>
|
||||
</actionProvider>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.navigator.viewer">
|
||||
<viewer
|
||||
viewerId="org.eclipse.remote.ui.view.connections">
|
||||
<options>
|
||||
<property
|
||||
name="org.eclipse.ui.navigator.hideLinkWithEditorAction"
|
||||
value="true">
|
||||
</property>
|
||||
</options>
|
||||
</viewer>
|
||||
<viewerContentBinding
|
||||
viewerId="org.eclipse.remote.ui.view.connections">
|
||||
<includes>
|
||||
<contentExtension
|
||||
isRoot="true"
|
||||
pattern="org.eclipse.remote.ui.navigatorContent.connections">
|
||||
</contentExtension>
|
||||
</includes>
|
||||
</viewerContentBinding>
|
||||
<viewerActionBinding
|
||||
viewerId="org.eclipse.remote.ui.view.connections">
|
||||
<includes>
|
||||
<actionExtension
|
||||
pattern="org.eclipse.remote.ui.actionProvider.*">
|
||||
</actionExtension>
|
||||
</includes>
|
||||
</viewerActionBinding>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.commands">
|
||||
<command
|
||||
defaultHandler="org.eclipse.remote.internal.ui.views.NewRemoteConnectionHandler"
|
||||
id="org.eclipse.remote.ui.command.newConnection"
|
||||
name="%NewConnectionCommand.name">
|
||||
</command>
|
||||
<command
|
||||
defaultHandler="org.eclipse.remote.internal.ui.views.DeleteRemoteConnectionHandler"
|
||||
id="org.eclipse.remote.ui.command.deleteConnection"
|
||||
name="%DeleteConnectionCommand.name">
|
||||
</command>
|
||||
<command
|
||||
defaultHandler="org.eclipse.remote.internal.ui.views.OpenTerminalHandler"
|
||||
id="org.eclipse.remote.ui.command.openTerminal"
|
||||
name="%OpenTerminalCommand.name">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.expressions.propertyTesters">
|
||||
<propertyTester
|
||||
class="org.eclipse.remote.internal.ui.ServicePropertyTester"
|
||||
id="org.eclipse.remote.ui.propertyTester.hasService"
|
||||
namespace="org.eclipse.remote.ui"
|
||||
properties="hasConnectionTypeService,hasConnectionService,canDelete"
|
||||
type="org.eclipse.remote.core.IRemoteConnection">
|
||||
</propertyTester>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
<menuContribution
|
||||
allPopups="false"
|
||||
locationURI="toolbar:org.eclipse.remote.ui.view.connections">
|
||||
<command
|
||||
commandId="org.eclipse.remote.ui.command.newConnection"
|
||||
icon="icons/new_wiz.gif"
|
||||
label="%NewConnectionCommand.name"
|
||||
style="push">
|
||||
</command>
|
||||
</menuContribution>
|
||||
<menuContribution
|
||||
allPopups="false"
|
||||
locationURI="popup:org.eclipse.remote.ui.view.connections">
|
||||
<command
|
||||
commandId="org.eclipse.remote.ui.command.deleteConnection"
|
||||
label="%DeleteConnectionCommand.name"
|
||||
style="push">
|
||||
<visibleWhen
|
||||
checkEnabled="false">
|
||||
<with
|
||||
variable="selection">
|
||||
<iterate>
|
||||
<test
|
||||
property="org.eclipse.remote.ui.canDelete">
|
||||
</test>
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
<command
|
||||
commandId="org.eclipse.remote.ui.command.openTerminal"
|
||||
label="%OpenTerminalCommand.name"
|
||||
style="push">
|
||||
<visibleWhen
|
||||
checkEnabled="false">
|
||||
<with
|
||||
variable="selection">
|
||||
<iterate>
|
||||
<test
|
||||
args="org.eclipse.remote.core.IRemoteCommandShellService"
|
||||
property="org.eclipse.remote.ui.hasConnectionService">
|
||||
</test>
|
||||
</iterate>
|
||||
</with>
|
||||
</visibleWhen>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.propertyPages">
|
||||
<page
|
||||
class="org.eclipse.remote.internal.ui.views.RemoteConnectionPropertyPage"
|
||||
id="org.eclipse.remote.ui.page.connectionProperties"
|
||||
name="%ConnectionProperties.name">
|
||||
<enabledWhen>
|
||||
<instanceof
|
||||
value="org.eclipse.remote.core.IRemoteConnection">
|
||||
</instanceof>
|
||||
</enabledWhen>
|
||||
</page>
|
||||
name</extension>
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>org.eclipse.remote.ui</artifactId>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
</project>
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!-- Schema file written by PDE -->
|
||||
<schema targetNamespace="org.eclipse.remote.ui" xmlns="http://www.w3.org/2001/XMLSchema">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.schema plugin="org.eclipse.remote.ui" id="org.eclipse.remote.ui" name="RemoteUI"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter description of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<element name="extension">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element />
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<sequence>
|
||||
<element ref="remoteUIServices"/>
|
||||
</sequence>
|
||||
<attribute name="point" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="id" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<element name="remoteUIServices">
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.element labelAttribute="name"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
<complexType>
|
||||
<attribute name="id" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="name" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute translatable="true"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
<attribute name="class" type="string" use="required">
|
||||
<annotation>
|
||||
<documentation>
|
||||
|
||||
</documentation>
|
||||
<appinfo>
|
||||
<meta.attribute kind="java" basedOn=":org.eclipse.remote.ui.IRemoteUIServicesFactory"/>
|
||||
</appinfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
</complexType>
|
||||
</element>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="since"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter the first release in which this extension point appears.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="examples"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter extension point usage example here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="apiInfo"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter API information here.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
<annotation>
|
||||
<appinfo>
|
||||
<meta.section type="implementation"/>
|
||||
</appinfo>
|
||||
<documentation>
|
||||
[Enter information about supplied implementation of this extension point.]
|
||||
</documentation>
|
||||
</annotation>
|
||||
|
||||
|
||||
</schema>
|
|
@ -0,0 +1,20 @@
|
|||
package org.eclipse.remote.internal.ui;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.remote.internal.ui.messages"; //$NON-NLS-1$
|
||||
public static String NewRemoteConnectionTypePage_LaunchTargetType;
|
||||
public static String NewRemoteConnectionTypePage_SelectTargetType;
|
||||
public static String NewRemoteConnectionWizard_0;
|
||||
public static String OpenTerminalHandler_OpenTerminalDesc;
|
||||
public static String OpenTerminalHandler_OpenTerminalTitle;
|
||||
public static String RemoteConnectionPropertyPage_ConnectionName;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import org.eclipse.core.runtime.Status;
|
|||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
|
@ -70,6 +71,18 @@ public class RemoteUIPlugin extends AbstractUIPlugin {
|
|||
log(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, Messages.PTPRemoteUIPlugin_3, e));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the OSGi service with the given service interface.
|
||||
*
|
||||
* @param service service interface
|
||||
* @return the specified service or null if it's not registered
|
||||
*/
|
||||
public static <T> T getService(Class<T> service) {
|
||||
BundleContext context = plugin.getBundle().getBundleContext();
|
||||
ServiceReference<T> ref = context.getServiceReference(service);
|
||||
return ref != null ? context.getService(ref) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui;
|
||||
|
||||
import org.eclipse.core.runtime.IConfigurationElement;
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.IRemoteUIServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIServicesDescriptor;
|
||||
import org.eclipse.remote.ui.IRemoteUIServicesFactory;
|
||||
|
||||
public class RemoteUIServicesDescriptor implements IRemoteUIServicesDescriptor {
|
||||
private static final String ATTR_ID = "id"; //$NON-NLS-1$
|
||||
private static final String ATTR_NAME = "name"; //$NON-NLS-1$
|
||||
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
|
||||
|
||||
private static String getAttribute(IConfigurationElement configElement, String name, String defaultValue) {
|
||||
String value = configElement.getAttribute(name);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
if (defaultValue != null) {
|
||||
return defaultValue;
|
||||
}
|
||||
throw new IllegalArgumentException(NLS.bind(Messages.RemoteUIServicesProxy_1, name));
|
||||
}
|
||||
|
||||
private final IConfigurationElement configElement;
|
||||
private final String id;
|
||||
private final String name;
|
||||
private IRemoteUIServicesFactory fFactory = null;
|
||||
private IRemoteUIServices fDelegate = null;
|
||||
|
||||
public RemoteUIServicesDescriptor(IConfigurationElement configElement) {
|
||||
this.configElement = configElement;
|
||||
this.id = getAttribute(configElement, ATTR_ID, null);
|
||||
this.name = getAttribute(configElement, ATTR_NAME, this.id);
|
||||
getAttribute(configElement, ATTR_CLASS, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the factory from the plugin
|
||||
*
|
||||
* @return instance of the factory
|
||||
*/
|
||||
public IRemoteUIServicesFactory getFactory() {
|
||||
if (fFactory != null) {
|
||||
return fFactory;
|
||||
}
|
||||
try {
|
||||
fFactory = (IRemoteUIServicesFactory) configElement.createExecutableExtension(ATTR_CLASS);
|
||||
} catch (Exception e) {
|
||||
RemoteUIPlugin.log(NLS.bind(Messages.RemoteUIServicesProxy_2, new Object[] { configElement.getAttribute(ATTR_CLASS),
|
||||
id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
|
||||
}
|
||||
return fFactory;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServices#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the remote UI services implementation for this descriptor.
|
||||
*
|
||||
* @return the remote UI services implementation, or null if initialization failed
|
||||
*/
|
||||
public IRemoteUIServices getUIServices(IRemoteServices services) {
|
||||
loadServices(services);
|
||||
return fDelegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and initialize the remote UI services factory
|
||||
*/
|
||||
private void loadServices(IRemoteServices services) {
|
||||
if (fDelegate == null) {
|
||||
IRemoteUIServicesFactory factory = getFactory();
|
||||
if (factory != null) {
|
||||
fDelegate = factory.getServices(services);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package org.eclipse.remote.internal.ui;
|
||||
|
||||
import org.eclipse.core.expressions.PropertyTester;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
|
||||
public class ServicePropertyTester extends PropertyTester {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
|
||||
if (receiver instanceof IRemoteConnection) {
|
||||
IRemoteConnection connection = (IRemoteConnection) receiver;
|
||||
if (property.equals("hasConnectionTypeService")) { //$NON-NLS-1$
|
||||
if (args.length > 0 && args[0] instanceof String) {
|
||||
String serviceName = (String) args[0];
|
||||
try {
|
||||
Class<?> service = Class.forName(serviceName);
|
||||
return connection.getConnectionType().hasService((Class<IRemoteConnectionType.Service>) service);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (property.equals("hasConnectionService")) { //$NON-NLS-1$
|
||||
if (args.length > 0 && args[0] instanceof String) {
|
||||
String serviceName = (String) args[0];
|
||||
try {
|
||||
Class<?> service = Class.forName(serviceName);
|
||||
return connection.hasService((Class<IRemoteConnection.Service>) service);
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (property.equals("canDelete")) { //$NON-NLS-1$
|
||||
return (connection.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_REMOVE_CONNECTIONS) != 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
NewRemoteConnectionTypePage_LaunchTargetType=Launch Target Type
|
||||
NewRemoteConnectionTypePage_SelectTargetType=Select type of launch target to create.
|
||||
NewRemoteConnectionWizard_0=Launch Target Type
|
||||
OpenTerminalHandler_OpenTerminalDesc=A real terminal would open now
|
||||
OpenTerminalHandler_OpenTerminalTitle=Open Terminal
|
||||
RemoteConnectionPropertyPage_ConnectionName=Connection Name:
|
|
@ -28,19 +28,17 @@ import org.eclipse.jface.viewers.TableLayout;
|
|||
import org.eclipse.jface.viewers.TableViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionControlService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemotePreferenceConstants;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesImpl;
|
||||
import org.eclipse.remote.internal.core.preferences.Preferences;
|
||||
import org.eclipse.remote.internal.ui.RemoteUIPlugin;
|
||||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionService;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.remote.ui.RemoteUIServices;
|
||||
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.MouseEvent;
|
||||
|
@ -112,10 +110,10 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
return connection.isOpen() ? Messages.ConnectionsPreferencePage_open : Messages.ConnectionsPreferencePage_closed;
|
||||
case 1:
|
||||
return connection.getName();
|
||||
case 2:
|
||||
return connection.getAddress();
|
||||
case 3:
|
||||
return connection.getUsername();
|
||||
// case 2:
|
||||
// return connection.getAttribute(IRemoteConnection.ADDRESS_ATTR);
|
||||
// case 3:
|
||||
// return connection.getAttribute(IRemoteConnection.USERNAME_ATTR);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -188,8 +186,8 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
private String[] fServiceIDs;
|
||||
private boolean fIsDirty;
|
||||
private IRemoteConnection fSelectedConnection;
|
||||
private IRemoteConnectionManager fConnectionManager;
|
||||
private IRemoteUIConnectionManager fUIConnectionManager;
|
||||
private IRemoteConnectionType fConnectionType;
|
||||
private IRemoteUIConnectionService fUIConnectionManager;
|
||||
|
||||
private final Map<String, IRemoteConnection> fWorkingCopies = new HashMap<String, IRemoteConnection>();
|
||||
|
||||
|
@ -214,7 +212,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
if (fIsDirty) {
|
||||
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null,
|
||||
Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION, new String[] {
|
||||
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
|
||||
IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
|
||||
if (dialog.open() == 1) {
|
||||
return;
|
||||
}
|
||||
|
@ -263,12 +261,18 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
label.setLayoutData(new GridData());
|
||||
fServicesCombo = new Combo(selectComp, SWT.READ_ONLY);
|
||||
label.setLayoutData(new GridData());
|
||||
List<RemoteServicesDescriptor> descriptors = RemoteServicesImpl.getRemoteServiceDescriptors();
|
||||
String[] names = new String[descriptors.size()];
|
||||
fServiceIDs = new String[descriptors.size()];
|
||||
for (int i = 0; i < descriptors.size(); i++) {
|
||||
names[i] = descriptors.get(i).getName();
|
||||
fServiceIDs[i] = descriptors.get(i).getId();
|
||||
|
||||
IRemoteServicesManager manager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
|
||||
List<IRemoteConnectionType> services = manager.getRemoteConnectionTypes();
|
||||
String[] names = new String[services.size()];
|
||||
fServiceIDs = new String[services.size()];
|
||||
{
|
||||
int i = 0;
|
||||
for (IRemoteConnectionType s : services) {
|
||||
names[i] = s.getName();
|
||||
fServiceIDs[i] = s.getId();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
fServicesCombo.addSelectionListener(fEventHandler);
|
||||
fServicesCombo.setItems(names);
|
||||
|
@ -287,8 +291,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
fConnectionTable.addMouseListener(new MouseListener() {
|
||||
@Override
|
||||
public void mouseDoubleClick(MouseEvent e) {
|
||||
if (fSelectedConnection != null && !getOriginalIfClean(fSelectedConnection).isOpen()) {
|
||||
editConnection();
|
||||
if (fSelectedConnection != null) {
|
||||
IRemoteConnection original = getOriginalIfClean(fSelectedConnection);
|
||||
if (original.isOpen()) {
|
||||
editConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +411,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
|
||||
private void initWorkingConnections() {
|
||||
fWorkingCopies.clear();
|
||||
for (IRemoteConnection conn : fConnectionManager.getConnections()) {
|
||||
for (IRemoteConnection conn : fConnectionType.getConnections()) {
|
||||
fWorkingCopies.put(conn.getName(), conn);
|
||||
}
|
||||
}
|
||||
|
@ -467,13 +474,13 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
}
|
||||
|
||||
private void selectServices(String id) {
|
||||
IRemoteServices services = RemoteServices.getRemoteServices(id);
|
||||
if (services != null) {
|
||||
fConnectionManager = services.getConnectionManager();
|
||||
fUIConnectionManager = RemoteUIServices.getRemoteUIServices(services).getUIConnectionManager();
|
||||
IRemoteServicesManager manager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
|
||||
fConnectionType = manager.getConnectionType(id);
|
||||
if (fConnectionType != null) {
|
||||
fUIConnectionManager = fConnectionType.getService(IRemoteUIConnectionService.class);
|
||||
initWorkingConnections();
|
||||
fConnectionViewer.refresh();
|
||||
fAddButton.setEnabled((services.getCapabilities() & IRemoteServices.CAPABILITY_ADD_CONNECTIONS) != 0);
|
||||
fAddButton.setEnabled((fConnectionType.getCapabilities() & IRemoteConnectionType.CAPABILITY_ADD_CONNECTIONS) != 0);
|
||||
}
|
||||
fIsDirty = false;
|
||||
}
|
||||
|
@ -485,12 +492,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
TableItem[] items = fConnectionTable.getSelection();
|
||||
if (items.length > 0) {
|
||||
IRemoteConnection conn = getOriginalIfClean((IRemoteConnection) items[0].getData());
|
||||
if (conn.isOpen()) {
|
||||
if (conn.hasService(IRemoteConnectionControlService.class) && conn.isOpen()) {
|
||||
conn.close();
|
||||
} else {
|
||||
if (conn instanceof IRemoteConnectionWorkingCopy) {
|
||||
IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
|
||||
conn = wc.getOriginal();
|
||||
if (wc.isDirty()) {
|
||||
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
|
||||
null, Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
|
||||
|
@ -498,15 +504,18 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
if (dialog.open() == 1) {
|
||||
return;
|
||||
}
|
||||
wc.save();
|
||||
try {
|
||||
conn = wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
RemoteUIPlugin.log(e);
|
||||
}
|
||||
/*
|
||||
* Replace working copy with original so that the correct version will be used in the future
|
||||
*/
|
||||
fWorkingCopies.put(conn.getName(), conn);
|
||||
}
|
||||
}
|
||||
IRemoteUIConnectionManager mgr = RemoteUIServices.getRemoteUIServices(conn.getRemoteServices())
|
||||
.getUIConnectionManager();
|
||||
IRemoteUIConnectionService mgr = conn.getConnectionType().getService(IRemoteUIConnectionService.class);
|
||||
if (mgr != null) {
|
||||
mgr.openConnectionWithProgress(getShell(), null, conn);
|
||||
}
|
||||
|
@ -523,10 +532,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
/*
|
||||
* Remove any deleted connections
|
||||
*/
|
||||
for (IRemoteConnection conn : fConnectionManager.getConnections()) {
|
||||
if (!fWorkingCopies.containsKey(conn.getName()) && !conn.isOpen()) {
|
||||
for (IRemoteConnection conn : fConnectionType.getConnections()) {
|
||||
if (!fWorkingCopies.containsKey(conn.getName()) &&
|
||||
(!conn.hasService(IRemoteConnectionControlService.class) || !conn.isOpen())) {
|
||||
try {
|
||||
fConnectionManager.removeConnection(conn);
|
||||
fConnectionType.removeConnection(conn);
|
||||
} catch (RemoteConnectionException e) {
|
||||
// Ignore
|
||||
}
|
||||
|
@ -539,7 +549,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
if (conn instanceof IRemoteConnectionWorkingCopy) {
|
||||
IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
|
||||
if (wc.isDirty()) {
|
||||
wc.save();
|
||||
try {
|
||||
wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
RemoteUIPlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -553,14 +567,16 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
fCloseButton.setEnabled(false);
|
||||
if (fSelectedConnection != null) {
|
||||
IRemoteConnection conn = getOriginalIfClean(fSelectedConnection);
|
||||
if (!conn.isOpen()) {
|
||||
fEditButton
|
||||
.setEnabled((conn.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_EDIT_CONNECTIONS) != 0);
|
||||
fRemoveButton
|
||||
.setEnabled((conn.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_REMOVE_CONNECTIONS) != 0);
|
||||
fOpenButton.setEnabled(true);
|
||||
if (conn.hasService(IRemoteConnectionControlService.class)) {
|
||||
if (!conn.isOpen()) {
|
||||
fEditButton.setEnabled((conn.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_EDIT_CONNECTIONS) != 0);
|
||||
fRemoveButton.setEnabled((conn.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_REMOVE_CONNECTIONS) != 0);
|
||||
fOpenButton.setEnabled(true);
|
||||
} else {
|
||||
fCloseButton.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
fCloseButton.setEnabled(true);
|
||||
fEditButton.setEnabled((conn.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_EDIT_CONNECTIONS) != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,9 @@ import java.util.List;
|
|||
import org.eclipse.jface.preference.ComboFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.remote.core.IRemotePreferenceConstants;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
|
||||
import org.eclipse.remote.internal.core.RemoteServicesImpl;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.internal.ui.RemoteUIPlugin;
|
||||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
@ -46,7 +47,8 @@ public class RemoteDevelopmentPreferencePage extends FieldEditorPreferencePage i
|
|||
nameAndValue[1] = ""; //$NON-NLS-1$
|
||||
namesAndValues.add(nameAndValue);
|
||||
|
||||
for (RemoteServicesDescriptor service : RemoteServicesImpl.getRemoteServiceDescriptors()) {
|
||||
IRemoteServicesManager manager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
|
||||
for (IRemoteConnectionType service : manager.getRemoteConnectionTypes()) {
|
||||
nameAndValue = new String[2];
|
||||
nameAndValue[0] = service.getName();
|
||||
nameAndValue[1] = service.getId();
|
||||
|
|
|
@ -15,15 +15,38 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType.Service;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileService;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.DirectoryDialog;
|
||||
import org.eclipse.swt.widgets.FileDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class LocalUIFileManager implements IRemoteUIFileManager {
|
||||
public class LocalUIFileService implements IRemoteUIFileService {
|
||||
private final IRemoteConnectionType connectionType;
|
||||
private IRemoteConnection connection = null;
|
||||
|
||||
public LocalUIFileService(IRemoteConnectionType connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
}
|
||||
|
||||
public static class Factory implements IRemoteConnectionType.Service.Factory {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service) {
|
||||
if (IRemoteUIFileService.class.equals(service)) {
|
||||
return (T) new LocalUIFileService(connectionType);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnectionType getConnectionType() {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
|
@ -1,76 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIFileManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIServices;
|
||||
|
||||
public class LocalUIServices implements IRemoteUIServices {
|
||||
private static LocalUIServices fInstance = null;
|
||||
private final static LocalUIFileManager fFileMgr = new LocalUIFileManager();
|
||||
|
||||
/**
|
||||
* Get shared instance of this class
|
||||
*
|
||||
* @return instance
|
||||
*/
|
||||
public static LocalUIServices getInstance(IRemoteServices services) {
|
||||
if (fInstance == null) {
|
||||
fInstance = new LocalUIServices(services);
|
||||
}
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
private final IRemoteServices fServices;
|
||||
|
||||
public LocalUIServices(IRemoteServices services) {
|
||||
fServices = services;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getId()
|
||||
*/
|
||||
public String getId() {
|
||||
return fServices.getId();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getName()
|
||||
*/
|
||||
public String getName() {
|
||||
return fServices.getName();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getUIConnectionManager(org.eclipse.remote.core.IRemoteConnectionManager)
|
||||
*/
|
||||
public IRemoteUIConnectionManager getUIConnectionManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getUIFileManager(org.eclipse.remote.core.IRemoteConnection)
|
||||
*/
|
||||
public IRemoteUIFileManager getUIFileManager() {
|
||||
return fFileMgr;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation 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:
|
||||
* IBM Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIServicesFactory;
|
||||
|
||||
public class LocalUIServicesFactory implements IRemoteUIServicesFactory {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIServicesFactory#getServices(org.eclipse.remote.core.IRemoteServices)
|
||||
*/
|
||||
public IRemoteUIServices getServices(IRemoteServices services) {
|
||||
return LocalUIServices.getInstance(services);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.ui.RemoteUIPlugin;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
public class DeleteRemoteConnectionHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
|
||||
if (selection != null && selection instanceof IStructuredSelection) {
|
||||
// Get the manageable connections from the selection
|
||||
List<IRemoteConnection> connections = new ArrayList<IRemoteConnection>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Object> i = ((IStructuredSelection) selection).iterator();
|
||||
while (i.hasNext()) {
|
||||
Object obj = i.next();
|
||||
if (obj instanceof IRemoteConnection) {
|
||||
IRemoteConnection connection = (IRemoteConnection)obj;
|
||||
IRemoteConnectionType connectionType = connection.getConnectionType();
|
||||
if ((connectionType.getCapabilities() & IRemoteConnectionType.CAPABILITY_REMOVE_CONNECTIONS) != 0) {
|
||||
connections.add(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Confirm the delete
|
||||
String message = Messages.DeleteRemoteConnectionHandler_ConfirmDeleteMessage;
|
||||
for (IRemoteConnection connection : connections) {
|
||||
message += " " + connection.getName(); //$NON-NLS-1 //$NON-NLS-1$
|
||||
}
|
||||
message += "?"; //$NON-NLS-1 //$NON-NLS-1$
|
||||
if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.DeleteRemoteConnectionHandler_DeleteConnectionTitle, message)) {
|
||||
for (IRemoteConnection connection : connections) {
|
||||
IRemoteConnectionType connectionType = connection.getConnectionType();
|
||||
try {
|
||||
connectionType.removeConnection(connection);
|
||||
} catch (RemoteConnectionException e) {
|
||||
RemoteUIPlugin.log(e.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.osgi.util.NLS;
|
||||
|
||||
public class Messages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.remote.internal.ui.views.messages"; //$NON-NLS-1$
|
||||
public static String DeleteRemoteConnectionHandler_ConfirmDeleteMessage;
|
||||
public static String DeleteRemoteConnectionHandler_DeleteConnectionTitle;
|
||||
static {
|
||||
// initialize resource bundle
|
||||
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
|
||||
}
|
||||
|
||||
private Messages() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
public class NewRemoteConnectionHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
NewRemoteConnectionWizard wizard = new NewRemoteConnectionWizard();
|
||||
Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||
WizardDialog dialog = new WizardDialog(parent, wizard);
|
||||
dialog.open();
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.jface.wizard.IWizardPage;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.internal.ui.Messages;
|
||||
import org.eclipse.remote.internal.ui.RemoteUIPlugin;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionService;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Table;
|
||||
import org.eclipse.swt.widgets.TableItem;
|
||||
|
||||
/**
|
||||
* @since 2.0 API tooling made me put this in even though it's an internal package...
|
||||
*/
|
||||
public class NewRemoteConnectionTypePage extends WizardPage {
|
||||
|
||||
private Table table;
|
||||
private IRemoteUIConnectionWizard nextWizard;
|
||||
|
||||
public NewRemoteConnectionTypePage() {
|
||||
super("NewLaunchTargetTypePage"); //$NON-NLS-1$
|
||||
setTitle(Messages.NewRemoteConnectionTypePage_LaunchTargetType);
|
||||
setDescription(Messages.NewRemoteConnectionTypePage_SelectTargetType);
|
||||
}
|
||||
|
||||
public IRemoteUIConnectionWizard getNextWizard() {
|
||||
return nextWizard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createControl(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
comp.setLayout(new GridLayout());
|
||||
|
||||
table = new Table(comp, SWT.SINGLE | SWT.BORDER);
|
||||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
table.setLayoutData(data);
|
||||
|
||||
setPageComplete(false);
|
||||
|
||||
IRemoteServicesManager remoteManager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
|
||||
for (IRemoteConnectionType connectionType : remoteManager.getAllConnectionTypes()) {
|
||||
if ((connectionType.getCapabilities() & IRemoteConnectionType.CAPABILITY_ADD_CONNECTIONS) == 0)
|
||||
continue;
|
||||
|
||||
IRemoteUIConnectionService connManager = connectionType.getService(IRemoteUIConnectionService.class);
|
||||
if (connManager == null)
|
||||
continue;
|
||||
|
||||
IRemoteUIConnectionWizard wizard = connManager.getConnectionWizard(parent.getShell());
|
||||
if (wizard == null)
|
||||
continue;
|
||||
|
||||
TableItem item = new TableItem(table, SWT.NONE);
|
||||
item.setText(connectionType.getName());
|
||||
item.setData(wizard);
|
||||
// TODO connection type icons somehow
|
||||
// Image icon = ui.getIcon();
|
||||
// if (icon != null) {
|
||||
// item.setImage(icon);
|
||||
// }
|
||||
|
||||
// TODO select the last selected entry
|
||||
table.select(0);
|
||||
setPageComplete(true);
|
||||
}
|
||||
|
||||
setControl(comp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFlipToNextPage() {
|
||||
return isPageComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWizardPage getNextPage() {
|
||||
nextWizard = (IRemoteUIConnectionWizard)table.getSelection()[0].getData();
|
||||
if (nextWizard != null) {
|
||||
nextWizard.addPages();
|
||||
IWizardPage [] pages = nextWizard.getPages();
|
||||
if (pages.length > 0) {
|
||||
return pages[0];
|
||||
}
|
||||
}
|
||||
|
||||
return super.getNextPage();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* Doug Schaefer
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.ui.Messages;
|
||||
import org.eclipse.remote.internal.ui.RemoteUIPlugin;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
public class NewRemoteConnectionWizard extends Wizard {
|
||||
|
||||
private final NewRemoteConnectionTypePage typePage;
|
||||
|
||||
public NewRemoteConnectionWizard() {
|
||||
setWindowTitle(Messages.NewRemoteConnectionWizard_0);
|
||||
typePage = new NewRemoteConnectionTypePage();
|
||||
setForcePreviousAndNextButtons(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPages() {
|
||||
addPage(typePage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performFinish() {
|
||||
IRemoteUIConnectionWizard nextWizard = typePage.getNextWizard();
|
||||
if (nextWizard != null) {
|
||||
IRemoteConnectionWorkingCopy wc = nextWizard.getConnection();
|
||||
try {
|
||||
wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
RemoteUIPlugin.log(e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
// what happened?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFinish() {
|
||||
// Need to move onto the new target wizard
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.remote.internal.ui.Messages;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
public class OpenTerminalHandler extends AbstractHandler {
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
// TODO Need to figure out how to open a terminal for this connection
|
||||
Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
|
||||
MessageDialog.open(MessageDialog.INFORMATION, parent,
|
||||
Messages.OpenTerminalHandler_OpenTerminalTitle, Messages.OpenTerminalHandler_OpenTerminalDesc, SWT.NONE);
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.internal.ui.Messages;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Control;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.dialogs.PropertyPage;
|
||||
|
||||
public class RemoteConnectionPropertyPage extends PropertyPage {
|
||||
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
Composite comp = new Composite(parent, SWT.NONE);
|
||||
comp.setLayout(new GridLayout(2, false));
|
||||
|
||||
IRemoteConnection connection = null;
|
||||
Object element = getElement();
|
||||
if (element instanceof IRemoteConnection) {
|
||||
connection = (IRemoteConnection) element;
|
||||
} else if (element instanceof IAdaptable) {
|
||||
connection = (IRemoteConnection) ((IAdaptable) element).getAdapter(IRemoteConnection.class);
|
||||
}
|
||||
|
||||
if (connection != null) {
|
||||
Label nameLabel = new Label(comp, SWT.NONE);
|
||||
nameLabel.setText(Messages.RemoteConnectionPropertyPage_ConnectionName);
|
||||
|
||||
Text nameText = new Text(comp, SWT.BORDER);
|
||||
nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
nameText.setText(connection.getName());
|
||||
}
|
||||
|
||||
return comp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
// TODO, change the name if it needs changing
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.window.SameShellProvider;
|
||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
||||
import org.eclipse.ui.navigator.CommonActionProvider;
|
||||
|
||||
public class RemoteConnectionsActionProvider extends CommonActionProvider {
|
||||
|
||||
@Override
|
||||
public void fillContextMenu(IMenuManager menu) {
|
||||
// Property menu
|
||||
menu.add(new PropertyDialogAction(new SameShellProvider(getActionSite().getViewSite().getShell()),
|
||||
getActionSite().getStructuredViewer()));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.jface.viewers.ITreeContentProvider;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
|
||||
public class RemoteConnectionsContentProvider implements ITreeContentProvider, IRemoteConnectionChangeListener {
|
||||
|
||||
private IRemoteServicesManager remoteServicesManager;
|
||||
private Viewer viewer;
|
||||
|
||||
@Override
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
this.viewer = viewer;
|
||||
|
||||
if (newInput instanceof IRemoteServicesManager) {
|
||||
if (remoteServicesManager != null) {
|
||||
// remove us as a listener on the old manager
|
||||
remoteServicesManager.removeRemoteConnectionChangeListener(this);
|
||||
}
|
||||
|
||||
remoteServicesManager = (IRemoteServicesManager) newInput;
|
||||
remoteServicesManager.addRemoteConnectionChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionChanged(RemoteConnectionChangeEvent event) {
|
||||
// Refresh the viewer on the UI thread
|
||||
viewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
viewer.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (remoteServicesManager != null) {
|
||||
remoteServicesManager.removeRemoteConnectionChangeListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return remoteServicesManager.getAllRemoteConnections().toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
// Connections have no children by default
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParent(Object element) {
|
||||
if (element instanceof IRemoteConnection) {
|
||||
return remoteServicesManager;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasChildren(Object element) {
|
||||
if (element instanceof IRemoteServicesManager) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package org.eclipse.remote.internal.ui.views;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
|
||||
|
||||
public class RemoteConnectionsLabelProvider extends LabelProvider {
|
||||
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
if (element instanceof IRemoteConnection) {
|
||||
return ((IRemoteConnection) element).getName();
|
||||
} else {
|
||||
return super.getText(element);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(Object element) {
|
||||
// TODO Need a method to get icons for the UI connection managers.
|
||||
return super.getImage(element);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2015 QNX Software Systems 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:
|
||||
* QNX - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.remote.internal.ui.views;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.internal.ui.RemoteUIPlugin;
|
||||
import org.eclipse.ui.navigator.CommonNavigator;
|
||||
|
||||
public class RemoteConnectionsView extends CommonNavigator {
|
||||
|
||||
@Override
|
||||
protected Object getInitialInput() {
|
||||
// the remote services manager is the root object
|
||||
return RemoteUIPlugin.getService(IRemoteServicesManager.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
DeleteRemoteConnectionHandler_ConfirmDeleteMessage=Delete connection
|
||||
DeleteRemoteConnectionHandler_DeleteConnectionTitle=Delete Connection
|
|
@ -27,18 +27,9 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
/**
|
||||
* Abstract base class for providing UI connection manager services.
|
||||
*
|
||||
* @since 7.0
|
||||
*/
|
||||
public abstract class AbstractRemoteUIConnectionManager implements IRemoteUIConnectionManager {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#
|
||||
* openConnectionWithProgress(org.eclipse.swt.widgets.Shell,
|
||||
* org.eclipse.jface.operation.IRunnableContext,
|
||||
* org.eclipse.remote.core.IRemoteConnection)
|
||||
*/
|
||||
public abstract class AbstractRemoteUIConnectionManager implements IRemoteUIConnectionService {
|
||||
|
||||
public void openConnectionWithProgress(final Shell shell, IRunnableContext context, final IRemoteConnection connection) {
|
||||
if (!connection.isOpen()) {
|
||||
IRunnableWithProgress op = new IRunnableWithProgress() {
|
||||
|
@ -70,4 +61,5 @@ public abstract class AbstractRemoteUIConnectionManager implements IRemoteUIConn
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,13 +12,15 @@ package org.eclipse.remote.ui;
|
|||
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Interface for providing connection management operations in the UI. Clients can call these methods to open generic dialogs for
|
||||
* operations on connections.
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteUIConnectionManager {
|
||||
public interface IRemoteUIConnectionService extends IRemoteConnectionType.Service {
|
||||
/**
|
||||
* Create a wizard for adding or editing connections. The implementation can choose to do this in any way, but typically will
|
||||
* use a dialog or wizard.
|
|
@ -12,12 +12,13 @@ package org.eclipse.remote.ui;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jface.wizard.IWizard;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
||||
/**
|
||||
* Interface for creating and editing connections in the UI.
|
||||
*/
|
||||
public interface IRemoteUIConnectionWizard {
|
||||
public interface IRemoteUIConnectionWizard extends IWizard {
|
||||
/**
|
||||
* Open configuration wizard allowing the user to enter information about a connection. If the user confirms the information is
|
||||
* correct (e.g. selects OK in a dialog) then a working copy of the connection is returned. If the user discards the
|
||||
|
@ -25,7 +26,15 @@ public interface IRemoteUIConnectionWizard {
|
|||
*
|
||||
* @return connection working copy or null if the wizard is canceled
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy open();
|
||||
IRemoteConnectionWorkingCopy open();
|
||||
|
||||
/**
|
||||
* Get the connection being edited.
|
||||
*
|
||||
* @return connection being edited
|
||||
* @since 2.0
|
||||
*/
|
||||
IRemoteConnectionWorkingCopy getConnection();
|
||||
|
||||
/**
|
||||
* Set a connection containing the information to be edited by the wizard. Setting this value overrides the
|
||||
|
@ -34,7 +43,7 @@ public interface IRemoteUIConnectionWizard {
|
|||
* @param connection
|
||||
* connection used to initialize the wizard
|
||||
*/
|
||||
public void setConnection(IRemoteConnectionWorkingCopy connection);
|
||||
void setConnection(IRemoteConnectionWorkingCopy connection);
|
||||
|
||||
/**
|
||||
* Set the initial name of the connection.
|
||||
|
@ -42,7 +51,7 @@ public interface IRemoteUIConnectionWizard {
|
|||
* @param name
|
||||
* initial connection name
|
||||
*/
|
||||
public void setConnectionName(String name);
|
||||
void setConnectionName(String name);
|
||||
|
||||
/**
|
||||
* Supply a set of connection names that are invalid. The dialog should display an error if the user trys to select a name from
|
||||
|
@ -51,5 +60,6 @@ public interface IRemoteUIConnectionWizard {
|
|||
* @param names
|
||||
* set of invalid connections names
|
||||
*/
|
||||
public void setInvalidConnectionNames(Set<String> names);
|
||||
void setInvalidConnectionNames(Set<String> names);
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue