Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Progressmonitor on EMF operation
Progressmonitor on EMF operation [message #487040] Mon, 21 September 2009 15:56 Go to next message
Artur Kronenberg is currently offline Artur KronenbergFriend
Messages: 159
Registered: August 2009
Senior Member
Hi,

I have a problem with the progressmonitors in my AbstractEMFOperations.

I have a very big diagram and I need to hide and show components on that diagram very often. This sometimes takes a little time so I wanted to show a progressmonitor when executing my operation.

I don't really know how to achieve this. I tried creating a Job and running my operation within the job and showing the progress on that progressmonitor, but the show/hide operation breaks if I do it like that (The diagram doesn't get refreshed in the correct way anymore).

Is there a right way of achieving this?

Best regards,
Artur
Re: Progressmonitor on EMF operation [message #487094 is a reply to message #487040] Mon, 21 September 2009 20:37 Go to previous messageGo to next message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello Artur,

> I don't really know how to achieve this. I tried creating a Job and
> running my operation within the job and showing the progress on that
> progressmonitor, but the show/hide operation breaks if I do it like
> that (The diagram doesn't get refreshed in the correct way anymore).
Any exceptions in error log/console/debugger?

-----------------
Alex Shatalin
Re: Progressmonitor on EMF operation [message #487106 is a reply to message #487094] Mon, 21 September 2009 22:08 Go to previous messageGo to next message
Artur Kronenberg is currently offline Artur KronenbergFriend
Messages: 159
Registered: August 2009
Senior Member
Hi Alex,

sorry, I should have thought of posting this before: This is what I get (I just post all of it, since I don't really know what is important) in the log:

!ENTRY org.eclipse.ui 4 0 2009-09-21 18:05:56.757
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException)
at org.eclipse.swt.SWT.error(SWT.java:3884)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:137)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3476)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Caused by: java.lang.NullPointerException
at org.eclipse.draw2d.geometry.Rectangle.contains(Rectangle.jav a:136)
at org.eclipse.draw2d.PolylineConnection.layout(PolylineConnect ion.java:175)
at org.eclipse.draw2d.Figure.validate(Figure.java:1739)
at org.eclipse.draw2d.Figure.validate(Figure.java:1741)
at org.eclipse.draw2d.Figure.validate(Figure.java:1741)
at org.eclipse.draw2d.Figure.validate(Figure.java:1741)
at org.eclipse.draw2d.Figure.validate(Figure.java:1741)
at org.eclipse.draw2d.FreeformViewport$FreeformViewportLayout.c alculatePreferredSize(FreeformViewport.java:28)
at org.eclipse.draw2d.AbstractLayout.getPreferredSize(AbstractL ayout.java:93)
at org.eclipse.draw2d.AbstractHintLayout.getPreferredSize(Abstr actHintLayout.java:85)
at org.eclipse.draw2d.Figure.getPreferredSize(Figure.java:735)
at org.eclipse.draw2d.ScrollPaneSolver.solve(ScrollPaneSolver.j ava:75)
at org.eclipse.draw2d.FigureCanvas.layoutViewport(FigureCanvas. java:315)
at org.eclipse.draw2d.FigureCanvas.access$4(FigureCanvas.java:3 13)
at org.eclipse.draw2d.FigureCanvas$3.notifyValidating(FigureCan vas.java:278)
at org.eclipse.draw2d.UpdateManager.fireValidating(UpdateManage r.java:123)
at org.eclipse.draw2d.DeferredUpdateManager.performValidation(D eferredUpdateManager.java:203)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer$ToggleUpdateManager.performValidation(DiagramGraphicalVi ewer.java:124)
at org.eclipse.draw2d.DeferredUpdateManager.performUpdate(Defer redUpdateManager.java:179)
at org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalVie wer$ToggleUpdateManager.performUpdate(DiagramGraphicalViewer .java:114)
at org.eclipse.draw2d.DeferredUpdateManager$UpdateRequest.run(D eferredUpdateManager.java:48)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
... 23 more


This is, when I huck the Job into my showAllComponents mehtod. This one iterates through my diagram and sets all the notation views visibility to true.
After that it triggers a arrangeAll to arrange the nodes on the diagram.

I get the exception. Funny thing is, when I just scroll around in the diagram, everything gets refreshed and looks like it is supposed to be looking.

Maybe it has something to do with me working on the UI and using a normal Job?

Best regards,
Artur

Alex Shatalin wrote on Mon, 21 September 2009 16:37
Hello Artur,

> I don't really know how to achieve this. I tried creating a Job and
> running my operation within the job and showing the progress on that
> progressmonitor, but the show/hide operation breaks if I do it like
> that (The diagram doesn't get refreshed in the correct way anymore).
Any exceptions in error log/console/debugger?

-----------------
Alex Shatalin

Re: Progressmonitor on EMF operation [message #487253 is a reply to message #487106] Tue, 22 September 2009 15:25 Go to previous message
Artur Kronenberg is currently offline Artur KronenbergFriend
Messages: 159
Registered: August 2009
Senior Member
Hi Alex,

I think I found a solution for that problem, at least I can do it now without errors and with progress monitor:

So. Problem Nr.1 was, that a Job normally isn't supposed to do changes to the UI so the Job class was the wrong approach from the beginning.

The UIJob is what should be used. The problem with that is, that it would freeze the UI and the progress monitor would not be shown.
However, if you call Display.getCurrent().readAndDispatch() this makes the UI not freezing plus it updates and shopws the monitor. The user should call this within loops in UI threads. This is important because the UI thread normally should only be used for very small actions, nothing that would normally take long enough to actually show a progress monitor.

I don't know if that is the 100 % correct method for that, but it seems to be working just fine.

Best regards,
Artur
Previous Topic:NPE with invisible shapes and connections
Next Topic:GMF Diagram Validation
Goto Forum:
  


Current Time: Thu Mar 28 23:05:45 GMT 2024

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

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

Back to the top