ProgressIndicator
ProgressIndicator 위젯은 프로그레서바를 보일 때 진행상태를 어떻게 채워나가야 하는지를 크게 신경쓰지 않도록 해줍니다. ProgressIndicator는 수행하기를 기대하는 작업의 전체량으로 초기화하고, 작업이 끝났을 때, 이를 통지하면 됩니다.
ProgressIndicator indicator = new ProgressIndicator(parent);
...
//전체 작업량 설정
indicator.beginTask(1000);
...
Display.getCurrent().asyncExec(new Runnable() {
@Override
public void run() {
//작업 완료량 설정
indicator.worked(1);
}
});
- ProgressIndicator를 사용하려면 컨트롤에게 전체 작업량이 얼마인지 알려주기 위해 beginTask() 메서드를 호출합니다.
 - 그 다음, worked() 메서드를 매번 호출하여 작업이 어느 정도 완료됐음을 알려줍니다.
 
▶ 예제코드
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 
49 
50 
51 
52 
53 
54 
55 
 | 
package com.swtjface.Ch5; 
import org.eclipse.jface.dialogs.ProgressIndicator; 
import org.eclipse.jface.window.ApplicationWindow; 
import org.eclipse.swt.widgets.Composite; 
import org.eclipse.swt.widgets.Control; 
import org.eclipse.swt.widgets.Display; 
/** 
 * ProgressIndicator 테스트 
 * 
 * @since 2013. 6. 8. 
 * @author Cremazer 
 * 
 */ 
public class ProgressIndicatorTest extends ApplicationWindow { 
 ProgressIndicator indicator; 
 public ProgressIndicatorTest() { 
  super(null); 
 } 
  public Control createContents(Composite parent) { 
  // --- Create the window title. --- 
   getShell().setText("ProgressIndicator Test"); 
   indicator = new ProgressIndicator(parent); 
  indicator.setBounds(10, 10, 200, 32); 
   //전체 작업량 설정 
  indicator.beginTask(1000); 
  for (int i = 0; i < 1000 ; i++) { 
   Display.getCurrent().asyncExec(new Runnable() { 
    @Override 
    public void run() { 
     //작업 완료량 설정 
     indicator.worked(1); 
    } 
   }); 
  } 
  return indicator; 
 } 
  public static void main(String[] args) { 
  // --- Display CoolBarTest until the window is closed. --- 
   ProgressIndicatorTest app = new ProgressIndicatorTest(); 
  app.setBlockOnOpen(true); 
  app.open(); 
  Display.getCurrent().dispose(); 
 } 
} 
 | 

댓글 없음:
댓글 쓰기