diff options
Diffstat (limited to 'bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/deferred/LoadingModelUIAnimationJob.java')
-rw-r--r-- | bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/deferred/LoadingModelUIAnimationJob.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/deferred/LoadingModelUIAnimationJob.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/deferred/LoadingModelUIAnimationJob.java new file mode 100644 index 00000000..680a91d9 --- /dev/null +++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/navigator/deferred/LoadingModelUIAnimationJob.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2011 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.wst.jsdt.internal.ui.navigator.deferred; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.viewers.AbstractTreeViewer; +import org.eclipse.ui.progress.UIJob; + +public class LoadingModelUIAnimationJob extends UIJob { + + /* we update the animation frame every 250 ms */ + private static final long DELAY = 200; + + /* the node holding the place for the model (the "Loading ..." in the tree ) */ + private LoadingModelNode placeHolder; + private AbstractTreeViewer viewer; + + public LoadingModelUIAnimationJob(AbstractTreeViewer viewer, + LoadingModelNode placeHolder) { + super(placeHolder.getText()); + this.viewer = viewer; + this.placeHolder = placeHolder; + /* + * this way we don't put alot of noise in the progress view, except for + * power users that turn on "show system jobs" in the view + */ + setSystem(true); + setRule(new NonConflictingRule()); + } + + public IStatus runInUIThread(IProgressMonitor monitor) { + + if (!placeHolder.isDisposed()) { + + /* update the animation frame */ + viewer.update(placeHolder, null); + + /* reschedule for the next animation frame */ + schedule(DELAY); + } + return Status.OK_STATUS; + + } +} |