blob: 006563c1a90fe1c75a61d2aa4e6ca6a89e19a33e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*******************************************************************************
* Copyright (c) 2012 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.ssh.proxy;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import com.jcraft.jsch.SftpProgressMonitor;
class ProgressMonitor implements SftpProgressMonitor {
private IProgressMonitor monitor;
private long max;
private String message;
public ProgressMonitor(IProgressMonitor monitor, String message) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
this.monitor = monitor;
this.message = message;
}
@Override
public void init(int op, String src, String dest, long max) {
monitor.beginTask(message, 100);
this.max = max;
}
@Override
public boolean count(long count) {
if (max != 0)
monitor.worked((int)(count/max));
return !monitor.isCanceled();
}
@Override
public void end() {
monitor.done();
}
}
|