Skip to main content



      Home
Home » Modeling » EMF » Displaying animated Gif in a view(EMF Edit Code)
Displaying animated Gif in a view [message #1843655] Thu, 12 August 2021 06:00 Go to next message
Eclipse UserFriend
Hi,
is it somehow possible to implement the getImage-Method in the ItemProvider of an element to return an animated GIF? Or to achieve an animated Gif in a Tree View using another method?

The Background is that I have a view which is updatable. The view displays contents of an underlying model in a tree view, which, in this case, is not editable by the user.
The update triggers some algorithms which require some time and already use the Eclipse Job-API. However, for the user, I want to display the pending state of some elements in the view by displaying a little spinner instead of the ordinary element icon. Unfortunately, I could not figure out a way, that enables the icon to be animated according to the gif-file that I have provided.

Thanks in advance!

Sample-Code:
@Override
	public Object getImage(Object object) {
		if (((UpdateableElement)object).isUpdating()) {
			return ((URL)getResourceLocator().getImage("full/obj16/spinner"));
		}
		return overlayImage(object, getResourceLocator().getImage("full/obj16/ModelStorage"));
	}

[Updated on: Thu, 12 August 2021 06:01] by Moderator

Re: Displaying animated Gif in a view [message #1843663 is a reply to message #1843655] Thu, 12 August 2021 12:12 Go to previous messageGo to next message
Eclipse UserFriend
No, there no such mechanism in JFace either. You'd need to refresh based on a timer (org.eclipse.swt.widgets.Display.timerExec(int, Runnable)) and yield a different icon each time to induce the animation.
Re: Displaying animated Gif in a view [message #1843681 is a reply to message #1843663] Fri, 13 August 2021 11:19 Go to previous messageGo to next message
Eclipse UserFriend
...Do I need to refresh the whole viewer each time the timer triggers? Or is there a way to do it from the ItemProvider via something similar to a ViewerNotification in order to only refresh the items that use an animated icon? As far as I have figured out, I cannot simply fire a ViewerNotification without an underlying Notification from a model transaction, correct?
Re: Displaying animated Gif in a view [message #1843692 is a reply to message #1843681] Sat, 14 August 2021 01:40 Go to previous message
Eclipse UserFriend
You can use org.eclipse.jface.viewers.StructuredViewer.update(Object, String[]) directly. It sounds like you've already noticed that org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider.ViewerRefresh does this type of thing based on model notifications. It it possible to create org.eclipse.emf.ecore.impl.ENotificationImpl directly and also to call org.eclipse.emf.common.notify.Notifier.eNotify(Notification) directly, though if you're using transactions other parts of the framework will think you've changed the model and made it dirty... If that doesn't matter, you could just set the feature used for the label to the same value it had before...
Previous Topic:Identifier specification
Next Topic:Ecore2Java ant task reports success, generates nothing.
Goto Forum:
  


Current Time: Tue Jul 01 13:10:36 EDT 2025

Powered by FUDForum. Page generated in 0.02892 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top