1 22 23 package org.gjt.sp.util; 24 25 30 public abstract class WorkRequest implements Runnable , ProgressObserver 31 { 32 37 private boolean largeValues; 38 39 42 public void setAbortable(boolean abortable) 43 { 44 Thread thread = Thread.currentThread(); 45 if(thread instanceof WorkThread) 46 ((WorkThread)thread).setAbortable(abortable); 47 } 48 49 53 public void setStatus(String status) 54 { 55 Thread thread = Thread.currentThread(); 56 if(thread instanceof WorkThread) 57 ((WorkThread)thread).setStatus(status); 58 } 59 60 65 public void setProgressValue(int value) 66 { 67 Thread thread = Thread.currentThread(); 68 if(thread instanceof WorkThread) 69 ((WorkThread)thread).setProgressValue(value); 70 } 71 72 77 public void setProgressMaximum(int value) 78 { 79 Thread thread = Thread.currentThread(); 80 if(thread instanceof WorkThread) 81 ((WorkThread)thread).setProgressMaximum(value); 82 } 83 84 91 public void setValue(long value) 92 { 93 Thread thread = Thread.currentThread(); 94 if(thread instanceof WorkThread) 95 { 96 if (largeValues) 97 { 98 ((WorkThread)thread).setProgressValue((int) (value >> 10)); 99 } 100 else 101 { 102 ((WorkThread)thread).setProgressValue((int) value); 103 } 104 } 105 } 107 114 public void setMaximum(long value) 115 { 116 Thread thread = Thread.currentThread(); 117 if(thread instanceof WorkThread) 118 { 119 if (value > Integer.MAX_VALUE) 120 { 121 largeValues = true; 122 ((WorkThread)thread).setProgressMaximum((int) (value >> 10)); 123 } 124 else 125 { 126 largeValues = false; 127 ((WorkThread)thread).setProgressMaximum((int) value); 128 } 129 } 130 } } 132 | Popular Tags |