mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-05 08:46:02 +02:00
[404967] - Removed some redundant methods/classes. Added
IRemoteUIConnectionWizard for better handling of connection creation/editing. Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
2ed7445888
commit
1223bb3755
19 changed files with 374 additions and 482 deletions
|
@ -20,6 +20,7 @@ import java.util.Map;
|
|||
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.osgi.util.NLS;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
@ -114,7 +115,7 @@ public class JSchConnectionManager implements IRemoteConnectionManager {
|
|||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
|
||||
if (getConnection(name) != null) {
|
||||
throw new RemoteConnectionException(Messages.JSchConnectionManager_connection_with_this_name_exists);
|
||||
throw new RemoteConnectionException(NLS.bind(Messages.JSchConnectionManager_connection_with_name_exists, name));
|
||||
}
|
||||
return createConnection(name).getWorkingCopy();
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public class JSchConnectionWorkingCopy extends JSchConnection implements IRemote
|
|||
*/
|
||||
@Override
|
||||
public IRemoteConnectionWorkingCopy getWorkingCopy() {
|
||||
return null;
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -36,7 +36,7 @@ public class Messages extends NLS {
|
|||
|
||||
public static String JSchConnection_Unable_to_open_sftp_channel;
|
||||
public static String JSchConnection_username_must_be_set;
|
||||
public static String JSchConnectionManager_connection_with_this_name_exists;
|
||||
public static String JSchConnectionManager_connection_with_name_exists;
|
||||
public static String JSchConnectionManager_cannotRemoveOpenConnection;
|
||||
public static String JSchConnectionManager_invalidConnectionType;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ JSchConnection_forwarding=Setting up remote forwarding
|
|||
JSchConnection_Remote_host_does_not_support_sftp=Remote host does not support sftp. Remote functionality requires sftp to be enabled
|
||||
JSchConnection_Unable_to_open_sftp_channel=Unable to open sftp channel: check sftp is enabled on remote host
|
||||
JSchConnection_username_must_be_set=Username must be set before opening connection
|
||||
JSchConnectionManager_connection_with_this_name_exists=A connection with this name already exists
|
||||
JSchConnectionManager_connection_with_name_exists=A connection with name \"{0}\" already exists
|
||||
JSchConnectionManager_cannotRemoveOpenConnection=Cannot remove an open connection
|
||||
JSchConnectionManager_invalidConnectionType=Invalid connection type
|
||||
JSchProcessBuilder_Connection_is_not_open=Connection is not open
|
||||
|
|
|
@ -75,6 +75,7 @@ public class JSchFileSystemContributor extends FileSystemContributor {
|
|||
try {
|
||||
return new URI(string);
|
||||
} catch (URISyntaxException e) {
|
||||
// Ignore
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -11,12 +11,10 @@
|
|||
package org.eclipse.internal.remote.jsch.ui;
|
||||
|
||||
import org.eclipse.internal.remote.jsch.core.JSchConnectionManager;
|
||||
import org.eclipse.internal.remote.jsch.core.JSchConnectionWorkingCopy;
|
||||
import org.eclipse.internal.remote.jsch.ui.wizards.JSchConnectionWizard;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.ui.AbstractRemoteUIConnectionManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class JSchUIConnectionManager extends AbstractRemoteUIConnectionManager {
|
||||
|
@ -29,49 +27,9 @@ public class JSchUIConnectionManager extends AbstractRemoteUIConnectionManager {
|
|||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ptp.remote.core.IRemoteUIConnectionManager#newConnection()
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#getConnectionWizard(org.eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(Shell shell) {
|
||||
return newConnection(shell, null, null);
|
||||
public IRemoteUIConnectionWizard getConnectionWizard(Shell shell) {
|
||||
return new JSchConnectionWizard(shell, fConnMgr);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.ptp.remote.ui.IRemoteUIConnectionManager#newConnection(org
|
||||
* .eclipse.swt.widgets.Shell,
|
||||
* org.eclipse.ptp.remote.ui.IRemoteUIConnectionManager
|
||||
* .IRemoteConnectionAttributeHint[], java.lang.String[])
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(Shell shell, String[] attrHints, String[] attrHintValues) {
|
||||
JSchConnectionWizard wizard = new JSchConnectionWizard(fConnMgr);
|
||||
WizardDialog dialog = new WizardDialog(shell, wizard);
|
||||
dialog.setBlockOnOpen(true);
|
||||
if (dialog.open() == WizardDialog.OK) {
|
||||
return wizard.getConnection();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#updateConnection(org.eclipse.swt.widgets.Shell,
|
||||
* org.eclipse.remote.core.IRemoteConnectionWorkingCopy)
|
||||
*/
|
||||
public boolean updateConnection(Shell shell, IRemoteConnectionWorkingCopy connection) {
|
||||
if (connection instanceof JSchConnectionWorkingCopy) {
|
||||
JSchConnectionWorkingCopy jSchConn = (JSchConnectionWorkingCopy) connection;
|
||||
JSchConnectionWizard wizard = new JSchConnectionWizard(fConnMgr, jSchConn);
|
||||
WizardDialog dialog = new WizardDialog(shell, wizard);
|
||||
dialog.setBlockOnOpen(true);
|
||||
if (dialog.open() == WizardDialog.OK) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public class Messages extends NLS {
|
|||
public static String JSchConnectionPage_A_connection_with_that_name_already_exists;
|
||||
public static String JSchConnectionPage_Edit_Connection;
|
||||
public static String JSchConnectionPage_Edit_properties_of_an_existing_connection;
|
||||
public static String JSchConnectionPage_Please_enter_name_for_connection;
|
||||
public static String JSchFileSystemContributor_0;
|
||||
public static String JSchNewConnectionPage_Advanced;
|
||||
public static String JSchNewConnectionPage_Connection_name;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
JSchConnectionPage_A_connection_with_that_name_already_exists=A connection with that name already exists
|
||||
JSchConnectionPage_Edit_Connection=Edit Connection
|
||||
JSchConnectionPage_Edit_properties_of_an_existing_connection=Edit properties of an existing connection
|
||||
JSchConnectionPage_Please_enter_name_for_connection=Please enter a name for the connection
|
||||
JSchFileSystemContributor_0=Browse File System
|
||||
JSchNewConnectionPage_Advanced=Advanced
|
||||
JSchNewConnectionPage_Connection_name=Connection name:
|
||||
|
|
|
@ -12,9 +12,13 @@
|
|||
package org.eclipse.internal.remote.jsch.ui.wizards;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.internal.remote.jsch.core.Activator;
|
||||
import org.eclipse.internal.remote.jsch.core.JSchConnection;
|
||||
import org.eclipse.internal.remote.jsch.core.JSchConnectionAttributes;
|
||||
import org.eclipse.internal.remote.jsch.core.JSchConnectionWorkingCopy;
|
||||
import org.eclipse.internal.remote.jsch.ui.messages.Messages;
|
||||
import org.eclipse.jface.wizard.WizardPage;
|
||||
|
@ -60,24 +64,18 @@ public class JSchConnectionPage extends WizardPage {
|
|||
private Combo fCipherCombo;
|
||||
private RemoteFileWidget fFileWidget;
|
||||
|
||||
private String fName;
|
||||
private String fInitialName = "Remote Host"; //$NON-NLS-1$
|
||||
private Set<String> fInvalidConnectionNames;
|
||||
private final Map<String, String> fInitialAttributes = new HashMap<String, String>();
|
||||
private JSchConnectionWorkingCopy fConnection;
|
||||
|
||||
private final IRemoteConnectionManager fConnectionManager;
|
||||
private JSchConnectionWorkingCopy fConnection;
|
||||
|
||||
private final DataModifyListener fDataModifyListener = new DataModifyListener();
|
||||
|
||||
public JSchConnectionPage(IRemoteConnectionManager connMgr) {
|
||||
super(Messages.JSchNewConnectionPage_New_Connection);
|
||||
fConnectionManager = connMgr;
|
||||
fConnection = null;
|
||||
setPageComplete(false);
|
||||
}
|
||||
|
||||
public JSchConnectionPage(IRemoteConnectionManager connMgr, JSchConnectionWorkingCopy conn) {
|
||||
super(Messages.JSchConnectionPage_Edit_Connection);
|
||||
fConnectionManager = connMgr;
|
||||
fConnection = conn;
|
||||
setPageComplete(false);
|
||||
}
|
||||
|
||||
|
@ -205,13 +203,14 @@ public class JSchConnectionPage extends WizardPage {
|
|||
|
||||
public void createControl(Composite parent) {
|
||||
if (fConnection == null) {
|
||||
this.setDescription(Messages.JSchNewConnectionPage_New_connection_properties);
|
||||
this.setTitle(Messages.JSchNewConnectionPage_New_Connection);
|
||||
setDescription(Messages.JSchNewConnectionPage_New_connection_properties);
|
||||
setTitle(Messages.JSchNewConnectionPage_New_Connection);
|
||||
} else {
|
||||
this.setDescription(Messages.JSchConnectionPage_Edit_properties_of_an_existing_connection);
|
||||
this.setTitle(Messages.JSchConnectionPage_Edit_Connection);
|
||||
setDescription(Messages.JSchConnectionPage_Edit_properties_of_an_existing_connection);
|
||||
setTitle(Messages.JSchConnectionPage_Edit_Connection);
|
||||
}
|
||||
this.setErrorMessage(null);
|
||||
setMessage(Messages.JSchConnectionPage_Please_enter_name_for_connection);
|
||||
setErrorMessage(null);
|
||||
|
||||
GridLayout topLayout = new GridLayout(2, false);
|
||||
final Composite topControl = new Composite(parent, SWT.NONE);
|
||||
|
@ -234,22 +233,22 @@ public class JSchConnectionPage extends WizardPage {
|
|||
createAuthControls(authGroup);
|
||||
createAdvancedControls(authGroup);
|
||||
|
||||
registerListeners();
|
||||
loadValues();
|
||||
/*
|
||||
* Register listeners after loading values so we don't trigger listeners
|
||||
*/
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
public JSchConnectionWorkingCopy getConnection() {
|
||||
return fConnection;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.jface.wizard.WizardPage#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return fName;
|
||||
private boolean isInvalidName(String name) {
|
||||
if (fInvalidConnectionNames == null) {
|
||||
return fConnectionManager.getConnection(name) != null;
|
||||
}
|
||||
return fInvalidConnectionNames.contains(name);
|
||||
}
|
||||
|
||||
private void loadValues() {
|
||||
|
@ -266,6 +265,40 @@ public class JSchConnectionPage extends WizardPage {
|
|||
fPassphraseText.setText(fConnection.getPassphrase());
|
||||
fFileWidget.setLocationPath(fConnection.getKeyFile());
|
||||
}
|
||||
} else {
|
||||
fConnectionName.setText(fInitialName);
|
||||
String host = fInitialAttributes.get(JSchConnectionAttributes.ADDRESS_ATTR);
|
||||
if (host != null) {
|
||||
fHostText.setText(host);
|
||||
}
|
||||
String username = fInitialAttributes.get(JSchConnectionAttributes.USERNAME_ATTR);
|
||||
if (username != null) {
|
||||
fUserText.setText(username);
|
||||
}
|
||||
String port = fInitialAttributes.get(JSchConnectionAttributes.PORT_ATTR);
|
||||
if (port != null) {
|
||||
fPortText.setText(port);
|
||||
}
|
||||
String timeout = fInitialAttributes.get(JSchConnectionAttributes.TIMEOUT_ATTR);
|
||||
if (timeout != null) {
|
||||
fTimeoutText.setText(timeout);
|
||||
}
|
||||
String isPwd = fInitialAttributes.get(JSchConnectionAttributes.IS_PASSWORD_ATTR);
|
||||
if (isPwd != null) {
|
||||
fPasswordButton.setSelection(Boolean.parseBoolean(isPwd));
|
||||
}
|
||||
String password = fInitialAttributes.get(JSchConnectionAttributes.PASSWORD_ATTR);
|
||||
if (password != null) {
|
||||
fPasswordText.setText(password);
|
||||
}
|
||||
String passphrase = fInitialAttributes.get(JSchConnectionAttributes.PASSPHRASE_ATTR);
|
||||
if (passphrase != null) {
|
||||
fPassphraseText.setText(passphrase);
|
||||
}
|
||||
String file = fInitialAttributes.get(JSchConnectionAttributes.KEYFILE_ATTR);
|
||||
if (file != null) {
|
||||
fFileWidget.setLocationPath(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -277,6 +310,26 @@ public class JSchConnectionPage extends WizardPage {
|
|||
fTimeoutText.addModifyListener(fDataModifyListener);
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
fInitialAttributes.put(JSchConnectionAttributes.ADDRESS_ATTR, address);
|
||||
}
|
||||
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
fInitialAttributes.putAll(attributes);
|
||||
}
|
||||
|
||||
public void setConnection(JSchConnectionWorkingCopy connection) {
|
||||
fConnection = connection;
|
||||
}
|
||||
|
||||
public void setConnectionName(String name) {
|
||||
fInitialName = name;
|
||||
}
|
||||
|
||||
public void setInvalidConnectionNames(Set<String> names) {
|
||||
fInvalidConnectionNames = names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPageComplete(boolean complete) {
|
||||
super.setPageComplete(complete);
|
||||
|
@ -285,6 +338,14 @@ public class JSchConnectionPage extends WizardPage {
|
|||
}
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
fInitialAttributes.put(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
fInitialAttributes.put(JSchConnectionAttributes.USERNAME_ATTR, username);
|
||||
}
|
||||
|
||||
private void storeValues() {
|
||||
if (fConnection == null) {
|
||||
try {
|
||||
|
@ -334,7 +395,7 @@ public class JSchConnectionPage extends WizardPage {
|
|||
String message = null;
|
||||
if (fConnectionName.getText().trim().length() == 0) {
|
||||
message = Messages.JSchNewConnectionPage_Please_enter_a_connection_name;
|
||||
} else if (fConnection == null && fConnectionManager.getConnection(fConnectionName.getText().trim()) != null) {
|
||||
} else if (isInvalidName(fConnectionName.getText().trim())) {
|
||||
message = Messages.JSchConnectionPage_A_connection_with_that_name_already_exists;
|
||||
} else if (fHostText.getText().trim().length() == 0) {
|
||||
message = Messages.JSchNewConnectionPage_Host_name_cannot_be_empty;
|
||||
|
@ -369,4 +430,5 @@ public class JSchConnectionPage extends WizardPage {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,22 +11,25 @@
|
|||
*/
|
||||
package org.eclipse.internal.remote.jsch.ui.wizards;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.internal.remote.jsch.core.JSchConnectionWorkingCopy;
|
||||
import org.eclipse.jface.wizard.Wizard;
|
||||
import org.eclipse.jface.wizard.WizardDialog;
|
||||
import org.eclipse.remote.core.IRemoteConnectionManager;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class JSchConnectionWizard extends Wizard {
|
||||
|
||||
public class JSchConnectionWizard extends Wizard implements IRemoteUIConnectionWizard {
|
||||
private final Shell fShell;
|
||||
private final JSchConnectionPage fPage;
|
||||
|
||||
public JSchConnectionWizard(IRemoteConnectionManager connMgr) {
|
||||
public JSchConnectionWizard(Shell shell, IRemoteConnectionManager connMgr) {
|
||||
fShell = shell;
|
||||
fPage = new JSchConnectionPage(connMgr);
|
||||
}
|
||||
|
||||
public JSchConnectionWizard(IRemoteConnectionManager connMgr, JSchConnectionWorkingCopy conn) {
|
||||
fPage = new JSchConnectionPage(connMgr, conn);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
@ -38,8 +41,18 @@ public class JSchConnectionWizard extends Wizard {
|
|||
addPage(fPage);
|
||||
}
|
||||
|
||||
public JSchConnectionWorkingCopy getConnection() {
|
||||
return fPage.getConnection();
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#getWorkingCopy()
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy open() {
|
||||
WizardDialog dialog = new WizardDialog(fShell, this);
|
||||
dialog.setBlockOnOpen(true);
|
||||
if (dialog.open() == WizardDialog.OK) {
|
||||
return fPage.getConnection();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -62,4 +75,30 @@ public class JSchConnectionWizard extends Wizard {
|
|||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setConnection(org.eclipse.remote.core.IRemoteConnectionWorkingCopy)
|
||||
*/
|
||||
public void setConnection(IRemoteConnectionWorkingCopy connection) {
|
||||
fPage.setConnection((JSchConnectionWorkingCopy) connection);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setConnectionName(java.lang.String)
|
||||
*/
|
||||
public void setConnectionName(String name) {
|
||||
fPage.setConnectionName(name);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setInvalidConnectionNames(java.util.Set)
|
||||
*/
|
||||
public void setInvalidConnectionNames(Set<String> names) {
|
||||
fPage.setInvalidConnectionNames(names);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.remote.ui.IRemoteUIServices;
|
|||
import org.eclipse.remote.ui.IRemoteUIServicesDescriptor;
|
||||
import org.eclipse.remote.ui.IRemoteUIServicesFactory;
|
||||
|
||||
public class RemoteUIServicesProxy implements IRemoteUIServicesDescriptor {
|
||||
public class RemoteUIServicesDescriptor implements IRemoteUIServicesDescriptor {
|
||||
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_CLASS = "class"; //$NON-NLS-1$
|
||||
|
@ -40,7 +40,7 @@ public class RemoteUIServicesProxy implements IRemoteUIServicesDescriptor {
|
|||
private IRemoteUIServicesFactory fFactory = null;
|
||||
private IRemoteUIServices fDelegate = null;
|
||||
|
||||
public RemoteUIServicesProxy(IConfigurationElement configElement) {
|
||||
public RemoteUIServicesDescriptor(IConfigurationElement configElement) {
|
||||
this.configElement = configElement;
|
||||
this.id = getAttribute(configElement, ATTR_ID, null);
|
||||
this.name = getAttribute(configElement, ATTR_NAME, this.id);
|
|
@ -13,6 +13,7 @@ package org.eclipse.internal.remote.ui.preferences;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.internal.remote.core.RemoteServicesDescriptor;
|
||||
import org.eclipse.internal.remote.core.RemoteServicesImpl;
|
||||
|
@ -36,7 +37,9 @@ 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.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.remote.ui.RemoteUIServices;
|
||||
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -61,6 +64,59 @@ import org.eclipse.ui.IWorkbenchPreferencePage;
|
|||
*/
|
||||
public class ConnectionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
|
||||
|
||||
private class ConnectionContentProvider implements IStructuredContentProvider {
|
||||
|
||||
public void dispose() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return fWorkingCopies.values().toArray(new IRemoteConnection[fWorkingCopies.size()]);
|
||||
}
|
||||
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ConnectionLabelProvider implements ITableLabelProvider {
|
||||
|
||||
public void addListener(ILabelProviderListener listener) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
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 boolean isLabelProperty(Object element, String property) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeListener(ILabelProviderListener listener) {
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle widget selection events for this page
|
||||
*
|
||||
|
@ -93,60 +149,8 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
|
||||
}
|
||||
|
||||
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 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) };
|
||||
|
@ -167,6 +171,8 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
|
||||
private final Map<String, IRemoteConnection> fWorkingCopies = new HashMap<String, IRemoteConnection>();
|
||||
|
||||
private static final String DEFAULT_CONNECTION_NAME = "Remote Host"; //$NON-NLS-1$
|
||||
|
||||
public ConnectionsPreferencePage() {
|
||||
super();
|
||||
}
|
||||
|
@ -179,43 +185,34 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
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;
|
||||
IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
|
||||
if (wizard != null) {
|
||||
wizard.setConnectionName(initialConnectionName());
|
||||
wizard.setInvalidConnectionNames(invalidConnectionNames());
|
||||
IRemoteConnectionWorkingCopy conn = wizard.open();
|
||||
if (conn != null) {
|
||||
fWorkingCopies.put(conn.getName(), conn);
|
||||
fConnectionViewer.refresh();
|
||||
fIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the contents for this page
|
||||
*
|
||||
* @param parent
|
||||
* - The parent widget for the client area
|
||||
*/
|
||||
@Override
|
||||
protected Control createContents(Composite parent) {
|
||||
return createWidgets(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the widgets for this page
|
||||
*
|
||||
|
@ -313,14 +310,65 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
private void editConnection() {
|
||||
if (fSelectedConnection != null) {
|
||||
IRemoteConnectionWorkingCopy copy = fSelectedConnection.getWorkingCopy();
|
||||
if (fUIConnectionManager.updateConnection(getShell(), copy)) {
|
||||
fWorkingCopies.put(copy.getName(), copy);
|
||||
fConnectionViewer.refresh();
|
||||
fIsDirty = true;
|
||||
IRemoteUIConnectionWizard wizard = fUIConnectionManager.getConnectionWizard(getShell());
|
||||
if (wizard != null) {
|
||||
wizard.setConnection(copy);
|
||||
wizard.setInvalidConnectionNames(invalidConnectionNames());
|
||||
IRemoteConnectionWorkingCopy conn = wizard.open();
|
||||
if (conn != null) {
|
||||
fWorkingCopies.put(copy.getName(), copy);
|
||||
fConnectionViewer.refresh();
|
||||
fIsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void init(IWorkbench workbench) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
private String initialConnectionName() {
|
||||
String name = RemoteConnectionWidget.DEFAULT_CONNECTION_NAME;
|
||||
int count = 2;
|
||||
while (fWorkingCopies.containsKey(name)) {
|
||||
name = DEFAULT_CONNECTION_NAME + " " + count++; //$NON-NLS-1$
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private Set<String> invalidConnectionNames() {
|
||||
return fWorkingCopies.keySet();
|
||||
}
|
||||
|
||||
private void initWorkingConnections() {
|
||||
fWorkingCopies.clear();
|
||||
for (IRemoteConnection conn : fConnectionManager.getConnections()) {
|
||||
fWorkingCopies.put(conn.getName(), conn);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performDefaults() {
|
||||
initWorkingConnections();
|
||||
fIsDirty = false;
|
||||
super.performDefaults();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the selected service configuration from the set of service
|
||||
* configurations
|
||||
|
@ -389,22 +437,4 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
|
|||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* 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.internal.remote.ui.services.local;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.internal.remote.ui.RemoteUIPlugin;
|
||||
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
public class LocalUIConnectionManager implements IRemoteUIConnectionManager {
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.core.IRemoteUIConnectionManager#newConnection()
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(Shell shell) {
|
||||
MessageDialog.openInformation(shell, Messages.LocalUIConnectionManager_2, Messages.LocalUIConnectionManager_3);
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.eclipse.remote.ui.IRemoteUIConnectionManager#newConnection(org
|
||||
* .eclipse.swt.widgets.Shell, java.lang.String[], java.lang.String[])
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(Shell shell, String[] attrHints, String[] attrHintValues) {
|
||||
return newConnection(shell);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#
|
||||
* openConnectionWithProgress(org.eclipse.swt.widgets.Shell,
|
||||
* org.eclipse.jface.operation.IRunnableContext,
|
||||
* org.eclipse.remote.core.IRemoteConnection)
|
||||
*/
|
||||
public void openConnectionWithProgress(final Shell shell, IRunnableContext context, final IRemoteConnection connection) {
|
||||
if (!connection.isOpen()) {
|
||||
IRunnableWithProgress op = new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
try {
|
||||
connection.open(monitor);
|
||||
} catch (RemoteConnectionException e) {
|
||||
ErrorDialog.openError(shell, Messages.LocalUIConnectionManager_0, Messages.LocalUIConnectionManager_1,
|
||||
new Status(IStatus.ERROR, RemoteUIPlugin.getUniqueIdentifier(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
if (context != null) {
|
||||
context.run(true, true, op);
|
||||
} else {
|
||||
new ProgressMonitorDialog(shell).run(true, true, op);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
ErrorDialog.openError(shell, Messages.LocalUIConnectionManager_0, Messages.LocalUIConnectionManager_1, new Status(
|
||||
IStatus.ERROR, RemoteUIPlugin.getUniqueIdentifier(), e.getMessage()));
|
||||
} catch (InterruptedException e) {
|
||||
ErrorDialog.openError(shell, Messages.LocalUIConnectionManager_0, Messages.LocalUIConnectionManager_1, new Status(
|
||||
IStatus.ERROR, RemoteUIPlugin.getUniqueIdentifier(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager#updateConnection(org.eclipse.swt.widgets.Shell,
|
||||
* org.eclipse.remote.core.IRemoteConnectionWorkingCopy)
|
||||
*/
|
||||
public boolean updateConnection(Shell shell, IRemoteConnectionWorkingCopy connection) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@ import org.eclipse.remote.ui.IRemoteUIServices;
|
|||
public class LocalUIServices implements IRemoteUIServices {
|
||||
private static LocalUIServices fInstance = null;
|
||||
private final static LocalUIFileManager fFileMgr = new LocalUIFileManager();
|
||||
private final static LocalUIConnectionManager fConnMgr = new LocalUIConnectionManager();
|
||||
|
||||
/**
|
||||
* Get shared instance of this class
|
||||
|
@ -63,7 +62,7 @@ public class LocalUIServices implements IRemoteUIServices {
|
|||
* org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getUIConnectionManager(org.eclipse.remote.core.IRemoteConnectionManager)
|
||||
*/
|
||||
public IRemoteUIConnectionManager getUIConnectionManager() {
|
||||
return fConnMgr;
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.remote.ui;
|
|||
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
|
@ -21,52 +20,14 @@ import org.eclipse.swt.widgets.Shell;
|
|||
*/
|
||||
public interface IRemoteUIConnectionManager {
|
||||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
public static String CONNECTION_ADDRESS_HINT = "CONNECTION_ADDRESS_HINT"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
public static String CONNECTION_PORT_HINT = "CONNECTION_PORT_HINT"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
public static String CONNECTION_TIMEOUT_HINT = "CONNECTION_TIMEOUT_HINT"; //$NON-NLS-1$
|
||||
/**
|
||||
* @since 5.0
|
||||
*/
|
||||
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 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.
|
||||
* Create a wizard for adding or editing connections. The implementation can choose to do this in any way, but typically will
|
||||
* use a dialog or wizard.
|
||||
*
|
||||
* @param shell
|
||||
* shell used to display dialogs
|
||||
* @return newly created remote connection working copy or null if none created
|
||||
* @return connection wizard
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(Shell shell);
|
||||
|
||||
/**
|
||||
* Create a new connection using the remote service provider new connection dialog. If attrHints and attrHintValues are provided
|
||||
* then the dialog will 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
|
||||
* shell used to display dialog
|
||||
* @param attrHints
|
||||
* array containing attribute hints
|
||||
* @param attrHintValues
|
||||
* array containing default values for each attribute specified
|
||||
* in attrHints
|
||||
* @return the newly created connection working copy or null if none created
|
||||
* @since 5.0
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy newConnection(Shell shell, String[] attrHints, String[] attrHintValues);
|
||||
public IRemoteUIConnectionWizard getConnectionWizard(Shell shell);
|
||||
|
||||
/**
|
||||
* Attempt to open a connection using a progress monitor. Can be called on either open or closed connections, and will
|
||||
|
@ -82,16 +43,4 @@ public interface IRemoteUIConnectionManager {
|
|||
* @since 5.0
|
||||
*/
|
||||
public void openConnectionWithProgress(Shell shell, IRunnableContext context, IRemoteConnection connection);
|
||||
|
||||
/**
|
||||
* Change a connection configuration. The implementation can chose to do this in any way, but typically will use a dialog or
|
||||
* wizard. Callers must call {@link IRemoteConnectionWorkingCopy#save()} on the working copy for the changes to be saved.
|
||||
*
|
||||
* @param shell
|
||||
* shell used to display dialogs
|
||||
* @param connection
|
||||
* working copy of the connection to modify
|
||||
* @return true if the connection information was changed
|
||||
*/
|
||||
public boolean updateConnection(Shell shell, IRemoteConnectionWorkingCopy connection);
|
||||
}
|
||||
|
|
|
@ -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.remote.ui;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
|
||||
|
||||
/**
|
||||
* Interface for creating and editing connections in the UI.
|
||||
*/
|
||||
public interface IRemoteUIConnectionWizard {
|
||||
/**
|
||||
* Open configuration wizard allowing the user to enter information about a connection. If the user confirms the information is
|
||||
* correct (e.g. selects OK in a dialog) then a working copy of the connection is returned. If the user discards the
|
||||
* information, then null is returned.
|
||||
*
|
||||
* @return connection working copy or null if the wizard is canceled
|
||||
*/
|
||||
public IRemoteConnectionWorkingCopy open();
|
||||
|
||||
/**
|
||||
* Set a connection containing the information to be edited by the wizard. Setting this value overrides the
|
||||
* {@link #setConnectionName(String)} method.
|
||||
*
|
||||
* @param connection
|
||||
* connection used to initialize the wizard
|
||||
*/
|
||||
public void setConnection(IRemoteConnectionWorkingCopy connection);
|
||||
|
||||
/**
|
||||
* Set the initial name of the connection.
|
||||
*
|
||||
* @param name
|
||||
* initial connection name
|
||||
*/
|
||||
public void setConnectionName(String name);
|
||||
|
||||
/**
|
||||
* Supply a set of connection names that are invalid. The dialog should display an error if the user trys to select a name from
|
||||
* the set.
|
||||
*
|
||||
* @param names
|
||||
* set of invalid connections names
|
||||
*/
|
||||
public void setInvalidConnectionNames(Set<String> names);
|
||||
}
|
|
@ -21,7 +21,7 @@ import org.eclipse.core.runtime.IExtensionRegistry;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.internal.remote.ui.RemoteUIPlugin;
|
||||
import org.eclipse.internal.remote.ui.RemoteUIServicesProxy;
|
||||
import org.eclipse.internal.remote.ui.RemoteUIServicesDescriptor;
|
||||
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
|
@ -37,7 +37,7 @@ import org.eclipse.ui.PlatformUI;
|
|||
public class RemoteUIServices {
|
||||
private static final String EXTENSION_POINT_ID = "remoteUIServices"; //$NON-NLS-1$
|
||||
|
||||
private static Map<String, RemoteUIServicesProxy> fRemoteUIServices = null;
|
||||
private static Map<String, RemoteUIServicesDescriptor> fRemoteUIServices = null;
|
||||
private static Map<String, IRemoteServices> fRemoteServices = new HashMap<String, IRemoteServices>();
|
||||
|
||||
/**
|
||||
|
@ -94,9 +94,9 @@ public class RemoteUIServices {
|
|||
/*
|
||||
* Find the UI services corresponding to services.
|
||||
*/
|
||||
RemoteUIServicesProxy proxy = fRemoteUIServices.get(services.getId());
|
||||
if (proxy != null) {
|
||||
return proxy.getUIServices(services);
|
||||
RemoteUIServicesDescriptor descriptor = fRemoteUIServices.get(services.getId());
|
||||
if (descriptor != null) {
|
||||
return descriptor.getUIServices(services);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -104,19 +104,19 @@ public class RemoteUIServices {
|
|||
/**
|
||||
* Find and load all remoteUIServices plugins.
|
||||
*/
|
||||
private static Map<String, RemoteUIServicesProxy> retrieveRemoteUIServices() {
|
||||
private static Map<String, RemoteUIServicesDescriptor> retrieveRemoteUIServices() {
|
||||
IExtensionRegistry registry = Platform.getExtensionRegistry();
|
||||
IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteUIPlugin.getUniqueIdentifier(), EXTENSION_POINT_ID);
|
||||
final IExtension[] extensions = extensionPoint.getExtensions();
|
||||
|
||||
Map<String, RemoteUIServicesProxy> services = new HashMap<String, RemoteUIServicesProxy>(5);
|
||||
Map<String, RemoteUIServicesDescriptor> services = new HashMap<String, RemoteUIServicesDescriptor>(5);
|
||||
|
||||
for (IExtension ext : extensions) {
|
||||
final IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||
|
||||
for (IConfigurationElement ce : elements) {
|
||||
RemoteUIServicesProxy proxy = new RemoteUIServicesProxy(ce);
|
||||
services.put(proxy.getId(), proxy);
|
||||
RemoteUIServicesDescriptor descriptor = new RemoteUIServicesDescriptor(ce);
|
||||
services.put(descriptor.getId(), descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2011 University of Illinois 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:
|
||||
* Albert L. Rossi - design and implementation
|
||||
******************************************************************************/
|
||||
package org.eclipse.remote.ui;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.internal.remote.ui.RemoteUIPlugin;
|
||||
import org.eclipse.internal.remote.ui.messages.Messages;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.remote.core.IRemoteConnection;
|
||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
/**
|
||||
* Convenience methods for handling various actions involving IRemoteUIServices.
|
||||
*
|
||||
* @see org.eclipse.remote.ui.IRemoteUIServices
|
||||
* @see org.eclipse.remote.ui.IRemoteUIFileManager
|
||||
* @see org.eclipse.remote.ui.IRemoteUIConnectionManager
|
||||
*
|
||||
* @since 5.0
|
||||
*
|
||||
*/
|
||||
public class RemoteUIServicesUtils {
|
||||
/**
|
||||
* @param shell
|
||||
* @param context
|
||||
* @param connection
|
||||
* @since 7.0
|
||||
*/
|
||||
public static void openConnectionWithProgress(final Shell shell, IRunnableContext context, final IRemoteConnection connection) {
|
||||
if (!connection.isOpen()) {
|
||||
IRunnableWithProgress op = new IRunnableWithProgress() {
|
||||
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
||||
try {
|
||||
connection.open(monitor);
|
||||
} catch (RemoteConnectionException e) {
|
||||
throw new InvocationTargetException(e);
|
||||
}
|
||||
if (monitor.isCanceled()) {
|
||||
throw new InterruptedException();
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
if (context != null) {
|
||||
context.run(true, true, op);
|
||||
} else {
|
||||
new ProgressMonitorDialog(shell).run(true, true, op);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
ErrorDialog.openError(shell, Messages.AbstractRemoteUIConnectionManager_Connection_Error,
|
||||
Messages.AbstractRemoteUIConnectionManager_Could_not_open_connection, new Status(IStatus.ERROR,
|
||||
RemoteUIPlugin.PLUGIN_ID, e.getCause().getMessage()));
|
||||
} catch (InterruptedException e) {
|
||||
ErrorDialog.openError(shell, Messages.AbstractRemoteUIConnectionManager_Connection_Error,
|
||||
Messages.AbstractRemoteUIConnectionManager_Could_not_open_connection, new Status(IStatus.ERROR,
|
||||
RemoteUIPlugin.PLUGIN_ID, e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to configure the default host and port in the wizard used for
|
||||
* choosing a resource manager connection.
|
||||
*
|
||||
* @see org.eclipse.remote.ui.widgets.RemoteConnectionWidget
|
||||
*
|
||||
* @param connectionWidget
|
||||
* the widget allowing the user to choose the connection
|
||||
* @param connection
|
||||
* name of the connection
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public static void setConnectionHints(RemoteConnectionWidget connectionWidget, IRemoteConnection connection)
|
||||
throws URISyntaxException {
|
||||
Map<String, String> result = new HashMap<String, String>();
|
||||
result.put(IRemoteUIConnectionManager.CONNECTION_ADDRESS_HINT, connection.getAddress());
|
||||
result.put(IRemoteUIConnectionManager.LOGIN_USERNAME_HINT, connection.getUsername());
|
||||
result.put(IRemoteUIConnectionManager.CONNECTION_PORT_HINT, String.valueOf(connection.getPort()));
|
||||
String[] hints = new String[result.size()];
|
||||
String[] defaults = new String[hints.length];
|
||||
int i = 0;
|
||||
for (String s : result.keySet()) {
|
||||
hints[i] = s;
|
||||
defaults[i++] = result.get(s);
|
||||
}
|
||||
connectionWidget.setHints(hints, defaults);
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import org.eclipse.remote.core.IRemotePreferenceConstants;
|
|||
import org.eclipse.remote.core.IRemoteServices;
|
||||
import org.eclipse.remote.core.RemoteServices;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
|
||||
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
|
||||
import org.eclipse.remote.ui.RemoteUIServices;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
|
@ -114,6 +115,8 @@ public class RemoteConnectionWidget extends Composite {
|
|||
|
||||
}
|
||||
|
||||
public static final String DEFAULT_CONNECTION_NAME = "Remote Host"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Force the use of a remote provider dialog, regardless of the PRE_REMOTE_SERVICES_ID preference setting.
|
||||
*
|
||||
|
@ -144,9 +147,6 @@ public class RemoteConnectionWidget extends Composite {
|
|||
|
||||
private final IRunnableContext fContext;
|
||||
|
||||
private String[] fAttrHints;
|
||||
private String[] fAttrHintValues;
|
||||
|
||||
private final ListenerList fSelectionListeners = new ListenerList();
|
||||
private final WidgetListener fWidgetListener = new WidgetListener();
|
||||
|
||||
|
@ -394,10 +394,14 @@ public class RemoteConnectionWidget extends Composite {
|
|||
*/
|
||||
protected void handleNewRemoteConnectionSelected() {
|
||||
if (getUIConnectionManager() != null) {
|
||||
IRemoteConnectionWorkingCopy conn = getUIConnectionManager().newConnection(getShell(), fAttrHints, fAttrHintValues);
|
||||
if (conn != null) {
|
||||
handleRemoteServiceSelected(conn.save());
|
||||
handleConnectionSelected();
|
||||
IRemoteUIConnectionWizard wizard = getUIConnectionManager().getConnectionWizard(getShell());
|
||||
if (wizard != null) {
|
||||
wizard.setConnectionName(initialConnectionName());
|
||||
IRemoteConnectionWorkingCopy conn = wizard.open();
|
||||
if (conn != null) {
|
||||
handleRemoteServiceSelected(conn.save());
|
||||
handleConnectionSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -478,6 +482,15 @@ public class RemoteConnectionWidget extends Composite {
|
|||
}
|
||||
}
|
||||
|
||||
private String initialConnectionName() {
|
||||
String name = DEFAULT_CONNECTION_NAME;
|
||||
int count = 1;
|
||||
while (getSelectedServices().getConnectionManager().getConnection(name) != null) {
|
||||
name = DEFAULT_CONNECTION_NAME + " " + count++; //$NON-NLS-1$
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the contents of the remote services combo. Keeps an array of remote services that matches the combo elements.
|
||||
* Returns the id of the selected element.
|
||||
|
@ -584,17 +597,6 @@ public class RemoteConnectionWidget extends Composite {
|
|||
updateEnablement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set hints to use when creating a new connection.
|
||||
*
|
||||
* @param attrHints
|
||||
* @param attrHintValues
|
||||
*/
|
||||
public void setHints(String[] attrHints, String[] attrHintValues) {
|
||||
fAttrHints = attrHints;
|
||||
fAttrHintValues = attrHintValues;
|
||||
}
|
||||
|
||||
private void updateEnablement() {
|
||||
if (fDefaultServices != null) {
|
||||
boolean isRemote = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue