svn-gvsig-desktop / tags / v1_0_1_RELEASE / libraries / libIverUtiles / src / com / iver / utiles / swing / threads / PipeTask.java @ 9531
History | View | Annotate | Download (1.47 KB)
1 | 8670 | azabala | /*
|
---|---|---|---|
2 | * Created on 10-nov-2006 by azabala
|
||
3 | *
|
||
4 | */
|
||
5 | package com.iver.utiles.swing.threads; |
||
6 | |||
7 | import java.util.Iterator; |
||
8 | |||
9 | /**
|
||
10 | * @author alzabord
|
||
11 | *
|
||
12 | * TODO To change the template for this generated type comment go to
|
||
13 | * Window - Preferences - Java - Code Style - Code Templates
|
||
14 | */
|
||
15 | public class PipeTask implements IMonitorableTask { |
||
16 | |||
17 | private IPipedTask task1;
|
||
18 | private IPipedTask task2;
|
||
19 | private boolean canceled = false; |
||
20 | |||
21 | private IPipedTask currentTask = null; |
||
22 | |||
23 | |||
24 | public PipeTask(IPipedTask task1, IPipedTask task2){
|
||
25 | this.task1 = task1;
|
||
26 | this.task2 = task2;
|
||
27 | this.currentTask = task1;
|
||
28 | } |
||
29 | |||
30 | |||
31 | public int getInitialStep() { |
||
32 | return 0; |
||
33 | } |
||
34 | |||
35 | public int getFinishStep() { |
||
36 | return currentTask.getFinishStep();
|
||
37 | } |
||
38 | |||
39 | public int getCurrentStep() { |
||
40 | return currentTask.getCurrentStep();
|
||
41 | } |
||
42 | |||
43 | public String getStatusMessage() { |
||
44 | return currentTask.getStatusMessage();
|
||
45 | } |
||
46 | |||
47 | public String getNote() { |
||
48 | if(currentTask != null){ |
||
49 | return currentTask.getNote();
|
||
50 | }else{
|
||
51 | return ""; |
||
52 | } |
||
53 | } |
||
54 | |||
55 | public boolean isDefined() { |
||
56 | return currentTask.isDefined();
|
||
57 | } |
||
58 | |||
59 | public void cancel() { |
||
60 | currentTask.cancel(); |
||
61 | canceled = true;
|
||
62 | } |
||
63 | |||
64 | public void run() throws Exception { |
||
65 | currentTask.run(); |
||
66 | 8714 | azabala | if(currentTask.isCanceled())
|
67 | return;
|
||
68 | 8670 | azabala | Object result = currentTask.getResult();
|
69 | currentTask = task2; |
||
70 | currentTask.setEntry(result); |
||
71 | currentTask.run(); |
||
72 | } |
||
73 | |||
74 | public boolean isCanceled() { |
||
75 | return currentTask.isCanceled();
|
||
76 | } |
||
77 | |||
78 | public boolean isFinished() { |
||
79 | 8735 | azabala | return task1.isFinished() && task2.isFinished();
|
80 | 8670 | azabala | } |
81 | |||
82 | } |