EMMA Coverage Report (generated Mon Sep 29 15:05:28 EDT 2008)
[all classes][org.eclipse.ui.internal.progress]

COVERAGE SUMMARY FOR SOURCE FILE [ProgressAnimationProcessor.java]

nameclass, %method, %block, %line, %
ProgressAnimationProcessor.java100% (1/1)73%  (8/11)67%  (80/120)69%  (24/35)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ProgressAnimationProcessor100% (1/1)73%  (8/11)67%  (80/120)69%  (24/35)
hasItems (): boolean 0%   (0/1)0%   (0/8)0%   (0/1)
itemsInactiveRedraw (): void 0%   (0/1)0%   (0/1)0%   (0/1)
startAnimationLoop (IProgressMonitor): void 0%   (0/1)0%   (0/31)0%   (0/9)
ProgressAnimationProcessor (AnimationManager): void 100% (1/1)100% (12/12)100% (4/4)
addItem (AnimationItem): void 100% (1/1)100% (10/10)100% (3/3)
animationFinished (): void 100% (1/1)100% (16/16)100% (4/4)
animationStarted (): void 100% (1/1)100% (16/16)100% (4/4)
getAnimationItems (): ProgressAnimationItem [] 100% (1/1)100% (12/12)100% (4/4)
getPreferredWidth (): int 100% (1/1)100% (2/2)100% (1/1)
isProcessorJob (Job): boolean 100% (1/1)100% (2/2)100% (1/1)
removeItem (AnimationItem): void 100% (1/1)100% (10/10)100% (3/3)

1/*******************************************************************************
2 * Copyright (c) 2004, 2006 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.ui.internal.progress;
12 
13import java.util.ArrayList;
14import java.util.Collections;
15import java.util.List;
16 
17import org.eclipse.core.runtime.Assert;
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.core.runtime.jobs.Job;
20import org.eclipse.ui.PlatformUI;
21 
22/**
23 * The ProgressAnimationProcessor is the processor for the animation using the
24 * system progress.
25 */
26class ProgressAnimationProcessor implements IAnimationProcessor {
27 
28    AnimationManager manager;
29 
30    /**
31     * Create a new instance of the receiver and listen to the animation
32     * manager.
33     * 
34     * @param animationManager
35     */
36    ProgressAnimationProcessor(AnimationManager animationManager) {
37        manager = animationManager;
38    }
39 
40    List items = Collections.synchronizedList(new ArrayList());
41 
42    /*
43     * (non-Javadoc)
44     * 
45     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#startAnimation(org.eclipse.core.runtime.IProgressMonitor)
46     */
47    public void startAnimationLoop(IProgressMonitor monitor) {
48 
49        // Create an off-screen image to draw on, and a GC to draw with.
50        // Both are disposed after the animation.
51        if (items.size() == 0) {
52                        return;
53                }
54        if (!PlatformUI.isWorkbenchRunning()) {
55                        return;
56                }
57 
58        while (manager.isAnimated() && !monitor.isCanceled()) {
59            //Do nothing while animation is happening
60        }
61 
62        ProgressAnimationItem[] animationItems = getAnimationItems();
63        for (int i = 0; i < animationItems.length; i++) {
64            animationItems[i].animationDone();
65        }
66 
67    }
68 
69    /*
70     * (non-Javadoc)
71     * 
72     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#addItem(org.eclipse.ui.internal.progress.AnimationItem)
73     */
74    public void addItem(AnimationItem item) {
75        Assert.isTrue(item instanceof ProgressAnimationItem);
76        items.add(item);
77    }
78 
79    /*
80     * (non-Javadoc)
81     * 
82     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#removeItem(org.eclipse.ui.internal.progress.AnimationItem)
83     */
84    public void removeItem(AnimationItem item) {
85        Assert.isTrue(item instanceof ProgressAnimationItem);
86        items.remove(item);
87    }
88 
89    /*
90     * (non-Javadoc)
91     * 
92     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#hasItems()
93     */
94    public boolean hasItems() {
95        return items.size() > 0;
96    }
97 
98    /*
99     * (non-Javadoc)
100     * 
101     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#itemsInactiveRedraw()
102     */
103    public void itemsInactiveRedraw() {
104        //Nothing to do here as SWT handles redraw
105 
106    }
107 
108    /*
109     * (non-Javadoc)
110     * 
111     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#animationStarted(org.eclipse.core.runtime.IProgressMonitor)
112     */
113    public void animationStarted() {
114        AnimationItem[] animationItems = getAnimationItems();
115        for (int i = 0; i < animationItems.length; i++) {
116            animationItems[i].animationStart();
117        }
118 
119    }
120 
121    /*
122     * (non-Javadoc)
123     * 
124     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#getPreferredWidth()
125     */
126    public int getPreferredWidth() {
127        return 30;
128    }
129 
130    /**
131     * Get the animation items currently registered for the receiver.
132     * 
133     * @return ProgressAnimationItem[]
134     */
135    private ProgressAnimationItem[] getAnimationItems() {
136        ProgressAnimationItem[] animationItems = new ProgressAnimationItem[items
137                .size()];
138        items.toArray(animationItems);
139        return animationItems;
140    }
141 
142    /* (non-Javadoc)
143     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#animationFinished()
144     */
145    public void animationFinished() {
146        AnimationItem[] animationItems = getAnimationItems();
147        for (int i = 0; i < animationItems.length; i++) {
148            animationItems[i].animationDone();
149        }
150 
151    }
152 
153    /* (non-Javadoc)
154     * @see org.eclipse.ui.internal.progress.IAnimationProcessor#isProcessorJob(org.eclipse.core.runtime.jobs.Job)
155     */
156    public boolean isProcessorJob(Job job) {
157        // We have no jobs
158        return false;
159    }
160 
161}

[all classes][org.eclipse.ui.internal.progress]
EMMA 2.0.5312 EclEmma Fix 1 (C) Vladimir Roubtsov