mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Add prefix to progress monitor task
Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
af665152e1
commit
28c493cbe7
5 changed files with 30 additions and 8 deletions
|
@ -50,11 +50,17 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
private Long fMaxWork;
|
private Long fMaxWork;
|
||||||
private String fMaxWorkSize;
|
private String fMaxWorkSize;
|
||||||
private long fWorkToDate;
|
private long fWorkToDate;
|
||||||
|
private String fPrefix;
|
||||||
|
|
||||||
public CommandProgressMonitor(IProgressMonitor monitor) {
|
public CommandProgressMonitor(IProgressMonitor monitor) {
|
||||||
fMonitor = monitor;
|
fMonitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandProgressMonitor(String prefix, IProgressMonitor monitor) {
|
||||||
|
fPrefix = prefix;
|
||||||
|
fMonitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean count(long count) {
|
public boolean count(long count) {
|
||||||
fWorkToDate += count;
|
fWorkToDate += count;
|
||||||
|
@ -67,15 +73,18 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
size = "KB"; //$NON-NLS-1$
|
size = "KB"; //$NON-NLS-1$
|
||||||
workToDate = fWorkToDate / 1024L;
|
workToDate = fWorkToDate / 1024L;
|
||||||
}
|
}
|
||||||
String subDesc;
|
StringBuffer taskName = new StringBuffer();
|
||||||
|
if (fPrefix != null) {
|
||||||
|
taskName.append(fPrefix);
|
||||||
|
}
|
||||||
if (fWorkPercentFactor < 0) {
|
if (fWorkPercentFactor < 0) {
|
||||||
subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size });
|
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size }));
|
||||||
} else {
|
} else {
|
||||||
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
||||||
subDesc = MessageFormat.format(Messages.AbstractRemoteCommand_format2, new Object[] { workToDate, size, fMaxWork,
|
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format2, new Object[] { workToDate, size,
|
||||||
fMaxWorkSize, workPercent });
|
fMaxWork, fMaxWorkSize, workPercent }));
|
||||||
}
|
}
|
||||||
fMonitor.subTask(subDesc);
|
fMonitor.subTask(taskName.toString());
|
||||||
fMonitor.worked((int) count);
|
fMonitor.worked((int) count);
|
||||||
return !(fMonitor.isCanceled());
|
return !(fMonitor.isCanceled());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,10 @@ import java.io.InputStream;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
||||||
|
import org.eclipse.remote.internal.jsch.core.messages.Messages;
|
||||||
|
|
||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
import com.jcraft.jsch.SftpException;
|
import com.jcraft.jsch.SftpException;
|
||||||
|
@ -28,7 +30,7 @@ public class GetInputStreamCommand extends AbstractRemoteCommand<InputStream> {
|
||||||
public InputStream call() throws JSchException, SftpException, IOException {
|
public InputStream call() throws JSchException, SftpException, IOException {
|
||||||
try {
|
try {
|
||||||
return getConnection().getSftpChannel().get(fRemotePath.toString(),
|
return getConnection().getSftpChannel().get(fRemotePath.toString(),
|
||||||
new CommandProgressMonitor(getProgressMonitor()));
|
new CommandProgressMonitor(NLS.bind(Messages.GetInputStreamCommand_Receiving, fRemotePath.toString()), getProgressMonitor()));
|
||||||
} catch (RemoteConnectionException e) {
|
} catch (RemoteConnectionException e) {
|
||||||
throw new IOException(e.getMessage());
|
throw new IOException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,10 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
import org.eclipse.remote.core.exception.RemoteConnectionException;
|
||||||
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
import org.eclipse.remote.internal.jsch.core.JSchConnection;
|
||||||
|
import org.eclipse.remote.internal.jsch.core.messages.Messages;
|
||||||
|
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
import com.jcraft.jsch.ChannelSftp;
|
||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
|
@ -48,8 +50,11 @@ public class GetOutputStreamCommand extends AbstractRemoteCommand<OutputStream>
|
||||||
if ((fOptions & EFS.APPEND) != 0) {
|
if ((fOptions & EFS.APPEND) != 0) {
|
||||||
mode = ChannelSftp.APPEND;
|
mode = ChannelSftp.APPEND;
|
||||||
}
|
}
|
||||||
getChannel().put(input, fRemotePath.toString(),
|
getChannel().put(
|
||||||
new CommandProgressMonitor(getProgressMonitor()), mode);
|
input,
|
||||||
|
fRemotePath.toString(),
|
||||||
|
new CommandProgressMonitor(NLS.bind(Messages.GetOutputStreamCommand_Sending, fRemotePath.toString()),
|
||||||
|
getProgressMonitor()), mode);
|
||||||
input.close();
|
input.close();
|
||||||
} finally {
|
} finally {
|
||||||
fIsClosed = true;
|
fIsClosed = true;
|
||||||
|
|
|
@ -22,6 +22,10 @@ public class Messages extends NLS {
|
||||||
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 GetInputStreamCommand_Receiving;
|
||||||
|
|
||||||
|
public static String GetOutputStreamCommand_Sending;
|
||||||
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;
|
||||||
|
|
|
@ -14,6 +14,8 @@ 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
|
||||||
ExecCommand_Exec_command=Executing command "{0}"
|
ExecCommand_Exec_command=Executing command "{0}"
|
||||||
|
GetInputStreamCommand_Receiving=Receiving {0}:
|
||||||
|
GetOutputStreamCommand_Sending=Sending {0}:
|
||||||
JSchConnection_Connection_was_cancelled=Connection was cancelled
|
JSchConnection_Connection_was_cancelled=Connection was cancelled
|
||||||
JSchConnection_connectionNotOpen=Connection is not open
|
JSchConnection_connectionNotOpen=Connection is not open
|
||||||
JSchConnection_Executing_command=Executing command "{0}"
|
JSchConnection_Executing_command=Executing command "{0}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue