diff options
author | Eric Moffatt | 2012-01-04 15:50:32 +0000 |
---|---|---|
committer | Eric Moffatt | 2012-01-04 15:52:22 +0000 |
commit | b89263ff83f52392a97608837007d589cd92059e (patch) | |
tree | 4e66acfbaef9b071e1c7785384f13744af22f005 /bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java | |
parent | 2a19a8f20efd19ca493434701de80a9c331cefef (diff) | |
download | eclipse.platform.ui-b89263ff83f52392a97608837007d589cd92059e.tar.gz eclipse.platform.ui-b89263ff83f52392a97608837007d589cd92059e.tar.xz eclipse.platform.ui-b89263ff83f52392a97608837007d589cd92059e.zip |
Fix for Bug 358739 - MinMaxAddon has a dependency on o.e.u.workbenchv20120104-1552
Diffstat (limited to 'bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java')
-rw-r--r-- | bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java new file mode 100644 index 00000000000..8b3415d06b1 --- /dev/null +++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (c) 2007, 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + ******************************************************************************/ +package org.eclipse.e4.ui.internal.workbench.swt; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.widgets.Shell; + +/** + * AnimationFeedBackBase is an abstract class which provides renderStep(), jobInit() and + * initialize() methods for AnimationEngine. + * Its the base class for all the + * animationFeedbacks + * + * @since 3.3 + * + */ +public abstract class AnimationFeedbackBase { + private AnimationEngine engine; + private Shell baseShell; + private Shell animationShell = null; + + /** + * Creates an AnimationFeedback + * + * @param parentShell specifies the composite where the animation will be drawn + */ + public AnimationFeedbackBase(Shell parentShell) { + baseShell = parentShell; + + baseShell.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + if (engine != null) + engine.cancelAnimation(); + } + }); + } + + /** + * Perform any initialization you want to do -prior- to the Job actually + * gets scheduled. + * + * @param animationEngine The engine we're hosted in. + */ + public abstract void initialize(AnimationEngine animationEngine); + + /** + * Its a draw method. All the code to render an animation goes in this + * method. + * + * @param engine + */ + public abstract void renderStep(AnimationEngine engine); + + /** + * Perform any initialization you want to have happen -before- the animation + * starts. Subclasses may subclass but not override (i.e. you have to call super). + * + * @param engine The AnimationEngine hosting the feedback + * @return 'true' iff the animation is capable of running + */ + public boolean jobInit(AnimationEngine engine) { + this.engine = engine; + return engine != null; + } + + /** + * Dispose any locally created resources + */ + public void dispose() { + if (animationShell != null && !animationShell.isDisposed()) + animationShell.dispose(); + } + + /** + * @return The shell this animation is being rendered 'on' + */ + public Shell getBaseShell() { + return baseShell; + } + + /** + * @return A shell that can be used to render the animation on + */ + public Shell getAnimationShell() { + if (animationShell == null) { + animationShell = new Shell(getBaseShell(), SWT.NO_TRIM | SWT.ON_TOP); + + animationShell.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + if (engine != null) + engine.cancelAnimation(); + } + }); + } + + return animationShell; + } + +} |