mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-09 01:55:24 +02:00
Moved logging console setup to org.eclipse.subsystems.files.ftp
This commit is contained in:
parent
78a62f47b4
commit
ac3fef760c
6 changed files with 63 additions and 43 deletions
|
@ -8,8 +8,6 @@ Bundle-Vendor: %providerName
|
||||||
Bundle-Localization: plugin
|
Bundle-Localization: plugin
|
||||||
Require-Bundle: org.eclipse.core.runtime,
|
Require-Bundle: org.eclipse.core.runtime,
|
||||||
org.eclipse.rse.services,
|
org.eclipse.rse.services,
|
||||||
org.apache.commons.net,
|
org.apache.commons.net
|
||||||
org.eclipse.ui.console,
|
|
||||||
org.eclipse.jface
|
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Export-Package: org.eclipse.rse.services.files.ftp
|
Export-Package: org.eclipse.rse.services.files.ftp
|
||||||
|
|
|
@ -63,9 +63,6 @@ import org.eclipse.rse.services.files.IFileService;
|
||||||
import org.eclipse.rse.services.files.IHostFile;
|
import org.eclipse.rse.services.files.IHostFile;
|
||||||
import org.eclipse.rse.services.files.RemoteFileIOException;
|
import org.eclipse.rse.services.files.RemoteFileIOException;
|
||||||
import org.eclipse.rse.services.files.RemoteFolderNotEmptyException;
|
import org.eclipse.rse.services.files.RemoteFolderNotEmptyException;
|
||||||
import org.eclipse.ui.console.ConsolePlugin;
|
|
||||||
import org.eclipse.ui.console.IConsole;
|
|
||||||
import org.eclipse.ui.console.MessageConsole;
|
|
||||||
|
|
||||||
|
|
||||||
public class FTPService extends AbstractFileService implements IFileService, IFTPService
|
public class FTPService extends AbstractFileService implements IFileService, IFTPService
|
||||||
|
@ -79,7 +76,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
private transient String _password;
|
private transient String _password;
|
||||||
private transient int _portNumber;
|
private transient int _portNumber;
|
||||||
|
|
||||||
private OutputStream _ftpConsoleOutputStream;
|
private OutputStream _ftpLoggingOutputStream;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -118,6 +115,11 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
{
|
{
|
||||||
_password = password;
|
_password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLoggingStream(OutputStream ftpLoggingOutputStream)
|
||||||
|
{
|
||||||
|
_ftpLoggingOutputStream = ftpLoggingOutputStream;
|
||||||
|
}
|
||||||
|
|
||||||
public void connect() throws Exception
|
public void connect() throws Exception
|
||||||
{
|
{
|
||||||
|
@ -126,30 +128,12 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
_ftpClient = new FTPClient();
|
_ftpClient = new FTPClient();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_ftpConsoleOutputStream==null)
|
if(_ftpLoggingOutputStream!=null)
|
||||||
{
|
{
|
||||||
MessageConsole messageConsole=null;
|
_ftpClient.registerSpyStream(_ftpLoggingOutputStream);
|
||||||
|
|
||||||
IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
|
|
||||||
for (int i = 0; i < consoles.length; i++) {
|
|
||||||
if(consoles[i].getName().equals("FTP log: "+_hostName+":"+_portNumber)) { //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
messageConsole = (MessageConsole)consoles[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(messageConsole==null){
|
|
||||||
messageConsole = new MessageConsole("FTP log: "+_hostName+":"+_portNumber, null); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ messageConsole });
|
|
||||||
}
|
|
||||||
|
|
||||||
_ftpConsoleOutputStream = messageConsole.newOutputStream();
|
|
||||||
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ftpClient.registerSpyStream(_ftpConsoleOutputStream);
|
|
||||||
|
|
||||||
if (_portNumber == 0) {
|
if (_portNumber == 0) {
|
||||||
_ftpClient.connect(_hostName);
|
_ftpClient.connect(_hostName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -552,7 +536,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
|
|
||||||
MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor);
|
MyProgressMonitor progressMonitor = new MyProgressMonitor(monitor);
|
||||||
|
|
||||||
progressMonitor.init("Deleting "+fileName, 1); //$NON-NLS-1$
|
progressMonitor.init(FTPServiceResources.FTP_File_Service_Deleting_Task+fileName, 1);
|
||||||
|
|
||||||
boolean isFile = getFile(null,remoteParent,fileName).isFile();
|
boolean isFile = getFile(null,remoteParent,fileName).isFile();
|
||||||
|
|
||||||
|
@ -572,7 +556,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!hasSucceeded){
|
if(!hasSucceeded){
|
||||||
throw new Exception(ftpClient.getReplyString()+" ("+fileName+")");
|
throw new Exception(ftpClient.getReplyString()+" ("+fileName+")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -716,7 +700,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
|
|
||||||
public boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName) throws SystemMessageException
|
public boolean copy(IProgressMonitor monitor, String srcParent, String srcName, String tgtParent, String tgtName) throws SystemMessageException
|
||||||
{
|
{
|
||||||
throw new RemoteFileIOException(new Exception("FTP copy not supported, use move instead")); //$NON-NLS-1$
|
throw new RemoteFileIOException(new Exception(FTPServiceResources.FTP_File_Service_Copy_Not_Supported));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean copyBatch(IProgressMonitor monitor, String[] srcParents, String[] srcNames, String tgtParent) throws SystemMessageException
|
public boolean copyBatch(IProgressMonitor monitor, String[] srcParents, String[] srcNames, String tgtParent) throws SystemMessageException
|
||||||
|
@ -753,14 +737,14 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
{
|
{
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
|
|
||||||
Job fetchJob = new Job("Listing files..."){ //$NON-NLS-1$
|
Job fetchJob = new Job(FTPServiceResources.FTP_File_Service_Listing_Job){
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
try {
|
try {
|
||||||
_ftpFiles = _ftpClient.listFiles();
|
_ftpFiles = _ftpClient.listFiles();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new Status(IStatus.ERROR, "org.eclipse.rse.services.files.ftp",IStatus.ERROR,e.getMessage(),e); //$NON-NLS-1$
|
return new Status(IStatus.ERROR, "org.eclipse.rse.services.files.ftp",IStatus.ERROR,e.getMessage(),e); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return new Status(IStatus.OK,"org.eclipse.rse.services.files.ftp",IStatus.OK,"Success",null); //$NON-NLS-1$
|
return new Status(IStatus.OK,"org.eclipse.rse.services.files.ftp",IStatus.OK,FTPServiceResources.FTP_File_Service_Listing_Job_Success,null); //$NON-NLS-1$
|
||||||
}};
|
}};
|
||||||
|
|
||||||
IStatus fetchResult = null;
|
IStatus fetchResult = null;
|
||||||
|
@ -845,7 +829,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
Long workToDateKB = new Long(fWorkToDate / 1024L);
|
Long workToDateKB = new Long(fWorkToDate / 1024L);
|
||||||
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
||||||
String subDesc = MessageFormat.format(
|
String subDesc = MessageFormat.format(
|
||||||
"{0,number,integer} KB of {1,number,integer} KB complete ({2,number,percent})", //$NON-NLS-1$
|
FTPServiceResources.FTP_File_Service_Monitor_Format,
|
||||||
new Object[] {
|
new Object[] {
|
||||||
workToDateKB, fMaxWorkKB, workPercent
|
workToDateKB, fMaxWorkKB, workPercent
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* {Name} (company) - description of contribution.
|
* Javier Montalvo Orus (Symbian) - Added Externalized Strings
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.services.files.ftp;
|
package org.eclipse.rse.services.files.ftp;
|
||||||
|
@ -21,7 +21,11 @@ import org.eclipse.osgi.util.NLS;
|
||||||
public class FTPServiceResources extends NLS
|
public class FTPServiceResources extends NLS
|
||||||
{
|
{
|
||||||
private static String BUNDLE_NAME = "org.eclipse.rse.services.files.ftp.FTPServiceResources";//$NON-NLS-1$
|
private static String BUNDLE_NAME = "org.eclipse.rse.services.files.ftp.FTPServiceResources";//$NON-NLS-1$
|
||||||
|
public static String FTP_File_Service_Copy_Not_Supported;
|
||||||
|
public static String FTP_File_Service_Deleting_Task;
|
||||||
|
public static String FTP_File_Service_Listing_Job;
|
||||||
|
public static String FTP_File_Service_Listing_Job_Success;
|
||||||
|
public static String FTP_File_Service_Monitor_Format;
|
||||||
public static String FTP_File_Service_Name;
|
public static String FTP_File_Service_Name;
|
||||||
public static String FTP_File_Service_Description;
|
public static String FTP_File_Service_Description;
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,13 @@
|
||||||
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
# Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
#
|
#
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# {Name} (company) - description of contribution.
|
# Javier Montalvo Orus (Symbian) - Added Externalized Strings
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
FTP_File_Service_Name=FTP File Service
|
FTP_File_Service_Name=FTP File Service
|
||||||
FTP_File_Service_Description=The FTP File Service uses the FTP protocol to provide service for the Files subsystem. It requires an FTP daemon to be running on the host machine.
|
FTP_File_Service_Description=The FTP File Service uses the FTP protocol to provide service for the Files subsystem. It requires an FTP daemon to be running on the host machine.
|
||||||
|
FTP_File_Service_Deleting_Task=Deleting
|
||||||
|
FTP_File_Service_Copy_Not_Supported=FTP copy not supported, use move instead
|
||||||
|
FTP_File_Service_Listing_Job=Listing files...
|
||||||
|
FTP_File_Service_Listing_Job_Success=Success
|
||||||
|
FTP_File_Service_Monitor_Format={0,number,integer} KB of {1,number,integer} KB complete ({2,number,percent})
|
||||||
|
|
|
@ -13,7 +13,8 @@ Require-Bundle: org.eclipse.ui,
|
||||||
org.eclipse.rse.files.ui,
|
org.eclipse.rse.files.ui,
|
||||||
org.eclipse.rse.subsystems.files.core,
|
org.eclipse.rse.subsystems.files.core,
|
||||||
org.eclipse.rse.core,
|
org.eclipse.rse.core,
|
||||||
org.eclipse.rse.ui
|
org.eclipse.rse.ui,
|
||||||
|
org.eclipse.ui.console
|
||||||
Eclipse-LazyStart: true
|
Eclipse-LazyStart: true
|
||||||
Export-Package: org.eclipse.rse.subsystems.files.ftp,
|
Export-Package: org.eclipse.rse.subsystems.files.ftp,
|
||||||
org.eclipse.rse.subsystems.files.ftp.connectorservice,
|
org.eclipse.rse.subsystems.files.ftp.connectorservice,
|
||||||
|
|
|
@ -11,11 +11,14 @@
|
||||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Javier Montalvo Orús (Symbian) - Bug 140348 - FTP did not use port number
|
* Javier Montalvo Orus (Symbian) - Bug 140348 - FTP did not use port number
|
||||||
|
* Javier Montalvo Orus (Symbian) - Bug 161209 - Need a Log of ftp commands
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.subsystems.files.ftp.connectorservice;
|
package org.eclipse.rse.subsystems.files.ftp.connectorservice;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.rse.core.model.IHost;
|
import org.eclipse.rse.core.model.IHost;
|
||||||
import org.eclipse.rse.core.model.SystemSignonInformation;
|
import org.eclipse.rse.core.model.SystemSignonInformation;
|
||||||
|
@ -23,6 +26,9 @@ import org.eclipse.rse.core.subsystems.AbstractConnectorService;
|
||||||
import org.eclipse.rse.services.files.IFileService;
|
import org.eclipse.rse.services.files.IFileService;
|
||||||
import org.eclipse.rse.services.files.ftp.FTPService;
|
import org.eclipse.rse.services.files.ftp.FTPService;
|
||||||
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
import org.eclipse.rse.subsystems.files.core.SystemFileResources;
|
||||||
|
import org.eclipse.ui.console.ConsolePlugin;
|
||||||
|
import org.eclipse.ui.console.IConsole;
|
||||||
|
import org.eclipse.ui.console.MessageConsole;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,12 +49,36 @@ public class FTPConnectorService extends AbstractConnectorService
|
||||||
|
|
||||||
private void internalConnect() throws Exception
|
private void internalConnect() throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
SystemSignonInformation info = getPasswordInformation();
|
SystemSignonInformation info = getPasswordInformation();
|
||||||
_ftpService.setHostName(info.getHostname());
|
_ftpService.setHostName(info.getHostname());
|
||||||
_ftpService.setUserId(info.getUserid());
|
_ftpService.setUserId(info.getUserid());
|
||||||
_ftpService.setPassword(info.getPassword());
|
_ftpService.setPassword(info.getPassword());
|
||||||
_ftpService.setPortNumber(getPort());
|
_ftpService.setPortNumber(getPort());
|
||||||
_ftpService.connect();
|
_ftpService.setLoggingStream(getLoggingStream(info.getHostname(),getPort()));
|
||||||
|
_ftpService.connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private OutputStream getLoggingStream(String hostName,int portNumber)
|
||||||
|
{
|
||||||
|
MessageConsole messageConsole=null;
|
||||||
|
|
||||||
|
IConsole[] consoles = ConsolePlugin.getDefault().getConsoleManager().getConsoles();
|
||||||
|
for (int i = 0; i < consoles.length; i++) {
|
||||||
|
if(consoles[i].getName().equals("FTP log: "+hostName+":"+portNumber)) { //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
messageConsole = (MessageConsole)consoles[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(messageConsole==null){
|
||||||
|
messageConsole = new MessageConsole("FTP log: "+hostName+":"+portNumber, null); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ messageConsole });
|
||||||
|
}
|
||||||
|
|
||||||
|
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(messageConsole);
|
||||||
|
|
||||||
|
return messageConsole.newOutputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFileService getFileService()
|
public IFileService getFileService()
|
||||||
|
@ -72,8 +102,6 @@ public class FTPConnectorService extends AbstractConnectorService
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean isConnected()
|
public boolean isConnected()
|
||||||
{
|
{
|
||||||
return (_ftpService != null && _ftpService.isConnected());
|
return (_ftpService != null && _ftpService.isConnected());
|
||||||
|
|
Loading…
Add table
Reference in a new issue