mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36: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:
parent
acbd43742d
commit
af665152e1
3 changed files with 30 additions and 11 deletions
|
@ -47,7 +47,8 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
protected static class CommandProgressMonitor implements SftpProgressMonitor {
|
protected static class CommandProgressMonitor implements SftpProgressMonitor {
|
||||||
private final IProgressMonitor fMonitor;
|
private final IProgressMonitor fMonitor;
|
||||||
private double fWorkPercentFactor;
|
private double fWorkPercentFactor;
|
||||||
private Long fMaxWorkKB;
|
private Long fMaxWork;
|
||||||
|
private String fMaxWorkSize;
|
||||||
private long fWorkToDate;
|
private long fWorkToDate;
|
||||||
|
|
||||||
public CommandProgressMonitor(IProgressMonitor monitor) {
|
public CommandProgressMonitor(IProgressMonitor monitor) {
|
||||||
|
@ -57,11 +58,23 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
@Override
|
@Override
|
||||||
public boolean count(long count) {
|
public boolean count(long count) {
|
||||||
fWorkToDate += count;
|
fWorkToDate += count;
|
||||||
Long workToDateKB = new Long(fWorkToDate / 1024L);
|
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);
|
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
||||||
String subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format,
|
subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format2, new Object[] { workToDate, size, fMaxWork,
|
||||||
new Object[] { workToDateKB, fMaxWorkKB, workPercent });
|
fMaxWorkSize, workPercent });
|
||||||
|
}
|
||||||
fMonitor.subTask(subDesc);
|
fMonitor.subTask(subDesc);
|
||||||
fMonitor.worked((int) count);
|
fMonitor.worked((int) count);
|
||||||
return !(fMonitor.isCanceled());
|
return !(fMonitor.isCanceled());
|
||||||
|
@ -75,7 +88,13 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
@Override
|
@Override
|
||||||
public void init(int op, String src, String dest, long max) {
|
public void init(int op, String src, String dest, long max) {
|
||||||
fWorkPercentFactor = 1.0 / 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;
|
fWorkToDate = 0;
|
||||||
fMonitor.beginTask(new Path(src).lastSegment(), (int) max);
|
fMonitor.beginTask(new Path(src).lastSegment(), (int) max);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,14 @@ import org.eclipse.osgi.util.NLS;
|
||||||
public class Messages extends NLS {
|
public class Messages extends NLS {
|
||||||
private static final String BUNDLE_ID = "org.eclipse.remote.internal.jsch.core.messages.messages"; //$NON-NLS-1$
|
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_Get_symlink_target;
|
||||||
public static String AbstractRemoteCommand_Operation_cancelled_by_user;
|
public static String AbstractRemoteCommand_Operation_cancelled_by_user;
|
||||||
public static String AuthInfo_Authentication_message;
|
public static String AuthInfo_Authentication_message;
|
||||||
public static String ExecCommand_Exec_command;
|
public static String ExecCommand_Exec_command;
|
||||||
public static String JSchConnection_Connection_was_cancelled;
|
public static String JSchConnection_Connection_was_cancelled;
|
||||||
public static String JSchConnection_connectionNotOpen;
|
public static String JSchConnection_connectionNotOpen;
|
||||||
|
|
||||||
public static String JSchConnection_Executing_command;
|
public static String JSchConnection_Executing_command;
|
||||||
public static String JSchConnection_remote_address_must_be_set;
|
public static String JSchConnection_remote_address_must_be_set;
|
||||||
public static String JSchConnection_remotePort;
|
public static String JSchConnection_remotePort;
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
# Contributors:
|
# Contributors:
|
||||||
# IBM Corporation - initial implementation
|
# 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_Get_symlink_target=Get symlink target
|
||||||
AbstractRemoteCommand_Operation_cancelled_by_user=Operation cancelled by user
|
AbstractRemoteCommand_Operation_cancelled_by_user=Operation cancelled by user
|
||||||
AuthInfo_Authentication_message=Authentication Message
|
AuthInfo_Authentication_message=Authentication Message
|
||||||
|
|
Loading…
Add table
Reference in a new issue