Home » Modeling » Graphiti » Progress Monitor(I would like to add a Progress Monitor to a Custom Feature (import function))
Progress Monitor [message #659779] |
Tue, 15 March 2011 15:12 |
Jan Schoubo Messages: 13 Registered: May 2010 Location: Stilling, Denmark |
Junior Member |
|
|
Hi,
I am trying to create a function to import and populate a diagram with a large number of elements. The import file is not an XML/EMF file.
So far I have created a Custom Feature and tied it to the Context Menu, as shown in the tutorial. This way I am sure the
import only happens at a time when a diagram exists.
The logic is roughly:
For every element defined in the import file:
- Create Business Object
- Create AddContext with the following information:
-- setNewObject(<Business Object>)
-- setTargetContainer(getFeatureProvider().getDiagramTypeProvid er().getDiagram());
-- setLocation(<x>, <y>);
-- setSize(<w>, <h>); // size and position from import file
- Call addGraphicalRepresentation(<AddContext>, <Business Object>);
This works, but...
My test data comprises 600 elements that end up covering an area twice the width and height of the visible canvas. It takes about 30 seconds, and nothing shows up until they are all done.
So I would like to add a Progress Monitor to show how far we have gotten.
I tried putting the logic above in a org.eclipse.ui.progress.Job, but now each call to addGraphicalRepresentation results in a Null Pointer Exception in org.eclipse.graphiti.ui.internal.editor.DomainModelChangeLis tener.resourceSetChanged(DomainModelChangeListener.java:109) (Full stacktrace below) - it seems SWT has no Display.getCurrent() value available, when executing in a separate thread.
However, the progress monitor works, the elements show up along the way, and the end result - apart from tons of stacktraces and a popup warning - seems correct.
I also tried changing the Job to a UIJob, that made the stacktraces and popup go away, but also the progress monitor, and after 30 seconds of nothing, the display started to chase around like mad, to catch up on all the UI updates that had build up. Very entertaining, but not I had hoped for
Can anyone recommend either a quick fix or a different approach?
Any example would be much appreciated!
- Jan
(The full stacktrace, in case you need it)
java.lang.NullPointerException
at org.eclipse.graphiti.ui.internal.editor.DomainModelChangeListener.resourceSetChanged(DomainModelChangeListener.java:109)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl$1.run(TransactionalEditingDomainImpl.java:781)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.postcommit(TransactionalEditingDomainImpl.java:771)
at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.deactivate(TransactionalEditingDomainImpl.java:543)
at org.eclipse.emf.transaction.impl.TransactionImpl.close(TransactionImpl.java:712)
at org.eclipse.emf.transaction.impl.TransactionImpl.commit(TransactionImpl.java:474)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(AbstractEMFOperation.java:155)
at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(DefaultOperationHistory.java:511)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doExecute(WorkspaceCommandStackImpl.java:208)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:165)
at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:47)
at org.eclipse.emf.transaction.impl.AbstractTransactionalCommandStack.execute(AbstractTransactionalCommandStack.java:219)
at org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandStackImpl.execute(GFWorkspaceCommandStackImpl.java:39)
at org.eclipse.graphiti.internal.command.CommandExec.executeCommand(CommandExec.java:74)
at org.eclipse.graphiti.features.impl.AbstractFeatureProvider.addIfPossible(AbstractFeatureProvider.java:337)
at org.eclipse.graphiti.features.impl.AbstractFeature.addGraphicalRepresentation(AbstractFeature.java:108)
at dk.schoubo.makegraphititracks.features.ImportLayoutFeature.agr(ImportLayoutFeature.java:126)
at dk.schoubo.makegraphititracks.features.ImportJob.run(ImportJob.java:61)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Jan Schoubo, schoubo reasoning
|
|
|
Re: Progress Monitor [message #660282 is a reply to message #659779] |
Thu, 17 March 2011 16:03 |
Michael Wenz Messages: 1931 Registered: July 2009 Location: Walldorf, Germany |
Senior Member |
|
|
Short answer to this: this appears to be a bug. Display.getCurrent() returns
null when called from the non-UI thread. We should instead use
Display.getDefault(). Could you open a bugzilla for that, please?
In fact, what you are doing seems to be perfectly right, I don't think
there's a better solution to that. Running the stuff inside a UI job will
not help, because that will simply block the UI (and have the nice
side-effects you mentioned...).
Michael
"Jan Schoubo" wrote in message news:ilnv85$ujj$1@news.eclipse.org...
Hi,
I am trying to create a function to import and populate a diagram with a
large number of elements. The import file is not an XML/EMF file.
So far I have created a Custom Feature and tied it to the Context Menu, as
shown in the tutorial. This way I am sure the
import only happens at a time when a diagram exists.
The logic is roughly:
For every element defined in the import file:
- Create Business Object
- Create AddContext with the following information:
-- setNewObject(<Business Object>)
-- setTargetContainer(getFeatureProvider().getDiagramTypeProvid
er().getDiagram());
-- setLocation(<x>, <y>);
-- setSize(<w>, <h>); // size and position from import file
- Call addGraphicalRepresentation(<AddContext>, <Business Object>);
This works, but...
My test data comprises 600 elements that end up covering an area twice the
width and height of the visible canvas. It takes about 30 seconds, and
nothing shows up until they are all done.
So I would like to add a Progress Monitor to show how far we have gotten.
I tried putting the logic above in a org.eclipse.ui.progress.Job, but now
each call to addGraphicalRepresentation results in a Null Pointer Exception
in org.eclipse.graphiti.ui.internal.editor.DomainModelChangeLis
tener.resourceSetChanged(DomainModelChangeListener.java:109) (Full
stacktrace below) - it seems SWT has no Display.getCurrent() value
available, when executing in a separate thread.
However, the progress monitor works, the elements show up along the way, and
the end result - apart from tons of stacktraces and a popup warning - seems
correct.
I also tried changing the Job to a UIJob, that made the stacktraces and
popup go away, but also the progress monitor, and after 30 seconds of
nothing, the display started to chase around like mad, to catch up on all
the UI updates that had build up. Very entertaining, but not I had hoped for
:)
Can anyone recommend either a quick fix or a different approach?
Any example would be much appreciated!
- Jan
(The full stacktrace, in case you need it)
java.lang.NullPointerException
at
org.eclipse.graphiti.ui.internal.editor.DomainModelChangeLis tener.resourceSetChanged(DomainModelChangeListener.java:109)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl$1.run(TransactionalEditingDomainImpl.java:781)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:328)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.postcommit(TransactionalEditingDomainImpl.java:771)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:543)
at
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:712)
at
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:474)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:155)
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:511)
at
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.doE xecute(WorkspaceCommandStackImpl.java:208)
at
org.eclipse.emf.transaction.impl.AbstractTransactionalComman dStack.execute(AbstractTransactionalCommandStack.java:165)
at
org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandSt ackImpl.execute(GFWorkspaceCommandStackImpl.java:47)
at
org.eclipse.emf.transaction.impl.AbstractTransactionalComman dStack.execute(AbstractTransactionalCommandStack.java:219)
at
org.eclipse.graphiti.ui.internal.editor.GFWorkspaceCommandSt ackImpl.execute(GFWorkspaceCommandStackImpl.java:39)
at
org.eclipse.graphiti.internal.command.CommandExec.executeCom mand(CommandExec.java:74)
at
org.eclipse.graphiti.features.impl.AbstractFeatureProvider.a ddIfPossible(AbstractFeatureProvider.java:337)
at
org.eclipse.graphiti.features.impl.AbstractFeature.addGraphi calRepresentation(AbstractFeature.java:108)
at
dk.schoubo.makegraphititracks.features.ImportLayoutFeature.a gr(ImportLayoutFeature.java:126)
at dk.schoubo.makegraphititracks.features.ImportJob.run(ImportJ ob.java:61)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
--
Jan Schoubo, schoubo reasoning
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 09:59:16 GMT 2024
Powered by FUDForum. Page generated in 0.03791 seconds
|