View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *         http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.argeo.eclipse.ui;
17  
18  import org.argeo.jcr.JcrMonitor;
19  import org.eclipse.core.runtime.IProgressMonitor;
20  
21  /**
22   * Wraps an Eclipse {@link IProgressMonitor} so that it can be passed to
23   * framework agnostic Argeo routines.
24   */
25  public class EclipseJcrMonitor implements JcrMonitor {
26  	private final IProgressMonitor progressMonitor;
27  
28  	public EclipseJcrMonitor(IProgressMonitor progressMonitor) {
29  		this.progressMonitor = progressMonitor;
30  	}
31  
32  	public void beginTask(String name, int totalWork) {
33  		progressMonitor.beginTask(name, totalWork);
34  	}
35  
36  	public void done() {
37  		progressMonitor.done();
38  	}
39  
40  	public boolean isCanceled() {
41  		return progressMonitor.isCanceled();
42  	}
43  
44  	public void setCanceled(boolean value) {
45  		progressMonitor.setCanceled(value);
46  	}
47  
48  	public void setTaskName(String name) {
49  		progressMonitor.setTaskName(name);
50  	}
51  
52  	public void subTask(String name) {
53  		progressMonitor.subTask(name);
54  	}
55  
56  	public void worked(int work) {
57  		progressMonitor.worked(work);
58  	}
59  }