1 11 package org.eclipse.ui.internal.progress; 12 13 import org.eclipse.swt.events.DisposeEvent; 14 import org.eclipse.swt.events.DisposeListener; 15 import org.eclipse.swt.events.MouseEvent; 16 import org.eclipse.swt.events.MouseListener; 17 import org.eclipse.swt.events.PaintEvent; 18 import org.eclipse.swt.graphics.Image; 19 import org.eclipse.swt.graphics.ImageData; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Control; 22 import org.eclipse.ui.internal.WorkbenchWindow; 23 24 27 public abstract class AnimationItem { 28 WorkbenchWindow window; 29 30 interface IAnimationContainer { 31 34 public abstract void animationStart(); 35 36 39 public abstract void animationDone(); 40 } 41 42 IAnimationContainer animationContainer = new IAnimationContainer() { 44 47 public void animationDone() { 48 } 50 51 54 public void animationStart() { 55 } 57 }; 58 59 65 public AnimationItem(WorkbenchWindow workbenchWindow) { 66 this.window = workbenchWindow; 67 } 68 69 74 public void createControl(Composite parent) { 75 76 Control animationItem = createAnimationItem(parent); 77 78 animationItem.addMouseListener(new MouseListener() { 79 84 public void mouseDoubleClick(MouseEvent arg0) { 85 ProgressManagerUtil.openProgressView(AnimationItem.this.window); 86 } 87 88 93 public void mouseDown(MouseEvent arg0) { 94 } 96 97 102 public void mouseUp(MouseEvent arg0) { 103 } 105 }); 106 animationItem.addDisposeListener(new DisposeListener() { 107 public void widgetDisposed(DisposeEvent e) { 108 AnimationManager.getInstance().removeItem(AnimationItem.this); 109 } 110 }); 111 AnimationManager.getInstance().addItem(this); 112 } 113 114 119 protected abstract Control createAnimationItem(Composite parent); 120 121 131 void paintImage(PaintEvent event, Image image, ImageData imageData) { 132 event.gc.drawImage(image, 0, 0); 133 } 134 135 140 public abstract Control getControl(); 141 142 145 void animationStart() { 146 animationContainer.animationStart(); 147 } 148 149 152 void animationDone() { 153 animationContainer.animationDone(); 154 } 155 156 161 public int getPreferredWidth() { 162 return AnimationManager.getInstance().getPreferredWidth() + 5; 163 } 164 165 169 void setAnimationContainer(IAnimationContainer container) { 170 this.animationContainer = container; 171 } 172 } 173 | Popular Tags |