1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Cleanup comments and interfaces.

Change-Id: Id7bb77b110963314b0daca143eab6a197a4201b0
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2015-02-27 10:08:31 -05:00
parent 1ad2aeddd6
commit 6e5f7a97bd
7 changed files with 361 additions and 58 deletions

View file

@ -11,7 +11,7 @@
package org.eclipse.remote.core; package org.eclipse.remote.core;
/** /**
* A connection type service for connectiont types that have automatic means of adding * A connection type service for connection types that have automatic means of adding
* and removing services. For example, the Local connection type needs to be able * and removing services. For example, the Local connection type needs to be able
* to ensure the Local connection is created, or adapters to other target management * to ensure the Local connection is created, or adapters to other target management
* systems may prefer to let those systems manage the connections. * systems may prefer to let those systems manage the connections.

View file

@ -16,7 +16,6 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.remote.core.exception.RemoteConnectionException; import org.eclipse.remote.core.exception.RemoteConnectionException;
/** /**
* A remote connection type manages a list of connections that implement the same services. * A remote connection type manages a list of connections that implement the same services.
* Services may be registered on the individual connections, or at the connection type level * Services may be registered on the individual connections, or at the connection type level
@ -28,11 +27,12 @@ import org.eclipse.remote.core.exception.RemoteConnectionException;
public interface IRemoteConnectionType { public interface IRemoteConnectionType {
/** /**
* The interface that is extend by services provided for this remote services implementation. * The interface that is extend by services provided for this remote services implementation.
*
* @since 2.0 * @since 2.0
*/ */
interface Service { interface Service {
IRemoteConnectionType getConnectionType(); IRemoteConnectionType getConnectionType();
interface Factory { interface Factory {
<T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service); <T extends Service> T getService(IRemoteConnectionType connectionType, Class<T> service);
} }
@ -84,9 +84,10 @@ public interface IRemoteConnectionType {
/** /**
* Get the service for this remote services implementation that implements the given interface. * Get the service for this remote services implementation that implements the given interface.
* *
* @param service the interface the required service must implements * @param service
* the interface the required service must implements
* @return the desired service or null if there is no such service available * @return the desired service or null if there is no such service available
* @throws CoreException * @throws CoreException
* @since 2.0 * @since 2.0
*/ */
<T extends Service> T getService(Class<T> service); <T extends Service> T getService(Class<T> service);
@ -94,7 +95,8 @@ public interface IRemoteConnectionType {
/** /**
* Does this connection type support the given service. * Does this connection type support the given service.
* *
* @param service the service to be tested * @param service
* the service to be tested
* @return true if this connection type supports this service * @return true if this connection type supports this service
*/ */
<T extends Service> boolean hasService(Class<T> service); <T extends Service> boolean hasService(Class<T> service);
@ -106,7 +108,7 @@ public interface IRemoteConnectionType {
* name of the connection (as returned by {@link IRemoteConnection#getName()}) * name of the connection (as returned by {@link IRemoteConnection#getName()})
* @return remote connection or null if no connection exists * @return remote connection or null if no connection exists
*/ */
public IRemoteConnection getConnection(String name); IRemoteConnection getConnection(String name);
/** /**
* Gets the remote connection corresponding to the supplied URI. * Gets the remote connection corresponding to the supplied URI.
@ -117,14 +119,14 @@ public interface IRemoteConnectionType {
* is incorrect * is incorrect
* @since 4.0 * @since 4.0
*/ */
public IRemoteConnection getConnection(URI uri); IRemoteConnection getConnection(URI uri);
/** /**
* Get all the connections for this service provider. * Get all the connections for this service provider.
* *
* @return connections that we know about * @return connections that we know about
*/ */
public List<IRemoteConnection> getConnections(); List<IRemoteConnection> getConnections();
/** /**
* Creates a new remote connection named with supplied name. The connection attributes will be the default for the * Creates a new remote connection named with supplied name. The connection attributes will be the default for the
@ -140,7 +142,7 @@ public interface IRemoteConnectionType {
* if connection creation failed * if connection creation failed
* @since 5.0 * @since 5.0
*/ */
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException; IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException;
/** /**
* Remove a connection and all resources associated with it. * Remove a connection and all resources associated with it.
@ -150,6 +152,6 @@ public interface IRemoteConnectionType {
* @throws RemoteConnectionException * @throws RemoteConnectionException
* if the connection could not be removed * if the connection could not be removed
*/ */
public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException; void removeConnection(IRemoteConnection connection) throws RemoteConnectionException;
} }

View file

@ -26,7 +26,8 @@ public interface IRemoteServicesManager {
/** /**
* Get the connection type identified by the id * Get the connection type identified by the id
* *
* @param id id of the connection type * @param id
* id of the connection type
* @return connection type or null if the service can not be found * @return connection type or null if the service can not be found
*/ */
IRemoteConnectionType getConnectionType(String id); IRemoteConnectionType getConnectionType(String id);
@ -35,9 +36,10 @@ public interface IRemoteServicesManager {
* Get the connection type that provides connections to locations identified by * Get the connection type that provides connections to locations identified by
* the URI. * the URI.
* *
* @param uri uri of locations to be accessed * @param uri
* uri of locations to be accessed
* @return the connection type that can be used to access the locations * @return the connection type that can be used to access the locations
* or null if no connection type is available for the uri. * or null if no connection type is available for the uri.
*/ */
IRemoteConnectionType getConnectionType(URI uri); IRemoteConnectionType getConnectionType(URI uri);
@ -49,16 +51,16 @@ public interface IRemoteServicesManager {
IRemoteConnectionType getLocalConnectionType(); IRemoteConnectionType getLocalConnectionType();
/** /**
* Returns the list of all connection type including the local services. * Returns the list of all connection types including the local services.
* *
* @return all remote services * @return all connection types
*/ */
List<IRemoteConnectionType> getAllConnectionTypes(); List<IRemoteConnectionType> getAllConnectionTypes();
/** /**
* Returns the list of connection types except for the local services. * Returns the list of connection types except for the local connection type.
* *
* @return all remote services that are really remote * @return all connection types that are really remote
*/ */
List<IRemoteConnectionType> getRemoteConnectionTypes(); List<IRemoteConnectionType> getRemoteConnectionTypes();
@ -72,14 +74,16 @@ public interface IRemoteServicesManager {
/** /**
* Add a global connection change listener that receives events for all connections. * Add a global connection change listener that receives events for all connections.
* *
* @param listener global connection change listener to be added * @param listener
* global connection change listener to be added
*/ */
void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener); void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener);
/** /**
* Remove the global connection change listener. * Remove the global connection change listener.
* *
* @param listener global connection change listener to be removed * @param listener
* global connection change listener to be removed
*/ */
void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener); void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener);
@ -87,7 +91,8 @@ public interface IRemoteServicesManager {
* Used by connections and other components to notify the global connection * Used by connections and other components to notify the global connection
* change listeners of events. * change listeners of events.
* *
* @param event connection change event * @param event
* connection change event
*/ */
void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event); void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event);

View file

@ -40,7 +40,7 @@ public class RemoteConnection implements IRemoteConnection {
private final RemoteConnectionType connectionType; private final RemoteConnectionType connectionType;
private String name; private String name;
private Map<String, Object> servicesMap = new HashMap<>(); private final Map<String, Object> servicesMap = new HashMap<>();
private final List<IRemoteConnectionChangeListener> fListeners = new ArrayList<>(); private final List<IRemoteConnectionChangeListener> fListeners = new ArrayList<>();
@ -51,11 +51,21 @@ public class RemoteConnection implements IRemoteConnection {
this.name = name; this.name = name;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getConnectionType()
*/
@Override @Override
public IRemoteConnectionType getConnectionType() { public IRemoteConnectionType getConnectionType() {
return connectionType; return connectionType;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getService(java.lang.Class)
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T extends Service> T getService(Class<T> service) { public <T extends Service> T getService(Class<T> service) {
@ -71,11 +81,21 @@ public class RemoteConnection implements IRemoteConnection {
return (T) obj; return (T) obj;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#hasService(java.lang.Class)
*/
@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(this, service);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getName()
*/
@Override @Override
public String getName() { public String getName() {
return name; return name;
@ -84,7 +104,8 @@ public class RemoteConnection implements IRemoteConnection {
/** /**
* Called from working copy when name has changed. * Called from working copy when name has changed.
* *
* @param name the new name * @param name
* the new name
*/ */
void rename(String newName) throws ConnectionExistsException { void rename(String newName) throws ConnectionExistsException {
try { try {
@ -103,7 +124,7 @@ public class RemoteConnection implements IRemoteConnection {
} catch (BackingStoreException e) { } catch (BackingStoreException e) {
RemoteCorePlugin.log(e); RemoteCorePlugin.log(e);
} }
this.name = newName; this.name = newName;
} }
@ -115,11 +136,21 @@ public class RemoteConnection implements IRemoteConnection {
return connectionType.getSecurePreferencesNode().node(name); return connectionType.getSecurePreferencesNode().node(name);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getAttribute(java.lang.String)
*/
@Override @Override
public String getAttribute(String key) { public String getAttribute(String key) {
return getPreferences().get(key, EMPTY_STRING); return getPreferences().get(key, EMPTY_STRING);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getSecureAttribute(java.lang.String)
*/
@Override @Override
public String getSecureAttribute(String key) { public String getSecureAttribute(String key) {
try { try {
@ -130,11 +161,21 @@ public class RemoteConnection implements IRemoteConnection {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
*/
@Override @Override
public IRemoteConnectionWorkingCopy getWorkingCopy() { public IRemoteConnectionWorkingCopy getWorkingCopy() {
return new RemoteConnectionWorkingCopy(this); return new RemoteConnectionWorkingCopy(this);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getProperty(java.lang.String)
*/
@Override @Override
public String getProperty(String key) { public String getProperty(String key) {
IRemoteConnectionPropertyService propertyService = getService(IRemoteConnectionPropertyService.class); IRemoteConnectionPropertyService propertyService = getService(IRemoteConnectionPropertyService.class);
@ -144,7 +185,12 @@ public class RemoteConnection implements IRemoteConnection {
return null; return null;
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#open(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
public void open(IProgressMonitor monitor) throws RemoteConnectionException { public void open(IProgressMonitor monitor) throws RemoteConnectionException {
IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class); IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
@ -153,6 +199,11 @@ public class RemoteConnection implements IRemoteConnection {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#close()
*/
@Override @Override
public void close() { public void close() {
IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class); IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
@ -161,6 +212,11 @@ public class RemoteConnection implements IRemoteConnection {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#isOpen()
*/
@Override @Override
public boolean isOpen() { public boolean isOpen() {
IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class); IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
@ -171,17 +227,36 @@ public class RemoteConnection implements IRemoteConnection {
return true; return true;
} }
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.remote.core.IRemoteConnection#addConnectionChangeListener(org.eclipse.remote.core.IRemoteConnectionChangeListener
* )
*/
@Override @Override
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) { public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
fListeners.add(listener); fListeners.add(listener);
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.remote.core.IRemoteConnection#removeConnectionChangeListener(org.eclipse.remote.core.IRemoteConnectionChangeListener
* )
*/
@Override @Override
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) { public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
fListeners.remove(listener); fListeners.remove(listener);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#fireConnectionChangeEvent(int)
*/
@Override @Override
public void fireConnectionChangeEvent(final int type) { public void fireConnectionChangeEvent(final int type) {
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type); RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type);
@ -192,6 +267,11 @@ public class RemoteConnection implements IRemoteConnection {
connectionType.getRemoteServicesManager().fireRemoteConnectionChangeEvent(event); connectionType.getRemoteServicesManager().fireRemoteConnectionChangeEvent(event);
} }
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
return name + " - " + connectionType.getName(); //$NON-NLS-1$ return name + " - " + connectionType.getName(); //$NON-NLS-1$

View file

@ -42,7 +42,7 @@ public class RemoteConnectionType implements IRemoteConnectionType {
private final Map<String, Object> serviceMap = new HashMap<>(); private final Map<String, Object> serviceMap = new HashMap<>();
private final Map<String, IConfigurationElement> serviceDefinitionMap = new HashMap<>(); private final Map<String, IConfigurationElement> serviceDefinitionMap = new HashMap<>();
private final Map<String, RemoteConnection> connections = new HashMap<>(); private final Map<String, RemoteConnection> connections = new HashMap<>();
public RemoteConnectionType(IConfigurationElement ce, RemoteServicesManager manager) { public RemoteConnectionType(IConfigurationElement ce, RemoteServicesManager manager) {
@ -57,7 +57,7 @@ public class RemoteConnectionType implements IRemoteConnectionType {
} else { } else {
capabilities = 0; capabilities = 0;
} }
// load up existing connections // load up existing connections
try { try {
for (String connectionName : getPreferenceNode().childrenNames()) { for (String connectionName : getPreferenceNode().childrenNames()) {
@ -76,31 +76,61 @@ public class RemoteConnectionType implements IRemoteConnectionType {
return remoteServicesManager.getSecurePreferenceNode().node(id); return remoteServicesManager.getSecurePreferenceNode().node(id);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getRemoteServicesManager()
*/
@Override @Override
public IRemoteServicesManager getRemoteServicesManager() { public IRemoteServicesManager getRemoteServicesManager() {
return remoteServicesManager; return remoteServicesManager;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getId()
*/
@Override @Override
public String getId() { public String getId() {
return id; return id;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getName()
*/
@Override @Override
public String getName() { public String getName() {
return name; return name;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getScheme()
*/
@Override @Override
public String getScheme() { public String getScheme() {
return scheme; return scheme;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getCapabilities()
*/
@Override @Override
public int getCapabilities() { public int getCapabilities() {
return capabilities; return capabilities;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getService(java.lang.Class)
*/
@Override @Override
public <T extends Service> T getService(Class<T> service) { public <T extends Service> T getService(Class<T> service) {
String serviceName = service.getName(); String serviceName = service.getName();
@ -124,6 +154,11 @@ public class RemoteConnectionType implements IRemoteConnectionType {
return obj; return obj;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#hasService(java.lang.Class)
*/
@Override @Override
public <T extends Service> boolean hasService(Class<T> service) { public <T extends Service> boolean hasService(Class<T> service) {
String serviceName = service.getName(); String serviceName = service.getName();
@ -133,8 +168,10 @@ public class RemoteConnectionType implements IRemoteConnectionType {
/** /**
* Called from the connection to get a service object for that connection. * Called from the connection to get a service object for that connection.
* *
* @param connection the connection to which the service applies * @param connection
* @param service the interface the service must implement * the connection to which the service applies
* @param service
* the interface the service must implement
* @return the service object * @return the service object
* @throws CoreException * @throws CoreException
*/ */
@ -144,7 +181,8 @@ public class RemoteConnectionType implements IRemoteConnectionType {
IConfigurationElement ce = serviceDefinitionMap.get(service.getName()); IConfigurationElement ce = serviceDefinitionMap.get(service.getName());
if (ce != null) { if (ce != null) {
try { try {
IRemoteConnection.Service.Factory factory = (IRemoteConnection.Service.Factory) ce.createExecutableExtension("factory"); //$NON-NLS-1$ IRemoteConnection.Service.Factory factory = (IRemoteConnection.Service.Factory) ce
.createExecutableExtension("factory"); //$NON-NLS-1$
if (factory != null) { if (factory != null) {
return factory.getService(connection, service); return factory.getService(connection, service);
} }
@ -164,7 +202,8 @@ public class RemoteConnectionType implements IRemoteConnectionType {
* Called from the remote service manager to register a service extension for * Called from the remote service manager to register a service extension for
* this remote services implementation * this remote services implementation
* *
* @param ce the extension element defining the service * @param ce
* the extension element defining the service
*/ */
public void addService(IConfigurationElement ce) { public void addService(IConfigurationElement ce) {
String service = ce.getAttribute("service"); //$NON-NLS-1$ String service = ce.getAttribute("service"); //$NON-NLS-1$
@ -173,22 +212,31 @@ public class RemoteConnectionType implements IRemoteConnectionType {
/** /**
* Signal connection has been added. * Signal connection has been added.
*
* @since 2.0 * @since 2.0
*/ */
protected void connectionAdded(final IRemoteConnection connection) { protected void connectionAdded(final IRemoteConnection connection) {
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection, RemoteConnectionChangeEvent.CONNECTION_ADDED); RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection,
RemoteConnectionChangeEvent.CONNECTION_ADDED);
remoteServicesManager.fireRemoteConnectionChangeEvent(event); remoteServicesManager.fireRemoteConnectionChangeEvent(event);
} }
/** /**
* Signal a connnection is about to be removed. * Signal a connnection is about to be removed.
*
* @since 2.0 * @since 2.0
*/ */
protected void connectionRemoved(final IRemoteConnection connection) { protected void connectionRemoved(final IRemoteConnection connection) {
RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection, RemoteConnectionChangeEvent.CONNECTION_ADDED); RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection,
RemoteConnectionChangeEvent.CONNECTION_ADDED);
remoteServicesManager.fireRemoteConnectionChangeEvent(event); remoteServicesManager.fireRemoteConnectionChangeEvent(event);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getConnection(java.lang.String)
*/
@Override @Override
public IRemoteConnection getConnection(String name) { public IRemoteConnection getConnection(String name) {
return connections.get(name); return connections.get(name);
@ -200,21 +248,31 @@ public class RemoteConnectionType implements IRemoteConnectionType {
if (connection != null) { if (connection != null) {
return connection; return connection;
} }
// If it's a file: scheme we must be the local connection type, just return our // If it's a file: scheme we must be the local connection type, just return our
// hopefully one connection, the Local connection. // hopefully one connection, the Local connection.
if (uri.getScheme().equals("file") && !connections.isEmpty()) { //$NON-NLS-1$ if (uri.getScheme().equals("file") && !connections.isEmpty()) { //$NON-NLS-1$
return connections.values().iterator().next(); return connections.values().iterator().next();
} }
return null; return null;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#getConnections()
*/
@Override @Override
public List<IRemoteConnection> getConnections() { public List<IRemoteConnection> getConnections() {
return new ArrayList<IRemoteConnection>(connections.values()); return new ArrayList<IRemoteConnection>(connections.values());
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#newConnection(java.lang.String)
*/
@Override @Override
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException { public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
if (connections.containsKey(name)) { if (connections.containsKey(name)) {
@ -231,6 +289,11 @@ public class RemoteConnectionType implements IRemoteConnectionType {
connections.remove(name); connections.remove(name);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionType#removeConnection(org.eclipse.remote.core.IRemoteConnection)
*/
@Override @Override
public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException { public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException {
if (connection instanceof RemoteConnection) { if (connection instanceof RemoteConnection) {

View file

@ -35,10 +35,10 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
private RemoteConnection original; private RemoteConnection original;
private RemoteConnectionType connectionType; private RemoteConnectionType connectionType;
private String newName; private String newName;
private Map<String, String> newAttributes = new HashMap<>(); private final Map<String, String> newAttributes = new HashMap<>();
private Map<String, String> newSecureAttributes = new HashMap<>(); private final Map<String, String> newSecureAttributes = new HashMap<>();
private List<IRemoteConnectionChangeListener> newListeners = new ArrayList<>(); private final List<IRemoteConnectionChangeListener> newListeners = new ArrayList<>();
/** /**
* New Connection. * New Connection.
*/ */
@ -53,7 +53,12 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
public RemoteConnectionWorkingCopy(RemoteConnection original) { public RemoteConnectionWorkingCopy(RemoteConnection original) {
this.original = original; this.original = original;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getName()
*/
@Override @Override
public String getName() { public String getName() {
if (newName != null) { if (newName != null) {
@ -65,6 +70,11 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
*/
@Override @Override
public void setName(String name) { public void setName(String name) {
// set if only if it's changed // set if only if it's changed
@ -73,20 +83,30 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getAttribute(java.lang.String)
*/
@Override @Override
public String getAttribute(String key) { public String getAttribute(String key) {
String value = newAttributes.get(key); String value = newAttributes.get(key);
if (value != null) { if (value != null) {
return value; return value;
} }
if (original != null) { if (original != null) {
return original.getAttribute(key); return original.getAttribute(key);
} }
return RemoteConnection.EMPTY_STRING; return RemoteConnection.EMPTY_STRING;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
*/
@Override @Override
public void setAttribute(String key, String value) { public void setAttribute(String key, String value) {
// set only if it's changed or value is null // set only if it's changed or value is null
@ -95,13 +115,18 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getSecureAttribute(java.lang.String)
*/
@Override @Override
public String getSecureAttribute(String key) { public String getSecureAttribute(String key) {
String value = newSecureAttributes.get(key); String value = newSecureAttributes.get(key);
if (value != null) { if (value != null) {
return value; return value;
} }
if (original != null) { if (original != null) {
return original.getSecureAttribute(key); return original.getSecureAttribute(key);
} }
@ -109,6 +134,11 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
return RemoteConnection.EMPTY_STRING; return RemoteConnection.EMPTY_STRING;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setSecureAttribute(java.lang.String, java.lang.String)
*/
@Override @Override
public void setSecureAttribute(String key, String value) { public void setSecureAttribute(String key, String value) {
// set only if it's changed or value is null // set only if it's changed or value is null
@ -116,7 +146,14 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
newSecureAttributes.put(key, value); newSecureAttributes.put(key, value);
} }
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.remote.core.IRemoteConnection#addConnectionChangeListener(org.eclipse.remote.core.IRemoteConnectionChangeListener
* )
*/
@Override @Override
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) { public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
if (original != null) { if (original != null) {
@ -126,6 +163,13 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.remote.core.IRemoteConnection#removeConnectionChangeListener(org.eclipse.remote.core.IRemoteConnectionChangeListener
* )
*/
@Override @Override
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) { public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
if (original != null) { if (original != null) {
@ -135,6 +179,11 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#fireConnectionChangeEvent(int)
*/
@Override @Override
public void fireConnectionChangeEvent(int type) { public void fireConnectionChangeEvent(int type) {
if (original != null) { if (original != null) {
@ -148,16 +197,31 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getConnectionType()
*/
@Override @Override
public IRemoteConnectionType getConnectionType() { public IRemoteConnectionType getConnectionType() {
return connectionType; return connectionType;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
*/
@Override @Override
public IRemoteConnectionWorkingCopy getWorkingCopy() { public IRemoteConnectionWorkingCopy getWorkingCopy() {
return this; return this;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getService(java.lang.Class)
*/
@Override @Override
public <T extends Service> T getService(Class<T> service) { public <T extends Service> T getService(Class<T> service) {
if (original != null) { if (original != null) {
@ -167,6 +231,11 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#hasService(java.lang.Class)
*/
@Override @Override
public <T extends Service> boolean hasService(Class<T> service) { public <T extends Service> boolean hasService(Class<T> service) {
if (original != null) { if (original != null) {
@ -176,16 +245,31 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#getOriginal()
*/
@Override @Override
public IRemoteConnection getOriginal() { public IRemoteConnection getOriginal() {
return original; return original;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#isDirty()
*/
@Override @Override
public boolean isDirty() { public boolean isDirty() {
return newName != null || !newAttributes.isEmpty() || !newSecureAttributes.isEmpty(); return newName != null || !newAttributes.isEmpty() || !newSecureAttributes.isEmpty();
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
*/
@Override @Override
public IRemoteConnection save() throws RemoteConnectionException { public IRemoteConnection save() throws RemoteConnectionException {
if (newName != null && original != null) { if (newName != null && original != null) {
@ -244,39 +328,54 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
return original; return original;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#open(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override @Override
public void open(IProgressMonitor monitor) throws RemoteConnectionException { public void open(IProgressMonitor monitor) throws RemoteConnectionException {
if (original != null) { if (original != null) {
original.open(monitor); original.open(monitor);
} else { } else {
IRemoteConnectionControlService controlService = IRemoteConnectionControlService controlService = connectionType.getConnectionService(this,
connectionType.getConnectionService(this, IRemoteConnectionControlService.class); IRemoteConnectionControlService.class);
if (controlService != null) { if (controlService != null) {
controlService.open(monitor); controlService.open(monitor);
} }
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#close()
*/
@Override @Override
public void close() { public void close() {
if (original != null) { if (original != null) {
original.close(); original.close();
} else { } else {
IRemoteConnectionControlService controlService = IRemoteConnectionControlService controlService = connectionType.getConnectionService(this,
connectionType.getConnectionService(this, IRemoteConnectionControlService.class); IRemoteConnectionControlService.class);
if (controlService != null) { if (controlService != null) {
controlService.close(); controlService.close();
} }
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#isOpen()
*/
@Override @Override
public boolean isOpen() { public boolean isOpen() {
if (original != null) { if (original != null) {
return original.isOpen(); return original.isOpen();
} else { } else {
IRemoteConnectionControlService controlService = IRemoteConnectionControlService controlService = connectionType.getConnectionService(this,
connectionType.getConnectionService(this, IRemoteConnectionControlService.class); IRemoteConnectionControlService.class);
if (controlService != null) { if (controlService != null) {
return controlService.isOpen(); return controlService.isOpen();
} else { } else {
@ -285,13 +384,18 @@ public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteConnection#getProperty(java.lang.String)
*/
@Override @Override
public String getProperty(String key) { public String getProperty(String key) {
if (original != null) { if (original != null) {
return original.getProperty(key); return original.getProperty(key);
} else { } else {
IRemoteConnectionPropertyService propertyService = IRemoteConnectionPropertyService propertyService = connectionType.getConnectionService(this,
connectionType.getConnectionService(this, IRemoteConnectionPropertyService.class); IRemoteConnectionPropertyService.class);
if (propertyService != null) { if (propertyService != null) {
return propertyService.getProperty(key); return propertyService.getProperty(key);
} else { } else {

View file

@ -35,6 +35,7 @@ import org.osgi.service.prefs.Preferences;
/** /**
* The implementation for the remote services manager service. * The implementation for the remote services manager service.
*
*/ */
public class RemoteServicesManager implements IRemoteServicesManager { public class RemoteServicesManager implements IRemoteServicesManager {
@ -109,52 +110,88 @@ public class RemoteServicesManager implements IRemoteServicesManager {
return SecurePreferencesFactory.getDefault().node(RemoteCorePlugin.getUniqueIdentifier()).node("connections"); //$NON-NLS-1$ return SecurePreferencesFactory.getDefault().node(RemoteCorePlugin.getUniqueIdentifier()).node("connections"); //$NON-NLS-1$
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#getConnectionType(java.lang.String)
*/
@Override @Override
public IRemoteConnectionType getConnectionType(String id) { public IRemoteConnectionType getConnectionType(String id) {
init(); init();
return connectionTypeMap.get(id); return connectionTypeMap.get(id);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#getConnectionType(java.net.URI)
*/
@Override @Override
public IRemoteConnectionType getConnectionType(URI uri) { public IRemoteConnectionType getConnectionType(URI uri) {
init(); init();
return schemeMap.get(uri.getScheme()); return schemeMap.get(uri.getScheme());
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#getLocalConnectionType()
*/
@Override @Override
public IRemoteConnectionType getLocalConnectionType() { public IRemoteConnectionType getLocalConnectionType() {
return getConnectionType(LOCAL_SERVICES_ID); return getConnectionType(LOCAL_SERVICES_ID);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#getAllConnectionTypes()
*/
@Override @Override
public List<IRemoteConnectionType> getAllConnectionTypes() { public List<IRemoteConnectionType> getAllConnectionTypes() {
init(); init();
return new ArrayList<IRemoteConnectionType>(connectionTypeMap.values()); return new ArrayList<IRemoteConnectionType>(connectionTypeMap.values());
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#getRemoteConnectionTypes()
*/
@Override @Override
public List<IRemoteConnectionType> getRemoteConnectionTypes() { public List<IRemoteConnectionType> getRemoteConnectionTypes() {
init(); init();
List<IRemoteConnectionType> services = new ArrayList<>(connectionTypeMap.values().size() - 1); List<IRemoteConnectionType> connTypes = new ArrayList<>(connectionTypeMap.values().size() - 1);
IRemoteConnectionType localServices = getLocalConnectionType(); IRemoteConnectionType localServices = getLocalConnectionType();
for (IRemoteConnectionType s : connectionTypeMap.values()) { for (IRemoteConnectionType s : connectionTypeMap.values()) {
if (!s.equals(localServices)) { if (!s.equals(localServices)) {
services.add(s); connTypes.add(s);
} }
} }
return services; return connTypes;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#getAllRemoteConnections()
*/
@Override @Override
public List<IRemoteConnection> getAllRemoteConnections() { public List<IRemoteConnection> getAllRemoteConnections() {
// TODO do this without getting the connection managers and force loading the plugins // TODO do this without getting the connection managers and force loading the plugins
List<IRemoteConnection> connections = new ArrayList<>(); List<IRemoteConnection> connections = new ArrayList<>();
for (IRemoteConnectionType services : getAllConnectionTypes()) { for (IRemoteConnectionType connType : getAllConnectionTypes()) {
connections.addAll(services.getConnections()); connections.addAll(connType.getConnections());
} }
return connections; return connections;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#addRemoteConnectionChangeListener(org.eclipse.remote.core.
* IRemoteConnectionChangeListener)
*/
@Override @Override
public void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) { public void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) {
synchronized (listeners) { synchronized (listeners) {
@ -162,6 +199,12 @@ public class RemoteServicesManager implements IRemoteServicesManager {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#removeRemoteConnectionChangeListener(org.eclipse.remote.core.
* IRemoteConnectionChangeListener)
*/
@Override @Override
public void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) { public void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) {
synchronized (listeners) { synchronized (listeners) {
@ -169,6 +212,12 @@ public class RemoteServicesManager implements IRemoteServicesManager {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.remote.core.IRemoteServicesManager#fireRemoteConnectionChangeEvent(org.eclipse.remote.core.
* RemoteConnectionChangeEvent)
*/
@Override @Override
public void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event) { public void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event) {
List<IRemoteConnectionChangeListener> iListeners; List<IRemoteConnectionChangeListener> iListeners;