KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > progress > aggregate > AggregateProgressFactory


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.progress.aggregate;
21
22 import javax.swing.Action JavaDoc;
23 import javax.swing.JComponent JavaDoc;
24 import javax.swing.JLabel JavaDoc;
25 import org.openide.util.Cancellable;
26
27 /**
28  * Factory for creation of aggregate progress indication handles and individual contributor instances.
29  * For a more simple version of progress indication, see {@link org.netbeans.api.progress.ProgressHandleFactory}
30  *
31  * @author mkleint (mkleint@netbeans.org)
32  */

33 public final class AggregateProgressFactory {
34
35     /** Creates a new instance of AggregateProgressFactory */
36     private AggregateProgressFactory() {
37     }
38     
39     /**
40      * Create an aggregating progress ui handle for a long lasting task.
41      * @param contributors the initial set of progress indication contributors that are aggregated in the UI.
42      * @param allowToCancel either null, if the task cannot be cancelled or
43      * an instance of {@link org.openide.util.Cancellable} that will be called when user
44      * triggers cancel of the task.
45      * @param linkOutput an <code>Action</code> instance that links the running task in the progress bar
46      * to an output of the task. The action is assumed to open the apropriate component with the task's output.
47      * @param displayName to be shown in the progress UI
48      * @return an instance of <code>ProgressHandle</code>, initialized but not started.
49      *
50      */

51     public static AggregateProgressHandle createHandle(String JavaDoc displayName, ProgressContributor[] contributors,
52                                                        Cancellable allowToCancel, Action JavaDoc linkOutput) {
53         return new AggregateProgressHandle(displayName, contributors, allowToCancel, linkOutput, false);
54     }
55     
56     public static ProgressContributor createProgressContributor(String JavaDoc trackingId) {
57         return new ProgressContributor(trackingId);
58     }
59     
60     /**
61      * Create an aggregating progress ui handle for a long lasting task.
62      * @param contributors the initial set of progress indication contributors that are aggregated in the UI.
63      * @param allowToCancel either null, if the task cannot be cancelled or
64      * an instance of {@link org.openide.util.Cancellable} that will be called when user
65      * triggers cancel of the task.
66      * @param linkOutput an <code>Action</code> instance that links the running task in the progress bar
67      * to an output of the task. The action is assumed to open the apropriate component with the task's output.
68      * @param displayName to be shown in the progress UI
69      * @return an instance of <code>ProgressHandle</code>, initialized but not started.
70      *
71      */

72     public static AggregateProgressHandle createSystemHandle(String JavaDoc displayName, ProgressContributor[] contributors,
73                                                        Cancellable allowToCancel, Action JavaDoc linkOutput) {
74         return new AggregateProgressHandle(displayName, contributors, allowToCancel, linkOutput, true);
75     }
76     
77     /**
78      * Get the progress bar component for use in custom dialogs, the task won't
79      * show in the progress bar anymore.
80      * @since org.netbeans.api.progress 1.3
81      * @return the component to use in custom UI.
82      */

83     public static JComponent JavaDoc createProgressComponent(AggregateProgressHandle handle) {
84         return handle.extractComponent();
85     }
86     
87     /**
88      * Get the task title component for use in custom dialogs, the task won't
89      * show in the progress bar anymore. The text of the label is changed by calls to handle's <code>setDisplayName()</code> method.
90      * @return the component to use in custom UI.
91      * @since org.netbeans.api.progress 1.8
92      */

93     public static JLabel JavaDoc createMainLabelComponent(AggregateProgressHandle handle) {
94         return handle.extractMainLabel();
95     }
96     
97     /**
98      * Get the detail messages component for use in custom dialogs, the task won't
99      * show in the progress bar anymore.The text of the label is changed by calls to contributors' <code>progress(String)</code> methods.
100      * @return the component to use in custom UI.
101      * @since org.netbeans.api.progress 1.8
102      */

103     public static JLabel JavaDoc createDetailLabelComponent(AggregateProgressHandle handle) {
104         return handle.extractDetailLabel();
105     }
106     
107 }
108
Popular Tags