mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Bug 461098 - Add support for filtering connection types.
Change-Id: I0ead2fcf73e6e1f39ce28078d898202d389b3e50 Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
6e5f7a97bd
commit
d8310d99c0
19 changed files with 145 additions and 23 deletions
|
@ -101,6 +101,15 @@ public interface IRemoteConnectionType {
|
|||
*/
|
||||
<T extends Service> boolean hasService(Class<T> service);
|
||||
|
||||
/**
|
||||
* Do connections created by this connection type support the given service.
|
||||
*
|
||||
* @param service
|
||||
* the service to be tested
|
||||
* @return true if connections created by this connection type support this service
|
||||
*/
|
||||
<T extends IRemoteConnection.Service> boolean hasConnectionService(Class<T> service);
|
||||
|
||||
/**
|
||||
* Gets the remote connection corresponding to the supplied name.
|
||||
*
|
||||
|
|
|
@ -57,6 +57,29 @@ public interface IRemoteServicesManager {
|
|||
*/
|
||||
List<IRemoteConnectionType> getAllConnectionTypes();
|
||||
|
||||
/**
|
||||
* Returns the list of all connection types that support connections that provide specific services. The connections
|
||||
* can provide additional services that are not included in the list, so this just guarantees the minimum set of services that
|
||||
* will be supported.
|
||||
*
|
||||
* @param services
|
||||
* services provided by connections supported by this connection type
|
||||
* @return compatible connection types
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IRemoteConnectionType> getConnectionTypesSupporting(Class<? extends IRemoteConnection.Service>... services);
|
||||
|
||||
/**
|
||||
* Returns the list of all connection types that provide specific services. The connection types can provide additional services
|
||||
* that are not included in the list, so this just guarantees the minimum set of services that will be supported.
|
||||
*
|
||||
* @param services
|
||||
* services provided by this connection type
|
||||
* @return compatible connection types
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IRemoteConnectionType> getConnectionTypesByService(Class<? extends IRemoteConnectionType.Service>... services);
|
||||
|
||||
/**
|
||||
* Returns the list of connection types except for the local connection type.
|
||||
*
|
||||
|
|
|
@ -88,7 +88,7 @@ public class RemoteConnection implements IRemoteConnection {
|
|||
*/
|
||||
@Override
|
||||
public <T extends Service> boolean hasService(Class<T> service) {
|
||||
return servicesMap.get(service.getName()) != null || connectionType.hasConnectionService(this, service);
|
||||
return servicesMap.get(service.getName()) != null || connectionType.hasConnectionService(service);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -194,7 +194,13 @@ public class RemoteConnectionType implements IRemoteConnectionType {
|
|||
return null;
|
||||
}
|
||||
|
||||
public <T extends IRemoteConnection.Service> boolean hasConnectionService(IRemoteConnection connection, Class<T> service) {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionType#hasConnectionService(java.lang.Class)
|
||||
*/
|
||||
@Override
|
||||
public <T extends IRemoteConnection.Service> boolean hasConnectionService(Class<T> service) {
|
||||
return serviceDefinitionMap.get(service.getName()) != null;
|
||||
}
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
|
|||
if (original != null) {
|
||||
return original.hasService(service);
|
||||
} else {
|
||||
return connectionType.hasConnectionService(this, service);
|
||||
return connectionType.hasConnectionService(service);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,6 +153,46 @@ public class RemoteServicesManager implements IRemoteServicesManager {
|
|||
return new ArrayList<IRemoteConnectionType>(connectionTypeMap.values());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServicesManager#getConnectionTypesSupporting(java.lang.Class[])
|
||||
*/
|
||||
@Override
|
||||
@SafeVarargs
|
||||
public final List<IRemoteConnectionType> getConnectionTypesSupporting(Class<? extends IRemoteConnection.Service>... services) {
|
||||
List<IRemoteConnectionType> connTypes = new ArrayList<IRemoteConnectionType>();
|
||||
for (IRemoteConnectionType connType : getRemoteConnectionTypes()) {
|
||||
for (Class<? extends IRemoteConnection.Service> service : services) {
|
||||
if (!connType.hasConnectionService(service)) {
|
||||
connTypes.add(connType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return connTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.core.IRemoteServicesManager#getConnectionTypesByService(java.lang.Class[])
|
||||
*/
|
||||
@Override
|
||||
@SafeVarargs
|
||||
public final List<IRemoteConnectionType> getConnectionTypesByService(Class<? extends IRemoteConnectionType.Service>... services) {
|
||||
List<IRemoteConnectionType> connTypes = new ArrayList<IRemoteConnectionType>();
|
||||
for (IRemoteConnectionType connType : getRemoteConnectionTypes()) {
|
||||
for (Class<? extends IRemoteConnectionType.Service> service : services) {
|
||||
if (!connType.hasService(service)) {
|
||||
connTypes.add(connType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return connTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
|
@ -21,4 +21,4 @@ Bundle-ActivationPolicy: lazy
|
|||
Export-Package: org.eclipse.remote.internal.jsch.ui;x-internal:=true,
|
||||
org.eclipse.remote.internal.jsch.ui.messages;x-internal:=true
|
||||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
|
|
|
@ -19,8 +19,10 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.jface.preference.PreferenceDialog;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionHostService;
|
||||
import org.eclipse.remote.core.IRemoteConnectionType;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemotePortForwardingService;
|
||||
import org.eclipse.remote.core.IRemoteServicesManager;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.internal.jsch.core.Activator;
|
||||
|
@ -289,6 +291,7 @@ public class JSchConnectionPage extends WizardPage {
|
|||
lblConnection.setText(Messages.JSchConnectionPage_SelectConnection);
|
||||
|
||||
fProxyConnectionWidget = new RemoteConnectionWidget(proxyComp, SWT.NONE, null, 0, null);
|
||||
fProxyConnectionWidget.filterConnections(IRemoteConnectionHostService.class, IRemotePortForwardingService.class);
|
||||
|
||||
Label lblCommand = new Label(proxyComp, SWT.WRAP);
|
||||
lblCommand.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
||||
|
|
|
@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.ui,
|
|||
org.eclipse.ui.trace,
|
||||
org.eclipse.ui.navigator,
|
||||
org.eclipse.core.expressions
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.eclipse.remote.internal.ui;x-internal:=true,
|
||||
org.eclipse.remote.internal.ui.messages;x-internal:=true,
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
/**
|
||||
* Interface for providing file management operations in the UI. Clients can call these methods to open generic dialogs for
|
||||
* operations on remote resources.
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface IRemoteUIFileService extends IRemoteConnectionType.Service {
|
||||
|
@ -91,7 +92,8 @@ public interface IRemoteUIFileService extends IRemoteConnectionType.Service {
|
|||
public IRemoteConnection getConnection();
|
||||
|
||||
/**
|
||||
* Set the connection to use for file browsing
|
||||
* Set the connection to use for file browsing. The connection must support the IRemoteFileService service or it will be
|
||||
* ignored.
|
||||
*
|
||||
* @param connection
|
||||
* connection to use for file browsing
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||
import org.eclipse.jface.wizard.ProgressMonitorPart;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteFileService;
|
||||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.widgets.RemoteResourceBrowserWidget;
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -256,12 +257,16 @@ public class RemoteResourceBrowser extends Dialog implements IRunnableContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the initial connection for the browser.
|
||||
* Set the connection for the browser. The connection must support the IRemoteFileService service or this method will have no
|
||||
* effect.
|
||||
*
|
||||
* @param connection
|
||||
* connection that supports the IRemoteFileService service
|
||||
*/
|
||||
public void setConnection(IRemoteConnection connection) {
|
||||
fConnection = connection;
|
||||
if (connection.hasService(IRemoteFileService.class)) {
|
||||
fConnection = connection;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -278,6 +278,24 @@ public class RemoteConnectionWidget extends Composite {
|
|||
fSelectionListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Limit the connection types that will be used when displaying valid connections. Only connection types that support
|
||||
* connections with supplied services will be displayed in the connection type combo, and only connections from these connection
|
||||
* types will be displayed in the connection combo.
|
||||
*
|
||||
* @param services
|
||||
* list of services {@link IRemoteConnection.Service}
|
||||
* @since 2.0
|
||||
*/
|
||||
@SafeVarargs
|
||||
public final void filterConnections(Class<? extends IRemoteConnection.Service>... services) {
|
||||
fConnectionTypes = fRemoteServicesManager.getConnectionTypesSupporting(services);
|
||||
if (fConnectionTypeCombo != null) {
|
||||
initializeConnectionTypeCombo();
|
||||
}
|
||||
handleConnectionTypeSelected(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the new button from the widget
|
||||
*
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteFileService;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionService;
|
||||
|
@ -84,6 +85,7 @@ public class RemoteDirectoryWidget extends Composite {
|
|||
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
|
||||
text.setLayoutData(data);
|
||||
text.addModifyListener(new ModifyListener() {
|
||||
@Override
|
||||
public void modifyText(ModifyEvent e) {
|
||||
String path = text.getText();
|
||||
setSavedPath(path);
|
||||
|
@ -172,6 +174,9 @@ public class RemoteDirectoryWidget extends Composite {
|
|||
/**
|
||||
* Set the remote connection to use for browsing for the remote directory.
|
||||
*
|
||||
* The connection type must provide the IRemoteUIConnectionService and IRemoteUIFileService services and the connection must
|
||||
* support the IRemoteFileService service. If any of these conditions are not met, this method will do nothing.
|
||||
*
|
||||
* @param conn
|
||||
* remote connection
|
||||
* @since 4.0
|
||||
|
@ -181,7 +186,8 @@ public class RemoteDirectoryWidget extends Composite {
|
|||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if (!conn.equals(fRemoteConnection)) {
|
||||
if (conn.hasService(IRemoteFileService.class) && conn.getConnectionType().hasService(IRemoteUIConnectionService.class)
|
||||
&& conn.getConnectionType().hasService(IRemoteUIFileService.class) && !conn.equals(fRemoteConnection)) {
|
||||
fRemoteConnection = conn;
|
||||
String path = getSavedPath();
|
||||
restoreDefault(path);
|
||||
|
|
|
@ -15,6 +15,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.core.runtime.ListenerList;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteFileService;
|
||||
import org.eclipse.remote.core.IRemoteProcessService;
|
||||
import org.eclipse.remote.internal.ui.messages.Messages;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionService;
|
||||
|
@ -228,6 +229,9 @@ public class RemoteFileWidget extends Composite {
|
|||
/**
|
||||
* Set the remote connection to use for browsing for the remote file.
|
||||
*
|
||||
* The connection type must provide the IRemoteUIConnectionService and IRemoteUIFileService services and the connection must
|
||||
* support the IRemoteFileService service. If any of these conditions are not met, this method will do nothing.
|
||||
*
|
||||
* @param conn
|
||||
* remote connection
|
||||
* @since 4.0
|
||||
|
@ -237,7 +241,8 @@ public class RemoteFileWidget extends Composite {
|
|||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
if (!conn.equals(fRemoteConnection)) {
|
||||
if (conn.hasService(IRemoteFileService.class) && conn.getConnectionType().hasService(IRemoteUIConnectionService.class)
|
||||
&& conn.getConnectionType().hasService(IRemoteUIFileService.class) && !conn.equals(fRemoteConnection)) {
|
||||
fRemoteConnection = conn;
|
||||
String path = getSavedPath();
|
||||
restoreDefault(path);
|
||||
|
|
|
@ -237,6 +237,7 @@ public class RemoteResourceBrowserWidget extends Composite {
|
|||
}));
|
||||
}
|
||||
});
|
||||
fRemoteConnectionWidget.filterConnections(IRemoteFileService.class);
|
||||
}
|
||||
|
||||
Composite textComp = new Composite(mainComp, SWT.NONE);
|
||||
|
@ -652,16 +653,20 @@ public class RemoteResourceBrowserWidget extends Composite {
|
|||
}
|
||||
|
||||
/**
|
||||
* Set the connection for the browser
|
||||
* Set the connection for the browser. The connection must support the IRemoteFileService service or this method will have no
|
||||
* effect.
|
||||
*
|
||||
* @param connection
|
||||
* connection that supports the IRemoteFileService service
|
||||
*/
|
||||
public void setConnection(IRemoteConnection connection) {
|
||||
changeInput(connection);
|
||||
if (fRemoteConnectionWidget != null) {
|
||||
fRemoteConnectionWidget.setConnection(connection);
|
||||
if (connection.hasService(IRemoteFileService.class)) {
|
||||
changeInput(connection);
|
||||
if (fRemoteConnectionWidget != null) {
|
||||
fRemoteConnectionWidget.setConnection(connection);
|
||||
}
|
||||
updateEnablement();
|
||||
}
|
||||
updateEnablement();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue