Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Canonical Edit Policy not being called ?
Canonical Edit Policy not being called ? [message #97320] Fri, 26 January 2007 08:51 Go to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hey,

I am trying to add something to my model programmatically and have it appear
in the diagram.
So I have a Diagram, a Container and an Object lets say.

When I add a container the Diagrams CanonicalEditPolicy gets called and the
Container appears.

When I add the Object to the Container the Containers CanonicalEditPolicy
does not get called.

I currently override the handleNotificationEvent so that when the Object is
added I call
refresh on the CanonicalEditPolicy manually and this works fine.
But how come its not called automatically ?


Also I run a diagram relayout when a new object is added.
relayout runs fine until I add the code to manaully refresh the Canonical
Edit Policy.
If I do that I get the exception you can see below.
The code to relayout and manually call the CanonicalEditPolicy can also be
seen below.
Maybe if I fix the problem above then this wouldn't happen but I'd still
like to understand what is going on.

Any help greatly appreciated.

Thanks.


public void relayout()

{

ArrangeRequest arrangeRequest =

new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);

List l = getChildren();

arrangeRequest.setPartsToArrange(l);

Command arrangeCmd = getCommand(arrangeRequest);

arrangeCmd.execute();



}


public void refreshSem()

{


EditPolicyIterator i = getEditPolicyIterator();

while (i.hasNext()) {

EditPolicy policy = i.next();

if (policy instanceof CanonicalEditPolicy) {

((CanonicalEditPolicy) policy).refresh();

}

}

}



!ENTRY org.eclipse.gmf.runtime.diagram.ui 4 2 2007-01-26 12:06:34.745

!MESSAGE IRJS0007E Semantic refresh failed.

!STACK 0

java.lang.IllegalStateException: Cannot activate read/write transaction in
read-only transaction context

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.acquire(TransactionalEditingDomainImpl.java:498)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.activate(TransactionalEditingDomainImpl.java:436)

at
org.eclipse.emf.transaction.impl.TransactionImpl.start(Trans actionImpl.java:154)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.startTransaction(TransactionalEditingDomainImpl.java:352 )

at
org.eclipse.emf.workspace.AbstractEMFOperation.createTransac tion(AbstractEMFOperation.java:414)

at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:124)

at
org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy.ex ecute(ICommandProxy.java:64)

at pmulti.diagram.edit.parts.PageEditPart.relayout(PageEditPart .java:84)

at
pmulti.diagram.edit.parts.AbstractContainerEditPart.addChild Visual(AbstractContainerEditPart.java:69)

at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:197)

at
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:727)

at
org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractE ditPart.java:677)

at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh( AbstractGraphicalEditPart.java:554)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$3(GraphicalEditPart.java:1)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$3.run(GraphicalEditPart.java:746)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:258)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refresh(GraphicalEditPart.java:736)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.postProcessRefreshSemantic(CanonicalEditPolicy.java: 1147)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:109 5)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemantic(CanonicalEditPolicy.java:950)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:932)

at
pmulti.diagram.edit.parts.InputContainerEditPart.refreshSem( InputContainerEditPart.java:95)

at
pmulti.diagram.edit.parts.InputContainerEditPart.handleNotif icationEvent(InputContainerEditPart.java:65)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.notifyChanged(GraphicalEditPart.java:1217)

at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.fireNotification(DiagramEventBroker.java:347)

at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.handleElementEvent(DiagramEventBroker.java:673)

at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.resourceSetChanged(DiagramEventBroker.java:305)

at
org.eclipse.gmf.runtime.diagram.ui.internal.DiagramEventBrok erThreadSafe.resourceSetChanged(DiagramEventBrokerThreadSafe .java:72)

at
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain.postcommit(DiagramEditingDomainFac tory.java:193)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:470)

at
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:474)

at
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:330)

at
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain.postcommit(DiagramEditingDomainFac tory.java:199)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:470)

at
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:474)

at
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:330)

at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)

at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:400)

at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:129)

at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:400)

at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:129)

at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)

at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:206)

at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:169)

at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:156)

at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTo ol.java:388)

at
org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(Abs tractTool.java:400)

at
org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.perfor mCreation(CreationTool.java:133)

at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:178)

at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1053)

at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:259)

at
org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouse Released(DomainEventDispatcher.java:374)

at
org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(Li ghtweightSystem.java:538)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:137)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1914)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)

at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:419)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)

at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:95)

at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)

at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)

at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)

at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)

at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)

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.core.launcher.Main.invokeFramework(Main.java:336 )

at org.eclipse.core.launcher.Main.basicRun(Main.java:280)

at org.eclipse.core.launcher.Main.run(Main.java:977)

at org.eclipse.core.launcher.Main.main(Main.java:952)
Re: Canonical Edit Policy not being called ? [message #97987 is a reply to message #97320] Mon, 29 January 2007 08:09 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alan,

CanonicalEditPolicy.activate() is responsible for adding a norification
listener to the underlying semantic element (addListenerFilter(SEMANTIC_FILTER_ID,
this, semanticHost);). So, I suggest you to debug this code to see why corresponding
notification will not be called on adding new element to the model (put a
breakpoint into CanonicalEditPolicy.notifyChanged()).
Concerning relayouting code - looks like the reason of the problem is:
"Cannot activate read/write transaction in read-only transaction context"
- you have to call layout code inside write transaction. This code will fail
if layouting procedure change any positions of the diagram elements AFAIU.
This could be the reason why this code works correctly if child element was
not added onto the diagram - in this case layout will not change anything.

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #98291 is a reply to message #97987] Mon, 29 January 2007 11:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Thanks for that....I will debug that.

As for the write transaction...what you are saying makes sense....how do I
go about creating a write transaction ?
I haven't had much experience here.

Thanks

"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e6f6678c911c64165d824@news.eclipse.org...
> Hello Alan,
>
> CanonicalEditPolicy.activate() is responsible for adding a norification
> listener to the underlying semantic element
> (addListenerFilter(SEMANTIC_FILTER_ID, this, semanticHost);). So, I
> suggest you to debug this code to see why corresponding notification will
> not be called on adding new element to the model (put a breakpoint into
> CanonicalEditPolicy.notifyChanged()). Concerning relayouting code - looks
> like the reason of the problem is: "Cannot activate read/write transaction
> in read-only transaction context" - you have to call layout code inside
> write transaction. This code will fail if layouting procedure change any
> positions of the diagram elements AFAIU. This could be the reason why this
> code works correctly if child element was not added onto the diagram - in
> this case layout will not change anything.
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #98335 is a reply to message #98291] Mon, 29 January 2007 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alan,

> go about creating a write transaction ?
You can subclass org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand,
create an instance of it and run .execute() method.

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #98491 is a reply to message #98335] Tue, 30 January 2007 03:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hi Alex,

I tried as you suggested below but I still got the same error message.
I have attached my code below and perhaps you can have a look and see if I
am doing something wrong ?

Thanks,
Alan.


public void relayout()

{

MyCommand myC = new MyCommand(getEditingDomain(),null,null);

try {

myC.execute(null, null);

} catch (ExecutionException e) {

e.printStackTrace();

}

}


class MyCommand extends AbstractTransactionalCommand

{

public MyCommand(TransactionalEditingDomain domain,

String label, List affectedFiles) {

super(domain, label, null, affectedFiles);

}



@Override

protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {

// TODO Auto-generated method stub

ArrangeRequest arrangeRequest =

new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);

List l = getChildren();

arrangeRequest.setPartsToArrange(l);

Command arrangeCmd = getCommand(arrangeRequest);

arrangeCmd.execute();

return null;

}


}





!ENTRY org.eclipse.gmf.runtime.diagram.ui 4 2 2007-01-30 08:44:32.646

!MESSAGE IRJS0007E Semantic refresh failed.

!STACK 0

java.lang.IllegalStateException: Cannot activate read/write transaction in
read-only transaction context

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.acquire(TransactionalEditingDomainImpl.java:498)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.activate(TransactionalEditingDomainImpl.java:436)

at
org.eclipse.emf.transaction.impl.TransactionImpl.start(Trans actionImpl.java:154)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.startTransaction(TransactionalEditingDomainImpl.java:352 )

at
org.eclipse.emf.workspace.AbstractEMFOperation.createTransac tion(AbstractEMFOperation.java:414)

at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:124)

at pmulti.diagram.edit.parts.PageEditPart.relayout(PageEditPart .java:110)

at
pmulti.diagram.edit.parts.AbstractContainerEditPart.addChild Visual(AbstractContainerEditPart.java:69)

at
org.eclipse.gef.editparts.AbstractEditPart.addChild(Abstract EditPart.java:197)

at
org.eclipse.gef.editparts.AbstractEditPart.refreshChildren(A bstractEditPart.java:727)

at
org.eclipse.gef.editparts.AbstractEditPart.refresh(AbstractE ditPart.java:677)

at
org.eclipse.gef.editparts.AbstractGraphicalEditPart.refresh( AbstractGraphicalEditPart.java:554)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.access$3(GraphicalEditPart.java:1)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt$3.run(GraphicalEditPart.java:746)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:258)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.refresh(GraphicalEditPart.java:736)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.postProcessRefreshSemantic(CanonicalEditPolicy.java: 1147)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemanticChildren(CanonicalEditPolicy.java:109 5)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refreshSemantic(CanonicalEditPolicy.java:950)

at
org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEdi tPolicy.refresh(CanonicalEditPolicy.java:932)

at
pmulti.diagram.edit.parts.InputContainerEditPart.refreshSem( InputContainerEditPart.java:95)

at
pmulti.diagram.edit.parts.InputContainerEditPart.handleNotif icationEvent(InputContainerEditPart.java:65)

at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.notifyChanged(GraphicalEditPart.java:1217)

at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.fireNotification(DiagramEventBroker.java:347)

at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.handleElementEvent(DiagramEventBroker.java:673)

at
org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBr oker.resourceSetChanged(DiagramEventBroker.java:305)

at
org.eclipse.gmf.runtime.diagram.ui.internal.DiagramEventBrok erThreadSafe.resourceSetChanged(DiagramEventBrokerThreadSafe .java:72)

at
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain.postcommit(DiagramEditingDomainFac tory.java:193)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:470)

at
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:474)

at
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:330)

at
org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain.postcommit(DiagramEditingDomainFac tory.java:199)

at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.deactivate(TransactionalEditingDomainImpl.java:470)

at
org.eclipse.emf.transaction.impl.TransactionImpl.close(Trans actionImpl.java:474)

at
org.eclipse.emf.transaction.impl.TransactionImpl.commit(Tran sactionImpl.java:330)

at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:130)

at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:400)

at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:129)

at
org.eclipse.gmf.runtime.common.core.command.CompositeCommand .doExecuteWithResult(CompositeCommand.java:400)

at
org.eclipse.gmf.runtime.common.core.command.AbstractCommand. execute(AbstractCommand.java:129)

at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)

at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:206)

at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:169)

at
org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack .execute(DiagramCommandStack.java:156)

at org.eclipse.gef.tools.AbstractTool.executeCommand(AbstractTo ol.java:388)

at
org.eclipse.gef.tools.AbstractTool.executeCurrentCommand(Abs tractTool.java:400)

at
org.eclipse.gmf.runtime.diagram.ui.tools.CreationTool.perfor mCreation(CreationTool.java:133)

at org.eclipse.gef.tools.CreationTool.handleButtonUp(CreationTo ol.java:178)

at org.eclipse.gef.tools.AbstractTool.mouseUp(AbstractTool.java :1053)

at org.eclipse.gef.EditDomain.mouseUp(EditDomain.java:259)

at
org.eclipse.gef.ui.parts.DomainEventDispatcher.dispatchMouse Released(DomainEventDispatcher.java:374)

at
org.eclipse.draw2d.LightweightSystem$EventHandler.mouseUp(Li ghtweightSystem.java:538)

at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:137)

at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :66)

at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)

at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3348)

at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2968)

at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:1914)

at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)

at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:419)

at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)

at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplicatio n.java:95)

at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:78)

at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)

at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)

at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)

at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)

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.core.launcher.Main.invokeFramework(Main.java:336 )

at org.eclipse.core.launcher.Main.basicRun(Main.java:280)

at org.eclipse.core.launcher.Main.run(Main.java:977)

at org.eclipse.core.launcher.Main.main(Main.java:952)










"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e6f6ad8c911f5a7a0d34a@news.eclipse.org...
> Hello Alan,
>
>> go about creating a write transaction ?
> You can subclass
> org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand,
> create an instance of it and run .execute() method.
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #98561 is a reply to message #98335] Tue, 30 January 2007 04:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hi Alex,

Just debugged notifyChanged on CanonicalEditPolicy there and it seems that
shouldHandleNotification
is returning false.
I could override it in my EditPolicy subclass something liek below and it
works but I don't understand why I have to do this at all ?
What I put below does work.
I have also attached the orginal method below. Is it normal to have to
override this method ?

Thanks.

protected boolean shouldHandleNotificationEvent(Notification event) {

if(event.getEventType() == Notification.SET

&& event.getFeature() instanceof EReferenceImpl)

{

return true;

}

return super.shouldHandleNotificationEvent(event);

}





protected boolean shouldHandleNotificationEvent(Notification event) {

if ( NotationPackage.eINSTANCE.getDrawerStyle_Collapsed() ==
event.getFeature() ||

NotationPackage.eINSTANCE.getCanonicalStyle_Canonical() ==
event.getFeature() ||

NotationPackage.eINSTANCE.getView_Visible() == event.getFeature() ||

NotationPackage.eINSTANCE.getView_PersistedChildren() == event.getFeature())
{

return true;

}


Object element = event.getNotifier();

return (element instanceof EObject

&& !(element instanceof View)

&& (NotificationUtil.isElementAddedToSlot(event)

|| NotificationUtil.isElementRemovedFromSlot(event)));

}


"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e6f6ad8c911f5a7a0d34a@news.eclipse.org...
> Hello Alan,
>
>> go about creating a write transaction ?
> You can subclass
> org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand,
> create an instance of it and run .execute() method.
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #98674 is a reply to message #98491] Tue, 30 January 2007 07:08 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alan,

> public MyCommand(TransactionalEditingDomain domain, String label, List
affectedFiles) {

Looks like you have to specify non-null list of affectedFiles to get rid
of this problem..

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #98702 is a reply to message #98561] Tue, 30 January 2007 07:26 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alan,

Original method contains the following line:

return (element instanceof EObject && !(element instanceof View) && (NotificationUtil.isElementAddedToSlot(event)
|| NotificationUtil.isElementRemovedFromSlot(event)));

NotificationUtil.isElementAddedToSlot(event) looks like:

return notification.getEventType() == Notification.ADD || notification.getEventType()
== Notification.ADD_MANY;

AFAIU in your situation notification.getEventType() == Notification.SET.
AFAIK, this means that you are modelling child element with multiplicity
(lower/upper bound in EMF) = 0..1 i.e. container could contains not more
then 1 child element of this type.. If this is correct description of your
situation, then you can modify this method in accordance and file a bugzilla
entry for GMF runtime component asking to fix CanonicalEditPolicy.

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #98732 is a reply to message #98674] Tue, 30 January 2007 07:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hi Alex,

Updated to pass in the diagrams list of children as the affected files.
Didn't change anything.
Then debugged and saw that in the case of a SemanticCreateCommand the
affectedFiles is an actual
list of files on the file system so I was way off it seems.
How do I get this list from the EditPart which is creating the Command is
the question because I can't see a way thus far ?

Thanks for all your help so far.

Alan.


"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e6f71c8c91286e28d83c4@news.eclipse.org...
> Hello Alan,
>
>> public MyCommand(TransactionalEditingDomain domain, String label, List
> affectedFiles) {
>
> Looks like you have to specify non-null list of affectedFiles to get rid
> of this problem..
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #98943 is a reply to message #98732] Tue, 30 January 2007 09:59 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alan,

WorkspaceSynchronizer.getFile(((View) getModel()).eResource()) could be used
to get IFile for the diagram. You can call ((View) getModel()).eResource().getResourceSet().getResources()
to get all the resources currently loaded into ResourceSet associated with
diagram editor.

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #99002 is a reply to message #98943] Tue, 30 January 2007 10:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hi Alex,

Sorry to keep bothering you on this one but I used your code below to return
the IFiles in question.
Put them in as the affected files list but I'm still getting the same
exception.

Any other ideas ?

Thanks.

"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e6f7518c9129ec60bcc57@news.eclipse.org...
> Hello Alan,
>
> WorkspaceSynchronizer.getFile(((View) getModel()).eResource()) could be
> used to get IFile for the diagram. You can call ((View)
> getModel()).eResource().getResourceSet().getResources() to get all the
> resources currently loaded into ResourceSet associated with diagram
> editor.
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #99030 is a reply to message #98702] Tue, 30 January 2007 11:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

You're spot on Alex.

The relationship is 0..1
If I override the method and do the following in my subclass then it works.
I just added a check for isSlotModified...which checks for a SET.

I guess what you are saying is that this is a bug as it should generate the
correct code.
I'm just a bit worried that I am making a stupid mistake somewhere due to
lack of knowledge that
is causing this.


protected boolean shouldHandleNotificationEvent(Notification event) {

if(super.shouldHandleNotificationEvent(event))

return true;

Object element = event.getNotifier();

return (element instanceof EObject

&& !(element instanceof View)

&& (NotificationUtil.isElementAddedToSlot(event)

|| NotificationUtil.isElementRemovedFromSlot(event))

|| NotificationUtil.isSlotModified(event));

}

"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e6f71f8c9128955b30479@news.eclipse.org...
> Hello Alan,
>
> Original method contains the following line:
>
> return (element instanceof EObject && !(element instanceof View) &&
> (NotificationUtil.isElementAddedToSlot(event) ||
> NotificationUtil.isElementRemovedFromSlot(event)));
>
> NotificationUtil.isElementAddedToSlot(event) looks like:
>
> return notification.getEventType() == Notification.ADD ||
> notification.getEventType() == Notification.ADD_MANY;
>
> AFAIU in your situation notification.getEventType() == Notification.SET.
> AFAIK, this means that you are modelling child element with multiplicity
> (lower/upper bound in EMF) = 0..1 i.e. container could contains not more
> then 1 child element of this type.. If this is correct description of your
> situation, then you can modify this method in accordance and file a
> bugzilla entry for GMF runtime component asking to fix
> CanonicalEditPolicy.
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #99060 is a reply to message #99030] Tue, 30 January 2007 11:38 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alan,

> The relationship is 0..1
> If I override the method and do the following in my subclass then it
> works.
So, solution for now is to modify this method manually and submitt request
for a runtim team to correct CanonicalEditPolicy.

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #99075 is a reply to message #98943] Tue, 30 January 2007 11:38 Go to previous messageGo to next message
Eclipse UserFriend
Hello Alex,

> WorkspaceSynchronizer.getFile(((View) getModel()).eResource()) could
> be used to get IFile for the diagram. You can call ((View)
> getModel()).eResource().getResourceSet().getResources() to get all the
> resources currently loaded into ResourceSet associated with diagram
> editor.
No ideas... Can you start a new thread describing this problem to let somebody
from the runtime team answer this question?

-----------------
Alex Shatalin
Re: Canonical Edit Policy not being called ? [message #99238 is a reply to message #99060] Tue, 30 January 2007 16:57 Go to previous messageGo to next message
Eclipse UserFriend
Alex ;
I agree this is a Runtime bug; the canonical edit policy should handle
set events on single Structural features.
I hope to be able to deliver the fix by the end of this week

Thank you for pointing this out


Alex Shatalin wrote:
> Hello Alan,
>
>> The relationship is 0..1
>> If I override the method and do the following in my subclass then it
>> works.
> So, solution for now is to modify this method manually and submitt
> request for a runtim team to correct CanonicalEditPolicy.
>
> -----------------
> Alex Shatalin
>
>
Re: Canonical Edit Policy not being called ? [message #99318 is a reply to message #99060] Tue, 30 January 2007 18:21 Go to previous message
Eclipse UserFriend
Hi ;
One more point; if we just modify the code to handle Set events as well
in the base class this will cause a performance regression, or let me
rephrase this it will expose another problem in the code that will cause
performance drop.

The problem is that the canonical edit policy does not check the
feature it just check event type, but the semantic element had many
feature, not all of them are important to teh canonical edit policy
actually in many case the canonical edit policy just care about one
EStructural feature.

Any, way for now it might be an OK workaround but i would suggest
adding one extra check so the code will look like that

return (element instanceof EObject

&& !(element instanceof View)

&& MyPackage.Literals.THE_FEATURE_I_CARE_ABOUT.equals(feature)

&& (NotificationUtil.isElementAddedToSlot(event)


|| NotificationUtil.isElementRemovedFromSlot(event))

|| NotificationUtil.isSlotModified(event));

}


where MyPackage is the semantic model package


I'm are working on fixing the issue GMF runtime




Alex Shatalin wrote:
> Hello Alan,
>
>> The relationship is 0..1
>> If I override the method and do the following in my subclass then it
>> works.
> So, solution for now is to modify this method manually and submitt
> request for a runtim team to correct CanonicalEditPolicy.
>
> -----------------
> Alex Shatalin
>
>
Previous Topic:create children automatically works in EMF editor but not using GMF editor
Next Topic:Change dynamicaly Figure for Link or Node
Goto Forum:
  


Current Time: Sat May 10 02:48:28 EDT 2025

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

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

Back to the top