KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > refactoring > spi > ProgressProviderAdapter


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.modules.refactoring.spi;
21
22 import org.netbeans.modules.refactoring.api.impl.ProgressSupport;
23 import org.netbeans.modules.refactoring.api.ProgressListener;
24
25 /**
26  * Simple implementation of ProgressProvider
27  * @see ProgressProvider
28  * @author Jan Becicka
29  */

30 public class ProgressProviderAdapter implements ProgressProvider {
31
32     private ProgressSupport progressSupport;
33
34     /**
35      * Default constructor
36      */

37     protected ProgressProviderAdapter() {
38     }
39     
40     /** Registers ProgressListener to receive events.
41      * @param listener The listener to register.
42      *
43      */

44     public synchronized void addProgressListener(ProgressListener listener) {
45         if (progressSupport == null ) {
46             progressSupport = new ProgressSupport();
47         }
48         progressSupport.addProgressListener(listener);
49     }
50     
51     /** Removes ProgressListener from the list of listeners.
52      * @param listener The listener to remove.
53      *
54      */

55     public synchronized void removeProgressListener(ProgressListener listener) {
56         if (progressSupport != null ) {
57             progressSupport.removeProgressListener(listener);
58         }
59     }
60     
61     /** Notifies all registered listeners about the event.
62      *
63      * @param type Type of operation that is starting.
64      * @param count Number of steps the operation consists of.
65      *
66      */

67     protected final void fireProgressListenerStart(int type, int count) {
68         if (progressSupport != null)
69             progressSupport.fireProgressListenerStart(this, type, count);
70     }
71     
72     /** Notifies all registered listeners about the event.
73      */

74     protected final void fireProgressListenerStep() {
75         if (progressSupport != null)
76             progressSupport.fireProgressListenerStep(this);
77     }
78     
79     /**
80      * Notifies all registered listeners about the event.
81      * @param count
82      */

83     protected final void fireProgressListenerStep(int count) {
84         if (progressSupport != null)
85             progressSupport.fireProgressListenerStep(this, count);
86     }
87     
88     /** Notifies all registered listeners about the event.
89      */

90     protected final void fireProgressListenerStop() {
91         if (progressSupport != null)
92             progressSupport.fireProgressListenerStop(this);
93     }
94 }
95
Popular Tags