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 219669
Collapse All | Expand All

(-)a/api.progress/src/org/netbeans/api/progress/ProgressHandleFactory.java (+21 lines)
Lines 44-49 Link Here
44
44
45
package org.netbeans.api.progress;
45
package org.netbeans.api.progress;
46
46
47
import java.util.concurrent.atomic.AtomicBoolean;
47
import javax.swing.Action;
48
import javax.swing.Action;
48
import javax.swing.JComponent;
49
import javax.swing.JComponent;
49
import javax.swing.JLabel;
50
import javax.swing.JLabel;
Lines 111-116 Link Here
111
    }
112
    }
112
    
113
    
113
    /**
114
    /**
115
     * Create a progress ui handle for a long lasting task.
116
     * @param allowToCancel either null, if the task cannot be cancelled or 
117
     *          an instance of {@link org.openide.util.Cancellable} that will be called when user 
118
     *          triggers cancel of the task.
119
     * @param suspendAndResume either <code>null</code> if this task does not
120
     *    support user initiated suspend/resume or an instance of a callback
121
     *    interface to propagate user control of progress to the task
122
     * @param linkOutput an <code>Action</code> instance that links the running task in the progress bar
123
     *                   to an output of the task. The action is assumed to open the apropriate component with the task's output.
124
     * @param displayName to be shown in the progress UI
125
     * @return an instance of {@link org.netbeans.api.progress.ProgressHandle}, initialized but not started.
126
     * @since XXX
127
     */
128
    public static ProgressHandle createHandle(
129
        String displayName, Cancellable allowToCancel, Resumable suspendAndResume, Action linkOutput
130
    ) {
131
        return new ProgressHandle(new InternalHandle(displayName, allowToCancel, suspendAndResume, true, linkOutput));
132
    }
133
    
134
    /**
114
     * Get the progress bar component for use in custom dialogs, the task won't 
135
     * Get the progress bar component for use in custom dialogs, the task won't 
115
     * show in the progress bar anymore.
136
     * show in the progress bar anymore.
116
     * @return the component to use in custom UI.
137
     * @return the component to use in custom UI.
(-)8023922119fe (+55 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.api.progress;
44
45
/** A callback interface for long running tasks that wish to give
46
 * the user a chance to suspend them and resume later. See
47
 * {@link ProgressHandleFactory#createHandle(java.lang.String, org.openide.util.Cancellable, org.netbeans.api.progress.Resumable, javax.swing.Action)}
48
 * factory method that accepts it.
49
 *
50
 * @author Jaroslav Tulach <jtulach@netbeans.org>
51
 * @since XXX
52
 */
53
public interface Resumable {
54
    
55
}
(-)a/api.progress/src/org/netbeans/modules/progress/spi/InternalHandle.java (+31 lines)
Lines 51-56 Link Here
51
import javax.swing.Action;
51
import javax.swing.Action;
52
import javax.swing.JComponent;
52
import javax.swing.JComponent;
53
import javax.swing.JLabel;
53
import javax.swing.JLabel;
54
import org.netbeans.api.progress.Resumable;
54
import org.netbeans.progress.module.*;
55
import org.netbeans.progress.module.*;
55
import org.openide.util.Cancellable;
56
import org.openide.util.Cancellable;
56
import org.openide.util.Lookup;
57
import org.openide.util.Lookup;
Lines 78-83 Link Here
78
    private long timeSleepy = 0;
79
    private long timeSleepy = 0;
79
    private String lastMessage;
80
    private String lastMessage;
80
    private final Cancellable cancelable;
81
    private final Cancellable cancelable;
82
    private final Resumable resumable;
81
    private final Action viewAction;
83
    private final Action viewAction;
82
    private final boolean userInitiated;
84
    private final boolean userInitiated;
83
    private int initialDelay = Controller.INITIAL_DELAY;
85
    private int initialDelay = Controller.INITIAL_DELAY;
Lines 98-109 Link Here
98
                   Cancellable cancel,
100
                   Cancellable cancel,
99
                   boolean userInitiated,
101
                   boolean userInitiated,
100
                   Action view) {
102
                   Action view) {
103
        this(displayName, cancel, null, userInitiated, view);
104
    }
105
106
    /**
107
     * 
108
     * @param displayName
109
     * @param cancel
110
     * @param suspendAndResume
111
     * @param userInitiated
112
     * @param view 
113
     * 
114
     * @since XXX
115
     */
116
    public InternalHandle(
117
        String displayName, 
118
        Cancellable cancel,
119
        Resumable suspendAndResume,
120
        boolean userInitiated,
121
        Action view
122
    ) {
101
        this.displayName = displayName;
123
        this.displayName = displayName;
102
        this.userInitiated = userInitiated;
124
        this.userInitiated = userInitiated;
103
        state = STATE_INITIALIZED;
125
        state = STATE_INITIALIZED;
104
        totalUnits = 0;
126
        totalUnits = 0;
105
        lastMessage = null;
127
        lastMessage = null;
106
        cancelable = cancel;
128
        cancelable = cancel;
129
        this.resumable = suspendAndResume;
107
        viewAction = view;
130
        viewAction = view;
108
    }
131
    }
109
132
Lines 118-123 Link Here
118
        return state;
141
        return state;
119
    }
142
    }
120
    
143
    
144
    /**
145
     * @return if the handle can be suspended and resumed
146
     * @since XXX
147
     */
148
    public boolean isResumable() {
149
        return resumable != null;
150
    }
151
    
121
    public boolean isAllowCancel() {
152
    public boolean isAllowCancel() {
122
        return cancelable != null && !isCustomPlaced();
153
        return cancelable != null && !isCustomPlaced();
123
    }
154
    }

Return to bug 219669