1 11 package org.eclipse.ui.internal.progress; 12 13 import java.util.ArrayList ; 14 import java.util.Collections ; 15 import java.util.List ; 16 17 import org.eclipse.core.runtime.Assert; 18 import org.eclipse.core.runtime.IProgressMonitor; 19 import org.eclipse.core.runtime.jobs.Job; 20 import org.eclipse.ui.PlatformUI; 21 22 26 class ProgressAnimationProcessor implements IAnimationProcessor { 27 28 AnimationManager manager; 29 30 36 ProgressAnimationProcessor(AnimationManager animationManager) { 37 manager = animationManager; 38 } 39 40 List items = Collections.synchronizedList(new ArrayList ()); 41 42 47 public void startAnimationLoop(IProgressMonitor monitor) { 48 49 if (items.size() == 0) { 52 return; 53 } 54 if (!PlatformUI.isWorkbenchRunning()) { 55 return; 56 } 57 58 while (manager.isAnimated() && !monitor.isCanceled()) { 59 } 61 62 ProgressAnimationItem[] animationItems = getAnimationItems(); 63 for (int i = 0; i < animationItems.length; i++) { 64 animationItems[i].animationDone(); 65 } 66 67 } 68 69 74 public void addItem(AnimationItem item) { 75 Assert.isTrue(item instanceof ProgressAnimationItem); 76 items.add(item); 77 } 78 79 84 public void removeItem(AnimationItem item) { 85 Assert.isTrue(item instanceof ProgressAnimationItem); 86 items.remove(item); 87 } 88 89 94 public boolean hasItems() { 95 return items.size() > 0; 96 } 97 98 103 public void itemsInactiveRedraw() { 104 106 } 107 108 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 126 public int getPreferredWidth() { 127 return 30; 128 } 129 130 135 private ProgressAnimationItem[] getAnimationItems() { 136 ProgressAnimationItem[] animationItems = new ProgressAnimationItem[items 137 .size()]; 138 items.toArray(animationItems); 139 return animationItems; 140 } 141 142 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 156 public boolean isProcessorJob(Job job) { 157 return false; 159 } 160 161 } 162 | Popular Tags |