mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 16:56:04 +02:00
[404967] - Minor API tweaks.
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
9157c5eb90
commit
2ed7445888
12 changed files with 54 additions and 39 deletions
|
@ -122,16 +122,14 @@ public class ConnectionTests extends TestCase {
|
|||
assertNotNull(fRemoteConnectionManager);
|
||||
|
||||
try {
|
||||
fRemoteConnection = fRemoteConnectionManager.newConnection("test_connection"); //$NON-NLS-1$
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnectionManager.newConnection("test_connection"); //$NON-NLS-1$
|
||||
wc.setAddress(HOST);
|
||||
wc.setUsername(USERNAME);
|
||||
wc.setPassword(PASSWORD);
|
||||
fRemoteConnection = wc.save();
|
||||
} catch (RemoteConnectionException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
assertNotNull(fRemoteConnection);
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||
wc.setAddress(HOST);
|
||||
wc.setUsername(USERNAME);
|
||||
wc.setPassword(PASSWORD);
|
||||
wc.save();
|
||||
|
||||
try {
|
||||
fRemoteConnection.open(new NullProgressMonitor());
|
||||
|
|
|
@ -129,16 +129,15 @@ public class FileStoreTests extends TestCase {
|
|||
assertNotNull(fRemoteConnectionManager);
|
||||
|
||||
try {
|
||||
fRemoteConnection = fRemoteConnectionManager.newConnection(CONNECTION_NAME);
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnectionManager.newConnection(CONNECTION_NAME);
|
||||
wc.setAddress(HOST);
|
||||
wc.setUsername(USERNAME);
|
||||
wc.setPassword(PASSWORD);
|
||||
fRemoteConnection = wc.save();
|
||||
assertNotNull(fRemoteConnection);
|
||||
} catch (RemoteConnectionException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
assertNotNull(fRemoteConnection);
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||
wc.setAddress(HOST);
|
||||
wc.setUsername(USERNAME);
|
||||
wc.setPassword(PASSWORD);
|
||||
wc.save();
|
||||
|
||||
try {
|
||||
fRemoteConnection.open(new NullProgressMonitor());
|
||||
|
|
|
@ -180,16 +180,15 @@ public class ProcessTests extends TestCase {
|
|||
assertNotNull(connMgr);
|
||||
|
||||
try {
|
||||
fRemoteConnection = connMgr.newConnection("test_connection"); //$NON-NLS-1$
|
||||
IRemoteConnectionWorkingCopy wc = connMgr.newConnection("test_connection"); //$NON-NLS-1$
|
||||
wc.setAddress(HOST);
|
||||
wc.setUsername(USERNAME);
|
||||
wc.setPassword(PASSWORD);
|
||||
fRemoteConnection = wc.save();
|
||||
assertNotNull(fRemoteConnection);
|
||||
} catch (RemoteConnectionException e) {
|
||||
fail(e.getLocalizedMessage());
|
||||
}
|
||||
assertNotNull(fRemoteConnection);
|
||||
IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
|
||||
wc.setAddress(HOST);
|
||||
wc.setUsername(USERNAME);
|
||||
wc.setPassword(PASSWORD);
|
||||
wc.save();
|
||||
|
||||
try {
|
||||
fRemoteConnection.open(new NullProgressMonitor());
|
||||
|
|
|
@ -8,6 +8,7 @@ public class Messages extends NLS {
|
|||
public static String LocalConnection_2;
|
||||
public static String RemoteServicesProxy_0;
|
||||
public static String RemoteServicesProxy_1;
|
||||
public static String Unable_to_create_new_local_connections;
|
||||
|
||||
static {
|
||||
// initialize resource bundle
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
LocalConnection_1=localhost
|
||||
LocalConnection_2=Port forwarding not supported
|
||||
Unable_to_create_new_local_connections=Unable to create new local connections
|
||||
RemoteServicesProxy_0=Missing {0} attribute
|
||||
RemoteServicesProxy_1=Failed to instantiate factory: {0} in type: {1} in plugin: {2}
|
||||
|
|
|
@ -15,8 +15,10 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.filesystem.EFS;
|
||||
import org.eclipse.internal.remote.core.messages.Messages;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
|
||||
|
@ -78,8 +80,8 @@ public class LocalConnectionManager implements IRemoteConnectionManager {
|
|||
* .lang.String)
|
||||
*/
|
||||
@Override
|
||||
public IRemoteConnection newConnection(String name) throws RemoteConnectionException {
|
||||
return fLocalConnection;
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
|
||||
throw new RemoteConnectionException(Messages.Unable_to_create_new_local_connections);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -10,12 +10,21 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.internal.remote.core.services.local;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
||||
public class LocalConnectionWorkingCopy extends LocalConnection implements IRemoteConnectionWorkingCopy {
|
||||
|
||||
private final LocalConnection fOriginal;
|
||||
|
||||
public LocalConnectionWorkingCopy(LocalConnection connection) {
|
||||
super(connection.getRemoteServices());
|
||||
fOriginal = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRemoteConnection save() {
|
||||
return fOriginal;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,9 +56,4 @@ public class LocalConnectionWorkingCopy extends LocalConnection implements IRemo
|
|||
public void setUsername(String username) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,17 +54,20 @@ public interface IRemoteConnectionManager {
|
|||
public List<IRemoteConnection> getConnections();
|
||||
|
||||
/**
|
||||
* Creates a new remote connection named with supplied name. The connection
|
||||
* attributes will be the default for the implementation.
|
||||
* Creates a new remote connection named with supplied name. The connection attributes will be the default for the
|
||||
* implementation.
|
||||
*
|
||||
* Returns a working copy of the remote connection. Callers must call {@link IRemoteConnectionWorkingCopy#save()} before the
|
||||
* connection can be used.
|
||||
*
|
||||
* @param name
|
||||
* name of the connection
|
||||
* @return a new connection with the supplied name
|
||||
* @return a new connection working copy with the supplied name
|
||||
* @throws RemoteConnectionException
|
||||
* if connection creation failed
|
||||
* @since 5.0
|
||||
*/
|
||||
public IRemoteConnection newConnection(String name) throws RemoteConnectionException;
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException;
|
||||
|
||||
/**
|
||||
* Remove a connection and all resources associated with it.
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
package org.eclipse.remote.core;
|
||||
|
||||
public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
|
||||
/**
|
||||
* Saves this working copy to its original connection and returns a handle to the resulting connection. Has no effect if this
|
||||
* connection does not need saving.
|
||||
*
|
||||
* @return saved connection
|
||||
*/
|
||||
public IRemoteConnection save();
|
||||
|
||||
/**
|
||||
* Set the address for this connection
|
||||
*
|
||||
|
@ -60,6 +68,4 @@ public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
|
|||
* @param username
|
||||
*/
|
||||
public void setUsername(String username);
|
||||
|
||||
public void save();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
|
|||
import org.eclipse.internal.remote.jsch.core.messages.Messages;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
|
@ -111,11 +112,11 @@ public class JSchConnectionManager implements IRemoteConnectionManager {
|
|||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
public IRemoteConnection newConnection(String name) throws RemoteConnectionException {
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
|
||||
if (getConnection(name) != null) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnectionManager_connection_with_this_name_exists);
|
||||
}
|
||||
return createConnection(name);
|
||||
return createConnection(name).getWorkingCopy();
|
||||
}
|
||||
|
||||
public void add(JSchConnection conn) {
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.internal.remote.jsch.core;
|
|||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
||||
|
@ -139,7 +140,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
|
|||
*
|
||||
* @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
|
||||
*/
|
||||
public void save() {
|
||||
public IRemoteConnection save() {
|
||||
JSchConnectionAttributes info = fOriginal.getInfo();
|
||||
info.getAttributes().clear();
|
||||
info.getAttributes().putAll(fWorkingAttributes.getAttributes());
|
||||
|
@ -152,6 +153,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
|
|||
}
|
||||
info.save();
|
||||
getManager().add(fOriginal);
|
||||
return fOriginal;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -396,8 +396,7 @@ public class RemoteConnectionWidget extends Composite {
|
|||
if (getUIConnectionManager() != null) {
|
||||
IRemoteConnectionWorkingCopy conn = getUIConnectionManager().newConnection(getShell(), fAttrHints, fAttrHintValues);
|
||||
if (conn != null) {
|
||||
conn.save();
|
||||
handleRemoteServiceSelected(conn);
|
||||
handleRemoteServiceSelected(conn.save());
|
||||
handleConnectionSelected();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue