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

Add JSch UI support

Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2013-09-11 11:38:26 -04:00
parent d6bcaedc01
commit 0f1d75b0ad
20 changed files with 1206 additions and 0 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.remote.jsch.ui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

View file

@ -0,0 +1,23 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.remote.jsch.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.eclipse.internal.remote.jsch.ui.Activator
Bundle-Vendor: %pluginProvider
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.filesystem,
org.eclipse.remote.core,
org.eclipse.remote.ui,
org.eclipse.remote.jsch.core,
org.eclipse.jsch.core,
com.jcraft.jsch,
org.eclipse.ui.forms,
org.eclipse.ui.ide,
org.eclipse.ui,
org.eclipse.jface
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.internal.remote.jsch.ui;x-internal:=true,
org.eclipse.internal.remote.jsch.ui.messages;x-internal:=true
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5

View file

@ -0,0 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html>
<head>
<title>About</title>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
</head>
<body lang="EN-US">
<h2>About This Content</h2>
<p>May 2, 2006</p>
<h3>License</h3>
<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
indicated below, the terms and conditions of the EPL still apply to any source code in the Content and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org.</p>
</body>
</html>

View file

@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
plugin.properties,\
about.html

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

View file

@ -0,0 +1,13 @@
###############################################################################
# Copyright (c) 2013 IBM Corporation.
# 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
#
###############################################################################
pluginName=JSch UI Remote Support
pluginProvider=Eclipse PTP
JSchTransferConnections.name=Remote Connections
JSchTransferConnections.description=All remote ssh connections

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="org.eclipse.remote.ui.remoteUIServices">
<remoteUIServices
class="org.eclipse.internal.remote.jsch.ui.JSchUIServicesFactory"
id="org.eclipse.remote.JSch"
name="JSch">
</remoteUIServices>
</extension>
<extension
point="org.eclipse.ui.ide.filesystemSupport">
<filesystemContributor
class="org.eclipse.internal.remote.jsch.ui.JSchFileSystemContributor"
label="JSch"
scheme="ssh">
</filesystemContributor>
</extension>
<extension
point="org.eclipse.ui.preferenceTransfer">
<transfer
icon="icons/full/obj16/connection.gif"
id="org.eclipse.remote.jsch.transfer.connections"
name="%JSchTransferConnections.name">
<mapping
scope="instance">
<entry
node="org.eclipse.remote.jsch.core/connections">
</entry>
</mapping>
<description>
%JSchTransferConnections.description
</description>
</transfer>
</extension>
</plugin>

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.ptp</groupId>
<artifactId>ptp-parent</artifactId>
<version>7.0.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.remote.jsch.core</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>

View file

@ -0,0 +1,112 @@
package org.eclipse.internal.remote.jsch.ui;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.jsch.core.IJSchService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin {
// The plug-in ID
private static final String PLUGIN_ID = "org.eclipse.remote.jsch.ui"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Get unique identifier
*
* @return
* @since 5.0
*/
public static String getUniqueIdentifier() {
if (getDefault() == null) {
return PLUGIN_ID;
}
return getDefault().getBundle().getSymbolicName();
}
/**
* Logs the specified status with this plug-in's log.
*
* @param status
* status to log
*/
public static void log(IStatus status) {
getDefault().getLog().log(status);
}
/**
* Logs an internal error with the specified message.
*
* @param message
* the error message to log
*/
public static void log(String message) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
}
/**
* Logs an internal error with the specified throwable
*
* @param e
* the exception to be logged
*/
public static void log(Throwable e) {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
}
private IJSchService fJSchService;
/**
* The constructor
*/
public Activator() {
}
public IJSchService getService() {
return fJSchService;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
ServiceReference<IJSchService> reference = context.getServiceReference(IJSchService.class);
fJSchService = context.getService(reference);
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
@Override
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
}

View file

@ -0,0 +1,81 @@
/********************************************************************************
* Copyright (c) 2002, 2008 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
*
* Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
*
* Contributors:
* Kushal Munir (IBM) - moved to internal package.
* Martin Oberhuber (Wind River) - [181917] EFS Improvements: Avoid unclosed Streams,
* - Fix early startup issues by deferring FileStore evaluation and classloading,
* - Improve performance by RSEFileStore instance factory and caching IRemoteFile.
* - Also remove unnecessary class RSEFileCache and obsolete branding files.
* Martin Oberhuber (Wind River) - [188360] renamed from plugin org.eclipse.rse.eclipse.filesystem
* Martin Oberhuber (Wind River) - [189441] fix EFS operations on Windows (Local) systems
* David Dykstal (IBM) - [235840] externalizing dialog title
********************************************************************************/
package org.eclipse.internal.remote.jsch.ui;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.internal.remote.jsch.core.JSchFileSystem;
import org.eclipse.internal.remote.jsch.core.JSchServices;
import org.eclipse.internal.remote.jsch.ui.messages.Messages;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.core.RemoteServices;
import org.eclipse.remote.ui.IRemoteUIFileManager;
import org.eclipse.remote.ui.IRemoteUIServices;
import org.eclipse.remote.ui.RemoteUIServices;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
public class JSchFileSystemContributor extends FileSystemContributor {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.ide.fileSystem.FileSystemContributor#browseFileSystem(
* java.lang.String, org.eclipse.swt.widgets.Shell)
*/
@Override
public URI browseFileSystem(String initialPath, Shell shell) {
IRemoteServices services = RemoteServices.getRemoteServices(JSchServices.JSCH_ID);
IRemoteUIServices uiServices = RemoteUIServices.getRemoteUIServices(services);
IRemoteUIFileManager uiFileMgr = uiServices.getUIFileManager();
uiFileMgr.showConnections(true);
String path = uiFileMgr.browseDirectory(shell, Messages.JSchFileSystemContributor_0, initialPath, 0);
if (path != null) {
IRemoteConnection conn = uiFileMgr.getConnection();
if (conn != null) {
return JSchFileSystem.getURIFor(conn.getName(), path);
}
}
return null;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.ide.fileSystem.FileSystemContributor#getURI(java.lang.
* String)
*/
@Override
public URI getURI(String string) {
try {
return new URI(string);
} catch (URISyntaxException e) {
}
return null;
}
}

View file

@ -0,0 +1,85 @@
/*******************************************************************************
* 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.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.swt.widgets.Shell;
public class JSchUIConnectionManager extends AbstractRemoteUIConnectionManager {
private final JSchConnectionManager connMgr;
public JSchUIConnectionManager(IRemoteServices services) {
connMgr = (JSchConnectionManager) services.getConnectionManager();
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ptp.remote.core.IRemoteUIConnectionManager#newConnection()
*/
public IRemoteConnectionWorkingCopy newConnection(Shell shell) {
return newConnection(shell, null, null);
}
/*
* (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) {
JSchConnectionWorkingCopy conn = createConnection(shell, attrHints, attrHintValues);
if (conn != null) {
return conn;
}
return null;
}
public JSchConnectionWorkingCopy createConnection(Shell shell, String[] attrHints, String[] attrHintValues) {
JSchConnectionWizard wizard = new JSchConnectionWizard(connMgr);
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(connMgr, jSchConn);
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.setBlockOnOpen(true);
if (dialog.open() == WizardDialog.OK) {
return true;
}
}
return false;
}
}

View file

@ -0,0 +1,130 @@
/*******************************************************************************
* 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.jsch.ui;
import org.eclipse.jface.window.Window;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.ui.IRemoteUIFileManager;
import org.eclipse.remote.ui.dialogs.RemoteResourceBrowser;
import org.eclipse.swt.widgets.Shell;
public class JSchUIFileManager implements IRemoteUIFileManager {
private IRemoteServices services = null;
private IRemoteConnection connection = null;
private boolean showConnections = false;
public JSchUIFileManager(IRemoteServices services) {
this.services = services;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ptp.remote.core.IRemoteFileManager#browseDirectory(org.eclipse
* .swt.widgets.Shell, java.lang.String, java.lang.String)
*/
public String browseDirectory(Shell shell, String message, String filterPath, int flags) {
RemoteResourceBrowser browser = new RemoteResourceBrowser(services, connection, shell, RemoteResourceBrowser.SINGLE);
browser.setType(RemoteResourceBrowser.DIRECTORY_BROWSER);
browser.setInitialPath(filterPath);
browser.setTitle(message);
browser.showConnections(showConnections);
if (browser.open() == Window.CANCEL) {
return null;
}
connection = browser.getConnection();
String path = browser.getPath();
if (path == null) {
return null;
}
return path;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ptp.remote.core.IRemoteFileManager#browseFile(org.eclipse
* .swt.widgets.Shell, java.lang.String, java.lang.String)
*/
public String browseFile(Shell shell, String message, String filterPath, int flags) {
RemoteResourceBrowser browser = new RemoteResourceBrowser(services, connection, shell, RemoteResourceBrowser.SINGLE);
browser.setType(RemoteResourceBrowser.FILE_BROWSER);
browser.setInitialPath(filterPath);
browser.setTitle(message);
browser.showConnections(showConnections);
if (browser.open() == Window.CANCEL) {
return null;
}
connection = browser.getConnection();
String path = browser.getPath();
if (path == null) {
return null;
}
return path;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ptp.remote.core.IRemoteFileManager#browseFile(org.eclipse
* .swt.widgets.Shell, java.lang.String, java.lang.String)
*/
public String[] browseFiles(Shell shell, String message, String filterPath, int flags) {
RemoteResourceBrowser browser = new RemoteResourceBrowser(services, connection, shell, RemoteResourceBrowser.MULTI);
browser.setType(RemoteResourceBrowser.FILE_BROWSER);
browser.setInitialPath(filterPath);
browser.setTitle(message);
browser.showConnections(showConnections);
if (browser.open() == Window.CANCEL) {
return null;
}
connection = browser.getConnection();
String path[] = browser.getPaths();
if (path == null) {
return null;
}
return path;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ptp.remote.ui.IRemoteUIFileManager#getConnection()
*/
public IRemoteConnection getConnection() {
return connection;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ptp.remote.ui.IRemoteUIFileManager#setConnection(org.eclipse
* .ptp.remote.core.IRemoteConnection)
*/
public void setConnection(IRemoteConnection connection) {
this.connection = connection;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ptp.remote.ui.IRemoteUIFileManager#showConnections(boolean)
*/
public void showConnections(boolean enable) {
showConnections = enable;
}
}

View file

@ -0,0 +1,74 @@
/*******************************************************************************
* 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.internal.remote.jsch.ui;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.ui.IRemoteUIConnectionManager;
import org.eclipse.remote.ui.IRemoteUIFileManager;
import org.eclipse.remote.ui.IRemoteUIServices;
public class JSchUIServices implements IRemoteUIServices {
private static JSchUIServices fInstance = null;
/**
* Get shared instance of this class
*
* @return instance
*/
public static JSchUIServices getInstance(IRemoteServices services) {
if (fInstance == null) {
fInstance = new JSchUIServices(services);
}
return fInstance;
}
private final IRemoteServices fServices;
public JSchUIServices(IRemoteServices services) {
fServices = services;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getId()
*/
public String getId() {
return fServices.getId();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getName()
*/
public String getName() {
return fServices.getName();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getUIConnectionManager()
*/
public IRemoteUIConnectionManager getUIConnectionManager() {
return new JSchUIConnectionManager(fServices);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getUIFileManager()
*/
public IRemoteUIFileManager getUIFileManager() {
return new JSchUIFileManager(fServices);
}
}

View file

@ -0,0 +1,26 @@
/*******************************************************************************
* 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.internal.remote.jsch.ui;
import org.eclipse.remote.core.IRemoteServices;
import org.eclipse.remote.ui.IRemoteUIServices;
import org.eclipse.remote.ui.IRemoteUIServicesFactory;
public class JSchUIServicesFactory implements IRemoteUIServicesFactory {
/*
* (non-Javadoc)
*
* @see org.eclipse.ptp.remote.ui.IRemoteUIServicesFactory#getServices(org.eclipse.ptp.remote.core.IRemoteServices)
*/
public IRemoteUIServices getServices(IRemoteServices services) {
return JSchUIServices.getInstance(services);
}
}

View file

@ -0,0 +1,55 @@
/**
* Copyright (c) 2013 IBM Corporation.
* 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 Implementation
*
*/
package org.eclipse.internal.remote.jsch.ui.messages;
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_ID = "org.eclipse.internal.remote.jsch.ui.messages.messages"; //$NON-NLS-1$
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_ID, Messages.class);
}
private Messages() {
// cannot create new instance
}
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 JSchFileSystemContributor_0;
public static String JSchNewConnectionPage_Advanced;
public static String JSchNewConnectionPage_Connection_name;
public static String JSchNewConnectionPage_File_with_private_key;
public static String JSchNewConnectionPage_Host;
public static String JSchNewConnectionPage_Host_information;
public static String JSchNewConnectionPage_Host_name_cannot_be_empty;
public static String JSchNewConnectionPage_New_Connection;
public static String JSchNewConnectionPage_New_connection_properties;
public static String JSchNewConnectionPage_Passphrase;
public static String JSchNewConnectionPage_Password;
public static String JSchNewConnectionPage_Password_based_authentication;
public static String JSchNewConnectionPage_Please_enter_a_connection_name;
public static String JSchNewConnectionPage_Port;
public static String JSchNewConnectionPage_Port_is_not_valid;
public static String JSchNewConnectionPage_Private_key_file_cannot_be_read;
public static String JSchNewConnectionPage_Private_key_file_does_not_exist;
public static String JSchNewConnectionPage_Private_key_file_is_invalid;
public static String JSchNewConnectionPage_Private_key_path_cannot_be_empty;
public static String JSchNewConnectionPage_Public_key_based_authentication;
public static String JSchNewConnectionPage_Timeout;
public static String JSchNewConnectionPage_Timeout_is_not_valid;
public static String JSchNewConnectionPage_User;
public static String JSchNewConnectionPage_User_name_cannot_be_empty;
}

View file

@ -0,0 +1,37 @@
###############################################################################
# Copyright (c) 2013 IBM Corporation.
# 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 implementation
###############################################################################
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
JSchFileSystemContributor_0=Browse File System
JSchNewConnectionPage_Advanced=Advanced
JSchNewConnectionPage_Connection_name=Connection name:
JSchNewConnectionPage_File_with_private_key=File with private key:
JSchNewConnectionPage_Host=Host:
JSchNewConnectionPage_Host_information=Host information
JSchNewConnectionPage_Host_name_cannot_be_empty=Host name cannot be empty
JSchNewConnectionPage_New_Connection=New Connection
JSchNewConnectionPage_New_connection_properties=New connection properties
JSchNewConnectionPage_Passphrase=Passphrase:
JSchNewConnectionPage_Password=Password:
JSchNewConnectionPage_Password_based_authentication=Password based authentication
JSchNewConnectionPage_Please_enter_a_connection_name=Please enter a connection name
JSchNewConnectionPage_Port=Port:
JSchNewConnectionPage_Port_is_not_valid=Port is not valid
JSchNewConnectionPage_Private_key_file_cannot_be_read=Private key file cannot be read
JSchNewConnectionPage_Private_key_file_does_not_exist=Private key file does not exist
JSchNewConnectionPage_Private_key_file_is_invalid=Private key file is invalid
JSchNewConnectionPage_Private_key_path_cannot_be_empty=Private key path cannot be empty
JSchNewConnectionPage_Public_key_based_authentication=Public key based authentication
JSchNewConnectionPage_Timeout=Timeout:
JSchNewConnectionPage_Timeout_is_not_valid=Timeout is not valid
JSchNewConnectionPage_User=User:
JSchNewConnectionPage_User_name_cannot_be_empty=User name cannot be empty

View file

@ -0,0 +1,370 @@
/**
* Copyright (c) 2013 IBM Corporation.
* 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 Implementation
*
*/
package org.eclipse.internal.remote.jsch.ui.wizards;
import java.io.File;
import org.eclipse.internal.remote.jsch.core.Activator;
import org.eclipse.internal.remote.jsch.core.JSchConnection;
import org.eclipse.internal.remote.jsch.core.JSchConnectionWorkingCopy;
import org.eclipse.internal.remote.jsch.ui.messages.Messages;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.remote.core.IRemoteConnectionManager;
import org.eclipse.remote.core.RemoteServices;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.ui.widgets.RemoteFileWidget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.events.ExpansionEvent;
import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
public class JSchConnectionPage extends WizardPage {
private class DataModifyListener implements ModifyListener {
public synchronized void modifyText(ModifyEvent e) {
validateFields();
getContainer().updateButtons();
}
}
private Text fConnectionName;
private Button fPasswordButton;
private Button fPublicKeyButton;
private Text fHostText;
private Text fUserText;
private Text fPasswordText;
private Text fPassphraseText;
private Text fPortText;
private Text fTimeoutText;
private Combo fCipherCombo;
private RemoteFileWidget fFileWidget;
private String fName;
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);
}
/**
* Create controls for the bottom (hideable) composite
*
* @param mold
*
*/
private void createAdvancedControls(final Composite parent) {
ExpandableComposite expComp = new ExpandableComposite(parent, ExpandableComposite.TWISTIE);
expComp.setText(Messages.JSchNewConnectionPage_Advanced);
expComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
expComp.setExpanded(false);
expComp.addExpansionListener(new IExpansionListener() {
public void expansionStateChanged(ExpansionEvent e) {
Point newSize = parent.computeSize(SWT.DEFAULT, SWT.DEFAULT);
Point currentSize = parent.getSize();
int deltaY = newSize.y - currentSize.y;
Point shellSize = getShell().getSize();
shellSize.y += deltaY;
getShell().setSize(shellSize);
getShell().layout(true, true);
}
public void expansionStateChanging(ExpansionEvent e) {
// Ignore
}
});
Composite advancedComp = new Composite(expComp, SWT.NONE);
advancedComp.setLayout(new GridLayout(2, false));
advancedComp.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
Label portLabel = new Label(advancedComp, SWT.NONE);
portLabel.setText(Messages.JSchNewConnectionPage_Port);
portLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fPortText = new Text(advancedComp, SWT.BORDER | SWT.SINGLE);
fPortText.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
fPortText.setTextLimit(5);
Label timeoutLabel = new Label(advancedComp, SWT.NONE);
timeoutLabel.setText(Messages.JSchNewConnectionPage_Timeout);
timeoutLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fTimeoutText = new Text(advancedComp, SWT.BORDER | SWT.SINGLE);
fTimeoutText.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
fTimeoutText.setTextLimit(5);
// Label cipherLabel = new Label(advancedComp, SWT.NONE);
// cipherLabel.setText("Cipher type:");
// cipherLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
// fCipherCombo = new Combo(advancedComp, SWT.NONE);
// fCipherCombo.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
expComp.setClient(advancedComp);
}
private void createAuthControls(Composite parent) {
Composite controls = new Composite(parent, SWT.NONE);
controls.setLayout(new GridLayout(2, false));
controls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
Label hostLabel = new Label(controls, SWT.NONE);
hostLabel.setText(Messages.JSchNewConnectionPage_Host);
hostLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fHostText = new Text(controls, SWT.BORDER | SWT.SINGLE);
fHostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Label userLabel = new Label(controls, SWT.NONE);
userLabel.setText(Messages.JSchNewConnectionPage_User);
userLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fUserText = new Text(controls, SWT.BORDER | SWT.SINGLE);
fUserText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
// User option box
fPasswordButton = new Button(controls, SWT.RADIO);
fPasswordButton.setText(Messages.JSchNewConnectionPage_Password_based_authentication);
fPasswordButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
fPasswordButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
}
});
// Password field
Label passwordLabel = new Label(controls, SWT.NONE);
passwordLabel.setText(Messages.JSchNewConnectionPage_Password);
passwordLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fPasswordText = new Text(controls, SWT.BORDER | SWT.SINGLE);
fPasswordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
// Key option box
fPublicKeyButton = new Button(controls, SWT.RADIO);
fPublicKeyButton.setText(Messages.JSchNewConnectionPage_Public_key_based_authentication);
fPublicKeyButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
fPublicKeyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
}
});
// Key file selection
fFileWidget = new RemoteFileWidget(controls, SWT.NONE, 0, null, ""); //$NON-NLS-1$
fFileWidget.setConnection(RemoteServices.getLocalServices().getConnectionManager()
.getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME));
fFileWidget.setLabel(Messages.JSchNewConnectionPage_File_with_private_key);
fFileWidget.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
// Passphrase field
Label passphraseLabel = new Label(controls, SWT.NONE);
passphraseLabel.setText(Messages.JSchNewConnectionPage_Passphrase);
passphraseLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fPassphraseText = new Text(controls, SWT.BORDER | SWT.SINGLE);
fPassphraseText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fPasswordButton.setSelection(true);
fPublicKeyButton.setSelection(false);
updateEnablement();
}
public void createControl(Composite parent) {
if (fConnection == null) {
this.setDescription(Messages.JSchNewConnectionPage_New_connection_properties);
this.setTitle(Messages.JSchNewConnectionPage_New_Connection);
} else {
this.setDescription(Messages.JSchConnectionPage_Edit_properties_of_an_existing_connection);
this.setTitle(Messages.JSchConnectionPage_Edit_Connection);
}
this.setErrorMessage(null);
GridLayout topLayout = new GridLayout(2, false);
final Composite topControl = new Composite(parent, SWT.NONE);
setControl(topControl);
topControl.setLayout(topLayout);
Label label = new Label(topControl, SWT.NONE);
label.setText(Messages.JSchNewConnectionPage_Connection_name);
label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
fConnectionName = new Text(topControl, SWT.BORDER | SWT.SINGLE);
fConnectionName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fConnectionName.setEnabled(fConnection == null);
final Group authGroup = new Group(topControl, SWT.NONE);
authGroup.setText(Messages.JSchNewConnectionPage_Host_information);
authGroup.setLayout(new GridLayout(1, false));
authGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
createAuthControls(authGroup);
createAdvancedControls(authGroup);
registerListeners();
loadValues();
}
public JSchConnectionWorkingCopy getConnection() {
return fConnection;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.WizardPage#getName()
*/
@Override
public String getName() {
return fName;
}
private void loadValues() {
if (fConnection != null) {
fConnectionName.setText(fConnection.getName());
fHostText.setText(fConnection.getAddress());
fUserText.setText(fConnection.getUsername());
fPortText.setText(Integer.toString(fConnection.getPort()));
fTimeoutText.setText(Integer.toString(fConnection.getTimeout()));
fPasswordButton.setSelection(fConnection.isPasswordAuth());
if (fConnection.isPasswordAuth()) {
fPasswordText.setText(fConnection.getPassword());
} else {
fPassphraseText.setText(fConnection.getPassphrase());
fFileWidget.setLocationPath(fConnection.getKeyFile());
}
}
}
private void registerListeners() {
fConnectionName.addModifyListener(fDataModifyListener);
fHostText.addModifyListener(fDataModifyListener);
fUserText.addModifyListener(fDataModifyListener);
fPortText.addModifyListener(fDataModifyListener);
fTimeoutText.addModifyListener(fDataModifyListener);
}
@Override
public void setPageComplete(boolean complete) {
super.setPageComplete(complete);
if (complete) {
storeValues();
}
}
private void storeValues() {
if (fConnection == null) {
try {
JSchConnection conn = (JSchConnection) fConnectionManager.newConnection(fConnectionName.getText().trim());
fConnection = (JSchConnectionWorkingCopy) conn.getWorkingCopy();
} catch (RemoteConnectionException e) {
Activator.log(e);
}
}
if (fConnection != null) {
fConnection.setAddress(fHostText.getText().trim());
fConnection.setUsername(fUserText.getText().trim());
fConnection.setPassword(fPasswordText.getText().trim());
fConnection.setPassphrase(fPassphraseText.getText().trim());
fConnection.setKeyFile(fFileWidget.getLocationPath());
fConnection.setIsPasswordAuth(fPasswordButton.getSelection());
fConnection.setTimeout(Integer.parseInt(fTimeoutText.getText().trim()));
fConnection.setPort(Integer.parseInt(fPortText.getText().trim()));
}
}
private void updateEnablement() {
boolean isPasswordAuth = fPasswordButton.getSelection();
fPasswordText.setEnabled(isPasswordAuth);
fPassphraseText.setEnabled(!isPasswordAuth);
fFileWidget.setEnabled(!isPasswordAuth);
}
private String validateAdvanced() {
try {
Integer.parseInt(fPortText.getText().trim());
} catch (NumberFormatException ne) {
return Messages.JSchNewConnectionPage_Port_is_not_valid;
}
try {
Integer.parseInt(fTimeoutText.getText().trim());
} catch (NumberFormatException ne) {
return Messages.JSchNewConnectionPage_Timeout_is_not_valid;
}
// if (fCipherCombo.getSelectionIndex() == -1) {
// return "Invalid cipher type";
// }
return null;
}
private void validateFields() {
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) {
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;
} else if (fUserText.getText().trim().length() == 0) {
message = Messages.JSchNewConnectionPage_User_name_cannot_be_empty;
}
if (message == null) {
message = validatePasskey();
}
if (message == null) {
message = validateAdvanced();
}
setErrorMessage(message);
setPageComplete(message == null);
}
private String validatePasskey() {
if (!fPasswordButton.getSelection()) {
if (fFileWidget.getLocationPath().trim().length() == 0) {
return Messages.JSchNewConnectionPage_Private_key_path_cannot_be_empty;
}
File path = new File(fFileWidget.getLocationPath().trim());
if (!path.exists()) {
return Messages.JSchNewConnectionPage_Private_key_file_does_not_exist;
}
if (!path.isFile()) {
return Messages.JSchNewConnectionPage_Private_key_file_is_invalid;
}
if (!path.canRead()) {
return Messages.JSchNewConnectionPage_Private_key_file_cannot_be_read;
}
}
return null;
}
}

View file

@ -0,0 +1,65 @@
/**
* Copyright (c) 2013 IBM Corporation.
* 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 Implementation
*
*/
package org.eclipse.internal.remote.jsch.ui.wizards;
import org.eclipse.internal.remote.jsch.core.JSchConnectionWorkingCopy;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.remote.core.IRemoteConnectionManager;
public class JSchConnectionWizard extends Wizard {
private final JSchConnectionPage fPage;
public JSchConnectionWizard(IRemoteConnectionManager connMgr) {
fPage = new JSchConnectionPage(connMgr);
}
public JSchConnectionWizard(IRemoteConnectionManager connMgr, JSchConnectionWorkingCopy conn) {
fPage = new JSchConnectionPage(connMgr, conn);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#addPages()
*/
@Override
public void addPages() {
super.addPages();
addPage(fPage);
}
public JSchConnectionWorkingCopy getConnection() {
return fPage.getConnection();
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performCancel()
*/
@Override
public boolean performCancel() {
return true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
return true;
}
}