diff options
author | Uwe Stieber | 2013-03-07 15:51:36 +0000 |
---|---|---|
committer | Uwe Stieber | 2013-03-07 15:51:36 +0000 |
commit | c8af5cb1f69bb78df360a58b20ac07481a41cc20 (patch) | |
tree | c465aebfc53034a7392331a3a17381a0f8e50ae9 /target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf | |
parent | 908b5ef406fd9dd18babac6cde71aa72ab197e95 (diff) | |
download | org.eclipse.tcf-c8af5cb1f69bb78df360a58b20ac07481a41cc20.tar.gz org.eclipse.tcf-c8af5cb1f69bb78df360a58b20ac07481a41cc20.tar.xz org.eclipse.tcf-c8af5cb1f69bb78df360a58b20ac07481a41cc20.zip |
Target Explorer: Remove animated pending image
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf')
3 files changed, 13 insertions, 116 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java index ced1637ec..66e122647 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java @@ -9,25 +9,17 @@ *******************************************************************************/ package org.eclipse.tcf.te.ui.activator; -import java.io.InputStream; import java.net.URL; -import java.util.Arrays; -import org.eclipse.core.runtime.ISafeRunnable; -import org.eclipse.core.runtime.SafeRunner; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; -import org.eclipse.swt.graphics.ImageLoader; -import org.eclipse.swt.widgets.Display; +import org.eclipse.tcf.te.runtime.model.MessageModelNode; import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences; import org.eclipse.tcf.te.runtime.tracing.TraceHandler; import org.eclipse.tcf.te.ui.interfaces.ImageConsts; import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; -import org.eclipse.tcf.te.ui.swt.DisplayUtil; import org.eclipse.tcf.te.ui.trees.ViewerStateManager; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -41,8 +33,6 @@ public class UIPlugin extends AbstractUIPlugin { private static volatile ScopedEclipsePreferences scopedPreferences; // The trace handler instance private static volatile TraceHandler traceHandler; - // The pending images used to display the animation. - /* default */ Image[] pendingImages; /** * The constructor @@ -51,40 +41,6 @@ public class UIPlugin extends AbstractUIPlugin { } /** - * Load the pending images used to animate. - */ - /* default */ void loadPendingImages() { - SafeRunner.run(new ISafeRunnable() { - @Override - public void handleException(Throwable exception) { - // Ignore it. - } - - @Override - public void run() throws Exception { - InputStream is = null; - try { - URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_ELCL + "pending.gif"); //$NON-NLS-1$ - if (url != null) { - is = url.openStream(); - ImageData[] imageDatas = new ImageLoader().load(is); - pendingImages = new Image[imageDatas.length]; - Display display = PlatformUI.getWorkbench().getDisplay(); - for (int i = 0; i < imageDatas.length; i++) { - pendingImages[i] = new Image(display, imageDatas[i]); - } - } - } - finally { - if (is != null) { - try { is.close(); } catch (Exception e) {} - } - } - } - }); - } - - /** * Returns the shared instance * * @return the shared instance @@ -132,13 +88,6 @@ public class UIPlugin extends AbstractUIPlugin { public void start(BundleContext context) throws Exception { super.start(context); plugin = this; - // Images should be loaded in the UI thread - DisplayUtil.safeAsyncExec(new Runnable() { - @Override - public void run() { - loadPendingImages(); - } - }); // Load the tree viewer's state. ViewerStateManager.getInstance().loadViewerStates(); } @@ -150,27 +99,12 @@ public class UIPlugin extends AbstractUIPlugin { public void stop(BundleContext context) throws Exception { // Save the tree viewer's state. ViewerStateManager.getInstance().storeViewerStates(); - if (pendingImages != null && pendingImages.length > 0) { - for (Image img : pendingImages) { - img.dispose(); - } - } - pendingImages = null; plugin = null; scopedPreferences = null; traceHandler = null; super.stop(context); } - /** - * Returns the image list used to animate the pending state. - * - * @return A image list. - */ - public final Image[] getPendingImages() { - return pendingImages != null ? Arrays.copyOf(pendingImages, pendingImages.length) : new Image[0]; - } - /* (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) */ @@ -204,6 +138,9 @@ public class UIPlugin extends AbstractUIPlugin { registry.put(ImageConsts.RED_X_OVR, ImageDescriptor.createFromURL(url)); url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "busy.gif"); //$NON-NLS-1$ registry.put(ImageConsts.BUSY_OVR, ImageDescriptor.createFromURL(url)); + + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "pending.gif"); //$NON-NLS-1$ + registry.put(MessageModelNode.OBJECT_MESSAGE_PENDING_ID, ImageDescriptor.createFromURL(url)); } /** diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ImageConsts.java index 18c16f59f..812f003ef 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ImageConsts.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ImageConsts.java @@ -46,6 +46,11 @@ public interface ImageConsts { */ public final static String IMAGE_DIR_OVR = "ovr16/"; //$NON-NLS-1$ + /** + * The directory where to load model object images from, relative to the image root directory. + */ + public final static String IMAGE_DIR_OBJ = "obj16/"; //$NON-NLS-1$ + // ***** The image constants ***** /** @@ -72,7 +77,7 @@ public interface ImageConsts { * The key to access the viewer filter configuration image (enabled). */ public static final String VIEWER_COLLAPSE_ALL = "ViewerCollapseAll_enabled"; //$NON-NLS-1$ - + /** * The key to access the viewer filter configuration image (disabled). */ @@ -97,7 +102,7 @@ public interface ImageConsts { * The key to access the target object red overlay image. */ public static final String RED_OVR = "RedOverlay"; //$NON-NLS-1$ - + /** * The key to access the filtering decoration image. */ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/Pending.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/Pending.java index cfd1bca7d..bdd8615cc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/Pending.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/trees/Pending.java @@ -9,10 +9,10 @@ *******************************************************************************/ package org.eclipse.tcf.te.ui.trees; -import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Display; +import org.eclipse.tcf.te.runtime.model.MessageModelNode; import org.eclipse.tcf.te.ui.activator.UIPlugin; import org.eclipse.tcf.te.ui.nls.Messages; @@ -21,16 +21,10 @@ import org.eclipse.tcf.te.ui.nls.Messages; * displays an animated GIF image read from "pending.gif". */ public class Pending { - // The interval between two frames. - private static final int FRAME_INTERVAL = 100; // Reference to the parent tree viewer TreeViewer viewer; // The display used to create image and timer. Display display; - // If it is animating. - boolean animating; - // The current frame index of the image list. - int frame; /** * Create a pending node for the specified tree viewer. @@ -40,32 +34,6 @@ public class Pending { public Pending(TreeViewer viewer) { this.viewer = viewer; this.display = viewer.getTree().getDisplay(); - this.animating = true; - this.frame = 0; - } - - /** - * Animate the pending images. Start a SWT timer to update - * the pending image periodically. - */ - public void startAnimation() { - if (Display.getCurrent() == null) { - display.asyncExec(new Runnable() { - @Override - public void run() { - startAnimation(); - } - }); - } - else { - display.timerExec(FRAME_INTERVAL, new Runnable() { - @Override - public void run() { - viewer.update(Pending.this, null); - if (animating) startAnimation(); - } - }); - } } /** @@ -83,20 +51,7 @@ public class Pending { * @return The current image. */ public Image getImage() { - Image img = null; - Image[] pendingImages = UIPlugin.getDefault().getPendingImages(); - Assert.isNotNull(pendingImages); - if (pendingImages.length > 0) { - img = pendingImages[frame++]; - frame = frame % pendingImages.length; - } - return img; + return UIPlugin.getImage(MessageModelNode.OBJECT_MESSAGE_PENDING_ID); } - /** - * Stop the animation. - */ - public void stopAnimation() { - animating = false; - } } |