This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 63586
Collapse All | Expand All

(-)api/doc/changes/apichanges.xml (+20 lines)
Lines 82-87 Link Here
82
    <!-- ACTUAL CHANGES BEGIN HERE: -->
82
    <!-- ACTUAL CHANGES BEGIN HERE: -->
83
83
84
  <changes>
84
  <changes>
85
    <change id="suspend">
86
        <api name="progress_api"/>
87
        <summary>Add <code>ProgressHandle.suspend(String)</code> method for visual suspend of a running task.</summary>
88
        <version major="1" minor="9"/>
89
        <date day="12" month="10" year="2006"/>
90
        <author login="mkleint"/>
91
        <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
92
        <description>
93
            <p>Adding <code>suspend(String)</code>  to <code>ProgressHandle</code> class. 
94
            Any progress event coming after this call wakes up the progress bar to previous state. </p> 
95
            <p>
96
           Currently running task can switch to silent suspend mode where the progress bar stops moving, hides completely or partially. 
97
           The exact UI behaviour is undefined. </p>
98
           <p>
99
        Useful to make progress in status bar less intrusive for very long running tasks, eg. running an ant script that executes user application, debugs user application etc.
100
            </p>
101
        </description>
102
        <class package="org.netbeans.api.progress" name="ProgressHandle"/>
103
        <issue number="63586"/>
104
    </change>      
85
    <change>
105
    <change>
86
        <api name="progress_api"/>
106
        <api name="progress_api"/>
87
        <summary>Add methods to create main/detail labels for an custom placed progress component.</summary>
107
        <summary>Add methods to create main/detail labels for an custom placed progress component.</summary>
(-)nbproject/project.properties (-1 / +1 lines)
Lines 18-24 Link Here
18
is.autoload=true
18
is.autoload=true
19
javac.compilerargs=-Xlint:unchecked
19
javac.compilerargs=-Xlint:unchecked
20
javac.source=1.5
20
javac.source=1.5
21
spec.version.base=1.8.0
21
spec.version.base=1.9.0
22
22
23
#javadoc.main.page=org/netbeans/api/progress/doc-files/api.html
23
#javadoc.main.page=org/netbeans/api/progress/doc-files/api.html
24
javadoc.arch=${basedir}/../arch/arch-core-progress.xml
24
javadoc.arch=${basedir}/../arch/arch-core-progress.xml
(-)src/org/netbeans/api/progress/ProgressHandle.java (+11 lines)
Lines 82-87 Link Here
82
    }
82
    }
83
    
83
    
84
    /**
84
    /**
85
     * Currently running task can switch to silent suspend mode where the progress bar 
86
     * stops moving, hides completely or partially. Useful to make progress in status bar less intrusive 
87
     * for very long running tasks, eg. running an ant script that executes user application, debugs user application etc.
88
     * Any incoming progress wakes up the progress bar to previous state.
89
     * @since org.netbeans.api.progress/1 1.9
90
     */
91
    public void suspend(String message) {
92
        internal.toSilent(message);
93
    }
94
    
95
    /**
85
     * Currently indeterminate task can be switched to show percentage completed.
96
     * Currently indeterminate task can be switched to show percentage completed.
86
     * A common usecase is to calculate the amount of work in the beginning showing 
97
     * A common usecase is to calculate the amount of work in the beginning showing 
87
     * in indeterminate mode and later switch to the progress with known steps
98
     * in indeterminate mode and later switch to the progress with known steps
(-)src/org/netbeans/progress/module/Controller.java (-2 / +12 lines)
Lines 119-124 Link Here
119
        postEvent(event);
119
        postEvent(event);
120
    }
120
    }
121
    
121
    
122
    public void toSilent(InternalHandle handle, String message) {
123
        ProgressEvent event = new ProgressEvent(handle, ProgressEvent.TYPE_SILENT, isWatched(handle), message);
124
        postEvent(event);
125
    }
126
    
127
    
122
    public void toDeterminate(InternalHandle handle) {
128
    public void toDeterminate(InternalHandle handle) {
123
        ProgressEvent event = new ProgressEvent(handle, ProgressEvent.TYPE_SWITCH, isWatched(handle));
129
        ProgressEvent event = new ProgressEvent(handle, ProgressEvent.TYPE_SWITCH, isWatched(handle));
124
        postEvent(event);
130
        postEvent(event);
Lines 132-146 Link Here
132
    
138
    
133
    public ProgressEvent snapshot(InternalHandle handle, String msg, 
139
    public ProgressEvent snapshot(InternalHandle handle, String msg, 
134
                  int units, int percentage, long estimate) {
140
                  int units, int percentage, long estimate) {
141
        if (handle.isInSleepMode()) {
142
            return new ProgressEvent(handle, ProgressEvent.TYPE_SILENT, isWatched(handle), msg);
143
        }
135
        return new ProgressEvent(handle, msg, units, percentage, estimate, isWatched(handle));
144
        return new ProgressEvent(handle, msg, units, percentage, estimate, isWatched(handle));
136
    }
145
    }
137
    
146
    
138
    
147
    
139
    public void explicitSelection(InternalHandle handle, int units, int percentage, long estimate) {
148
    public void explicitSelection(InternalHandle handle) {
140
        InternalHandle old = model.getExplicitSelection();
149
        InternalHandle old = model.getExplicitSelection();
141
        model.explicitlySelect(handle);
150
        model.explicitlySelect(handle);
142
        Collection<ProgressEvent> evnts = new ArrayList<ProgressEvent>();
151
        Collection<ProgressEvent> evnts = new ArrayList<ProgressEvent>();
143
        evnts.add(new ProgressEvent(handle, null, units, percentage, estimate, isWatched(handle)));
152
        evnts.add(handle.requestStateSnapshot());
144
        if (old != null && old != handle) {
153
        if (old != null && old != handle) {
145
            // refresh the old one, results in un-bodling the text.
154
            // refresh the old one, results in un-bodling the text.
146
            evnts.add(old.requestStateSnapshot());
155
            evnts.add(old.requestStateSnapshot());
Lines 307-312 Link Here
307
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
316
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
308
        run();
317
        run();
309
    }
318
    }
319
310
    
320
    
311
321
312
}
322
}
(-)src/org/netbeans/progress/spi/InternalHandle.java (-5 / +25 lines)
Lines 55-60 Link Here
55
    private long initialEstimate;
55
    private long initialEstimate;
56
    private long timeStarted;
56
    private long timeStarted;
57
    private long timeLastProgress;
57
    private long timeLastProgress;
58
    private long timeSleepy = 0;
58
    private String lastMessage;
59
    private String lastMessage;
59
    private final Cancellable cancelable;
60
    private final Cancellable cancelable;
60
    private final Action viewAction;
61
    private final Action viewAction;
Lines 134-139 Link Here
134
        return initialDelay;
135
        return initialDelay;
135
    }
136
    }
136
    
137
    
138
    public synchronized void toSilent(String message) {
139
        if (state != STATE_RUNNING && state != STATE_REQUEST_STOP) {
140
            assert false : "cannot switch to silent mode when not running";
141
        }
142
        timeLastProgress = System.currentTimeMillis();
143
        timeSleepy = timeLastProgress;
144
        if (message != null) {
145
            lastMessage = message;
146
        }
147
        controller.toSilent(this, message);
148
    }
149
    
150
    public boolean isInSleepMode() {
151
        return timeSleepy == timeLastProgress;
152
    }
153
    
137
    public synchronized void toIndeterminate() {
154
    public synchronized void toIndeterminate() {
138
        if (state != STATE_RUNNING && state != STATE_REQUEST_STOP) {
155
        if (state != STATE_RUNNING && state != STATE_REQUEST_STOP) {
139
            assert false : "cannot switch to indeterminate mode when not running";
156
            assert false : "cannot switch to indeterminate mode when not running";
Lines 273-282 Link Here
273
    
290
    
274
   // XXX - called from UI, threading
291
   // XXX - called from UI, threading
275
    public synchronized void requestExplicitSelection() {
292
    public synchronized void requestExplicitSelection() {
276
        timeLastProgress = System.currentTimeMillis();
293
        if (!isInSleepMode()) {
277
        controller.explicitSelection(this, currentUnit, 
294
            timeLastProgress = System.currentTimeMillis();
278
                            totalUnits > 0 ? getPercentageDone() : -1, 
295
        }
279
                            (initialEstimate == -1 ? -1 : calculateFinishEstimate()));
296
        controller.explicitSelection(this);
280
    }
297
    }
281
    
298
    
282
    public synchronized void requestDisplayNameChange(String newDisplayName) {
299
    public synchronized void requestDisplayNameChange(String newDisplayName) {
Lines 292-298 Link Here
292
    
309
    
293
// XXX - called from UI, threading 
310
// XXX - called from UI, threading 
294
    public synchronized ProgressEvent requestStateSnapshot() {
311
    public synchronized ProgressEvent requestStateSnapshot() {
295
        timeLastProgress = System.currentTimeMillis();
312
        if (!isInSleepMode()) {
313
            timeLastProgress = System.currentTimeMillis();
314
        }
296
        return controller.snapshot(this, lastMessage, currentUnit, 
315
        return controller.snapshot(this, lastMessage, currentUnit, 
297
                            totalUnits > 0 ? getPercentageDone() : -1, 
316
                            totalUnits > 0 ? getPercentageDone() : -1, 
298
                            (initialEstimate == -1 ? -1 : calculateFinishEstimate()));
317
                            (initialEstimate == -1 ? -1 : calculateFinishEstimate()));
Lines 374-379 Link Here
374
    public long getTimeStampStarted() {
393
    public long getTimeStampStarted() {
375
        return timeStarted;
394
        return timeStarted;
376
    }
395
    }
396
377
397
378
398
379
}
399
}
(-)src/org/netbeans/progress/spi/ProgressEvent.java (+10 lines)
Lines 31-36 Link Here
31
    public static final int TYPE_REQUEST_STOP = 3;
31
    public static final int TYPE_REQUEST_STOP = 3;
32
    public static final int TYPE_PROGRESS = 1;
32
    public static final int TYPE_PROGRESS = 1;
33
    public static final int TYPE_SWITCH = 5;
33
    public static final int TYPE_SWITCH = 5;
34
    public static final int TYPE_SILENT = 6;
34
35
35
     private InternalHandle source;
36
     private InternalHandle source;
36
     private long estimatedCompletion;
37
     private long estimatedCompletion;
Lines 41-46 Link Here
41
     private boolean watched;
42
     private boolean watched;
42
     private boolean switched;
43
     private boolean switched;
43
     private String displayName;
44
     private String displayName;
45
44
    /** Creates a new instance of ProgressEvent 
46
    /** Creates a new instance of ProgressEvent 
45
     * @param type one of TYPE_START, TYPE_REQUEST_STOP, TYPE_FINISH, TYPE_SWITCHED
47
     * @param type one of TYPE_START, TYPE_REQUEST_STOP, TYPE_FINISH, TYPE_SWITCHED
46
     */
48
     */
Lines 53-58 Link Here
53
        this.type = type;
55
        this.type = type;
54
        watched = isWatched;
56
        watched = isWatched;
55
        switched = (type == TYPE_SWITCH);
57
        switched = (type == TYPE_SWITCH);
58
    }
59
    
60
    /** Creates a new instance of ProgressEvent 
61
     * @param type one of TYPE_SILENT
62
     */
63
    public ProgressEvent(InternalHandle src, int type, boolean isWatched, String msg) {
64
        this(src, type, isWatched);
65
        message = msg;
56
    }
66
    }
57
    /**
67
    /**
58
     * @param percentage completed work percentage
68
     * @param percentage completed work percentage

Return to bug 63586