diff --git a/rse/plugins/org.eclipse.rse.services.ssh/.settings/org.eclipse.core.resources.prefs b/rse/plugins/org.eclipse.rse.services.ssh/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..15ddd885914 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.ssh/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Fri Jul 07 10:39:59 CEST 2006 +eclipse.preferences.version=1 +encoding//src/org/eclipse/rse/services/ssh/SshServiceResources.properties=8859_1 diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/SshServiceResources.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/SshServiceResources.java new file mode 100644 index 00000000000..13e3152d956 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/SshServiceResources.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2006 Wind River Systems, Inc. + * 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: + * Martin Oberhuber (Wind River) - initial API and implementation + *******************************************************************************/ + +package org.eclipse.rse.services.ssh; + +import org.eclipse.osgi.util.NLS; + +public class SshServiceResources extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.rse.services.ssh.SshServiceResources"; //$NON-NLS-1$ + + public static String SftpFileService_Description; + + public static String SftpFileService_Error_JschSessionLost; + + public static String SftpFileService_Msg_Progress; + + public static String SftpFileService_Name; + + public static String SshShellService_Description; + + public static String SshShellService_Name; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, SshServiceResources.class); + } + + private SshServiceResources() { + } +} diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/SshServiceResources.properties b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/SshServiceResources.properties new file mode 100644 index 00000000000..d9efcf5d040 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/SshServiceResources.properties @@ -0,0 +1,18 @@ +################################################################################ +# Copyright (c) 2006 Wind River Systems, Inc. +# 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: +# Martin Oberhuber (Wind River) - initial API and implementation +################################################################################ + +SftpFileService_Name=Ssh / Sftp File Service +SftpFileService_Description=Access a remote file system via Ssh / Sftp protocol +SftpFileService_Error_JschSessionLost=jsch session lost +SftpFileService_Msg_Progress={0,number,integer} KB of {1,number,integer} KB complete ({2,number,percent}) + +SshShellService_Name=SSH Shell Service +SshShellService_Description=SSH Shell Service Description diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/files/SftpFileService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/files/SftpFileService.java index fa9738db3a3..a516212357e 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/files/SftpFileService.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/files/SftpFileService.java @@ -33,6 +33,7 @@ import org.eclipse.rse.services.files.IHostFile; import org.eclipse.rse.services.ssh.Activator; import org.eclipse.rse.services.ssh.ISshService; import org.eclipse.rse.services.ssh.ISshSessionProvider; +import org.eclipse.rse.services.ssh.SshServiceResources; import com.jcraft.jsch.Channel; import com.jcraft.jsch.ChannelExec; @@ -57,11 +58,11 @@ public class SftpFileService extends AbstractFileService implements IFileService } public String getName() { - return "Ssh / Sftp File Service"; + return SshServiceResources.SftpFileService_Name; } public String getDescription() { - return "Access a remote file system via Ssh / Sftp protocol"; + return SshServiceResources.SftpFileService_Description; } public void connect() throws Exception { @@ -114,7 +115,7 @@ public class SftpFileService extends AbstractFileService implements IFileService //This will lead to jsch exceptions (NPE, or disconnected) //which are ignored for now since the connection is about //to be disconnected anyways. - throw new IOException("jsch session lost"); + throw new IOException(SshServiceResources.SftpFileService_Error_JschSessionLost); } } return fChannelSftp; @@ -270,7 +271,7 @@ public class SftpFileService extends AbstractFileService implements IFileService if (attr.getSize() != localFile.length()) { //Error: file truncated? - Inform the user!! //TODO throw exception to show an error dialog! - System.err.println("ssh.upload: file size mismatch for "+dst); + System.err.println("ssh.upload: file size mismatch for "+dst); //$NON-NLS-1$ return false; } } @@ -304,7 +305,7 @@ public class SftpFileService extends AbstractFileService implements IFileService fWorkToDate = 0; String srcFile = new Path(src).lastSegment(); //String desc = ((op==SftpProgressMonitor.PUT)? - // "Uploading " : "Downloading ")+srcFile; //$NON-NLS-1$ //$NON-NLS-2$ + // "Uploading " : "Downloading ")+srcFile; String desc = srcFile; //TODO avoid cast from long to int fMonitor.beginTask(desc, (int)max); @@ -313,8 +314,9 @@ public class SftpFileService extends AbstractFileService implements IFileService fWorkToDate += count; Long workToDateKB = new Long(fWorkToDate / 1024L); Double workPercent = new Double(fWorkPercentFactor * fWorkToDate); - String pattern = "{0,number,integer} KB of {1,number,integer} KB complete ({2,number,percent})"; - String subDesc = MessageFormat.format(pattern, new Object[] { + String subDesc = MessageFormat.format( + SshServiceResources.SftpFileService_Msg_Progress, + new Object[] { workToDateKB, fMaxWorkKB, workPercent }); fMonitor.subTask(subDesc); @@ -384,7 +386,7 @@ public class SftpFileService extends AbstractFileService implements IFileService if (attr.getSize() != localFile.length()) { //Error: file truncated? - Inform the user!! //TODO throw exception to show an error dialog! - System.err.println("ssh.download: file size mismatch for "+remotePath); + System.err.println("ssh.download: file size mismatch for "+remotePath); //$NON-NLS-1$ return false; } } @@ -423,13 +425,6 @@ public class SftpFileService extends AbstractFileService implements IFileService return new IHostFile[] { root }; } - // TODO - /******************************************************** - * - * The following APIs need to be implemented - * - ********************************************************/ - public IHostFile createFile(IProgressMonitor monitor, String remoteParent, String fileName) throws SystemMessageException { IHostFile result = null; @@ -571,7 +566,6 @@ public class SftpFileService extends AbstractFileService implements IFileService return result; } - private static Pattern fValidShellPattern = Pattern.compile("[a-zA-Z0-9._/]*"); //$NON-NLS-1$ /** * Quotes a string such that it can be used in a remote UNIX shell. * On Windows, special characters likes quotes and dollar sign. and @@ -619,6 +613,7 @@ public class SftpFileService extends AbstractFileService implements IFileService return buf.toString(); } } + private static Pattern fValidShellPattern = Pattern.compile("[a-zA-Z0-9._/]*"); //$NON-NLS-1$ public boolean move(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName) throws SystemMessageException { diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/SshShellService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/SshShellService.java index 74f9d156e04..f1ff0ddb9ff 100644 --- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/SshShellService.java +++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/services/ssh/shell/SshShellService.java @@ -22,6 +22,7 @@ import org.eclipse.rse.services.shells.IHostShell; import org.eclipse.rse.services.shells.IShellService; import org.eclipse.rse.services.ssh.ISshService; import org.eclipse.rse.services.ssh.ISshSessionProvider; +import org.eclipse.rse.services.ssh.SshServiceResources; /** * A Shell Services for ssh. @@ -29,7 +30,7 @@ import org.eclipse.rse.services.ssh.ISshSessionProvider; */ public class SshShellService implements ISshService, IShellService { - private static final String SHELL_INVOCATION = ">"; + private static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$ private ISshSessionProvider fSessionProvider; public SshShellService(ISshSessionProvider sessionProvider) { @@ -71,12 +72,11 @@ public class SshShellService implements ISshService, IShellService { } public String getName() { - //TODO Externalize Strings - return "SSH Shell Service"; + return SshServiceResources.SshShellService_Name; } public String getDescription() { - return "SSH Shell Service Description"; + return SshServiceResources.SshShellService_Description; } public void initService(IProgressMonitor monitor) {