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

Improve progress messages for i/o stream operations.

Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
Greg Watson 2014-01-31 08:20:48 -05:00
parent acbd43742d
commit af665152e1
3 changed files with 30 additions and 11 deletions

View file

@ -47,7 +47,8 @@ public abstract class AbstractRemoteCommand<T> {
protected static class CommandProgressMonitor implements SftpProgressMonitor {
private final IProgressMonitor fMonitor;
private double fWorkPercentFactor;
private Long fMaxWorkKB;
private Long fMaxWork;
private String fMaxWorkSize;
private long fWorkToDate;
public CommandProgressMonitor(IProgressMonitor monitor) {
@ -57,11 +58,23 @@ public abstract class AbstractRemoteCommand<T> {
@Override
public boolean count(long count) {
fWorkToDate += count;
Long workToDateKB = new Long(fWorkToDate / 1024L);
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
String subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format,
new Object[] { workToDateKB, fMaxWorkKB, workPercent });
String size;
Long workToDate;
if (fWorkToDate < 1024L) {
size = "bytes"; //$NON-NLS-1$
workToDate = fWorkToDate;
} else {
size = "KB"; //$NON-NLS-1$
workToDate = fWorkToDate / 1024L;
}
String subDesc;
if (fWorkPercentFactor < 0) {
subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size });
} else {
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format2, new Object[] { workToDate, size, fMaxWork,
fMaxWorkSize, workPercent });
}
fMonitor.subTask(subDesc);
fMonitor.worked((int) count);
return !(fMonitor.isCanceled());
@ -75,7 +88,13 @@ public abstract class AbstractRemoteCommand<T> {
@Override
public void init(int op, String src, String dest, long max) {
fWorkPercentFactor = 1.0 / max;
fMaxWorkKB = new Long(max / 1024L);
if (max < 1024L) {
fMaxWorkSize = "bytes"; //$NON-NLS-1$
fMaxWork = max;
} else {
fMaxWorkSize = "KB"; //$NON-NLS-1$
fMaxWork = max / 1024L;
}
fWorkToDate = 0;
fMonitor.beginTask(new Path(src).lastSegment(), (int) max);
}

View file

@ -16,15 +16,14 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_ID = "org.eclipse.remote.internal.jsch.core.messages.messages"; //$NON-NLS-1$
public static String AbstractRemoteCommand_format;
public static String AbstractRemoteCommand_format1;
public static String AbstractRemoteCommand_format2;
public static String AbstractRemoteCommand_Get_symlink_target;
public static String AbstractRemoteCommand_Operation_cancelled_by_user;
public static String AuthInfo_Authentication_message;
public static String ExecCommand_Exec_command;
public static String JSchConnection_Connection_was_cancelled;
public static String JSchConnection_connectionNotOpen;
public static String JSchConnection_Executing_command;
public static String JSchConnection_remote_address_must_be_set;
public static String JSchConnection_remotePort;

View file

@ -8,7 +8,8 @@
# Contributors:
# IBM Corporation - initial implementation
###############################################################################
AbstractRemoteCommand_format={0,number,integer} KB of {1,number,integer} KB complete ({2,number,percent})
AbstractRemoteCommand_format1={0,number,integer} {1} completed
AbstractRemoteCommand_format2={0,number,integer} {1} of {2,number,integer} {3} complete ({4,number,percent})
AbstractRemoteCommand_Get_symlink_target=Get symlink target
AbstractRemoteCommand_Operation_cancelled_by_user=Operation cancelled by user
AuthInfo_Authentication_message=Authentication Message