1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-21 16:05:25 +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:
Greg Watson 2015-02-27 20:54:15 -05:00
parent 6e5f7a97bd
commit d8310d99c0
19 changed files with 145 additions and 23 deletions

View file

@ -101,6 +101,15 @@ public interface IRemoteConnectionType {
*/ */
<T extends Service> boolean hasService(Class<T> service); <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. * Gets the remote connection corresponding to the supplied name.
* *

View file

@ -57,6 +57,29 @@ public interface IRemoteServicesManager {
*/ */
List<IRemoteConnectionType> getAllConnectionTypes(); 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. * Returns the list of connection types except for the local connection type.
* *

View file

@ -88,7 +88,7 @@ public class RemoteConnection implements IRemoteConnection {
*/ */
@Override @Override
public <T extends Service> boolean hasService(Class<T> service) { 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);
} }
/* /*

View file

@ -194,7 +194,13 @@ public class RemoteConnectionType implements IRemoteConnectionType {
return null; 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; return serviceDefinitionMap.get(service.getName()) != null;
} }

View file

@ -241,7 +241,7 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
if (original != null) { if (original != null) {
return original.hasService(service); return original.hasService(service);
} else { } else {
return connectionType.hasConnectionService(this, service); return connectionType.hasConnectionService(service);
} }
} }

View file

@ -153,6 +153,46 @@ public class RemoteServicesManager implements IRemoteServicesManager {
return new ArrayList<IRemoteConnectionType>(connectionTypeMap.values()); 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) * (non-Javadoc)
* *

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <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="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>

View file

@ -1,11 +1,11 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 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.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.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=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

View file

@ -21,4 +21,4 @@ Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.remote.internal.jsch.ui;x-internal:=true, Export-Package: org.eclipse.remote.internal.jsch.ui;x-internal:=true,
org.eclipse.remote.internal.jsch.ui.messages;x-internal:=true org.eclipse.remote.internal.jsch.ui.messages;x-internal:=true
Bundle-Localization: plugin Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View file

@ -19,8 +19,10 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.wizard.WizardPage; import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionHostService;
import org.eclipse.remote.core.IRemoteConnectionType; import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy; import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemotePortForwardingService;
import org.eclipse.remote.core.IRemoteServicesManager; import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException; import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.internal.jsch.core.Activator; import org.eclipse.remote.internal.jsch.core.Activator;
@ -289,6 +291,7 @@ public class JSchConnectionPage extends WizardPage {
lblConnection.setText(Messages.JSchConnectionPage_SelectConnection); lblConnection.setText(Messages.JSchConnectionPage_SelectConnection);
fProxyConnectionWidget = new RemoteConnectionWidget(proxyComp, SWT.NONE, null, 0, null); fProxyConnectionWidget = new RemoteConnectionWidget(proxyComp, SWT.NONE, null, 0, null);
fProxyConnectionWidget.filterConnections(IRemoteConnectionHostService.class, IRemotePortForwardingService.class);
Label lblCommand = new Label(proxyComp, SWT.WRAP); Label lblCommand = new Label(proxyComp, SWT.WRAP);
lblCommand.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); lblCommand.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <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="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>

View file

@ -1,11 +1,11 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 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.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.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=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

View file

@ -15,7 +15,7 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.trace, org.eclipse.ui.trace,
org.eclipse.ui.navigator, org.eclipse.ui.navigator,
org.eclipse.core.expressions org.eclipse.core.expressions
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.remote.internal.ui;x-internal:=true, Export-Package: org.eclipse.remote.internal.ui;x-internal:=true,
org.eclipse.remote.internal.ui.messages;x-internal:=true, org.eclipse.remote.internal.ui.messages;x-internal:=true,

View file

@ -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 * Interface for providing file management operations in the UI. Clients can call these methods to open generic dialogs for
* operations on remote resources. * operations on remote resources.
*
* @since 2.0 * @since 2.0
*/ */
public interface IRemoteUIFileService extends IRemoteConnectionType.Service { public interface IRemoteUIFileService extends IRemoteConnectionType.Service {
@ -91,7 +92,8 @@ public interface IRemoteUIFileService extends IRemoteConnectionType.Service {
public IRemoteConnection getConnection(); 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 * @param connection
* connection to use for file browsing * connection to use for file browsing

View file

@ -24,6 +24,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.wizard.ProgressMonitorPart; import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteFileService;
import org.eclipse.remote.internal.ui.messages.Messages; import org.eclipse.remote.internal.ui.messages.Messages;
import org.eclipse.remote.ui.widgets.RemoteResourceBrowserWidget; import org.eclipse.remote.ui.widgets.RemoteResourceBrowserWidget;
import org.eclipse.swt.SWT; 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 * @param connection
* connection that supports the IRemoteFileService service
*/ */
public void setConnection(IRemoteConnection connection) { public void setConnection(IRemoteConnection connection) {
fConnection = connection; if (connection.hasService(IRemoteFileService.class)) {
fConnection = connection;
}
} }
/** /**

View file

@ -278,6 +278,24 @@ public class RemoteConnectionWidget extends Composite {
fSelectionListeners.add(listener); 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 * Get the new button from the widget
* *

View file

@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.ListenerList;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteFileService;
import org.eclipse.remote.core.IRemoteProcessService; import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.internal.ui.messages.Messages; import org.eclipse.remote.internal.ui.messages.Messages;
import org.eclipse.remote.ui.IRemoteUIConnectionService; 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); GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
text.setLayoutData(data); text.setLayoutData(data);
text.addModifyListener(new ModifyListener() { text.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) { public void modifyText(ModifyEvent e) {
String path = text.getText(); String path = text.getText();
setSavedPath(path); setSavedPath(path);
@ -172,6 +174,9 @@ public class RemoteDirectoryWidget extends Composite {
/** /**
* Set the remote connection to use for browsing for the remote directory. * 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 * @param conn
* remote connection * remote connection
* @since 4.0 * @since 4.0
@ -181,7 +186,8 @@ public class RemoteDirectoryWidget extends Composite {
throw new NullPointerException(); 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; fRemoteConnection = conn;
String path = getSavedPath(); String path = getSavedPath();
restoreDefault(path); restoreDefault(path);

View file

@ -15,6 +15,7 @@ import java.util.Map;
import org.eclipse.core.runtime.ListenerList; import org.eclipse.core.runtime.ListenerList;
import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteFileService;
import org.eclipse.remote.core.IRemoteProcessService; import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.internal.ui.messages.Messages; import org.eclipse.remote.internal.ui.messages.Messages;
import org.eclipse.remote.ui.IRemoteUIConnectionService; 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. * 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 * @param conn
* remote connection * remote connection
* @since 4.0 * @since 4.0
@ -237,7 +241,8 @@ public class RemoteFileWidget extends Composite {
throw new NullPointerException(); 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; fRemoteConnection = conn;
String path = getSavedPath(); String path = getSavedPath();
restoreDefault(path); restoreDefault(path);

View file

@ -237,6 +237,7 @@ public class RemoteResourceBrowserWidget extends Composite {
})); }));
} }
}); });
fRemoteConnectionWidget.filterConnections(IRemoteFileService.class);
} }
Composite textComp = new Composite(mainComp, SWT.NONE); 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 * @param connection
* connection that supports the IRemoteFileService service
*/ */
public void setConnection(IRemoteConnection connection) { public void setConnection(IRemoteConnection connection) {
changeInput(connection); if (connection.hasService(IRemoteFileService.class)) {
if (fRemoteConnectionWidget != null) { changeInput(connection);
fRemoteConnectionWidget.setConnection(connection); if (fRemoteConnectionWidget != null) {
fRemoteConnectionWidget.setConnection(connection);
}
updateEnablement();
} }
updateEnablement();
} }
/** /**