Changing between different figures - Undo problem [message #220257] |
Fri, 27 February 2009 17:05 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Hello!
I have a new problem which belongs to the "changing between
EditParts"-issue.
In my project I have one Object called "Location" which has 6 different
graphical representations (=6 EditParts). Which EditPart the user can
see depends on the data: A Location can contain Vehicles, Stations
and/or Depots. That means, when for example the first Vehicle is added
to a Location, it changes its appearance, and when the last Vehicle is
deleted at the Location it changes its appearance back again.
Normal adding and deleting of vehicles, stations and depots works
(nearly) fine. (-> see "Changing between different figures")
But when I do something that leads to an EditPart-Change (like adding
the first vehicle to a location or removing the last vehicle from a
location) and then click Edit -> Undo, a red box appears on the screen
with the text "invalid view - remove from diagram".
Adding the second or third vehicle to the location and undo this
operation works. That means it must have something to do with the
EditPart-Change.
I already debugged it:
When I click Undo XXXEditPartFactory.createEditPart() gets an additional
call for a Node (additional to what is normally called, when I undo a
vehicle-creation). This Node has no VisualID (the VisualID is null) and
its element is a ShapesDiagramImpl. For that Node
createUnrecognizedEditPart() is called (because of VisualID=null) and
this makes the red box.
The call for this node is completely unnecessary. But I don`t know where
it comes from/what triggers it and how I can prevent it.
Does anyone have an idea what to do?
Thanks in advance!
Best wishes
Julia
|
|
|
|
Re: Changing between different figures - Undo problem [message #221034 is a reply to message #220905] |
Tue, 10 March 2009 15:31 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
> Can you please post a stack trace leading to the
> XXXEditPartFactory.createEditPart() call here?
Yep, here it is:
de.pvs.cms.editor.diagram.edit.parts.CmseditorEditPartFactor y.createUnrecognizedEditPart(CmseditorEditPartFactory.java:1 29)
de.pvs.cms.editor.diagram.edit.parts.CmseditorEditPartFactor y.createEditPart(CmseditorEditPartFactory.java:121)
de.pvs.cms.editor.diagram.providers.CmseditorEditPartProvide r.createEditPart(CmseditorEditPartProvider.java:88)
de.pvs.cms.editor.diagram.providers.CmseditorEditPartProvide r.provides(CmseditorEditPartProvider.java:139)
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService$ProviderDescriptor.provides(EditPartService.java:10 0)
org.eclipse.gmf.runtime.common.core.service.Service.safeProv ides(Service.java:860)
org.eclipse.gmf.runtime.common.core.service.ExecutionStrateg y$1.getUncachedProviders(ExecutionStrategy.java:89)
org.eclipse.gmf.runtime.common.core.service.Service.getProvi ders(Service.java:563)
org.eclipse.gmf.runtime.common.core.service.ExecutionStrateg y$1.execute(ExecutionStrategy.java:68)
org.eclipse.gmf.runtime.common.core.service.Service.execute( Service.java:652)
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.execute(EditPartService.java:217)
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createGraphicEditPart(EditPartService.java:191)
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService$1.run(EditPartService.java:228)
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:289)
org.eclipse.gmf.runtime.diagram.ui.services.editpart.EditPar tService.createEditPart(EditPartService.java:226)
org.eclipse.gef.editparts.AbstractEditPart.createChild(Abstr actEditPart.java:249)
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:726)
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refreshChild(GraphicalEditPart.java:1208)
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.handleMajorSemanticChange(GraphicalEditPart.java:1234)
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart.h andleNotificationEvent(ShapeEditPart.java:145)
org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPa rt.handleNotificationEvent(ShapeNodeEditPart.java:231)
de.pvs.cms.editor.diagram.edit.parts.DepotEditPart.handleNot ificationEvent(DepotEditPart.java:364)
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.notifyChanged(GraphicalEditPart.java:1414)
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.fireNotification(DiagramEventBroker.java:500)
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.resourceSetChanged(DiagramEventBroker.java:395)
org.eclipse.gmf.runtime.diagram.ui.internal.DiagramEventBrok erThreadSafe.resourceSetChanged(DiagramEventBrokerThreadSafe .java:72)
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain.postcommit(DiagramEditingDomainFac tory.java:213)
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:504)
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:623)
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:415)
org.eclipse.emf.workspace.AbstractEMFOperation.undo(Abstract EMFOperation.java:360)
org.eclipse.core.commands.operations.DefaultOperationHistory .doUndo(DefaultOperationHistory.java:415)
org.eclipse.core.commands.operations.DefaultOperationHistory .undo(DefaultOperationHistory.java:1268)
org.eclipse.ui.operations.UndoActionHandler.runCommand(UndoA ctionHandler.java:78)
org.eclipse.ui.operations.OperationHistoryActionHandler$4.ru n(OperationHistoryActionHandler.java:301)
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:458)
org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:366)
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(Progress MonitorDialog.java:507)
org.eclipse.ui.internal.operations.TimeTriggeredProgressMoni torDialog.access$6(TimeTriggeredProgressMonitorDialog.java:1 )
org.eclipse.ui.internal.operations.TimeTriggeredProgressMoni torDialog$2.run(TimeTriggeredProgressMonitorDialog.java:203)
org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
org.eclipse.ui.internal.operations.TimeTriggeredProgressMoni torDialog.run(TimeTriggeredProgressMonitorDialog.java:216)
org.eclipse.ui.operations.OperationHistoryActionHandler.run( OperationHistoryActionHandler.java:316)
org.eclipse.gmf.runtime.common.ui.action.actions.global.Glob alUndoAction.doRun(GlobalUndoAction.java:245)
org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandl er.run(AbstractActionHandler.java:359)
org.eclipse.gmf.runtime.common.ui.action.ActionManager.run(A ctionManager.java:229)
org.eclipse.gmf.runtime.common.ui.action.AbstractActionHandl er.runWithEvent(AbstractActionHandler.java:377)
org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetA ction.java:230)
org.eclipse.jface.action.ActionContributionItem.handleWidget Selection(ActionContributionItem.java:583)
org.eclipse.jface.action.ActionContributionItem.access$2(Act ionContributionItem.java:500)
org.eclipse.jface.action.ActionContributionItem$5.handleEven t(ActionContributionItem.java:411)
org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3823)
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3422)
org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:113)
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:386)
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
org.eclipse.equinox.launcher.Main.run(Main.java:1236)
org.eclipse.equinox.launcher.Main.main(Main.java:1212)
|
|
|
|
Re: Changing between different figures - Undo problem [message #221480 is a reply to message #221122] |
Mon, 16 March 2009 10:16 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Hello Alex,
I tried it like this, but it doesn`t work, the red box still appears:
Object feature = notification.getFeature();
if (EditorPackage.Literals.LOCATION__NUMBER_OF_VEHICLES.equals( feature)
|| EditorPackage.Literals.LOCATION__NUMBER_OF_STATIONS.equals(f eature)
|| EditorPackage.Literals.LOCATION__NUMBER_OF_DEPOTS.equals(fea ture))
{
TransactionalEditingDomain editingDomain =
((CmseditorDiagramEditor)((DiagramEditDomain)this.getDiagram EditDomain()).getDiagramEditorPart()).getEditingDomain();
final EObject modelElement = ((View) ((EditPart)
this.getParent()).getModel()).getElement();
AbstractEMFOperation cmd = new AbstractEMFOperation(editingDomain, "my
F5 command")
{
protected IStatus doExecute(IProgressMonitor arg0, IAdaptable arg1)
throws ExecutionException
{
CmseditorEditPartFactory.myF5Command( modelElement);
return new Status(IStatus.OK, "LocationEditPart_F5", "Everything OK");
}
};
try
{
cmd.execute(null, null);
}
catch (ExecutionException e)
{
e.printStackTrace();
}
return;
}
I can`t just call cmd.execute() because there`s no such method.
Did I something wrong?
Best wishes
Julia
Alex Shatalin schrieb:
> Hello Cayla,
>
> Looks like you have to exclude diagram update command (changing the
> shape of this node) from undo process.
> Try modifying handleNotificationEvent() implementation (that part where
> you call "F5" command) to wrap everything into AbstractEMFOperation and
> execute it _without_ OperationHistory - just like:
>
> AbstractEMFOperation myOperation = ...;
> myOperation.execute();
>
> -----------------
> Alex Shatalin
>
>
|
|
|
|
Re: Changing between different figures - Undo problem [message #221503 is a reply to message #221496] |
Mon, 16 March 2009 11:41 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
>> I can`t just call cmd.execute() because there`s no such method. Did I
>> something wrong?
> See
> org.eclipse.emf.workspace.AbstractEMFOperation.execute(IProg ressMonitor
> monitor, IAdaptable info);
> So, this method present in the corresponding class - try calling it.
I already call this method:
cmd.execute(null, null);
|
|
|
Re: Changing between different figures - Undo problem [message #221563 is a reply to message #221122] |
Mon, 16 March 2009 15:00 |
Eclipse User |
|
|
|
Originally posted by: cayla_sha.gmx.net
Now (I think) I know, why this idea can`t work:
F5 is called _everytime_ when I add or delete a vehicle at a location.
But the red box appears only, when I undo the creation of the first
vehicle at a location or when I undo the removal of the last vehicle at
location - thus when I undo a operation that causes a change of the
appearance.
It must have something to do with the deletion of the old EditPart and
the creation of the new EditPart,
since I also have problems with the undo of the creation of a location
-> see "Undo problem - undo of node creation causes StackOverflowError"
but I don`t have problems when I undo the deletion of a location, hmmm...
So the problem must have something to do with the creation of the EditPart!
I already debugged the creation but I can`t see anything strange...
Just to remember: I have one node in my editor called Location. This
Location has 6 different appearances. When I create a location it has
its "standard-appearance" and when I add or remove vehicles, stations
and/or depots it changes its appearance.
Alex Shatalin schrieb:
> Hello Cayla,
>
> Looks like you have to exclude diagram update command (changing the
> shape of this node) from undo process.
> Try modifying handleNotificationEvent() implementation (that part where
> you call "F5" command) to wrap everything into AbstractEMFOperation and
> execute it _without_ OperationHistory - just like:
>
> AbstractEMFOperation myOperation = ...;
> myOperation.execute();
>
> -----------------
> Alex Shatalin
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03352 seconds