Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 10:00 Go to next message
Lukas Baron is currently offline Lukas BaronFriend
Messages: 17
Registered: June 2012
Junior Member
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 10:01]

Report message to a moderator

Re: Displaying animated Gif in a view [message #1843663 is a reply to message #1843655] Thu, 12 August 2021 16:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
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.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Displaying animated Gif in a view [message #1843681 is a reply to message #1843663] Fri, 13 August 2021 15:19 Go to previous messageGo to next message
Lukas Baron is currently offline Lukas BaronFriend
Messages: 17
Registered: June 2012
Junior Member
...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 05:40 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33143
Registered: July 2009
Senior Member
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...

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Identifier specification
Next Topic:Ecore2Java ant task reports success, generates nothing.
Goto Forum:
  


Current Time: Thu May 02 00:56:35 GMT 2024

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

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

Back to the top