? progress63586.diff ? src/org/netbeans/spi Index: api/doc/changes/apichanges.xml =================================================================== RCS file: /cvs/core/progress/api/doc/changes/apichanges.xml,v retrieving revision 1.11 diff -u -r1.11 apichanges.xml --- api/doc/changes/apichanges.xml 4 Aug 2006 15:00:55 -0000 1.11 +++ api/doc/changes/apichanges.xml 12 Oct 2006 08:59:06 -0000 @@ -82,6 +82,26 @@ + + + Add ProgressHandle.suspend(String) method for visual suspend of a running task. + + + + + +

Adding suspend(String) to ProgressHandle class. + Any progress event coming after this call wakes up the progress bar to previous state.

+

+ Currently running task can switch to silent suspend mode where the progress bar stops moving, hides completely or partially. + The exact UI behaviour is undefined.

+

+ 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. +

+
+ + +
Add methods to create main/detail labels for an custom placed progress component. Index: nbproject/project.properties =================================================================== RCS file: /cvs/core/progress/nbproject/project.properties,v retrieving revision 1.12 diff -u -r1.12 project.properties --- nbproject/project.properties 16 Aug 2006 06:28:16 -0000 1.12 +++ nbproject/project.properties 12 Oct 2006 08:59:06 -0000 @@ -18,7 +18,7 @@ is.autoload=true javac.compilerargs=-Xlint:unchecked javac.source=1.5 -spec.version.base=1.8.0 +spec.version.base=1.9.0 #javadoc.main.page=org/netbeans/api/progress/doc-files/api.html javadoc.arch=${basedir}/../arch/arch-core-progress.xml Index: src/org/netbeans/api/progress/ProgressHandle.java =================================================================== RCS file: /cvs/core/progress/src/org/netbeans/api/progress/ProgressHandle.java,v retrieving revision 1.8 diff -u -r1.8 ProgressHandle.java --- src/org/netbeans/api/progress/ProgressHandle.java 4 Aug 2006 09:24:03 -0000 1.8 +++ src/org/netbeans/api/progress/ProgressHandle.java 12 Oct 2006 08:59:06 -0000 @@ -82,6 +82,17 @@ } /** + * Currently running task can switch to silent suspend mode where the progress bar + * stops moving, hides completely or partially. 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. + * Any incoming progress wakes up the progress bar to previous state. + * @since org.netbeans.api.progress/1 1.9 + */ + public void suspend(String message) { + internal.toSilent(message); + } + + /** * Currently indeterminate task can be switched to show percentage completed. * A common usecase is to calculate the amount of work in the beginning showing * in indeterminate mode and later switch to the progress with known steps Index: src/org/netbeans/progress/module/Controller.java =================================================================== RCS file: /cvs/core/progress/src/org/netbeans/progress/module/Controller.java,v retrieving revision 1.20 diff -u -r1.20 Controller.java --- src/org/netbeans/progress/module/Controller.java 4 Aug 2006 09:24:04 -0000 1.20 +++ src/org/netbeans/progress/module/Controller.java 12 Oct 2006 08:59:06 -0000 @@ -119,6 +119,12 @@ postEvent(event); } + public void toSilent(InternalHandle handle, String message) { + ProgressEvent event = new ProgressEvent(handle, ProgressEvent.TYPE_SILENT, isWatched(handle), message); + postEvent(event); + } + + public void toDeterminate(InternalHandle handle) { ProgressEvent event = new ProgressEvent(handle, ProgressEvent.TYPE_SWITCH, isWatched(handle)); postEvent(event); @@ -132,15 +138,18 @@ public ProgressEvent snapshot(InternalHandle handle, String msg, int units, int percentage, long estimate) { + if (handle.isInSleepMode()) { + return new ProgressEvent(handle, ProgressEvent.TYPE_SILENT, isWatched(handle), msg); + } return new ProgressEvent(handle, msg, units, percentage, estimate, isWatched(handle)); } - public void explicitSelection(InternalHandle handle, int units, int percentage, long estimate) { + public void explicitSelection(InternalHandle handle) { InternalHandle old = model.getExplicitSelection(); model.explicitlySelect(handle); Collection evnts = new ArrayList(); - evnts.add(new ProgressEvent(handle, null, units, percentage, estimate, isWatched(handle))); + evnts.add(handle.requestStateSnapshot()); if (old != null && old != handle) { // refresh the old one, results in un-bodling the text. evnts.add(old.requestStateSnapshot()); @@ -307,6 +316,7 @@ public void actionPerformed(java.awt.event.ActionEvent actionEvent) { run(); } + } Index: src/org/netbeans/progress/spi/InternalHandle.java =================================================================== RCS file: /cvs/core/progress/src/org/netbeans/progress/spi/InternalHandle.java,v retrieving revision 1.3 diff -u -r1.3 InternalHandle.java --- src/org/netbeans/progress/spi/InternalHandle.java 7 Aug 2006 07:26:03 -0000 1.3 +++ src/org/netbeans/progress/spi/InternalHandle.java 12 Oct 2006 08:59:06 -0000 @@ -55,6 +55,7 @@ private long initialEstimate; private long timeStarted; private long timeLastProgress; + private long timeSleepy = 0; private String lastMessage; private final Cancellable cancelable; private final Action viewAction; @@ -134,6 +135,22 @@ return initialDelay; } + public synchronized void toSilent(String message) { + if (state != STATE_RUNNING && state != STATE_REQUEST_STOP) { + assert false : "cannot switch to silent mode when not running"; + } + timeLastProgress = System.currentTimeMillis(); + timeSleepy = timeLastProgress; + if (message != null) { + lastMessage = message; + } + controller.toSilent(this, message); + } + + public boolean isInSleepMode() { + return timeSleepy == timeLastProgress; + } + public synchronized void toIndeterminate() { if (state != STATE_RUNNING && state != STATE_REQUEST_STOP) { assert false : "cannot switch to indeterminate mode when not running"; @@ -273,10 +290,10 @@ // XXX - called from UI, threading public synchronized void requestExplicitSelection() { - timeLastProgress = System.currentTimeMillis(); - controller.explicitSelection(this, currentUnit, - totalUnits > 0 ? getPercentageDone() : -1, - (initialEstimate == -1 ? -1 : calculateFinishEstimate())); + if (!isInSleepMode()) { + timeLastProgress = System.currentTimeMillis(); + } + controller.explicitSelection(this); } public synchronized void requestDisplayNameChange(String newDisplayName) { @@ -292,7 +309,9 @@ // XXX - called from UI, threading public synchronized ProgressEvent requestStateSnapshot() { - timeLastProgress = System.currentTimeMillis(); + if (!isInSleepMode()) { + timeLastProgress = System.currentTimeMillis(); + } return controller.snapshot(this, lastMessage, currentUnit, totalUnits > 0 ? getPercentageDone() : -1, (initialEstimate == -1 ? -1 : calculateFinishEstimate())); @@ -374,6 +393,7 @@ public long getTimeStampStarted() { return timeStarted; } + } Index: src/org/netbeans/progress/spi/ProgressEvent.java =================================================================== RCS file: /cvs/core/progress/src/org/netbeans/progress/spi/ProgressEvent.java,v retrieving revision 1.1 diff -u -r1.1 ProgressEvent.java --- src/org/netbeans/progress/spi/ProgressEvent.java 28 Jul 2006 11:32:45 -0000 1.1 +++ src/org/netbeans/progress/spi/ProgressEvent.java 12 Oct 2006 08:59:06 -0000 @@ -31,6 +31,7 @@ public static final int TYPE_REQUEST_STOP = 3; public static final int TYPE_PROGRESS = 1; public static final int TYPE_SWITCH = 5; + public static final int TYPE_SILENT = 6; private InternalHandle source; private long estimatedCompletion; @@ -41,6 +42,7 @@ private boolean watched; private boolean switched; private String displayName; + /** Creates a new instance of ProgressEvent * @param type one of TYPE_START, TYPE_REQUEST_STOP, TYPE_FINISH, TYPE_SWITCHED */ @@ -53,6 +55,14 @@ this.type = type; watched = isWatched; switched = (type == TYPE_SWITCH); + } + + /** Creates a new instance of ProgressEvent + * @param type one of TYPE_SILENT + */ + public ProgressEvent(InternalHandle src, int type, boolean isWatched, String msg) { + this(src, type, isWatched); + message = msg; } /** * @param percentage completed work percentage