Lines 29-34
Link Here
|
29 |
import java.util.logging.Logger; |
29 |
import java.util.logging.Logger; |
30 |
import javax.swing.Action; |
30 |
import javax.swing.Action; |
31 |
import javax.swing.JComponent; |
31 |
import javax.swing.JComponent; |
|
|
32 |
import javax.swing.JLabel; |
32 |
import javax.swing.JProgressBar; |
33 |
import javax.swing.JProgressBar; |
33 |
import javax.swing.SwingUtilities; |
34 |
import javax.swing.SwingUtilities; |
34 |
import org.netbeans.progress.module.*; |
35 |
import org.netbeans.progress.module.*; |
Lines 45-51
Link Here
|
45 |
private String displayName; |
46 |
private String displayName; |
46 |
private boolean allowCancel; |
47 |
private boolean allowCancel; |
47 |
private boolean allowBackground; |
48 |
private boolean allowBackground; |
48 |
private boolean customPlaced = false; |
49 |
private boolean customPlaced1 = false; |
|
|
50 |
private boolean customPlaced2 = false; |
51 |
private boolean customPlaced3 = false; |
49 |
private int state; |
52 |
private int state; |
50 |
private int totalUnits; |
53 |
private int totalUnits; |
51 |
private int currentUnit; |
54 |
private int currentUnit; |
Lines 58-63
Link Here
|
58 |
private final boolean userInitiated; |
61 |
private final boolean userInitiated; |
59 |
private int initialDelay = Controller.INITIAL_DELAY; |
62 |
private int initialDelay = Controller.INITIAL_DELAY; |
60 |
private Controller controller; |
63 |
private Controller controller; |
|
|
64 |
private ExtractedProgressUIWorker component; |
61 |
|
65 |
|
62 |
public static final int STATE_INITIALIZED = 0; |
66 |
public static final int STATE_INITIALIZED = 0; |
63 |
public static final int STATE_RUNNING = 1; |
67 |
public static final int STATE_RUNNING = 1; |
Lines 103-109
Link Here
|
103 |
|
107 |
|
104 |
|
108 |
|
105 |
public boolean isCustomPlaced() { |
109 |
public boolean isCustomPlaced() { |
106 |
return customPlaced; |
110 |
return component != null; |
107 |
} |
111 |
} |
108 |
|
112 |
|
109 |
public boolean isUserInitialized() { |
113 |
public boolean isUserInitialized() { |
Lines 180-186
Link Here
|
180 |
timeStarted = System.currentTimeMillis(); |
184 |
timeStarted = System.currentTimeMillis(); |
181 |
timeLastProgress = timeStarted; |
185 |
timeLastProgress = timeStarted; |
182 |
|
186 |
|
183 |
if (! customPlaced) { |
187 |
if (controller == null) { |
184 |
controller = Controller.getDefault(); |
188 |
controller = Controller.getDefault(); |
185 |
} |
189 |
} |
186 |
|
190 |
|
Lines 294-318
Link Here
|
294 |
(initialEstimate == -1 ? -1 : calculateFinishEstimate())); |
298 |
(initialEstimate == -1 ? -1 : calculateFinishEstimate())); |
295 |
} |
299 |
} |
296 |
|
300 |
|
|
|
301 |
private void createExtractedWorker() { |
302 |
if (component == null) { |
303 |
ProgressUIWorkerProvider prov = (ProgressUIWorkerProvider)Lookup.getDefault().lookup(ProgressUIWorkerProvider.class); |
304 |
assert prov != null; |
305 |
component = prov.getExtractedComponentWorker(); |
306 |
controller = new Controller(component); |
307 |
} |
308 |
} |
297 |
/** |
309 |
/** |
298 |
* have the component in custom location, don't include in the status bar. |
310 |
* have the component in custom location, don't include in the status bar. |
299 |
*/ |
311 |
*/ |
300 |
public synchronized JComponent extractComponent() { |
312 |
public synchronized JComponent extractComponent() { |
301 |
if (customPlaced) { |
313 |
if (customPlaced1) { |
302 |
throw new IllegalStateException("Cannot retrieve progress component multiple times"); |
314 |
throw new IllegalStateException("Cannot retrieve progress component multiple times"); |
303 |
} |
315 |
} |
304 |
if (state != STATE_INITIALIZED) { |
316 |
if (state != STATE_INITIALIZED) { |
305 |
throw new IllegalStateException("You can request custom placement of progress component only before starting the task"); |
317 |
throw new IllegalStateException("You can request custom placement of progress component only before starting the task"); |
306 |
} |
318 |
} |
307 |
customPlaced = true; |
319 |
customPlaced1 = true; |
308 |
ProgressUIWorkerProvider prov = (ProgressUIWorkerProvider)Lookup.getDefault().lookup(ProgressUIWorkerProvider.class); |
320 |
createExtractedWorker(); |
309 |
assert prov != null; |
321 |
return component.getProgressComponent(); |
310 |
ProgressUIWorker component = prov.getExtractedComponentWorker(); |
|
|
311 |
controller = new Controller(component); |
312 |
return (JComponent)component; |
313 |
} |
322 |
} |
314 |
|
323 |
|
315 |
|
324 |
public JLabel extractDetailLabel() { |
|
|
325 |
if (customPlaced2) { |
326 |
throw new IllegalStateException("Cannot retrieve progress detail label component multiple times"); |
327 |
} |
328 |
if (state != STATE_INITIALIZED) { |
329 |
throw new IllegalStateException("You can request custom placement of progress component only before starting the task"); |
330 |
} |
331 |
customPlaced2 = true; |
332 |
createExtractedWorker(); |
333 |
return component.getDetailLabelComponent(); |
334 |
} |
335 |
|
336 |
public JLabel extractMainLabel() { |
337 |
if (customPlaced3) { |
338 |
throw new IllegalStateException("Cannot retrieve progress main label component multiple times"); |
339 |
} |
340 |
if (state != STATE_INITIALIZED) { |
341 |
throw new IllegalStateException("You can request custom placement of progress component only before starting the task"); |
342 |
} |
343 |
customPlaced3 = true; |
344 |
createExtractedWorker(); |
345 |
return component.getMainLabelComponent(); |
346 |
} |
347 |
|
316 |
long calculateFinishEstimate() { |
348 |
long calculateFinishEstimate() { |
317 |
|
349 |
|
318 |
// we are interested in seconds only |
350 |
// we are interested in seconds only |