mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-02 22:05:44 +02:00
Changes to remote support, including adding
IRemoteConnectionWorkingCopy. Added connection preference page. Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
bb84e48cd4
commit
d6bcaedc01
48 changed files with 1836 additions and 604 deletions
|
@ -9,6 +9,7 @@ import junit.framework.TestCase;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.IRemoteFileManager;
|
import org.eclipse.remote.core.IRemoteFileManager;
|
||||||
import org.eclipse.remote.core.IRemoteProcess;
|
import org.eclipse.remote.core.IRemoteProcess;
|
||||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||||
|
@ -126,9 +127,11 @@ public class ConnectionTests extends TestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
assertNotNull(fRemoteConnection);
|
assertNotNull(fRemoteConnection);
|
||||||
fRemoteConnection.setAddress(HOST);
|
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||||
fRemoteConnection.setUsername(USERNAME);
|
wc.setAddress(HOST);
|
||||||
fRemoteConnection.setPassword(PASSWORD);
|
wc.setUsername(USERNAME);
|
||||||
|
wc.setPassword(PASSWORD);
|
||||||
|
wc.save();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fRemoteConnection.open(new NullProgressMonitor());
|
fRemoteConnection.open(new NullProgressMonitor());
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.IRemoteFileManager;
|
import org.eclipse.remote.core.IRemoteFileManager;
|
||||||
import org.eclipse.remote.core.IRemoteServices;
|
import org.eclipse.remote.core.IRemoteServices;
|
||||||
import org.eclipse.remote.core.RemoteServices;
|
import org.eclipse.remote.core.RemoteServices;
|
||||||
|
@ -133,9 +134,11 @@ public class FileStoreTests extends TestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
assertNotNull(fRemoteConnection);
|
assertNotNull(fRemoteConnection);
|
||||||
fRemoteConnection.setAddress(HOST);
|
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||||
fRemoteConnection.setUsername(USERNAME);
|
wc.setAddress(HOST);
|
||||||
fRemoteConnection.setPassword(PASSWORD);
|
wc.setUsername(USERNAME);
|
||||||
|
wc.setPassword(PASSWORD);
|
||||||
|
wc.save();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fRemoteConnection.open(new NullProgressMonitor());
|
fRemoteConnection.open(new NullProgressMonitor());
|
||||||
|
|
|
@ -12,6 +12,7 @@ import junit.framework.TestCase;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.IRemoteProcess;
|
import org.eclipse.remote.core.IRemoteProcess;
|
||||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||||
import org.eclipse.remote.core.IRemoteServices;
|
import org.eclipse.remote.core.IRemoteServices;
|
||||||
|
@ -113,9 +114,11 @@ public class ProcessTests extends TestCase {
|
||||||
fail(e.getLocalizedMessage());
|
fail(e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
assertNotNull(fRemoteConnection);
|
assertNotNull(fRemoteConnection);
|
||||||
fRemoteConnection.setAddress(HOST);
|
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||||
fRemoteConnection.setUsername(USERNAME);
|
wc.setAddress(HOST);
|
||||||
fRemoteConnection.setPassword(PASSWORD);
|
wc.setUsername(USERNAME);
|
||||||
|
wc.setPassword(PASSWORD);
|
||||||
|
wc.save();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fRemoteConnection.open(new NullProgressMonitor());
|
fRemoteConnection.open(new NullProgressMonitor());
|
||||||
|
|
|
@ -18,3 +18,4 @@ Export-Package: org.eclipse.internal.remote.core;x-friends:="org.eclipse.remote.
|
||||||
org.eclipse.remote.core.exception
|
org.eclipse.remote.core.exception
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||||
|
Import-Package: org.eclipse.equinox.security.storage
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
class="org.eclipse.internal.remote.core.services.local.LocalServicesFactory"
|
class="org.eclipse.internal.remote.core.services.local.LocalServicesFactory"
|
||||||
id="org.eclipse.remote.LocalServices"
|
id="org.eclipse.remote.LocalServices"
|
||||||
name="Local"
|
name="Local"
|
||||||
newConnections="false"
|
|
||||||
scheme="file">
|
scheme="file">
|
||||||
</remoteServices>
|
</remoteServices>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -88,16 +88,10 @@
|
||||||
</appInfo>
|
</appInfo>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="newConnections" type="boolean" use="required">
|
|
||||||
<annotation>
|
|
||||||
<documentation>
|
|
||||||
Indicates if this service supports the creation of new connections.
|
|
||||||
</documentation>
|
|
||||||
</annotation>
|
|
||||||
</attribute>
|
|
||||||
</complexType>
|
</complexType>
|
||||||
</element>
|
</element>
|
||||||
|
|
||||||
|
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.section type="apiInfo"/>
|
<meta.section type="apiInfo"/>
|
||||||
|
@ -107,7 +101,6 @@
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
|
|
||||||
|
|
||||||
<annotation>
|
<annotation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.section type="examples"/>
|
<meta.section type="examples"/>
|
||||||
|
@ -120,7 +113,6 @@
|
||||||
class="org.eclipse.internal.remote.core.services.local.LocalServicesFactory"
|
class="org.eclipse.internal.remote.core.services.local.LocalServicesFactory"
|
||||||
id="org.eclipse.ptp.remote.LocalServices"
|
id="org.eclipse.ptp.remote.LocalServices"
|
||||||
name="Local"
|
name="Local"
|
||||||
newConnections="false"
|
|
||||||
scheme="file">
|
scheme="file">
|
||||||
</remoteServices>
|
</remoteServices>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class RemoteCorePlugin extends Plugin {
|
||||||
ResourcesPlugin.getWorkspace().addSaveParticipant(getUniqueIdentifier(), new ISaveParticipant() {
|
ResourcesPlugin.getWorkspace().addSaveParticipant(getUniqueIdentifier(), new ISaveParticipant() {
|
||||||
@Override
|
@Override
|
||||||
public void saving(ISaveContext saveContext) throws CoreException {
|
public void saving(ISaveContext saveContext) throws CoreException {
|
||||||
Preferences.savePreferences(getUniqueIdentifier());
|
Preferences.savePreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,7 +123,7 @@ public class RemoteCorePlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop(BundleContext context) throws Exception {
|
public void stop(BundleContext context) throws Exception {
|
||||||
Preferences.savePreferences(getUniqueIdentifier());
|
Preferences.savePreferences();
|
||||||
plugin = null;
|
plugin = null;
|
||||||
super.stop(context);
|
super.stop(context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,20 +17,11 @@ import org.eclipse.remote.core.IRemoteServices;
|
||||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||||
import org.eclipse.remote.core.IRemoteServicesFactory;
|
import org.eclipse.remote.core.IRemoteServicesFactory;
|
||||||
|
|
||||||
public class RemoteServicesProxy implements IRemoteServicesDescriptor {
|
public class RemoteServicesDescriptor implements IRemoteServicesDescriptor {
|
||||||
private static final String ATTR_ID = "id"; //$NON-NLS-1$
|
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_NAME = "name"; //$NON-NLS-1$
|
||||||
private static final String ATTR_SCHEME = "scheme"; //$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 final String ATTR_CLASS = "class"; //$NON-NLS-1$
|
||||||
private static final String ATTR_NEWCONNECTIONS = "newConnections"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private static boolean getAttribute(IConfigurationElement configElement, String name, boolean defaultValue) {
|
|
||||||
String attr = configElement.getAttribute(name);
|
|
||||||
if (attr != null) {
|
|
||||||
return Boolean.parseBoolean(attr);
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getAttribute(IConfigurationElement configElement, String name, String defaultValue) {
|
private static String getAttribute(IConfigurationElement configElement, String name, String defaultValue) {
|
||||||
String value = configElement.getAttribute(name);
|
String value = configElement.getAttribute(name);
|
||||||
|
@ -48,16 +39,14 @@ public class RemoteServicesProxy implements IRemoteServicesDescriptor {
|
||||||
private final String fId;
|
private final String fId;
|
||||||
private final String fName;
|
private final String fName;
|
||||||
private final String fScheme;
|
private final String fScheme;
|
||||||
private final boolean fNewConnections;
|
|
||||||
private IRemoteServicesFactory fFactory;
|
private IRemoteServicesFactory fFactory;
|
||||||
private IRemoteServices fDelegate = null;
|
private IRemoteServices fDelegate = null;
|
||||||
|
|
||||||
public RemoteServicesProxy(IConfigurationElement configElement) {
|
public RemoteServicesDescriptor(IConfigurationElement configElement) {
|
||||||
fConfigElement = configElement;
|
fConfigElement = configElement;
|
||||||
fId = getAttribute(configElement, ATTR_ID, null);
|
fId = getAttribute(configElement, ATTR_ID, null);
|
||||||
fName = getAttribute(configElement, ATTR_NAME, fId);
|
fName = getAttribute(configElement, ATTR_NAME, fId);
|
||||||
fScheme = getAttribute(configElement, ATTR_SCHEME, null);
|
fScheme = getAttribute(configElement, ATTR_SCHEME, null);
|
||||||
fNewConnections = getAttribute(configElement, ATTR_NEWCONNECTIONS, false);
|
|
||||||
getAttribute(configElement, ATTR_CLASS, null);
|
getAttribute(configElement, ATTR_CLASS, null);
|
||||||
fFactory = null;
|
fFactory = null;
|
||||||
}
|
}
|
||||||
|
@ -65,13 +54,11 @@ public class RemoteServicesProxy implements IRemoteServicesDescriptor {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
* org.eclipse.remote.core.IRemoteServicesDescriptor#canCreateConnections
|
|
||||||
* ()
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canCreateConnections() {
|
public int compareTo(IRemoteServicesDescriptor arg0) {
|
||||||
return fNewConnections;
|
return getName().compareTo(arg0.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,9 +73,8 @@ public class RemoteServicesProxy implements IRemoteServicesDescriptor {
|
||||||
try {
|
try {
|
||||||
fFactory = (IRemoteServicesFactory) fConfigElement.createExecutableExtension(ATTR_CLASS);
|
fFactory = (IRemoteServicesFactory) fConfigElement.createExecutableExtension(ATTR_CLASS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
RemoteCorePlugin
|
RemoteCorePlugin.log(NLS.bind(Messages.RemoteServicesProxy_1, new Object[] { fConfigElement.getAttribute(ATTR_CLASS),
|
||||||
.log(NLS.bind(Messages.RemoteServicesProxy_1, new Object[] { fConfigElement.getAttribute(ATTR_CLASS), fId,
|
fId, fConfigElement.getDeclaringExtension().getNamespaceIdentifier() }));
|
||||||
fConfigElement.getDeclaringExtension().getNamespaceIdentifier() }));
|
|
||||||
}
|
}
|
||||||
return fFactory;
|
return fFactory;
|
||||||
}
|
}
|
|
@ -13,7 +13,6 @@ package org.eclipse.internal.remote.core;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -33,28 +32,21 @@ public class RemoteServicesImpl {
|
||||||
public static final String REMOTE_SERVICES_EXTENSION_POINT_ID = "remoteServices"; //$NON-NLS-1$
|
public static final String REMOTE_SERVICES_EXTENSION_POINT_ID = "remoteServices"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Active remote services plugins (not necessarily loaded)
|
// Active remote services plugins (not necessarily loaded)
|
||||||
private static final Map<String, RemoteServicesProxy> fRemoteServicesById = Collections
|
private static final Map<String, RemoteServicesDescriptor> fRemoteServicesById = Collections
|
||||||
.synchronizedMap(new HashMap<String, RemoteServicesProxy>());
|
.synchronizedMap(new HashMap<String, RemoteServicesDescriptor>());
|
||||||
private static final Map<String, RemoteServicesProxy> fRemoteServicesByScheme = Collections
|
private static final Map<String, RemoteServicesDescriptor> fRemoteServicesByScheme = Collections
|
||||||
.synchronizedMap(new HashMap<String, RemoteServicesProxy>());
|
.synchronizedMap(new HashMap<String, RemoteServicesDescriptor>());
|
||||||
|
|
||||||
private RemoteServicesImpl() {
|
private RemoteServicesImpl() {
|
||||||
// Hide constructor
|
// Hide constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RemoteServicesSorter implements Comparator<RemoteServicesProxy> {
|
public static RemoteServicesDescriptor getRemoteServiceDescriptorById(String id) {
|
||||||
@Override
|
|
||||||
public int compare(RemoteServicesProxy o1, RemoteServicesProxy o2) {
|
|
||||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RemoteServicesProxy getRemoteServiceProxyById(String id) {
|
|
||||||
retrieveRemoteServices();
|
retrieveRemoteServices();
|
||||||
return fRemoteServicesById.get(id);
|
return fRemoteServicesById.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RemoteServicesProxy getRemoteServiceProxyByURI(URI uri) {
|
public static RemoteServicesDescriptor getRemoteServiceDescriptorByURI(URI uri) {
|
||||||
String scheme = uri.getScheme();
|
String scheme = uri.getScheme();
|
||||||
if (scheme != null) {
|
if (scheme != null) {
|
||||||
retrieveRemoteServices();
|
retrieveRemoteServices();
|
||||||
|
@ -64,18 +56,18 @@ public class RemoteServicesImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a sorted list of remote service proxies.
|
* Retrieve a sorted list of remote service descriptors.
|
||||||
*
|
*
|
||||||
* @return remote service proxies
|
* @return remote service descriptors
|
||||||
*/
|
*/
|
||||||
public static RemoteServicesProxy[] getRemoteServiceProxies() {
|
public static List<RemoteServicesDescriptor> getRemoteServiceDescriptors() {
|
||||||
retrieveRemoteServices();
|
retrieveRemoteServices();
|
||||||
List<RemoteServicesProxy> services = new ArrayList<RemoteServicesProxy>();
|
List<RemoteServicesDescriptor> descriptors = new ArrayList<RemoteServicesDescriptor>();
|
||||||
for (RemoteServicesProxy proxy : fRemoteServicesById.values()) {
|
for (RemoteServicesDescriptor descriptor : fRemoteServicesById.values()) {
|
||||||
services.add(proxy);
|
descriptors.add(descriptor);
|
||||||
}
|
}
|
||||||
Collections.sort(services, new RemoteServicesSorter());
|
Collections.sort(descriptors);
|
||||||
return services.toArray(new RemoteServicesProxy[0]);
|
return descriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +84,7 @@ public class RemoteServicesImpl {
|
||||||
final IConfigurationElement[] elements = ext.getConfigurationElements();
|
final IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||||
|
|
||||||
for (IConfigurationElement ce : elements) {
|
for (IConfigurationElement ce : elements) {
|
||||||
RemoteServicesProxy proxy = new RemoteServicesProxy(ce);
|
RemoteServicesDescriptor proxy = new RemoteServicesDescriptor(ce);
|
||||||
fRemoteServicesById.put(proxy.getId(), proxy);
|
fRemoteServicesById.put(proxy.getId(), proxy);
|
||||||
fRemoteServicesByScheme.put(proxy.getScheme(), proxy);
|
fRemoteServicesByScheme.put(proxy.getScheme(), proxy);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
package org.eclipse.internal.remote.core.preferences;
|
package org.eclipse.internal.remote.core.preferences;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||||
import org.eclipse.internal.remote.core.RemoteCorePlugin;
|
|
||||||
import org.eclipse.remote.core.IRemotePreferenceConstants;
|
import org.eclipse.remote.core.IRemotePreferenceConstants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +23,6 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
Preferences.setDefaultString(RemoteCorePlugin.getUniqueIdentifier(), IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID,
|
Preferences.setDefaultString(IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID, "org.eclipse.remote.JSch"); //$NON-NLS-1$
|
||||||
IRemotePreferenceConstants.REMOTE_TOOLS_REMOTE_SERVICES_ID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import org.eclipse.internal.remote.core.RemoteCorePlugin;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience class to facilitate using the new {@link IEclipsePreferences}
|
* Convenience class to facilitate using the new {@link IEclipsePreferences} story. Adapted from
|
||||||
* story. Adapted from org.eclipse.debug.internal.core.Preferences.
|
* org.eclipse.debug.internal.core.Preferences.
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
* @noinstantiate This class is not intended to be instantiated by clients.
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
@ -33,28 +33,27 @@ public final class Preferences {
|
||||||
private static final int DEFAULT_CONTEXT = 0;
|
private static final int DEFAULT_CONTEXT = 0;
|
||||||
private static final int INSTANCE_CONTEXT = 1;
|
private static final int INSTANCE_CONTEXT = 1;
|
||||||
|
|
||||||
|
private static final String fQualifier = RemoteCorePlugin.getUniqueIdentifier();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given preference listener to the {@link DefaultScope} and the
|
* Adds the given preference listener to the {@link DefaultScope} and the {@link InstanceScope}
|
||||||
* {@link InstanceScope}
|
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
public static void addPreferenceChangeListener(String qualifier, IPreferenceChangeListener listener) {
|
public static void addPreferenceChangeListener(IPreferenceChangeListener listener) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).addPreferenceChangeListener(listener);
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).addPreferenceChangeListener(listener);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).addPreferenceChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the named preference is know in the preference store.
|
* Returns whether the named preference is know in the preference store.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean contains(String qualifier, String name) {
|
public static boolean contains(String name) {
|
||||||
return (contexts[INSTANCE_CONTEXT].getNode(qualifier).get(name, null) != null || contexts[DEFAULT_CONTEXT].getNode(
|
return (contexts[INSTANCE_CONTEXT].getNode(fQualifier).get(name, null) != null || contexts[DEFAULT_CONTEXT].getNode(
|
||||||
qualifier).get(name, null) != null);
|
fQualifier).get(name, null) != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,14 +61,13 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static boolean getBoolean(String qualifier, String key) {
|
public static boolean getBoolean(String key) {
|
||||||
return Platform.getPreferencesService().getBoolean(qualifier, key, false, null);
|
return Platform.getPreferencesService().getBoolean(fQualifier, key, false, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,14 +75,13 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static byte[] getByteArray(String qualifier, String key) {
|
public static byte[] getByteArray(String key) {
|
||||||
return Platform.getPreferencesService().getByteArray(qualifier, key, null, null);
|
return Platform.getPreferencesService().getByteArray(fQualifier, key, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,31 +89,29 @@ public final class Preferences {
|
||||||
* the given key or the specified default value if the key does not appear
|
* the given key or the specified default value if the key does not appear
|
||||||
* in the {@link DefaultScope}
|
* in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the boolean value set in the {@link DefaultScope} for the given
|
* @return the boolean value set in the {@link DefaultScope} for the given
|
||||||
* key, or the specified default value.
|
* key, or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized boolean getDefaultBoolean(String qualifier, String key, boolean defaultvalue) {
|
public static synchronized boolean getDefaultBoolean(String key, boolean defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).getBoolean(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).getBoolean(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the default byte array value stored in the {@link DefaultScope}
|
* Returns the default byte array value stored in the {@link DefaultScope} for the given key or the specified default value if
|
||||||
* for the given key or the specified default value if the key does not
|
* the key does not
|
||||||
* appear in the {@link DefaultScope}
|
* appear in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the byte array value set in the {@link DefaultScope} for the
|
* @return the byte array value set in the {@link DefaultScope} for the
|
||||||
* given key, or the specified default value.
|
* given key, or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized byte[] getDefaultByteArray(String qualifier, String key, byte[] defaultvalue) {
|
public static synchronized byte[] getDefaultByteArray(String key, byte[] defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).getByteArray(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).getByteArray(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -124,15 +119,14 @@ public final class Preferences {
|
||||||
* the given key or the specified default value if the key does not appear
|
* the given key or the specified default value if the key does not appear
|
||||||
* in the {@link DefaultScope}
|
* in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the double value set in the {@link DefaultScope} for the given
|
* @return the double value set in the {@link DefaultScope} for the given
|
||||||
* key, or the specified default value.
|
* key, or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized double getDefaultDouble(String qualifier, String key, double defaultvalue) {
|
public static synchronized double getDefaultDouble(String key, double defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).getDouble(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).getDouble(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -140,15 +134,14 @@ public final class Preferences {
|
||||||
* the given key or the specified default value if the key does not appear
|
* the given key or the specified default value if the key does not appear
|
||||||
* in the {@link DefaultScope}
|
* in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the float value set in the {@link DefaultScope} for the given
|
* @return the float value set in the {@link DefaultScope} for the given
|
||||||
* key, or the specified default value.
|
* key, or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized float getDefaultFloat(String qualifier, String key, float defaultvalue) {
|
public static synchronized float getDefaultFloat(String key, float defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).getFloat(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).getFloat(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,15 +149,14 @@ public final class Preferences {
|
||||||
* the given key or the specified default value if the key does not appear
|
* the given key or the specified default value if the key does not appear
|
||||||
* in the {@link DefaultScope}
|
* in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the integer value set in the {@link DefaultScope} for the given
|
* @return the integer value set in the {@link DefaultScope} for the given
|
||||||
* key, or the specified default value.
|
* key, or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized int getDefaultInt(String qualifier, String key, int defaultvalue) {
|
public static synchronized int getDefaultInt(String key, int defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).getInt(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).getInt(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -172,15 +164,14 @@ public final class Preferences {
|
||||||
* given key or the specified default value if the key does not appear in
|
* given key or the specified default value if the key does not appear in
|
||||||
* the {@link DefaultScope}
|
* the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the long value set in the {@link DefaultScope} for the given key,
|
* @return the long value set in the {@link DefaultScope} for the given key,
|
||||||
* or the specified default value.
|
* or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized long getDefaultLong(String qualifier, String key, long defaultvalue) {
|
public static synchronized long getDefaultLong(String key, long defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).getLong(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).getLong(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,15 +179,14 @@ public final class Preferences {
|
||||||
* the given key or the specified default value if the key does not appear
|
* the given key or the specified default value if the key does not appear
|
||||||
* in the {@link DefaultScope}
|
* in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the string value set in the {@link DefaultScope} for the given
|
* @return the string value set in the {@link DefaultScope} for the given
|
||||||
* key, or the specified default value.
|
* key, or the specified default value.
|
||||||
*/
|
*/
|
||||||
public static synchronized String getDefaultString(String qualifier, String key, String defaultvalue) {
|
public static synchronized String getDefaultString(String key, String defaultvalue) {
|
||||||
return contexts[DEFAULT_CONTEXT].getNode(qualifier).get(key, defaultvalue);
|
return contexts[DEFAULT_CONTEXT].getNode(fQualifier).get(key, defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,14 +194,13 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static double getDouble(String qualifier, String key) {
|
public static double getDouble(String key) {
|
||||||
return Platform.getPreferencesService().getDouble(qualifier, key, 0.0, null);
|
return Platform.getPreferencesService().getDouble(fQualifier, key, 0.0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,14 +208,14 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
* @param fQualifier
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static float getFloat(String qualifier, String key) {
|
public static float getFloat(String key) {
|
||||||
return Platform.getPreferencesService().getFloat(qualifier, key, 0.0f, null);
|
return Platform.getPreferencesService().getFloat(fQualifier, key, 0.0f, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -234,14 +223,14 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
* @param fQualifier
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static int getInt(String qualifier, String key) {
|
public static int getInt(String key) {
|
||||||
return Platform.getPreferencesService().getInt(qualifier, key, 0, null);
|
return Platform.getPreferencesService().getInt(fQualifier, key, 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -249,14 +238,13 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static long getLong(String qualifier, String key) {
|
public static long getLong(String key) {
|
||||||
return Platform.getPreferencesService().getLong(qualifier, key, 0L, null);
|
return Platform.getPreferencesService().getLong(fQualifier, key, 0L, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -264,27 +252,25 @@ public final class Preferences {
|
||||||
* is not defined then return the default value. Use the canonical scope
|
* is not defined then return the default value. Use the canonical scope
|
||||||
* lookup order for finding the preference value.
|
* lookup order for finding the preference value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* @param defaultvalue
|
* @param defaultvalue
|
||||||
*
|
*
|
||||||
* @return the value of the preference or the given default value
|
* @return the value of the preference or the given default value
|
||||||
*/
|
*/
|
||||||
public static String getString(String qualifier, String key) {
|
public static String getString(String key) {
|
||||||
return Platform.getPreferencesService().getString(qualifier, key, null, null);
|
return Platform.getPreferencesService().getString(fQualifier, key, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the named preference has the default value.
|
* Returns true if the named preference has the default value.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isDefault(String qualifier, String name) {
|
public static boolean isDefault(String name) {
|
||||||
String defVal = contexts[DEFAULT_CONTEXT].getNode(qualifier).get(name, null);
|
String defVal = contexts[DEFAULT_CONTEXT].getNode(fQualifier).get(name, null);
|
||||||
if (defVal != null) {
|
if (defVal != null) {
|
||||||
String val = contexts[INSTANCE_CONTEXT].getNode(qualifier).get(name, null);
|
String val = contexts[INSTANCE_CONTEXT].getNode(fQualifier).get(name, null);
|
||||||
return (val != null && val.equals(defVal));
|
return (val != null && val.equals(defVal));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -294,24 +280,21 @@ public final class Preferences {
|
||||||
* Removes the given preference listener from the {@link DefaultScope} and
|
* Removes the given preference listener from the {@link DefaultScope} and
|
||||||
* the {@link InstanceScope}
|
* the {@link InstanceScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param listener
|
* @param listener
|
||||||
*/
|
*/
|
||||||
public static void removePreferenceChangeListener(String qualifier, IPreferenceChangeListener listener) {
|
public static void removePreferenceChangeListener(IPreferenceChangeListener listener) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).removePreferenceChangeListener(listener);
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).removePreferenceChangeListener(listener);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).removePreferenceChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the preferences for the given plugin identifier. It should be noted
|
* Save the preferences for the given plugin identifier. It should be noted
|
||||||
* that all pending preference changes will be flushed with this method.
|
* that all pending preference changes will be flushed with this method.
|
||||||
*
|
|
||||||
* @param qualifier
|
|
||||||
*/
|
*/
|
||||||
public static synchronized void savePreferences(String qualifier) {
|
public static synchronized void savePreferences() {
|
||||||
try {
|
try {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).flush();
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).flush();
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).flush();
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).flush();
|
||||||
} catch (BackingStoreException bse) {
|
} catch (BackingStoreException bse) {
|
||||||
RemoteCorePlugin.log(bse);
|
RemoteCorePlugin.log(bse);
|
||||||
}
|
}
|
||||||
|
@ -320,183 +303,169 @@ public final class Preferences {
|
||||||
/**
|
/**
|
||||||
* Sets a boolean preference in the {@link InstanceScope}.
|
* Sets a boolean preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setBoolean(String qualifier, String key, boolean value) {
|
public static synchronized void setBoolean(String key, boolean value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).putBoolean(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).putBoolean(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a byte array preference in the {@link InstanceScope}.
|
* Sets a byte array preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setByteArray(String qualifier, String key, byte[] value) {
|
public static synchronized void setByteArray(String key, byte[] value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).putByteArray(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).putByteArray(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a boolean in the {@link DefaultScope}
|
* Sets a boolean in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultBoolean(String qualifier, String key, boolean value) {
|
public static synchronized void setDefaultBoolean(String key, boolean value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).putBoolean(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).putBoolean(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a byte array in the {@link DefaultScope}
|
* Sets a byte array in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultByteArray(String qualifier, String key, byte[] value) {
|
public static synchronized void setDefaultByteArray(String key, byte[] value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).putByteArray(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).putByteArray(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a double in the {@link DefaultScope}
|
* Sets a double in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultDouble(String qualifier, String key, double value) {
|
public static synchronized void setDefaultDouble(String key, double value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).putDouble(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).putDouble(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a float in the {@link DefaultScope}
|
* Sets a float in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultFloat(String qualifier, String key, float value) {
|
public static synchronized void setDefaultFloat(String key, float value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).putFloat(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).putFloat(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a integer in the {@link DefaultScope}
|
* Sets a integer in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultInt(String qualifier, String key, int value) {
|
public static synchronized void setDefaultInt(String key, int value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).putInt(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).putInt(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a long in the {@link DefaultScope}
|
* Sets a long in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultLong(String qualifier, String key, long value) {
|
public static synchronized void setDefaultLong(String key, long value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).putLong(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).putLong(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string in the {@link DefaultScope}
|
* Sets a string in the {@link DefaultScope}
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the new value
|
* the new value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDefaultString(String qualifier, String key, String value) {
|
public static synchronized void setDefaultString(String key, String value) {
|
||||||
contexts[DEFAULT_CONTEXT].getNode(qualifier).put(key, value);
|
contexts[DEFAULT_CONTEXT].getNode(fQualifier).put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a double preference in the {@link InstanceScope}.
|
* Sets a double preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setDouble(String qualifier, String key, double value) {
|
public static synchronized void setDouble(String key, double value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).putDouble(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).putDouble(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a float preference in the {@link InstanceScope}.
|
* Sets a float preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setFloat(String qualifier, String key, float value) {
|
public static synchronized void setFloat(String key, float value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).putFloat(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).putFloat(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a integer preference in the {@link InstanceScope}.
|
* Sets a integer preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setInt(String qualifier, String key, int value) {
|
public static synchronized void setInt(String key, int value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).putInt(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).putInt(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a long preference in the {@link InstanceScope}.
|
* Sets a long preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setLong(String qualifier, String key, long value) {
|
public static synchronized void setLong(String key, long value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).putLong(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).putLong(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a string preference in the {@link InstanceScope}.
|
* Sets a string preference in the {@link InstanceScope}.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key
|
* the key
|
||||||
* @param value
|
* @param value
|
||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public static synchronized void setString(String qualifier, String key, String value) {
|
public static synchronized void setString(String key, String value) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).put(key, value);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -504,13 +473,12 @@ public final class Preferences {
|
||||||
* any set value from the {@link InstanceScope}. Has no effect if the given
|
* any set value from the {@link InstanceScope}. Has no effect if the given
|
||||||
* key is <code>null</code>.
|
* key is <code>null</code>.
|
||||||
*
|
*
|
||||||
* @param qualifier
|
|
||||||
* @param key
|
* @param key
|
||||||
* the key for the preference
|
* the key for the preference
|
||||||
*/
|
*/
|
||||||
public static synchronized void setToDefault(String qualifier, String key) {
|
public static synchronized void setToDefault(String key) {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
contexts[INSTANCE_CONTEXT].getNode(qualifier).remove(key);
|
contexts[INSTANCE_CONTEXT].getNode(fQualifier).remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.IRemoteFileManager;
|
import org.eclipse.remote.core.IRemoteFileManager;
|
||||||
import org.eclipse.remote.core.IRemoteProcess;
|
import org.eclipse.remote.core.IRemoteProcess;
|
||||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||||
|
@ -33,9 +34,9 @@ import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
import org.eclipse.remote.core.exception.UnableToForwardPortException;
|
import org.eclipse.remote.core.exception.UnableToForwardPortException;
|
||||||
|
|
||||||
public class LocalConnection implements IRemoteConnection {
|
public class LocalConnection implements IRemoteConnection {
|
||||||
private String fName = IRemoteConnectionManager.LOCAL_CONNECTION_NAME;
|
private final String fName = IRemoteConnectionManager.LOCAL_CONNECTION_NAME;
|
||||||
private String fAddress = Messages.LocalConnection_1;
|
private final String fAddress = Messages.LocalConnection_1;
|
||||||
private String fUsername = System.getProperty("user.name"); //$NON-NLS-1$
|
private final String fUsername = System.getProperty("user.name"); //$NON-NLS-1$
|
||||||
private boolean fConnected = true;
|
private boolean fConnected = true;
|
||||||
private IPath fWorkingDir = null;
|
private IPath fWorkingDir = null;
|
||||||
|
|
||||||
|
@ -73,12 +74,23 @@ public class LocalConnection implements IRemoteConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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.
|
* Notify all listeners when this connection's status changes.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
private void fireConnectionChangeEvent(final int type) {
|
@Override
|
||||||
|
public void fireConnectionChangeEvent(final int type) {
|
||||||
IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
|
IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
|
||||||
@Override
|
@Override
|
||||||
public IRemoteConnection getConnection() {
|
public IRemoteConnection getConnection() {
|
||||||
|
@ -274,6 +286,16 @@ public class LocalConnection implements IRemoteConnection {
|
||||||
return fUsername;
|
return fUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||||
|
return new LocalConnectionWorkingCopy(this);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -364,76 +386,6 @@ public class LocalConnection implements IRemoteConnection {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.remote.core.IRemoteConnection#setAddress(java.lang.String
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setAddress(String address) {
|
|
||||||
fAddress = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.remote.core.IRemoteConnection#setAttribute(java.lang.
|
|
||||||
* String, java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setAttribute(String key, String value) {
|
|
||||||
// Not supported
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.remote.core.IRemoteConnection#setName(java.lang.String)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setName(String name) {
|
|
||||||
fName = name;
|
|
||||||
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_RENAMED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.remote.core.IRemoteConnection#setPassword(java.lang.String
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setPassword(String password) {
|
|
||||||
// Not supported
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setPort(int)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setPort(int port) {
|
|
||||||
// Not supported
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.remote.core.IRemoteConnection#setUsername(java.lang.String
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setUsername(String username) {
|
|
||||||
fUsername = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,6 +11,8 @@
|
||||||
package org.eclipse.internal.remote.core.services.local;
|
package org.eclipse.internal.remote.core.services.local;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.filesystem.EFS;
|
import org.eclipse.core.filesystem.EFS;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
@ -62,8 +64,10 @@ public class LocalConnectionManager implements IRemoteConnectionManager {
|
||||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
|
* org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public IRemoteConnection[] getConnections() {
|
public Set<IRemoteConnection> getConnections() {
|
||||||
return new IRemoteConnection[] { fLocalConnection };
|
Set<IRemoteConnection> set = new HashSet<IRemoteConnection>();
|
||||||
|
set.add(fLocalConnection);
|
||||||
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.internal.remote.core.services.local;
|
||||||
|
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
|
|
||||||
|
public class LocalConnectionWorkingCopy extends LocalConnection implements IRemoteConnectionWorkingCopy {
|
||||||
|
|
||||||
|
public LocalConnectionWorkingCopy(LocalConnection connection) {
|
||||||
|
super(connection.getRemoteServices());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAddress(String address) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(String key, String value) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPassword(String password) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPort(int port) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUsername(String username) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,30 +11,27 @@
|
||||||
package org.eclipse.internal.remote.core.services.local;
|
package org.eclipse.internal.remote.core.services.local;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.remote.core.AbstractRemoteServices;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||||
import org.eclipse.remote.core.IRemoteServices;
|
|
||||||
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
import org.eclipse.remote.core.IRemoteServicesDescriptor;
|
||||||
|
|
||||||
public class LocalServices implements IRemoteServices {
|
public class LocalServices extends AbstractRemoteServices {
|
||||||
public static final String LocalServicesId = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
|
public static final String LocalServicesId = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
|
||||||
|
|
||||||
private final IRemoteConnectionManager fConnMgr = new LocalConnectionManager(this);
|
private final IRemoteConnectionManager fConnMgr = new LocalConnectionManager(this);
|
||||||
private final IRemoteServicesDescriptor fDescriptor;
|
|
||||||
|
|
||||||
public LocalServices(IRemoteServicesDescriptor descriptor) {
|
public LocalServices(IRemoteServicesDescriptor descriptor) {
|
||||||
fDescriptor = descriptor;
|
super(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see org.eclipse.remote.core.IRemoteServices#getCapabilities()
|
||||||
* org.eclipse.remote.core.IRemoteServicesDescriptor#canCreateConnections
|
|
||||||
* ()
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canCreateConnections() {
|
public int getCapabilities() {
|
||||||
return fDescriptor.canCreateConnections();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -49,36 +46,6 @@ public class LocalServices implements IRemoteServices {
|
||||||
return fConnMgr;
|
return fConnMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,13 +27,11 @@ public abstract class AbstractRemoteServices implements IRemoteServices {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
* org.eclipse.remote.core.IRemoteServicesDescriptor#canCreateConnections
|
|
||||||
* ()
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canCreateConnections() {
|
public int compareTo(IRemoteServicesDescriptor o) {
|
||||||
return fDescriptor.canCreateConnections();
|
return fDescriptor.compareTo(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
* then call the {{@link #open(IProgressMonitor)} method. Once the connection is completed, call the {@link #close()} method to
|
* then call the {{@link #open(IProgressMonitor)} method. Once the connection is completed, call the {@link #close()} method to
|
||||||
* terminate the connection.
|
* terminate the connection.
|
||||||
*/
|
*/
|
||||||
public interface IRemoteConnection {
|
public interface IRemoteConnection extends Comparable<IRemoteConnection> {
|
||||||
public final static String OS_NAME_PROPERTY = "os.name"; //$NON-NLS-1$
|
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_VERSION_PROPERTY = "os.version"; //$NON-NLS-1$
|
||||||
public final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
|
public final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
|
||||||
|
@ -55,6 +55,15 @@ public interface IRemoteConnection {
|
||||||
*/
|
*/
|
||||||
public void close();
|
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
|
* 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.
|
* fwdAddress, the port will be routed via the connection machine to fwdAddress.
|
||||||
|
@ -239,6 +248,8 @@ public interface IRemoteConnection {
|
||||||
*/
|
*/
|
||||||
public String getUsername();
|
public String getUsername();
|
||||||
|
|
||||||
|
public IRemoteConnectionWorkingCopy getWorkingCopy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the working directory. Relative paths will be resolved using this path.
|
* Get the working directory. Relative paths will be resolved using this path.
|
||||||
*
|
*
|
||||||
|
@ -310,58 +321,10 @@ public interface IRemoteConnection {
|
||||||
public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
|
public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the address for this connection
|
* 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.
|
||||||
*
|
*
|
||||||
* @param address
|
* Relative paths will be resolved using this path. The path must be valid and absolute for any changes to be made.
|
||||||
*/
|
|
||||||
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()}
|
|
||||||
*
|
|
||||||
* @param key
|
|
||||||
* attribute key
|
|
||||||
* @param value
|
|
||||||
* attribute value
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
public void setAttribute(String key, String value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the name for this connection
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
*/
|
|
||||||
public void setName(String name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the password for this connection
|
|
||||||
*
|
|
||||||
* @param password
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
public void setPassword(String password);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the port used for this connection. Only valid if supported by the underlying service provider.
|
|
||||||
*
|
|
||||||
* @param port
|
|
||||||
* port number for the connection
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
public void setPort(int port);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the username for this connection
|
|
||||||
*
|
|
||||||
* @param username
|
|
||||||
*/
|
|
||||||
public void setUsername(String username);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the working directory. Relative paths will be resolved using this path. The path must be valid and absolute for any
|
|
||||||
* changes to be made.
|
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* String representing the current working directory
|
* String representing the current working directory
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.remote.core;
|
package org.eclipse.remote.core;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ public interface IRemoteConnectionManager {
|
||||||
*
|
*
|
||||||
* @return connections that we know about
|
* @return connections that we know about
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection[] getConnections();
|
public Set<IRemoteConnection> getConnections();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new remote connection named with supplied name. The connection
|
* Creates a new remote connection named with supplied name. The connection
|
||||||
|
|
|
@ -0,0 +1,65 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the name for this connection
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
public void setName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the password for this connection
|
||||||
|
*
|
||||||
|
* @param password
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public void setPassword(String password);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the port used for this connection. Only valid if supported by the underlying service provider.
|
||||||
|
*
|
||||||
|
* @param port
|
||||||
|
* port number for the connection
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public void setPort(int port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the username for this connection
|
||||||
|
*
|
||||||
|
* @param username
|
||||||
|
*/
|
||||||
|
public void setUsername(String username);
|
||||||
|
|
||||||
|
public void save();
|
||||||
|
}
|
|
@ -21,18 +21,4 @@ public interface IRemotePreferenceConstants {
|
||||||
* has been set, and if so, what the provider ID is.
|
* has been set, and if so, what the provider ID is.
|
||||||
*/
|
*/
|
||||||
public static final String PREF_REMOTE_SERVICES_ID = "remoteServicesId"; //$NON-NLS-1$
|
public static final String PREF_REMOTE_SERVICES_ID = "remoteServicesId"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
|
||||||
* ID of the Remote Tools provider
|
|
||||||
*
|
|
||||||
* @since 6.0
|
|
||||||
*/
|
|
||||||
public static final String REMOTE_TOOLS_REMOTE_SERVICES_ID = "org.eclipse.ptp.remote.RemoteTools"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ID of the RSE provider
|
|
||||||
*
|
|
||||||
* @since 6.0
|
|
||||||
*/
|
|
||||||
public static final String RSE_REMOTE_SERVICES_ID = "org.eclipse.ptp.remote.RSERemoteServices"; //$NON-NLS-1$
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -17,6 +17,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* {@link RemoteServices}. The methods on this interface can then be used to access the full range of remote services provided.
|
* {@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 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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a connection manager for managing remote connections.
|
* Get a connection manager for managing remote connections.
|
||||||
*
|
*
|
||||||
|
@ -31,4 +37,11 @@ public interface IRemoteServices extends IRemoteServicesDescriptor {
|
||||||
* @since 7.0
|
* @since 7.0
|
||||||
*/
|
*/
|
||||||
public boolean initialize(IProgressMonitor monitor);
|
public boolean initialize(IProgressMonitor monitor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the capabilities of the remote service.
|
||||||
|
*
|
||||||
|
* @return bit-wise or of capability flag constants
|
||||||
|
*/
|
||||||
|
public int getCapabilities();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,7 @@ package org.eclipse.remote.core;
|
||||||
* Interface representing a remote services provider extension. Clients can use this to find out information about the extension
|
* Interface representing a remote services provider extension. Clients can use this to find out information about the extension
|
||||||
* without loading it.
|
* without loading it.
|
||||||
*/
|
*/
|
||||||
public interface IRemoteServicesDescriptor {
|
public interface IRemoteServicesDescriptor extends Comparable<IRemoteServicesDescriptor> {
|
||||||
/**
|
|
||||||
* Test if this provider can create connections.
|
|
||||||
*
|
|
||||||
* @return true if new connections can be created
|
|
||||||
* @since 5.0
|
|
||||||
*/
|
|
||||||
public boolean canCreateConnections();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get unique ID of this service. Can be used as a lookup key.
|
* Get unique ID of this service. Can be used as a lookup key.
|
||||||
*
|
*
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.net.URI;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesProxy;
|
import org.eclipse.internal.remote.core.RemoteServicesDescriptor;
|
||||||
import org.eclipse.internal.remote.core.services.local.LocalServices;
|
import org.eclipse.internal.remote.core.services.local.LocalServices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +61,7 @@ public class RemoteServices {
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public static IRemoteServices getRemoteServices(String id, IProgressMonitor monitor) {
|
public static IRemoteServices getRemoteServices(String id, IProgressMonitor monitor) {
|
||||||
RemoteServicesProxy proxy = RemoteServicesImpl.getRemoteServiceProxyById(id);
|
RemoteServicesDescriptor proxy = RemoteServicesImpl.getRemoteServiceDescriptorById(id);
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
IRemoteServices service = proxy.getServices();
|
IRemoteServices service = proxy.getServices();
|
||||||
if (service.initialize(monitor)) {
|
if (service.initialize(monitor)) {
|
||||||
|
@ -94,7 +94,7 @@ public class RemoteServices {
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public static IRemoteServices getRemoteServices(URI uri, IProgressMonitor monitor) {
|
public static IRemoteServices getRemoteServices(URI uri, IProgressMonitor monitor) {
|
||||||
RemoteServicesProxy proxy = RemoteServicesImpl.getRemoteServiceProxyByURI(uri);
|
RemoteServicesDescriptor proxy = RemoteServicesImpl.getRemoteServiceDescriptorByURI(uri);
|
||||||
if (proxy != null) {
|
if (proxy != null) {
|
||||||
IRemoteServices service = proxy.getServices();
|
IRemoteServices service = proxy.getServices();
|
||||||
if (service.initialize(monitor)) {
|
if (service.initialize(monitor)) {
|
||||||
|
|
|
@ -17,9 +17,8 @@ import org.eclipse.core.filesystem.IFileStore;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
import org.eclipse.internal.remote.core.RemoteCorePlugin;
|
import org.eclipse.internal.remote.core.RemoteServicesDescriptor;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesProxy;
|
|
||||||
import org.eclipse.internal.remote.core.preferences.Preferences;
|
import org.eclipse.internal.remote.core.preferences.Preferences;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,8 +107,7 @@ public class RemoteServicesUtils {
|
||||||
services = RemoteServices.getRemoteServices(parts[0]);
|
services = RemoteServices.getRemoteServices(parts[0]);
|
||||||
connName = parts[1];
|
connName = parts[1];
|
||||||
} else if (parts.length == 1) {
|
} else if (parts.length == 1) {
|
||||||
String id = Preferences.getString(RemoteCorePlugin.getUniqueIdentifier(),
|
String id = Preferences.getString(IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
|
||||||
IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
services = RemoteServices.getRemoteServices(id);
|
services = RemoteServices.getRemoteServices(id);
|
||||||
}
|
}
|
||||||
|
@ -124,7 +122,7 @@ public class RemoteServicesUtils {
|
||||||
if (services != null) {
|
if (services != null) {
|
||||||
conn = services.getConnectionManager().getConnection(connName);
|
conn = services.getConnectionManager().getConnection(connName);
|
||||||
} else if (connName != null) {
|
} else if (connName != null) {
|
||||||
for (RemoteServicesProxy proxy : RemoteServicesImpl.getRemoteServiceProxies()) {
|
for (RemoteServicesDescriptor proxy : RemoteServicesImpl.getRemoteServiceDescriptors()) {
|
||||||
conn = proxy.getServices().getConnectionManager().getConnection(connName);
|
conn = proxy.getServices().getConnectionManager().getConnection(connName);
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,9 +9,10 @@ Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.core.filesystem,
|
org.eclipse.core.filesystem,
|
||||||
org.eclipse.remote.core,
|
org.eclipse.remote.core,
|
||||||
org.eclipse.jsch.core,
|
org.eclipse.jsch.core,
|
||||||
com.jcraft.jsch
|
com.jcraft.jsch,
|
||||||
|
org.eclipse.equinox.security
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
Export-Package: org.eclipse.internal.remote.jsch.core;x-internal:=true,
|
Export-Package: org.eclipse.internal.remote.jsch.core;x-friends:="org.eclipse.remote.jsch.ui",
|
||||||
org.eclipse.internal.remote.jsch.core.messages;x-internal:=true
|
org.eclipse.internal.remote.jsch.core.messages;x-internal:=true
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
pluginName=PTP JSch Support
|
pluginName=JSch Remote Support
|
||||||
pluginProvider=Eclipse PTP
|
pluginProvider=Eclipse PTP
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
class="org.eclipse.internal.remote.jsch.core.JSchServicesFactory"
|
class="org.eclipse.internal.remote.jsch.core.JSchServicesFactory"
|
||||||
id="org.eclipse.remote.JSch"
|
id="org.eclipse.remote.JSch"
|
||||||
name="JSch"
|
name="JSch"
|
||||||
newConnections="true"
|
|
||||||
scheme="ssh">
|
scheme="ssh">
|
||||||
</remoteServices>
|
</remoteServices>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
|
@ -13,10 +13,7 @@ import org.osgi.framework.ServiceReference;
|
||||||
public class Activator extends Plugin {
|
public class Activator extends Plugin {
|
||||||
|
|
||||||
// The plug-in ID
|
// The plug-in ID
|
||||||
private static final String PLUGIN_ID = "org.eclipse.ptp.remote.core.remotetools"; //$NON-NLS-1$
|
public static final String PLUGIN_ID = "org.eclipse.remote.jsch.core"; //$NON-NLS-1$
|
||||||
|
|
||||||
// The remote services ID
|
|
||||||
public static final String SERVICES_ID = "org.eclipse.ptp.remote.RemoteTools"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
// The shared instance
|
// The shared instance
|
||||||
private static Activator plugin;
|
private static Activator plugin;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.jsch.core.IJSchService;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.IRemoteFileManager;
|
import org.eclipse.remote.core.IRemoteFileManager;
|
||||||
import org.eclipse.remote.core.IRemoteProcess;
|
import org.eclipse.remote.core.IRemoteProcess;
|
||||||
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
import org.eclipse.remote.core.IRemoteProcessBuilder;
|
||||||
|
@ -48,19 +49,20 @@ import com.jcraft.jsch.UserInfo;
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public class JSchConnection implements IRemoteConnection {
|
public class JSchConnection implements IRemoteConnection {
|
||||||
private static int DEFAULT_PORT = 22;
|
protected static final int DEFAULT_PORT = 22;
|
||||||
|
protected static final int DEFAULT_TIMEOUT = 5;
|
||||||
|
protected static final boolean DEFAULT_IS_PASSWORD = true;
|
||||||
|
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
private String fWorkingDir;
|
private String fWorkingDir;
|
||||||
private final Map<String, String> fEnv = new HashMap<String, String>();
|
|
||||||
private final Map<String, String> fProperties = new HashMap<String, String>();
|
|
||||||
private String fHost;
|
|
||||||
private String fUsername;
|
|
||||||
private String fPassword;
|
|
||||||
private int fPort = DEFAULT_PORT;
|
|
||||||
private String fConnName;
|
|
||||||
private boolean fIsOpen;
|
private boolean fIsOpen;
|
||||||
|
|
||||||
private final IJSchService fJSchService;
|
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 IRemoteServices fRemoteServices;
|
||||||
private final ListenerList fListeners = new ListenerList();
|
private final ListenerList fListeners = new ListenerList();
|
||||||
private final List<Session> fSessions = new ArrayList<Session>();
|
private final List<Session> fSessions = new ArrayList<Session>();
|
||||||
|
@ -68,8 +70,9 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
private ChannelSftp fSftpChannel;
|
private ChannelSftp fSftpChannel;
|
||||||
|
|
||||||
public JSchConnection(String name, IRemoteServices services) {
|
public JSchConnection(String name, IRemoteServices services) {
|
||||||
fConnName = name;
|
|
||||||
fRemoteServices = services;
|
fRemoteServices = services;
|
||||||
|
fManager = (JSchConnectionManager) services.getConnectionManager();
|
||||||
|
fAttributes = new JSchConnectionAttributes(name);
|
||||||
fJSchService = Activator.getDefault().getService();
|
fJSchService = Activator.getDefault().getService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,10 +119,10 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
* @throws RemoteConnectionException
|
* @throws RemoteConnectionException
|
||||||
*/
|
*/
|
||||||
private void checkIsConfigured() throws RemoteConnectionException {
|
private void checkIsConfigured() throws RemoteConnectionException {
|
||||||
if (fHost == null) {
|
if (fAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, null) == null) {
|
||||||
throw new RemoteConnectionException(Messages.JSchConnection_remote_address_must_be_set);
|
throw new RemoteConnectionException(Messages.JSchConnection_remote_address_must_be_set);
|
||||||
}
|
}
|
||||||
if (fUsername == null) {
|
if (fAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, null) == null) {
|
||||||
throw new RemoteConnectionException(Messages.JSchConnection_username_must_be_set);
|
throw new RemoteConnectionException(Messages.JSchConnection_username_must_be_set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,16 +143,26 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fIsOpen = false;
|
fIsOpen = false;
|
||||||
fireConnectionChangeEvent(this, IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
|
*/
|
||||||
|
public int compareTo(IRemoteConnection o) {
|
||||||
|
return getName().compareTo(o.getName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify all fListeners when this connection's status changes.
|
* Notify all fListeners when this connection's status changes.
|
||||||
*
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
public void fireConnectionChangeEvent(final IRemoteConnection connection, final int type) {
|
public void fireConnectionChangeEvent(final int type) {
|
||||||
|
final IRemoteConnection connection = this;
|
||||||
IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
|
IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
|
||||||
public IRemoteConnection getConnection() {
|
public IRemoteConnection getConnection() {
|
||||||
return connection;
|
return connection;
|
||||||
|
@ -271,7 +284,7 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#getAddress()
|
* @see org.eclipse.remote.core.IRemoteConnection#getAddress()
|
||||||
*/
|
*/
|
||||||
public String getAddress() {
|
public String getAddress() {
|
||||||
return fHost;
|
return fAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, EMPTY_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -280,7 +293,7 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
|
* @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
|
||||||
*/
|
*/
|
||||||
public Map<String, String> getAttributes() {
|
public Map<String, String> getAttributes() {
|
||||||
return Collections.unmodifiableMap(fProperties);
|
return Collections.unmodifiableMap(fAttributes.getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -292,6 +305,22 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
throw new IOException("Not currently implemented"); //$NON-NLS-1$
|
throw new IOException("Not currently implemented"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the result of executing a pwd command.
|
||||||
|
*
|
||||||
|
* @return current working directory
|
||||||
|
*/
|
||||||
|
private String getCwd(IProgressMonitor monitor) {
|
||||||
|
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
||||||
|
ExecCommand exec = new ExecCommand(this);
|
||||||
|
try {
|
||||||
|
return exec.setCommand("pwd").getResult(subMon.newChild(10)).trim(); //$NON-NLS-1$
|
||||||
|
} catch (RemoteConnectionException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -335,13 +364,33 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
return new JSchFileManager(this);
|
return new JSchFileManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSchConnectionAttributes getInfo() {
|
||||||
|
return fAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKeyFile() {
|
||||||
|
return fAttributes.getAttribute(JSchConnectionAttributes.KEYFILE_ATTR, EMPTY_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSchConnectionManager getManager() {
|
||||||
|
return fManager;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#getName()
|
* @see org.eclipse.remote.core.IRemoteConnection#getName()
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return fConnName;
|
return fAttributes.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassphrase() {
|
||||||
|
return fAttributes.getSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, EMPTY_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return fAttributes.getSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, EMPTY_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -350,7 +399,7 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#getPort()
|
* @see org.eclipse.remote.core.IRemoteConnection#getPort()
|
||||||
*/
|
*/
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return fPort;
|
return fAttributes.getInt(JSchConnectionAttributes.PORT_ATTR, DEFAULT_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -380,15 +429,6 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
return fProperties.get(key);
|
return fProperties.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the result of executing a pwd command.
|
|
||||||
*
|
|
||||||
* @return current working directory
|
|
||||||
*/
|
|
||||||
private String getPwd() {
|
|
||||||
return null; // TODO: implement
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -419,13 +459,26 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
return fSftpChannel;
|
return fSftpChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimeout() {
|
||||||
|
return fAttributes.getInt(JSchConnectionAttributes.TIMEOUT_ATTR, DEFAULT_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#getUsername()
|
* @see org.eclipse.remote.core.IRemoteConnection#getUsername()
|
||||||
*/
|
*/
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return fUsername;
|
return fAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, EMPTY_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
|
||||||
|
*/
|
||||||
|
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||||
|
return new JSchConnectionWorkingCopy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -437,12 +490,9 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
return "/"; //$NON-NLS-1$
|
return "/"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
if (fWorkingDir == null) {
|
|
||||||
fWorkingDir = getPwd();
|
|
||||||
if (fWorkingDir == null) {
|
if (fWorkingDir == null) {
|
||||||
return "/"; //$NON-NLS-1$
|
return "/"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return fWorkingDir;
|
return fWorkingDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,6 +505,10 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
return fIsOpen;
|
return fIsOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPasswordAuth() {
|
||||||
|
return fAttributes.getBoolean(JSchConnectionAttributes.IS_PASSWORD_ATTR, DEFAULT_IS_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
private void loadEnv(IProgressMonitor monitor) throws RemoteConnectionException {
|
private void loadEnv(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
SubMonitor subMon = SubMonitor.convert(monitor, 10);
|
||||||
ExecCommand exec = new ExecCommand(this);
|
ExecCommand exec = new ExecCommand(this);
|
||||||
|
@ -523,7 +577,7 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
fProperties.put(FILE_SEPARATOR_PROPERTY, "/"); //$NON-NLS-1$
|
fProperties.put(FILE_SEPARATOR_PROPERTY, "/"); //$NON-NLS-1$
|
||||||
fProperties.put(PATH_SEPARATOR_PROPERTY, ":"); //$NON-NLS-1$
|
fProperties.put(PATH_SEPARATOR_PROPERTY, ":"); //$NON-NLS-1$
|
||||||
fProperties.put(LINE_SEPARATOR_PROPERTY, "\n"); //$NON-NLS-1$
|
fProperties.put(LINE_SEPARATOR_PROPERTY, "\n"); //$NON-NLS-1$
|
||||||
fProperties.put(USER_HOME_PROPERTY, getPwd());
|
fProperties.put(USER_HOME_PROPERTY, getWorkingDirectory());
|
||||||
|
|
||||||
ExecCommand exec = new ExecCommand(this);
|
ExecCommand exec = new ExecCommand(this);
|
||||||
String osVersion;
|
String osVersion;
|
||||||
|
@ -566,8 +620,8 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
private Session newSession(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
|
private Session newSession(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||||
SubMonitor progress = SubMonitor.convert(monitor, 10);
|
SubMonitor progress = SubMonitor.convert(monitor, 10);
|
||||||
try {
|
try {
|
||||||
final IJSchLocation location = fJSchService.getLocation(fUsername, fHost, fPort);
|
final IJSchLocation location = fJSchService.getLocation(getUsername(), getAddress(), getPort());
|
||||||
location.setPassword(fPassword);
|
location.setPassword(getPassword());
|
||||||
UserInfo userInfo = null;
|
UserInfo userInfo = null;
|
||||||
if (authenticator != null) {
|
if (authenticator != null) {
|
||||||
userInfo = new UserInfo() {
|
userInfo = new UserInfo() {
|
||||||
|
@ -607,7 +661,7 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Session session = fJSchService.createSession(location, userInfo);
|
Session session = fJSchService.createSession(location, userInfo);
|
||||||
session.setPassword(fPassword);
|
session.setPassword(getPassword());
|
||||||
fJSchService.connect(session, 0, progress.newChild(10));
|
fJSchService.connect(session, 0, progress.newChild(10));
|
||||||
if (!progress.isCanceled()) {
|
if (!progress.isCanceled()) {
|
||||||
fSessions.add(session);
|
fSessions.add(session);
|
||||||
|
@ -637,16 +691,17 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
public void open(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
|
public void open(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
|
||||||
if (!isOpen()) {
|
if (!isOpen()) {
|
||||||
checkIsConfigured();
|
checkIsConfigured();
|
||||||
SubMonitor subMon = SubMonitor.convert(monitor, 30);
|
SubMonitor subMon = SubMonitor.convert(monitor, 70);
|
||||||
Session session = newSession(authenticator, subMon.newChild(10));
|
Session session = newSession(authenticator, subMon.newChild(10));
|
||||||
if (!subMon.isCanceled()) {
|
if (!subMon.isCanceled()) {
|
||||||
if (!checkConfiguration(session, subMon.newChild(20))) {
|
if (!checkConfiguration(session, subMon.newChild(20))) {
|
||||||
newSession(authenticator, subMon.newChild(10));
|
newSession(authenticator, subMon.newChild(10));
|
||||||
loadEnv(subMon.newChild(10));
|
loadEnv(subMon.newChild(10));
|
||||||
}
|
}
|
||||||
|
fWorkingDir = getCwd(subMon.newChild(10));
|
||||||
loadProperties(subMon.newChild(10));
|
loadProperties(subMon.newChild(10));
|
||||||
fIsOpen = true;
|
fIsOpen = true;
|
||||||
fireConnectionChangeEvent(this, IRemoteConnectionChangeEvent.CONNECTION_OPENED);
|
fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -703,61 +758,6 @@ public class JSchConnection implements IRemoteConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setAddress(java.lang.String )
|
|
||||||
*/
|
|
||||||
public void setAddress(String address) {
|
|
||||||
fHost = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setAttribute(java.lang. String, java.lang.String)
|
|
||||||
*/
|
|
||||||
public void setAttribute(String key, String value) {
|
|
||||||
fProperties.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setName(java.lang.String)
|
|
||||||
*/
|
|
||||||
public void setName(String name) {
|
|
||||||
fConnName = name;
|
|
||||||
fireConnectionChangeEvent(this, IRemoteConnectionChangeEvent.CONNECTION_RENAMED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setPassword(java.lang.String )
|
|
||||||
*/
|
|
||||||
public void setPassword(String password) {
|
|
||||||
fPassword = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setPort(int)
|
|
||||||
*/
|
|
||||||
public void setPort(int port) {
|
|
||||||
fPort = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.remote.core.IRemoteConnection#setUsername(java.lang.String )
|
|
||||||
*/
|
|
||||||
public void setUsername(String userName) {
|
|
||||||
fUsername = userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,213 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.internal.remote.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 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 KEYFILE_ATTR = "JSCH_KEYFILE_ATTR"; //$NON-NLS-1$
|
||||||
|
public static final String TIMEOUT_ATTR = "JSCH_TIMEOUT_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>());
|
||||||
|
|
||||||
|
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.getSecureAttributes().putAll(fSecureAttributes);
|
||||||
|
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 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) {
|
||||||
|
if (fSecureAttributes.containsKey(key)) {
|
||||||
|
return fSecureAttributes.get(key);
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(String key, int def) {
|
||||||
|
try {
|
||||||
|
return Integer.parseInt(fAttributes.get(key));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean(String key, boolean def) {
|
||||||
|
if (fAttributes.containsKey(key)) {
|
||||||
|
return Boolean.parseBoolean(fAttributes.get(key));
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getSecureAttributes() {
|
||||||
|
return fSecureAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
ISecurePreferences secRoot = SecurePreferencesFactory.getDefault();
|
||||||
|
ISecurePreferences secConnections = secRoot.node(CONNECTIONS_KEY);
|
||||||
|
ISecurePreferences secNode = secConnections.node(fName);
|
||||||
|
try {
|
||||||
|
loadAuthAttributes(secNode);
|
||||||
|
} catch (StorageException e) {
|
||||||
|
Activator.log(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAttributes(Preferences node) throws BackingStoreException {
|
||||||
|
fAttributes.clear();
|
||||||
|
for (String key : node.keys()) {
|
||||||
|
fAttributes.put(key, node.get(key, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadAuthAttributes(ISecurePreferences node) throws StorageException {
|
||||||
|
fSecureAttributes.clear();
|
||||||
|
for (String key : node.keys()) {
|
||||||
|
fSecureAttributes.put(key, node.get(key, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
clearPreferences();
|
||||||
|
if (fNewName != null) {
|
||||||
|
fName = fNewName;
|
||||||
|
fNewName = null;
|
||||||
|
}
|
||||||
|
savePreferences();
|
||||||
|
flushPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
clearPreferences();
|
||||||
|
flushPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void savePreferences() {
|
||||||
|
Preferences node = getPreferences();
|
||||||
|
synchronized (fAttributes) {
|
||||||
|
for (Entry<String, String> entry : fAttributes.entrySet()) {
|
||||||
|
node.put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
fSecureAttributes.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,18 +13,23 @@ package org.eclipse.internal.remote.jsch.core;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
|
import org.eclipse.core.runtime.preferences.InstanceScope;
|
||||||
import org.eclipse.internal.remote.jsch.core.messages.Messages;
|
import org.eclipse.internal.remote.jsch.core.messages.Messages;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||||
import org.eclipse.remote.core.IRemoteServices;
|
import org.eclipse.remote.core.IRemoteServices;
|
||||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
import org.osgi.service.prefs.Preferences;
|
||||||
|
|
||||||
public class JSchConnectionManager implements IRemoteConnectionManager {
|
public class JSchConnectionManager implements IRemoteConnectionManager {
|
||||||
private final IRemoteServices fRemoteServices;
|
private final IRemoteServices fRemoteServices;
|
||||||
private final Map<String, IRemoteConnection> fConnections = Collections
|
private Map<String, JSchConnection> fConnections;
|
||||||
.synchronizedMap(new HashMap<String, IRemoteConnection>());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
|
@ -41,6 +46,7 @@ public class JSchConnectionManager implements IRemoteConnectionManager {
|
||||||
* .lang.String)
|
* .lang.String)
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection getConnection(String name) {
|
public IRemoteConnection getConnection(String name) {
|
||||||
|
loadConnections();
|
||||||
return fConnections.get(name);
|
return fConnections.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,14 +68,53 @@ public class JSchConnectionManager implements IRemoteConnectionManager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSchConnection createConnection(String name) {
|
||||||
|
return new JSchConnection(name, fRemoteServices);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see
|
||||||
* org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
|
* org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection[] getConnections() {
|
public Set<IRemoteConnection> getConnections() {
|
||||||
return fConnections.values().toArray(new IRemoteConnection[fConnections.size()]);
|
loadConnections();
|
||||||
|
Set<IRemoteConnection> set = new HashSet<IRemoteConnection>();
|
||||||
|
set.addAll(fConnections.values());
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
// private void loadAuth(ISecurePreferences node) throws StorageException {
|
||||||
|
// JSchConnection connection = fConnections.get(node.name());
|
||||||
|
// if (connection != null) {
|
||||||
|
// boolean isPasswordAuth = node.getBoolean(IS_PASSWORD_AUTH_KEY, true);
|
||||||
|
// connection.setIsPasswordAuth(isPasswordAuth);
|
||||||
|
// if (isPasswordAuth) {
|
||||||
|
// connection.setPassword(node.get(PASSWORD_KEY, null));
|
||||||
|
// } else {
|
||||||
|
// connection.setPassphrase(node.get(PASSPHRASE_KEY, null));
|
||||||
|
// connection.setKeyFile(node.get(KEYFILE_KEY, null));
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// node.removeNode();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
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, fRemoteServices);
|
||||||
|
fConnections.put(name, connection);
|
||||||
|
}
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
Activator.log(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -86,9 +131,19 @@ public class JSchConnectionManager implements IRemoteConnectionManager {
|
||||||
if (getConnection(name) != null) {
|
if (getConnection(name) != null) {
|
||||||
throw new RemoteConnectionException(Messages.JSchConnectionManager_connection_with_this_name_exists);
|
throw new RemoteConnectionException(Messages.JSchConnectionManager_connection_with_this_name_exists);
|
||||||
}
|
}
|
||||||
IRemoteConnection connection = new JSchConnection(name, fRemoteServices);
|
return createConnection(name);
|
||||||
fConnections.put(name, connection);
|
}
|
||||||
return connection;
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -105,6 +160,62 @@ public class JSchConnectionManager implements IRemoteConnectionManager {
|
||||||
if (conn.isOpen()) {
|
if (conn.isOpen()) {
|
||||||
throw new RemoteConnectionException(Messages.JSchConnectionManager_cannotRemoveOpenConnection);
|
throw new RemoteConnectionException(Messages.JSchConnectionManager_cannotRemoveOpenConnection);
|
||||||
}
|
}
|
||||||
|
((JSchConnection) conn).getInfo().remove();
|
||||||
fConnections.remove(conn.getName());
|
fConnections.remove(conn.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private void saveAuth(JSchConnection conn, ISecurePreferences node) throws StorageException {
|
||||||
|
// boolean isPasswordAuth = conn.isPasswordAuth();
|
||||||
|
// node.putBoolean(IS_PASSWORD_AUTH_KEY, isPasswordAuth, false);
|
||||||
|
// if (isPasswordAuth) {
|
||||||
|
// node.put(PASSWORD_KEY, conn.getPassword(), true);
|
||||||
|
// } else {
|
||||||
|
// node.put(PASSPHRASE_KEY, conn.getPassphrase(), true);
|
||||||
|
// node.put(KEYFILE_KEY, conn.getKeyFile(), false);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void saveConnection(JSchConnection conn, Preferences node) {
|
||||||
|
// node.put(HOST_KEY, conn.getAddress());
|
||||||
|
// node.put(USER_KEY, conn.getUsername());
|
||||||
|
// node.putInt(PORT_KEY, conn.getPort());
|
||||||
|
// node.putInt(TIMEOUT_KEY, conn.getTimeout());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public synchronized void saveConnections() {
|
||||||
|
// if (fConnections != null) {
|
||||||
|
// IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
|
||||||
|
// Preferences connections = root.node(CONNECTIONS_KEY);
|
||||||
|
// try {
|
||||||
|
// connections.clear();
|
||||||
|
// } catch (BackingStoreException e) {
|
||||||
|
// Activator.log(e.getMessage());
|
||||||
|
// }
|
||||||
|
// for (JSchConnection conn : fConnections.values()) {
|
||||||
|
// Preferences node = connections.node(conn.getName());
|
||||||
|
// saveConnection(conn, node);
|
||||||
|
// }
|
||||||
|
// ISecurePreferences secRoot = SecurePreferencesFactory.getDefault();
|
||||||
|
// ISecurePreferences secConnections = secRoot.node("org.eclipse.remote.jsch.connections");
|
||||||
|
// secConnections.clear();
|
||||||
|
// try {
|
||||||
|
// for (JSchConnection conn : fConnections.values()) {
|
||||||
|
// ISecurePreferences secNode = secConnections.node(conn.getName());
|
||||||
|
// saveAuth(conn, secNode);
|
||||||
|
// }
|
||||||
|
// } catch (StorageException e) {
|
||||||
|
// Activator.log(e.getMessage());
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// root.flush();
|
||||||
|
// } catch (BackingStoreException e) {
|
||||||
|
// Activator.log(e.getMessage());
|
||||||
|
// }
|
||||||
|
// try {
|
||||||
|
// secRoot.flush();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// Activator.log(e.getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,231 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2007, 2010 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.internal.remote.jsch.core;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public JSchConnectionWorkingCopy(JSchConnection connection) {
|
||||||
|
super(connection.getName(), connection.getRemoteServices());
|
||||||
|
fWorkingAttributes = connection.getInfo().copy();
|
||||||
|
fOriginal = connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (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());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKeyFile() {
|
||||||
|
return fWorkingAttributes.getAttribute(JSchConnectionAttributes.KEYFILE_ATTR, EMPTY_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnection#getName()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return fWorkingAttributes.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.internal.remote.jsch.core.JSchConnection#getPassphrase()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getPassphrase() {
|
||||||
|
return fWorkingAttributes.getSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, EMPTY_STRING);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.internal.remote.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.internal.remote.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 null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.internal.remote.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()
|
||||||
|
*/
|
||||||
|
public void save() {
|
||||||
|
JSchConnectionAttributes info = fOriginal.getInfo();
|
||||||
|
info.getAttributes().clear();
|
||||||
|
info.getAttributes().putAll(fWorkingAttributes.getAttributes());
|
||||||
|
info.getSecureAttributes().clear();
|
||||||
|
info.getSecureAttributes().putAll(fWorkingAttributes.getSecureAttributes());
|
||||||
|
if (!getName().equals(info.getName())) {
|
||||||
|
info.setName(getName());
|
||||||
|
getManager().remove(fOriginal);
|
||||||
|
fOriginal.fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_RENAMED);
|
||||||
|
}
|
||||||
|
info.save();
|
||||||
|
getManager().add(fOriginal);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAddress(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setAddress(String address) {
|
||||||
|
fWorkingAttributes.setAttribute(JSchConnectionAttributes.ADDRESS_ATTR, address);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setAttribute(String key, String value) {
|
||||||
|
fWorkingAttributes.setAttribute(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsPasswordAuth(boolean isPasswordAuth) {
|
||||||
|
fWorkingAttributes.setAttribute(JSchConnectionAttributes.IS_PASSWORD_ATTR, Boolean.toString(isPasswordAuth));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKeyFile(String keyFile) {
|
||||||
|
fWorkingAttributes.setAttribute(JSchConnectionAttributes.KEYFILE_ATTR, keyFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setName(String name) {
|
||||||
|
fWorkingAttributes.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassphrase(String passphrase) {
|
||||||
|
fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, passphrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPassword(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setPassword(String password) {
|
||||||
|
fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPort(int)
|
||||||
|
*/
|
||||||
|
public void setPort(int port) {
|
||||||
|
fWorkingAttributes.setAttribute(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTimeout(int timeout) {
|
||||||
|
fWorkingAttributes.setAttribute(JSchConnectionAttributes.TIMEOUT_ATTR, Integer.toString(timeout));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setUsername(java.lang.String)
|
||||||
|
*/
|
||||||
|
public void setUsername(String userName) {
|
||||||
|
fWorkingAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, userName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,4 +43,9 @@ public class JSchServices extends AbstractRemoteServices {
|
||||||
public boolean initialize(IProgressMonitor monitor) {
|
public boolean initialize(IProgressMonitor monitor) {
|
||||||
return true;
|
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,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2006 IBM Corporation.
|
* Copyright (c) 2013 IBM Corporation.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,11 +13,6 @@ package org.eclipse.internal.remote.jsch.core.messages;
|
||||||
|
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Daniel Felix Ferber
|
|
||||||
*
|
|
||||||
* @since 3.0
|
|
||||||
*/
|
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_ID = "org.eclipse.internal.remote.jsch.core.messages.messages"; //$NON-NLS-1$
|
private static final String BUNDLE_ID = "org.eclipse.internal.remote.jsch.core.messages.messages"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
AbstractRemoteCommand_Get_symlink_target=Get symlink target
|
|
||||||
AbstractRemoteCommand_Operation_cancelled_by_user=Operation cancelled by user
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2006 IBM Corporation.
|
# Copyright (c) 2013 IBM Corporation.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +8,8 @@ AbstractRemoteCommand_Operation_cancelled_by_user=Operation cancelled by user
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# IBM Corporation - initial implementation
|
# IBM Corporation - initial implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
AbstractRemoteCommand_Get_symlink_target=Get symlink target
|
||||||
|
AbstractRemoteCommand_Operation_cancelled_by_user=Operation cancelled by user
|
||||||
AbstractRemoteCommand_Execution_exception=Execution exception
|
AbstractRemoteCommand_Execution_exception=Execution exception
|
||||||
AuthInfo_Authentication_message=Authentication Message
|
AuthInfo_Authentication_message=Authentication Message
|
||||||
ChildInfosCommand_Get_file_attributes=Get file attributes
|
ChildInfosCommand_Get_file_attributes=Get file attributes
|
||||||
|
|
|
@ -7,6 +7,7 @@ Bundle-Activator: org.eclipse.internal.remote.ui.RemoteUIPlugin
|
||||||
Bundle-Vendor: %pluginProvider
|
Bundle-Vendor: %pluginProvider
|
||||||
Require-Bundle: org.eclipse.ui,
|
Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.ui.ide,
|
org.eclipse.ui.ide,
|
||||||
|
org.eclipse.ui.forms,
|
||||||
org.eclipse.core.runtime,
|
org.eclipse.core.runtime,
|
||||||
org.eclipse.remote.core,
|
org.eclipse.remote.core,
|
||||||
org.eclipse.core.filesystem,
|
org.eclipse.core.filesystem,
|
||||||
|
|
|
@ -10,3 +10,4 @@
|
||||||
pluginName=PTP Remote UI
|
pluginName=PTP Remote UI
|
||||||
pluginProvider=Eclipse PTP
|
pluginProvider=Eclipse PTP
|
||||||
RemoteDevPrefPage.name=Remote Development
|
RemoteDevPrefPage.name=Remote Development
|
||||||
|
ConnectionsPreferencePage.name=Connections
|
|
@ -6,7 +6,7 @@
|
||||||
point="org.eclipse.remote.ui.remoteUIServices">
|
point="org.eclipse.remote.ui.remoteUIServices">
|
||||||
<remoteUIServices
|
<remoteUIServices
|
||||||
class="org.eclipse.internal.remote.ui.services.local.LocalUIServicesFactory"
|
class="org.eclipse.internal.remote.ui.services.local.LocalUIServicesFactory"
|
||||||
id="org.eclipse.ptp.remote.LocalServices"
|
id="org.eclipse.remote.LocalServices"
|
||||||
name="Local">
|
name="Local">
|
||||||
</remoteUIServices>
|
</remoteUIServices>
|
||||||
</extension>
|
</extension>
|
||||||
|
@ -18,5 +18,14 @@
|
||||||
name="%RemoteDevPrefPage.name">
|
name="%RemoteDevPrefPage.name">
|
||||||
</page>
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
|
<extension
|
||||||
|
point="org.eclipse.ui.preferencePages">
|
||||||
|
<page
|
||||||
|
category="org.eclipse.remote.ui.RemoteDevelopmentPreferencePage"
|
||||||
|
class="org.eclipse.internal.remote.ui.preferences.ConnectionsPreferencePage"
|
||||||
|
id="org.eclipse.remote.connections"
|
||||||
|
name="%ConnectionsPreferencePage.name">
|
||||||
|
</page>
|
||||||
|
</extension>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
|
@ -20,6 +20,20 @@ public class Messages extends NLS {
|
||||||
|
|
||||||
public static String AbstractRemoteUIConnectionManager_Could_not_open_connection;
|
public static String AbstractRemoteUIConnectionManager_Could_not_open_connection;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_Add;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_Connection_Name;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_Edit;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_Host;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_Remote_Services;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_Remove;
|
||||||
|
|
||||||
|
public static String ConnectionsPreferencePage_User;
|
||||||
|
|
||||||
public static String LocalUIConnectionManager_0;
|
public static String LocalUIConnectionManager_0;
|
||||||
public static String LocalUIConnectionManager_1;
|
public static String LocalUIConnectionManager_1;
|
||||||
public static String LocalUIConnectionManager_2;
|
public static String LocalUIConnectionManager_2;
|
||||||
|
@ -44,6 +58,14 @@ public class Messages extends NLS {
|
||||||
public static String RemoteDirectoryWidget_2;
|
public static String RemoteDirectoryWidget_2;
|
||||||
public static String RemoteDirectoryWidget_3;
|
public static String RemoteDirectoryWidget_3;
|
||||||
|
|
||||||
|
public static String RemoteFileWidget_Browse;
|
||||||
|
|
||||||
|
public static String RemoteFileWidget_File;
|
||||||
|
|
||||||
|
public static String RemoteFileWidget_Restore_Default;
|
||||||
|
|
||||||
|
public static String RemoteFileWidget_Select_File;
|
||||||
|
|
||||||
public static String RemoteResourceBrowser_resourceTitle;
|
public static String RemoteResourceBrowser_resourceTitle;
|
||||||
public static String RemoteResourceBrowser_fileTitle;
|
public static String RemoteResourceBrowser_fileTitle;
|
||||||
public static String RemoteResourceBrowser_directoryTitle;
|
public static String RemoteResourceBrowser_directoryTitle;
|
||||||
|
|
|
@ -7,6 +7,13 @@ AbstractRemoteUIConnectionManager_Could_not_open_connection=Could not open conne
|
||||||
# http://www.eclipse.org/legal/epl-v10.html
|
# http://www.eclipse.org/legal/epl-v10.html
|
||||||
###############################################################################
|
###############################################################################
|
||||||
AbstractRemoteUIConnectionManager_Connection_Error=Connection Error
|
AbstractRemoteUIConnectionManager_Connection_Error=Connection Error
|
||||||
|
ConnectionsPreferencePage_Add=Add
|
||||||
|
ConnectionsPreferencePage_Connection_Name=Connection Name
|
||||||
|
ConnectionsPreferencePage_Edit=Edit
|
||||||
|
ConnectionsPreferencePage_Host=Host
|
||||||
|
ConnectionsPreferencePage_Remote_Services=Remote Services:
|
||||||
|
ConnectionsPreferencePage_Remove=Remove
|
||||||
|
ConnectionsPreferencePage_User=User
|
||||||
LocalUIConnectionManager_0=Connection Error
|
LocalUIConnectionManager_0=Connection Error
|
||||||
LocalUIConnectionManager_1=Could not open connection
|
LocalUIConnectionManager_1=Could not open connection
|
||||||
LocalUIConnectionManager_2=Can not create local connection
|
LocalUIConnectionManager_2=Can not create local connection
|
||||||
|
@ -26,6 +33,10 @@ RemoteDirectoryWidget_0=Select Directory
|
||||||
RemoteDirectoryWidget_1=Directory:
|
RemoteDirectoryWidget_1=Directory:
|
||||||
RemoteDirectoryWidget_2=Browse...
|
RemoteDirectoryWidget_2=Browse...
|
||||||
RemoteDirectoryWidget_3=Restore Default
|
RemoteDirectoryWidget_3=Restore Default
|
||||||
|
RemoteFileWidget_Browse=Browse...
|
||||||
|
RemoteFileWidget_File=File:
|
||||||
|
RemoteFileWidget_Restore_Default=Restore Default
|
||||||
|
RemoteFileWidget_Select_File=Select File
|
||||||
RemoteResourceBrowser_resourceTitle=Browse Resource
|
RemoteResourceBrowser_resourceTitle=Browse Resource
|
||||||
RemoteResourceBrowser_fileTitle=Browse File
|
RemoteResourceBrowser_fileTitle=Browse File
|
||||||
RemoteResourceBrowser_directoryTitle=Browse Directory
|
RemoteResourceBrowser_directoryTitle=Browse Directory
|
||||||
|
|
|
@ -0,0 +1,410 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 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.internal.remote.ui.preferences;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.internal.remote.core.RemoteServicesDescriptor;
|
||||||
|
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
||||||
|
import org.eclipse.internal.remote.core.preferences.Preferences;
|
||||||
|
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||||
|
import org.eclipse.jface.preference.PreferencePage;
|
||||||
|
import org.eclipse.jface.resource.ImageDescriptor;
|
||||||
|
import org.eclipse.jface.viewers.ColumnLayoutData;
|
||||||
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
|
import org.eclipse.jface.viewers.ILabelProviderListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredContentProvider;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
|
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.IRemoteConnectionWorkingCopy;
|
||||||
|
import org.eclipse.remote.core.IRemotePreferenceConstants;
|
||||||
|
import org.eclipse.remote.core.IRemoteServices;
|
||||||
|
import org.eclipse.remote.core.RemoteServices;
|
||||||
|
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
|
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||||
|
import org.eclipse.remote.ui.RemoteUIServices;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Combo;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Control;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
import org.eclipse.swt.widgets.TableItem;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class implements a preference page which can be used to view a list of
|
||||||
|
* JSch connections, create new connections or to delete existing connections.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConnectionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle widget selection events for this page
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private class EventHandler extends SelectionAdapter {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
Object source;
|
||||||
|
|
||||||
|
source = e.getSource();
|
||||||
|
if (source == fAddButton) {
|
||||||
|
addConnection();
|
||||||
|
} else if (source == fEditButton) {
|
||||||
|
editConnection();
|
||||||
|
} else if (source == fRemoveButton) {
|
||||||
|
removeConnections();
|
||||||
|
} else if (source == fConnectionTable) {
|
||||||
|
selectConnection();
|
||||||
|
} else if (source == fServicesCombo) {
|
||||||
|
String id = fServiceIDs[fServicesCombo.getSelectionIndex()];
|
||||||
|
selectServices(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ConnectionContentProvider implements IStructuredContentProvider {
|
||||||
|
|
||||||
|
public Object[] getElements(Object inputElement) {
|
||||||
|
return fWorkingCopies.values().toArray(new IRemoteConnection[fWorkingCopies.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ConnectionLabelProvider implements ITableLabelProvider {
|
||||||
|
|
||||||
|
public Image getColumnImage(Object element, int columnIndex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColumnText(Object element, int columnIndex) {
|
||||||
|
IRemoteConnection connection = (IRemoteConnection) element;
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0:
|
||||||
|
return connection.getName();
|
||||||
|
case 1:
|
||||||
|
return connection.getAddress();
|
||||||
|
case 2:
|
||||||
|
return connection.getUsername();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addListener(ILabelProviderListener listener) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLabelProperty(Object element, String property) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeListener(ILabelProviderListener listener) {
|
||||||
|
// Nothing to do
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String[] fTableColumnHeaders = { Messages.ConnectionsPreferencePage_Connection_Name, Messages.ConnectionsPreferencePage_Host, Messages.ConnectionsPreferencePage_User };
|
||||||
|
|
||||||
|
private final ColumnLayoutData[] fTableColumnLayouts = { new ColumnWeightData(30), new ColumnWeightData(50),
|
||||||
|
new ColumnWeightData(20) };
|
||||||
|
|
||||||
|
private Combo fServicesCombo;
|
||||||
|
private Button fAddButton;
|
||||||
|
private Button fEditButton;
|
||||||
|
private Button fRemoveButton;
|
||||||
|
private Table fConnectionTable;
|
||||||
|
private TableViewer fConnectionViewer;
|
||||||
|
private EventHandler fEventHandler;
|
||||||
|
|
||||||
|
private String[] fServiceIDs;
|
||||||
|
private boolean fIsDirty;
|
||||||
|
private IRemoteConnection fSelectedConnection;
|
||||||
|
private IRemoteConnectionManager fConnectionManager;
|
||||||
|
private IRemoteUIConnectionManager fUIConnectionManager;
|
||||||
|
|
||||||
|
private final Map<String, IRemoteConnection> fWorkingCopies = new HashMap<String, IRemoteConnection>();
|
||||||
|
|
||||||
|
public ConnectionsPreferencePage() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionsPreferencePage(String title) {
|
||||||
|
super(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionsPreferencePage(String title, ImageDescriptor image) {
|
||||||
|
super(title, image);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(IWorkbench workbench) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initWorkingConnections() {
|
||||||
|
fWorkingCopies.clear();
|
||||||
|
for (IRemoteConnection conn : fConnectionManager.getConnections()) {
|
||||||
|
fWorkingCopies.put(conn.getName(), conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete service configurations when Ok button is pressed
|
||||||
|
*
|
||||||
|
* @return Status from superclass indicating if Ok processing is to continue
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean performOk() {
|
||||||
|
if (fIsDirty) {
|
||||||
|
updateConnections();
|
||||||
|
fIsDirty = false;
|
||||||
|
}
|
||||||
|
return super.performOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a service configuration to the set of service configurations
|
||||||
|
*/
|
||||||
|
private void addConnection() {
|
||||||
|
IRemoteConnectionWorkingCopy conn = fUIConnectionManager.newConnection(getShell(), null, null);
|
||||||
|
if (conn != null) {
|
||||||
|
fWorkingCopies.put(conn.getName(), conn);
|
||||||
|
fConnectionViewer.refresh();
|
||||||
|
fIsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the widgets for this page
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* The parent widget for the client area
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Control createWidgets(Composite parent) {
|
||||||
|
fEventHandler = new EventHandler();
|
||||||
|
|
||||||
|
Composite selectComp = new Composite(parent, SWT.NONE);
|
||||||
|
selectComp.setLayout(new GridLayout(2, false));
|
||||||
|
selectComp.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
|
||||||
|
|
||||||
|
Label label = new Label(selectComp, SWT.NONE);
|
||||||
|
label.setText(Messages.ConnectionsPreferencePage_Remote_Services);
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
fServicesCombo.addSelectionListener(fEventHandler);
|
||||||
|
fServicesCombo.setItems(names);
|
||||||
|
|
||||||
|
Composite preferencePane = new Composite(parent, SWT.NONE);
|
||||||
|
preferencePane.setLayout(new GridLayout(2, false));
|
||||||
|
|
||||||
|
fConnectionTable = new Table(preferencePane, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
|
||||||
|
GridData data = new GridData(GridData.FILL_BOTH);
|
||||||
|
data.widthHint = 425;
|
||||||
|
data.heightHint = fConnectionTable.getItemHeight();
|
||||||
|
data.horizontalSpan = 1;
|
||||||
|
fConnectionTable.setLayoutData(data);
|
||||||
|
fConnectionTable.setFont(parent.getFont());
|
||||||
|
fConnectionTable.addSelectionListener(fEventHandler);
|
||||||
|
|
||||||
|
TableLayout tableLayout = new TableLayout();
|
||||||
|
fConnectionTable.setLayout(tableLayout);
|
||||||
|
fConnectionTable.setHeaderVisible(true);
|
||||||
|
fConnectionTable.setLinesVisible(true);
|
||||||
|
|
||||||
|
for (int i = 0; i < fTableColumnHeaders.length; i++) {
|
||||||
|
tableLayout.addColumnData(fTableColumnLayouts[i]);
|
||||||
|
TableColumn column = new TableColumn(fConnectionTable, SWT.NONE, i);
|
||||||
|
column.setResizable(fTableColumnLayouts[i].resizable);
|
||||||
|
column.setText(fTableColumnHeaders[i]);
|
||||||
|
}
|
||||||
|
fConnectionViewer = new TableViewer(fConnectionTable);
|
||||||
|
fConnectionViewer.setContentProvider(new ConnectionContentProvider());
|
||||||
|
fConnectionViewer.setLabelProvider(new ConnectionLabelProvider());
|
||||||
|
fConnectionViewer.setInput(this);
|
||||||
|
|
||||||
|
Composite buttonPane = new Composite(preferencePane, SWT.NONE);
|
||||||
|
buttonPane.setLayout(new GridLayout(1, false));
|
||||||
|
buttonPane.setLayoutData(new GridData(GridData.FILL_VERTICAL));
|
||||||
|
buttonPane.setFont(preferencePane.getFont());
|
||||||
|
|
||||||
|
fAddButton = new Button(buttonPane, SWT.PUSH);
|
||||||
|
setButtonLayoutData(fAddButton);
|
||||||
|
fAddButton.setText(Messages.ConnectionsPreferencePage_Add);
|
||||||
|
fAddButton.addSelectionListener(fEventHandler);
|
||||||
|
fEditButton = new Button(buttonPane, SWT.PUSH);
|
||||||
|
setButtonLayoutData(fEditButton);
|
||||||
|
fEditButton.setText(Messages.ConnectionsPreferencePage_Edit);
|
||||||
|
fEditButton.addSelectionListener(fEventHandler);
|
||||||
|
fEditButton.setEnabled(false);
|
||||||
|
fRemoveButton = new Button(buttonPane, SWT.PUSH);
|
||||||
|
setButtonLayoutData(fRemoveButton);
|
||||||
|
fRemoveButton.setText(Messages.ConnectionsPreferencePage_Remove);
|
||||||
|
fRemoveButton.addSelectionListener(fEventHandler);
|
||||||
|
fRemoveButton.setEnabled(false);
|
||||||
|
|
||||||
|
String id = Preferences.getString(IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
|
||||||
|
if ("".equals(id)) { //$NON-NLS-1$
|
||||||
|
id = fServiceIDs[0];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < fServiceIDs.length; i++) {
|
||||||
|
if (id.equals(fServiceIDs[i])) {
|
||||||
|
fServicesCombo.select(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectServices(id);
|
||||||
|
|
||||||
|
return preferencePane;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit an existing service configuration
|
||||||
|
*/
|
||||||
|
private void editConnection() {
|
||||||
|
if (fSelectedConnection != null) {
|
||||||
|
IRemoteConnectionWorkingCopy copy = fSelectedConnection.getWorkingCopy();
|
||||||
|
if (fUIConnectionManager.updateConnection(getShell(), copy)) {
|
||||||
|
fWorkingCopies.put(copy.getName(), copy);
|
||||||
|
fConnectionViewer.refresh();
|
||||||
|
fIsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the selected service configuration from the set of service
|
||||||
|
* configurations
|
||||||
|
*/
|
||||||
|
private void removeConnections() {
|
||||||
|
TableItem[] items = fConnectionTable.getSelection();
|
||||||
|
if (items.length > 0) {
|
||||||
|
for (TableItem item : items) {
|
||||||
|
fWorkingCopies.remove(((IRemoteConnection) item.getData()).getName());
|
||||||
|
}
|
||||||
|
fConnectionViewer.refresh();
|
||||||
|
fIsDirty = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Record the selected connection and enable the buttons.
|
||||||
|
*/
|
||||||
|
private void selectConnection() {
|
||||||
|
TableItem[] selection = fConnectionTable.getSelection();
|
||||||
|
fEditButton.setEnabled(false);
|
||||||
|
fRemoveButton.setEnabled(false);
|
||||||
|
if (selection.length > 0) {
|
||||||
|
fSelectedConnection = (IRemoteConnection) selection[0].getData();
|
||||||
|
IRemoteServices services = fSelectedConnection.getRemoteServices();
|
||||||
|
fEditButton.setEnabled((services.getCapabilities() & IRemoteServices.CAPABILITY_EDIT_CONNECTIONS) != 0);
|
||||||
|
fRemoveButton.setEnabled((services.getCapabilities() & IRemoteServices.CAPABILITY_REMOVE_CONNECTIONS) != 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectServices(String id) {
|
||||||
|
IRemoteServices services = RemoteServices.getRemoteServices(id);
|
||||||
|
if (services != null) {
|
||||||
|
fConnectionManager = services.getConnectionManager();
|
||||||
|
fUIConnectionManager = RemoteUIServices.getRemoteUIServices(services).getUIConnectionManager();
|
||||||
|
initWorkingConnections();
|
||||||
|
fConnectionViewer.refresh();
|
||||||
|
fAddButton.setEnabled((services.getCapabilities() & IRemoteServices.CAPABILITY_ADD_CONNECTIONS) != 0);
|
||||||
|
}
|
||||||
|
fIsDirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the connection manager with changes to the connections.
|
||||||
|
*/
|
||||||
|
private void updateConnections() {
|
||||||
|
/*
|
||||||
|
* Remove any deleted connections
|
||||||
|
*/
|
||||||
|
for (IRemoteConnection conn : fConnectionManager.getConnections()) {
|
||||||
|
if (!fWorkingCopies.containsKey(conn.getName()) && !conn.isOpen()) {
|
||||||
|
try {
|
||||||
|
fConnectionManager.removeConnection(conn);
|
||||||
|
} catch (RemoteConnectionException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Save any added/edited connections
|
||||||
|
*/
|
||||||
|
for (IRemoteConnection conn : fWorkingCopies.values()) {
|
||||||
|
if (conn instanceof IRemoteConnectionWorkingCopy) {
|
||||||
|
((IRemoteConnectionWorkingCopy) conn).save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initWorkingConnections();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the contents for this page
|
||||||
|
*
|
||||||
|
* @param parent
|
||||||
|
* - The parent widget for the client area
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Control createContents(Composite parent) {
|
||||||
|
return createWidgets(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void performDefaults() {
|
||||||
|
initWorkingConnections();
|
||||||
|
fIsDirty = false;
|
||||||
|
super.performDefaults();
|
||||||
|
}
|
||||||
|
}
|
|
@ -48,8 +48,6 @@ public class PreferencesAdapter implements IPreferenceStore {
|
||||||
/** Listener on the adapted Preferences */
|
/** Listener on the adapted Preferences */
|
||||||
private final PreferenceChangeListener fListener = new PreferenceChangeListener();
|
private final PreferenceChangeListener fListener = new PreferenceChangeListener();
|
||||||
|
|
||||||
private final String fPrefsQualifier;
|
|
||||||
|
|
||||||
/** True iff no events should be forwarded */
|
/** True iff no events should be forwarded */
|
||||||
private boolean fSilent;
|
private boolean fSilent;
|
||||||
|
|
||||||
|
@ -63,9 +61,8 @@ public class PreferencesAdapter implements IPreferenceStore {
|
||||||
* The preferences to wrap.
|
* The preferences to wrap.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public PreferencesAdapter(String qualifier) {
|
public PreferencesAdapter() {
|
||||||
fPrefsQualifier = qualifier;
|
Preferences.addPreferenceChangeListener(fListener);
|
||||||
Preferences.addPreferenceChangeListener(fPrefsQualifier, fListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +83,7 @@ public class PreferencesAdapter implements IPreferenceStore {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public boolean contains(String name) {
|
public boolean contains(String name) {
|
||||||
return Preferences.contains(fPrefsQualifier, name);
|
return Preferences.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -107,91 +104,91 @@ public class PreferencesAdapter implements IPreferenceStore {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public boolean getBoolean(String name) {
|
public boolean getBoolean(String name) {
|
||||||
return Preferences.getBoolean(fPrefsQualifier, name);
|
return Preferences.getBoolean(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public boolean getDefaultBoolean(String name) {
|
public boolean getDefaultBoolean(String name) {
|
||||||
return Preferences.getDefaultBoolean(fPrefsQualifier, name, false);
|
return Preferences.getDefaultBoolean(name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public double getDefaultDouble(String name) {
|
public double getDefaultDouble(String name) {
|
||||||
return Preferences.getDefaultDouble(fPrefsQualifier, name, 0.0);
|
return Preferences.getDefaultDouble(name, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public float getDefaultFloat(String name) {
|
public float getDefaultFloat(String name) {
|
||||||
return Preferences.getDefaultFloat(fPrefsQualifier, name, 0.0f);
|
return Preferences.getDefaultFloat(name, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public int getDefaultInt(String name) {
|
public int getDefaultInt(String name) {
|
||||||
return Preferences.getDefaultInt(fPrefsQualifier, name, 0);
|
return Preferences.getDefaultInt(name, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public long getDefaultLong(String name) {
|
public long getDefaultLong(String name) {
|
||||||
return Preferences.getDefaultLong(fPrefsQualifier, name, 0L);
|
return Preferences.getDefaultLong(name, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public String getDefaultString(String name) {
|
public String getDefaultString(String name) {
|
||||||
return Preferences.getDefaultString(fPrefsQualifier, name, ""); //$NON-NLS-1$
|
return Preferences.getDefaultString(name, ""); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public double getDouble(String name) {
|
public double getDouble(String name) {
|
||||||
return Preferences.getDouble(fPrefsQualifier, name);
|
return Preferences.getDouble(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public float getFloat(String name) {
|
public float getFloat(String name) {
|
||||||
return Preferences.getFloat(fPrefsQualifier, name);
|
return Preferences.getFloat(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public int getInt(String name) {
|
public int getInt(String name) {
|
||||||
return Preferences.getInt(fPrefsQualifier, name);
|
return Preferences.getInt(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public long getLong(String name) {
|
public long getLong(String name) {
|
||||||
return Preferences.getLong(fPrefsQualifier, name);
|
return Preferences.getLong(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public String getString(String name) {
|
public String getString(String name) {
|
||||||
return Preferences.getString(fPrefsQualifier, name);
|
return Preferences.getString(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public boolean isDefault(String name) {
|
public boolean isDefault(String name) {
|
||||||
return Preferences.isDefault(fPrefsQualifier, name);
|
return Preferences.isDefault(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -207,7 +204,7 @@ public class PreferencesAdapter implements IPreferenceStore {
|
||||||
public void putValue(String name, String value) {
|
public void putValue(String name, String value) {
|
||||||
try {
|
try {
|
||||||
fSilent = true;
|
fSilent = true;
|
||||||
Preferences.setString(fPrefsQualifier, name, value);
|
Preferences.setString(name, value);
|
||||||
} finally {
|
} finally {
|
||||||
fSilent = false;
|
fSilent = false;
|
||||||
}
|
}
|
||||||
|
@ -217,90 +214,90 @@ public class PreferencesAdapter implements IPreferenceStore {
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setDefault(String name, double value) {
|
public void setDefault(String name, double value) {
|
||||||
Preferences.setDefaultDouble(fPrefsQualifier, name, value);
|
Preferences.setDefaultDouble(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setDefault(String name, float value) {
|
public void setDefault(String name, float value) {
|
||||||
Preferences.setDefaultFloat(fPrefsQualifier, name, value);
|
Preferences.setDefaultFloat(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setDefault(String name, int value) {
|
public void setDefault(String name, int value) {
|
||||||
Preferences.setDefaultInt(fPrefsQualifier, name, value);
|
Preferences.setDefaultInt(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setDefault(String name, long value) {
|
public void setDefault(String name, long value) {
|
||||||
Preferences.setDefaultLong(fPrefsQualifier, name, value);
|
Preferences.setDefaultLong(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setDefault(String name, String defaultObject) {
|
public void setDefault(String name, String defaultObject) {
|
||||||
Preferences.setDefaultString(fPrefsQualifier, name, defaultObject);
|
Preferences.setDefaultString(name, defaultObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setDefault(String name, boolean value) {
|
public void setDefault(String name, boolean value) {
|
||||||
Preferences.setDefaultBoolean(fPrefsQualifier, name, value);
|
Preferences.setDefaultBoolean(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setToDefault(String name) {
|
public void setToDefault(String name) {
|
||||||
Preferences.setToDefault(fPrefsQualifier, name);
|
Preferences.setToDefault(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setValue(String name, double value) {
|
public void setValue(String name, double value) {
|
||||||
Preferences.setDouble(fPrefsQualifier, name, value);
|
Preferences.setDouble(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setValue(String name, float value) {
|
public void setValue(String name, float value) {
|
||||||
Preferences.setFloat(fPrefsQualifier, name, value);
|
Preferences.setFloat(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setValue(String name, int value) {
|
public void setValue(String name, int value) {
|
||||||
Preferences.setInt(fPrefsQualifier, name, value);
|
Preferences.setInt(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setValue(String name, long value) {
|
public void setValue(String name, long value) {
|
||||||
Preferences.setLong(fPrefsQualifier, name, value);
|
Preferences.setLong(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setValue(String name, String value) {
|
public void setValue(String name, String value) {
|
||||||
Preferences.setString(fPrefsQualifier, name, value);
|
Preferences.setString(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void setValue(String name, boolean value) {
|
public void setValue(String name, boolean value) {
|
||||||
Preferences.setBoolean(fPrefsQualifier, name, value);
|
Preferences.setBoolean(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,8 @@ package org.eclipse.internal.remote.ui.preferences;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.internal.remote.core.RemoteCorePlugin;
|
import org.eclipse.internal.remote.core.RemoteServicesDescriptor;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesProxy;
|
|
||||||
import org.eclipse.internal.remote.ui.messages.Messages;
|
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||||
import org.eclipse.jface.preference.ComboFieldEditor;
|
import org.eclipse.jface.preference.ComboFieldEditor;
|
||||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||||
|
@ -32,7 +31,7 @@ public class RemoteDevelopmentPreferencePage extends FieldEditorPreferencePage i
|
||||||
|
|
||||||
public RemoteDevelopmentPreferencePage() {
|
public RemoteDevelopmentPreferencePage() {
|
||||||
super(GRID);
|
super(GRID);
|
||||||
setPreferenceStore(new PreferencesAdapter(RemoteCorePlugin.getUniqueIdentifier()));
|
setPreferenceStore(new PreferencesAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(IWorkbench workbench) {
|
public void init(IWorkbench workbench) {
|
||||||
|
@ -42,9 +41,13 @@ public class RemoteDevelopmentPreferencePage extends FieldEditorPreferencePage i
|
||||||
@Override
|
@Override
|
||||||
protected void createFieldEditors() {
|
protected void createFieldEditors() {
|
||||||
List<String[]> namesAndValues = new ArrayList<String[]>();
|
List<String[]> namesAndValues = new ArrayList<String[]>();
|
||||||
|
|
||||||
for (RemoteServicesProxy service : RemoteServicesImpl.getRemoteServiceProxies()) {
|
|
||||||
String[] nameAndValue = new String[2];
|
String[] nameAndValue = new String[2];
|
||||||
|
nameAndValue[0] = "None"; //$NON-NLS-1$
|
||||||
|
nameAndValue[1] = ""; //$NON-NLS-1$
|
||||||
|
namesAndValues.add(nameAndValue);
|
||||||
|
|
||||||
|
for (RemoteServicesDescriptor service : RemoteServicesImpl.getRemoteServiceDescriptors()) {
|
||||||
|
nameAndValue = new String[2];
|
||||||
nameAndValue[0] = service.getName();
|
nameAndValue[0] = service.getName();
|
||||||
nameAndValue[1] = service.getId();
|
nameAndValue[1] = service.getId();
|
||||||
namesAndValues.add(nameAndValue);
|
namesAndValues.add(nameAndValue);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
import org.eclipse.jface.operation.IRunnableContext;
|
||||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
@ -34,7 +35,7 @@ public class LocalUIConnectionManager implements IRemoteUIConnectionManager {
|
||||||
* @see
|
* @see
|
||||||
* org.eclipse.remote.core.IRemoteUIConnectionManager#newConnection()
|
* org.eclipse.remote.core.IRemoteUIConnectionManager#newConnection()
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection newConnection(Shell shell) {
|
public IRemoteConnectionWorkingCopy newConnection(Shell shell) {
|
||||||
MessageDialog.openInformation(shell, Messages.LocalUIConnectionManager_2, Messages.LocalUIConnectionManager_3);
|
MessageDialog.openInformation(shell, Messages.LocalUIConnectionManager_2, Messages.LocalUIConnectionManager_3);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ public class LocalUIConnectionManager implements IRemoteUIConnectionManager {
|
||||||
* org.eclipse.remote.ui.IRemoteUIConnectionManager#newConnection(org
|
* org.eclipse.remote.ui.IRemoteUIConnectionManager#newConnection(org
|
||||||
* .eclipse.swt.widgets.Shell, java.lang.String[], java.lang.String[])
|
* .eclipse.swt.widgets.Shell, java.lang.String[], java.lang.String[])
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection newConnection(Shell shell, String[] attrHints, String[] attrHintValues) {
|
public IRemoteConnectionWorkingCopy newConnection(Shell shell, String[] attrHints, String[] attrHintValues) {
|
||||||
return newConnection(shell);
|
return newConnection(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,13 +90,10 @@ public class LocalUIConnectionManager implements IRemoteUIConnectionManager {
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
* @see
|
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#updateConnection(org.eclipse.swt.widgets.Shell,
|
||||||
* org.eclipse.remote.ui.IRemoteUIConnectionManager#updateConnection
|
* org.eclipse.remote.core.IRemoteConnectionWorkingCopy)
|
||||||
* (org.eclipse.swt.widgets.Shell,
|
|
||||||
* org.eclipse.remote.core.IRemoteConnection)
|
|
||||||
*/
|
*/
|
||||||
public void updateConnection(Shell shell, IRemoteConnection connection) {
|
public boolean updateConnection(Shell shell, IRemoteConnectionWorkingCopy connection) {
|
||||||
// TODO Auto-generated method stub
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ package org.eclipse.remote.ui;
|
||||||
|
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
import org.eclipse.jface.operation.IRunnableContext;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,20 +38,23 @@ public interface IRemoteUIConnectionManager {
|
||||||
public static String LOGIN_USERNAME_HINT = "LOGIN_USERNAME_HINT"; //$NON-NLS-1$
|
public static String LOGIN_USERNAME_HINT = "LOGIN_USERNAME_HINT"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new connection. The implementation can choose to do this in any
|
* Create a new connection. The implementation can choose to do this in any way, but typically will use a dialog or wizard.
|
||||||
* way, but typically will use a dialog or wizard.
|
*
|
||||||
|
* Returns a working copy of the remote connection. Callers must call {@link IRemoteConnectionWorkingCopy#save()} before the
|
||||||
|
* connection can be used.
|
||||||
*
|
*
|
||||||
* @param shell
|
* @param shell
|
||||||
* shell used to display dialogs
|
* shell used to display dialogs
|
||||||
* @return newly created remote connection or null if none created
|
* @return newly created remote connection working copy or null if none created
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection newConnection(Shell shell);
|
public IRemoteConnectionWorkingCopy newConnection(Shell shell);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new connection using the remote service provider new connection
|
* Create a new connection using the remote service provider new connection dialog. If attrHints and attrHintValues are provided
|
||||||
* dialog. If attrHints and attrHintValues are provided then the dialog will
|
* then the dialog will attempt to use these values as the default values for the appropriate dialog fields.
|
||||||
* attempt to use these values as the default values for the appropriate
|
*
|
||||||
* dialog fields.
|
* Returns a working copy of the remote connection. Callers must call {@link IRemoteConnectionWorkingCopy#save()} before the
|
||||||
|
* connection can be used.
|
||||||
*
|
*
|
||||||
* @param shell
|
* @param shell
|
||||||
* shell used to display dialog
|
* shell used to display dialog
|
||||||
|
@ -59,10 +63,10 @@ public interface IRemoteUIConnectionManager {
|
||||||
* @param attrHintValues
|
* @param attrHintValues
|
||||||
* array containing default values for each attribute specified
|
* array containing default values for each attribute specified
|
||||||
* in attrHints
|
* in attrHints
|
||||||
* @return the newly created connection or null if none created
|
* @return the newly created connection working copy or null if none created
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public IRemoteConnection newConnection(Shell shell, String[] attrHints, String[] attrHintValues);
|
public IRemoteConnectionWorkingCopy newConnection(Shell shell, String[] attrHints, String[] attrHintValues);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to open a connection using a progress monitor. Can be called on either open or closed connections, and will
|
* Attempt to open a connection using a progress monitor. Can be called on either open or closed connections, and will
|
||||||
|
@ -80,13 +84,14 @@ public interface IRemoteUIConnectionManager {
|
||||||
public void openConnectionWithProgress(Shell shell, IRunnableContext context, IRemoteConnection connection);
|
public void openConnectionWithProgress(Shell shell, IRunnableContext context, IRemoteConnection connection);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a connection configuration. The implementation can chose to do
|
* Change a connection configuration. The implementation can chose to do this in any way, but typically will use a dialog or
|
||||||
* this in any way, but typically will use a dialog or wizard.
|
* wizard. Callers must call {@link IRemoteConnectionWorkingCopy#save()} on the working copy for the changes to be saved.
|
||||||
*
|
*
|
||||||
* @param shell
|
* @param shell
|
||||||
* shell used to display dialogs
|
* shell used to display dialogs
|
||||||
* @param connection
|
* @param connection
|
||||||
* connection to modify
|
* working copy of the connection to modify
|
||||||
|
* @return true if the connection information was changed
|
||||||
*/
|
*/
|
||||||
public void updateConnection(Shell shell, IRemoteConnection connection);
|
public boolean updateConnection(Shell shell, IRemoteConnectionWorkingCopy connection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.remote.ui.widgets;
|
package org.eclipse.remote.ui.widgets;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.List;
|
||||||
import java.util.Comparator;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.ListenerList;
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
import org.eclipse.internal.remote.core.RemoteCorePlugin;
|
import org.eclipse.internal.remote.core.RemoteServicesDescriptor;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
||||||
import org.eclipse.internal.remote.core.RemoteServicesProxy;
|
|
||||||
import org.eclipse.internal.remote.core.preferences.Preferences;
|
import org.eclipse.internal.remote.core.preferences.Preferences;
|
||||||
import org.eclipse.internal.remote.ui.messages.Messages;
|
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||||
import org.eclipse.jface.operation.IRunnableContext;
|
import org.eclipse.jface.operation.IRunnableContext;
|
||||||
|
@ -135,7 +135,7 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
private final Combo fConnectionCombo;
|
private final Combo fConnectionCombo;
|
||||||
private final Button fNewConnectionButton;
|
private final Button fNewConnectionButton;
|
||||||
|
|
||||||
private final RemoteServicesProxy[] fRemoteServices;
|
private final List<RemoteServicesDescriptor> fRemoteServices;
|
||||||
private IRemoteConnection fSelectedConnection;
|
private IRemoteConnection fSelectedConnection;
|
||||||
private IRemoteServices fDefaultServices;
|
private IRemoteServices fDefaultServices;
|
||||||
private boolean fSelectionListernersEnabled = true;
|
private boolean fSelectionListernersEnabled = true;
|
||||||
|
@ -195,8 +195,7 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
* Check if we need a remote services combo, or we should just use the default provider
|
* Check if we need a remote services combo, or we should just use the default provider
|
||||||
*/
|
*/
|
||||||
if ((flags & FLAG_FORCE_PROVIDER_SELECTION) == 0) {
|
if ((flags & FLAG_FORCE_PROVIDER_SELECTION) == 0) {
|
||||||
String id = Preferences.getString(RemoteCorePlugin.getUniqueIdentifier(),
|
String id = Preferences.getString(IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
|
||||||
IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
fDefaultServices = getRemoteServices(id);
|
fDefaultServices = getRemoteServices(id);
|
||||||
}
|
}
|
||||||
|
@ -258,7 +257,7 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
fNewConnectionButton.setLayoutData(gd);
|
fNewConnectionButton.setLayoutData(gd);
|
||||||
fNewConnectionButton.addSelectionListener(fWidgetListener);
|
fNewConnectionButton.addSelectionListener(fWidgetListener);
|
||||||
|
|
||||||
fRemoteServices = RemoteServicesImpl.getRemoteServiceProxies();
|
fRemoteServices = RemoteServicesImpl.getRemoteServiceDescriptors();
|
||||||
|
|
||||||
if (fServicesCombo != null) {
|
if (fServicesCombo != null) {
|
||||||
initializeRemoteServicesCombo(null);
|
initializeRemoteServicesCombo(null);
|
||||||
|
@ -339,8 +338,8 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
return fDefaultServices;
|
return fDefaultServices;
|
||||||
}
|
}
|
||||||
int selectionIndex = fServicesCombo.getSelectionIndex();
|
int selectionIndex = fServicesCombo.getSelectionIndex();
|
||||||
if (fRemoteServices.length > 0 && selectionIndex > 0) {
|
if (fRemoteServices.size() > 0 && selectionIndex > 0) {
|
||||||
return RemoteServices.getRemoteServices(fRemoteServices[selectionIndex - 1].getId());
|
return RemoteServices.getRemoteServices(fRemoteServices.get(selectionIndex - 1).getId());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -428,8 +427,8 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
* service.
|
* service.
|
||||||
*/
|
*/
|
||||||
if (fDefaultServices == null && conn != null) {
|
if (fDefaultServices == null && conn != null) {
|
||||||
for (int index = 0; index < fRemoteServices.length; index++) {
|
for (int index = 0; index < fRemoteServices.size(); index++) {
|
||||||
if (fRemoteServices[index].getId().equals(selectedServices.getId())) {
|
if (fRemoteServices.get(index).getId().equals(selectedServices.getId())) {
|
||||||
fServicesCombo.select(index + 1);
|
fServicesCombo.select(index + 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -451,20 +450,17 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
/*
|
/*
|
||||||
* Populate the connection combo and select the connection
|
* Populate the connection combo and select the connection
|
||||||
*/
|
*/
|
||||||
IRemoteConnection[] connections = connectionManager.getConnections();
|
|
||||||
Arrays.sort(connections, new Comparator<IRemoteConnection>() {
|
|
||||||
public int compare(IRemoteConnection c1, IRemoteConnection c2) {
|
|
||||||
return c1.getName().compareToIgnoreCase(c2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
int offset = 1;
|
int offset = 1;
|
||||||
|
|
||||||
for (int i = 0; i < connections.length; i++) {
|
Set<IRemoteConnection> sorted = new TreeSet<IRemoteConnection>(connectionManager.getConnections());
|
||||||
fConnectionCombo.add(connections[i].getName());
|
|
||||||
if (conn != null && connections[i].getName().equals(conn.getName())) {
|
for (IRemoteConnection s : sorted) {
|
||||||
selected = i + offset;
|
fConnectionCombo.add(s.getName());
|
||||||
|
if (conn != null && s.getName().equals(conn.getName())) {
|
||||||
|
selected = offset;
|
||||||
}
|
}
|
||||||
|
offset++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fConnectionCombo.select(selected);
|
fConnectionCombo.select(selected);
|
||||||
|
@ -473,7 +469,8 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
/*
|
/*
|
||||||
* Enable 'new' button if new connections are supported
|
* Enable 'new' button if new connections are supported
|
||||||
*/
|
*/
|
||||||
fNewConnectionButton.setEnabled(selectedServices.canCreateConnections());
|
fNewConnectionButton
|
||||||
|
.setEnabled((selectedServices.getCapabilities() & IRemoteServices.CAPABILITY_ADD_CONNECTIONS) != 0);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
fWidgetListener.setEnabled(enabled);
|
fWidgetListener.setEnabled(enabled);
|
||||||
|
@ -493,22 +490,17 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
defService = getRemoteServices(id);
|
defService = getRemoteServices(id);
|
||||||
}
|
}
|
||||||
Arrays.sort(fRemoteServices, new Comparator<RemoteServicesProxy>() {
|
|
||||||
public int compare(RemoteServicesProxy c1, RemoteServicesProxy c2) {
|
|
||||||
return c1.getName().compareToIgnoreCase(c2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fServicesCombo.removeAll();
|
fServicesCombo.removeAll();
|
||||||
int offset = 1;
|
int offset = 1;
|
||||||
int defIndex = 0;
|
int defIndex = 0;
|
||||||
fServicesCombo.add(Messages.RemoteConnectionWidget_selectRemoteProvider);
|
fServicesCombo.add(Messages.RemoteConnectionWidget_selectRemoteProvider);
|
||||||
for (int i = 0; i < fRemoteServices.length; i++) {
|
for (int i = 0; i < fRemoteServices.size(); i++) {
|
||||||
fServicesCombo.add(fRemoteServices[i].getName());
|
fServicesCombo.add(fRemoteServices.get(i).getName());
|
||||||
if (defService != null && fRemoteServices[i].equals(defService)) {
|
if (defService != null && fRemoteServices.get(i).equals(defService)) {
|
||||||
defIndex = i + offset;
|
defIndex = i + offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fRemoteServices.length > 0) {
|
if (fRemoteServices.size() > 0) {
|
||||||
fServicesCombo.select(defIndex);
|
fServicesCombo.select(defIndex);
|
||||||
}
|
}
|
||||||
fWidgetListener.setEnabled(enabled);
|
fWidgetListener.setEnabled(enabled);
|
||||||
|
@ -611,11 +603,13 @@ public class RemoteConnectionWidget extends Composite {
|
||||||
isRemote = !fLocalButton.getSelection();
|
isRemote = !fLocalButton.getSelection();
|
||||||
}
|
}
|
||||||
fConnectionCombo.setEnabled(fEnabled && isRemote);
|
fConnectionCombo.setEnabled(fEnabled && isRemote);
|
||||||
fNewConnectionButton.setEnabled(fEnabled && isRemote && fDefaultServices.canCreateConnections());
|
fNewConnectionButton.setEnabled(fEnabled && isRemote
|
||||||
|
&& (fDefaultServices.getCapabilities() & IRemoteServices.CAPABILITY_ADD_CONNECTIONS) != 0);
|
||||||
} else {
|
} else {
|
||||||
IRemoteServices services = getSelectedServices();
|
IRemoteServices services = getSelectedServices();
|
||||||
fConnectionCombo.setEnabled(fEnabled && services != null);
|
fConnectionCombo.setEnabled(fEnabled && services != null);
|
||||||
fNewConnectionButton.setEnabled(fEnabled && services != null && services.canCreateConnections());
|
fNewConnectionButton.setEnabled(fEnabled && services != null
|
||||||
|
&& (services.getCapabilities() & IRemoteServices.CAPABILITY_ADD_CONNECTIONS) != 0);
|
||||||
fServicesCombo.setEnabled(fEnabled);
|
fServicesCombo.setEnabled(fEnabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,10 +43,8 @@ import org.eclipse.swt.widgets.Text;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RemoteDirectoryWidget extends Composite {
|
public class RemoteDirectoryWidget extends Composite {
|
||||||
// /private final Label label;
|
|
||||||
private final Text text;
|
private final Text text;
|
||||||
private final Button browseButton;
|
private final Button browseButton;
|
||||||
// private final Button validateButton;
|
|
||||||
private final Button defaultButton;
|
private final Button defaultButton;
|
||||||
|
|
||||||
private final String fDefaultPath = null;
|
private final String fDefaultPath = null;
|
||||||
|
|
|
@ -0,0 +1,292 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 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:
|
||||||
|
* Mike Kucera (IBM) - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.remote.ui.widgets;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
|
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||||
|
import org.eclipse.remote.ui.IRemoteUIFileManager;
|
||||||
|
import org.eclipse.remote.ui.RemoteUIServices;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.ModifyEvent;
|
||||||
|
import org.eclipse.swt.events.ModifyListener;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Group;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widget to allow the user to select a remote file. Provides a "Browse"
|
||||||
|
* button that uses the currently specified connection and a "Restore Default"
|
||||||
|
* button to revert to the initial setting.
|
||||||
|
*
|
||||||
|
* If title is supplied then the widget will be placed in a group.
|
||||||
|
*
|
||||||
|
* The browse message can be modified using {@link #setBrowseMessage(String)}
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RemoteFileWidget extends Composite {
|
||||||
|
public static int GROUP_FLAG = 0x01;
|
||||||
|
public static int RESTORE_BUTTON_FLAG = 0x02;
|
||||||
|
|
||||||
|
private final Label fLabel;
|
||||||
|
private final Text fText;
|
||||||
|
private final Button fBrowseButton;
|
||||||
|
|
||||||
|
private Button fDefaultButton;
|
||||||
|
private String fDefaultPath;
|
||||||
|
private String fBrowseMessage = Messages.RemoteFileWidget_Select_File;
|
||||||
|
private IRemoteConnection fRemoteConnection;
|
||||||
|
|
||||||
|
private final ListenerList fModifyListeners = new ListenerList();
|
||||||
|
private final Map<String, String> fPreviousSelections = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public RemoteFileWidget(Composite parent, int style, int flags, String title, String defaultPath) {
|
||||||
|
super(parent, style);
|
||||||
|
|
||||||
|
GridLayout layout = new GridLayout(4, false);
|
||||||
|
layout.marginHeight = 0;
|
||||||
|
layout.marginWidth = 0;
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
Composite body = this;
|
||||||
|
|
||||||
|
if ((flags & GROUP_FLAG) != 0) {
|
||||||
|
Group group = new Group(this, SWT.NONE);
|
||||||
|
group.setText(title);
|
||||||
|
group.setLayout(new GridLayout(1, false));
|
||||||
|
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
|
body = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Composite textComp = new Composite(body, SWT.NONE);
|
||||||
|
// textComp.setLayout(new GridLayout(2, false));
|
||||||
|
// textComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
|
|
||||||
|
fLabel = new Label(body, SWT.NONE);
|
||||||
|
fLabel.setText(Messages.RemoteFileWidget_File);
|
||||||
|
fLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
|
||||||
|
|
||||||
|
fText = new Text(body, SWT.BORDER);
|
||||||
|
fText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
||||||
|
fText.addModifyListener(new ModifyListener() {
|
||||||
|
public void modifyText(ModifyEvent e) {
|
||||||
|
String path = fText.getText();
|
||||||
|
setSavedPath(path);
|
||||||
|
notifyListeners(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Composite buttonComp = new Composite(body, SWT.NONE);
|
||||||
|
// buttonComp.setLayout(new GridLayout(2, true));
|
||||||
|
// GridData buttonCompData = new GridData(SWT.FILL, SWT.FILL, false, false);
|
||||||
|
// buttonCompData.horizontalAlignment = SWT.END;
|
||||||
|
// buttonComp.setLayoutData(buttonCompData);
|
||||||
|
|
||||||
|
fBrowseButton = new Button(body, SWT.NONE);
|
||||||
|
fBrowseButton.setText(Messages.RemoteFileWidget_Browse);
|
||||||
|
GridData browseButtonData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
|
||||||
|
browseButtonData.widthHint = 110;
|
||||||
|
fBrowseButton.setLayoutData(browseButtonData);
|
||||||
|
fBrowseButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
browse();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ((flags & RESTORE_BUTTON_FLAG) != 0) {
|
||||||
|
fDefaultButton = new Button(body, SWT.NONE);
|
||||||
|
fDefaultButton.setText(Messages.RemoteFileWidget_Restore_Default);
|
||||||
|
GridData defaultButtonData = new GridData(SWT.LEFT, SWT.CENTER, false, false);
|
||||||
|
defaultButtonData.widthHint = 110;
|
||||||
|
fDefaultButton.setLayoutData(defaultButtonData);
|
||||||
|
fDefaultButton.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
restoreDefault(fDefaultPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (defaultPath != null) {
|
||||||
|
fDefaultPath = defaultPath;
|
||||||
|
fText.setText(defaultPath);
|
||||||
|
}
|
||||||
|
updateBrowseButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a listener that will be notified when the file path is modified.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* listener to add
|
||||||
|
*/
|
||||||
|
public void addModifyListener(ModifyListener listener) {
|
||||||
|
fModifyListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browse() {
|
||||||
|
IRemoteUIConnectionManager connMgr = getUIConnectionManager();
|
||||||
|
if (connMgr != null) {
|
||||||
|
connMgr.openConnectionWithProgress(getShell(), null, fRemoteConnection);
|
||||||
|
if (fRemoteConnection.isOpen()) {
|
||||||
|
IRemoteUIFileManager fileMgr = getUIFileManager();
|
||||||
|
if (fileMgr != null) {
|
||||||
|
fileMgr.setConnection(fRemoteConnection);
|
||||||
|
String path = fileMgr.browseFile(getShell(), fBrowseMessage, "", 0); //$NON-NLS-1$
|
||||||
|
if (path != null) {
|
||||||
|
setLocationPath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the file location path. This path will be relative to the remote
|
||||||
|
* machine.
|
||||||
|
*
|
||||||
|
* @return file location path
|
||||||
|
*/
|
||||||
|
public String getLocationPath() {
|
||||||
|
return fText.getText();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSavedPath() {
|
||||||
|
if (fRemoteConnection != null) {
|
||||||
|
return fPreviousSelections.get(fRemoteConnection.getRemoteServices().getId() + "." + fRemoteConnection.getName()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IRemoteUIConnectionManager getUIConnectionManager() {
|
||||||
|
if (fRemoteConnection != null) {
|
||||||
|
return RemoteUIServices.getRemoteUIServices(fRemoteConnection.getRemoteServices()).getUIConnectionManager();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IRemoteUIFileManager getUIFileManager() {
|
||||||
|
if (fRemoteConnection != null) {
|
||||||
|
return RemoteUIServices.getRemoteUIServices(fRemoteConnection.getRemoteServices()).getUIFileManager();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyListeners(ModifyEvent e) {
|
||||||
|
for (Object listener : fModifyListeners.getListeners()) {
|
||||||
|
((ModifyListener) listener).modifyText(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a listener that will be notified when the file path is
|
||||||
|
* modified.
|
||||||
|
*
|
||||||
|
* @param listener
|
||||||
|
* listener to remove
|
||||||
|
*/
|
||||||
|
public void removeModifyListener(ModifyListener listener) {
|
||||||
|
fModifyListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreDefault(String path) {
|
||||||
|
if (path == null && fRemoteConnection != null) {
|
||||||
|
path = fRemoteConnection.getWorkingDirectory().toString();
|
||||||
|
}
|
||||||
|
if (path == null) {
|
||||||
|
path = ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
setLocationPath(path); // modify event listener updates map
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the message that will be displayed in the remote file browser
|
||||||
|
* dialog.
|
||||||
|
*
|
||||||
|
* @param message
|
||||||
|
* message to be displayed
|
||||||
|
*/
|
||||||
|
public void setBrowseMessage(String message) {
|
||||||
|
fBrowseMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the remote connection to use for browsing for the remote file.
|
||||||
|
*
|
||||||
|
* @param conn
|
||||||
|
* remote connection
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public void setConnection(IRemoteConnection conn) {
|
||||||
|
if (conn == null) {
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!conn.equals(fRemoteConnection)) {
|
||||||
|
fRemoteConnection = conn;
|
||||||
|
String path = getSavedPath();
|
||||||
|
restoreDefault(path);
|
||||||
|
updateBrowseButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
if (!fText.isDisposed()) {
|
||||||
|
fText.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
if (!fBrowseButton.isDisposed()) {
|
||||||
|
fBrowseButton.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the label to be displayed
|
||||||
|
*
|
||||||
|
* @param label
|
||||||
|
*/
|
||||||
|
public void setLabel(String label) {
|
||||||
|
if (fLabel != null && !fLabel.isDisposed()) {
|
||||||
|
fLabel.setText(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the initial remote location that will be displayed in the widget.
|
||||||
|
*
|
||||||
|
* @param path
|
||||||
|
*/
|
||||||
|
public void setLocationPath(String path) {
|
||||||
|
if (path != null && !path.equals(getLocationPath())) {
|
||||||
|
fText.setText(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSavedPath(String path) {
|
||||||
|
if (fRemoteConnection != null) {
|
||||||
|
fPreviousSelections.put(fRemoteConnection.getRemoteServices().getId() + "." + fRemoteConnection.getName(), path); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBrowseButton() {
|
||||||
|
fBrowseButton.setEnabled(getUIFileManager() != null);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue