Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Link Constraint with Java Expression causes Exception
Link Constraint with Java Expression causes Exception [message #52760] Thu, 21 September 2006 11:33 Go to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Hello,

I want to constrain my 'SequenceFlow' links so they can only connect
elements within the same process. Since I do not know much about OCL I
created a Constraint within the Link and set Language to java. I specified
the method name in the body field and implemented the method, so it returns
true only when source and target may be connected, else false.

But when I run the editor it does not show the "forbidden" mouse cursor when
I drag the connection somewhere it may not attach to. Instead, when I drop
the connection on a forbidden node I get an ExecutionEXception, because
there seems to be some null-value long long after the constraint method has
returned the false value.

Am I doing something wrong or is this a known GMF bug?

Tobias
Re: Link Constraint with Java Expression causes Exception [message #52787 is a reply to message #52760] Thu, 21 September 2006 12:02 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Tobias,

Any 'Error Log' entry with a stack trace?

Regards,
/Radek

"tobias" <tobk@gmx.de> wrote in message
news:eetta9$ce6$1@utils.eclipse.org...
> Hello,
>
> I want to constrain my 'SequenceFlow' links so they can only connect
> elements within the same process. Since I do not know much about OCL I
> created a Constraint within the Link and set Language to java. I specified
> the method name in the body field and implemented the method, so it
> returns
> true only when source and target may be connected, else false.
>
> But when I run the editor it does not show the "forbidden" mouse cursor
> when
> I drag the connection somewhere it may not attach to. Instead, when I drop
> the connection on a forbidden node I get an ExecutionEXception, because
> there seems to be some null-value long long after the constraint method
> has
> returned the false value.
>
> Am I doing something wrong or is this a known GMF bug?
>
> Tobias
Re: Link Constraint with Java Expression causes Exception [message #52958 is a reply to message #52787] Thu, 21 September 2006 13:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Radek Dvorak wrote:

> Hi Tobias,
>
> Any 'Error Log' entry with a stack trace?

Sure.
As I said the exception occurs after the constraint-checking-method has
returned it'S false-value. To me it looked like it expected to get some
resulting model element, but got only null.

I'll write down what exactly I configured and implemented:
in the GMF map:
Link Mapping
+-Constraint (body= sequenceFlowConstraint, language= java)
In the diagram.part.VisualIDRegistry (strange place for this stuff, but the
only file the search returned...) I implemented the method marked with TODO
with some simple if-else construct.

Tobias

Ok, now here's the log:


eclipse.buildId=unknown
java.version=1.5.0_07
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86, WS=gtk, NL=de_DE
Framework arguments: -product org.eclipse.platform.ide -pdelaunch
Command-line arguments: -product org.eclipse.platform.ide
-data /home/tobias/Documents/Programme/GMF/../runtime-EclipseAppli cation
-dev
file:/home/tobias/Documents/Programme/GMF/.metadata/.plugins /org.eclipse.pde.core/Eclipse
Application/dev.properties -pdelaunch -os linux -ws gtk -arch x86

Error
Thu Sep 21 13:37:02 CEST 2006
execute

org.eclipse.core.commands.ExecutionException: While executing the operation,
an exception occurred
at
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:517)
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.ConnectionCreationT ool.handleCreateConnection(ConnectionCreationTool.java:343)
at
org.eclipse.gmf.runtime.diagram.ui.tools.ConnectionCreationT ool.handleButtonUp(ConnectionCreationTool.java:180)
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:1085)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:3164)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :2840)
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(NativeMethodAcce ssorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe thodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
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)
Caused by: org.eclipse.jface.util.Assert$AssertionFailedException: null
argument;failed to create a view
at org.eclipse.jface.util.Assert.isNotNull(Assert.java:150)
at
org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand.do ExecuteWithResult(CreateCommand.java:99)
at
org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTr ansactionalCommand.doExecute(AbstractTransactionalCommand.ja va:245)
at
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:127)
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.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)
.... 34 more
Re: Link Constraint with Java Expression causes Exception [message #53132 is a reply to message #52760] Thu, 21 September 2006 15:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Update:

I made some more tests:
- test plugin with similar structure as mine, but a lot smaller.
- link with 'constraint' (no 'link constraint'! [1]) with a very simple OCL
expression (self.source<>self.target)
- fresh gmfgen and diagram-plugin

The result:
I cannot draw reflexive links with source and target being the same (as said
in the constraint), but instead of a "forbidden" symbol before drawing the
link i get an exception afterwards just like in my main project with a java
expression constraint. the editor seems to continue work normaly even after
the exception, but well, it just doesn't feel right.

any ideas in how to avoid this? or is this exception "normal" and doesn't
mean anything?

tobias

[1] in the tutorial a link constraint is used (and seems to work fine), but
it seems to me that this type of constraint is only applicable if the link
is not an object but only a reference. when I try to use such a constraint,
the "self" object is the ocject holding the link object, making it
difficult to find an appropriate expression...
Re: Link Constraint with Java Expression causes Exception [message #53158 is a reply to message #53132] Thu, 21 September 2006 17:05 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Concerning [1]:
There is a bug fix in 1.0.1
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=148818).
This caused the source context mismatch if the a Link Mapping uses
sourceFeature, so please
use 1.0.1 maintenance build.

However, there should be no exception as the forementioned problem caused
only a wrong source end context
of Link Creation Constraints.
Just a hint, in the other post you mention that you find the constraint
method in 'diagram.part.VisualIDRegistry' class.
This class is to contain the link domain element constraint, which enables
creation of multiple link mappings for the same domain
element, while the constraint here is the matching condition.
So I think you have used the Link EClass constraint instead of Link Creation
Constraint.

/Radek

"tobias" <tobk@gmx.de> wrote in message
news:eeuab0$5ju$1@utils.eclipse.org...
> Update:
>
> I made some more tests:
> - test plugin with similar structure as mine, but a lot smaller.
> - link with 'constraint' (no 'link constraint'! [1]) with a very simple
> OCL
> expression (self.source<>self.target)
> - fresh gmfgen and diagram-plugin
>
> The result:
> I cannot draw reflexive links with source and target being the same (as
> said
> in the constraint), but instead of a "forbidden" symbol before drawing the
> link i get an exception afterwards just like in my main project with a
> java
> expression constraint. the editor seems to continue work normaly even
> after
> the exception, but well, it just doesn't feel right.
>
> any ideas in how to avoid this? or is this exception "normal" and doesn't
> mean anything?
>
> tobias
>
> [1] in the tutorial a link constraint is used (and seems to work fine),
> but
> it seems to me that this type of constraint is only applicable if the link
> is not an object but only a reference. when I try to use such a
> constraint,
> the "self" object is the ocject holding the link object, making it
> difficult to find an appropriate expression...
Re: Link Constraint with Java Expression causes Exception [message #53410 is a reply to message #53158] Fri, 22 September 2006 09:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: tobk.gmx.de

Radek Dvorak wrote:

> Concerning [1]:
> There is a bug fix in 1.0.1
> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=148818).
> This caused the source context mismatch if the a Link Mapping uses
> sourceFeature, so please
> use 1.0.1 maintenance build.

I tried to install the latest maintenance build, but the configuration
management showed an error...

However, I was able to set up an OCL constraint for what I wanted, and now
everything works fine using the OCL expression in a Link Constraint (Target
End Constraint).

By the way, is there any difference between a Source End Constraint and a
Target End Constraint, other than that 'self' and 'oppositeEnd' are
swapped? I'd guess that a source end constraint is evaluated already when
you choose the connections source, but what would be oppositeEnd in that
case?

tobias
Re: Link Constraint with Java Expression causes Exception [message #53901 is a reply to message #53410] Fri, 22 September 2006 12:57 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi tobias,

Every link mapping can have LinkConstraints with either sourceEnd or
targetEnd, eventually both elements,
containing the constraints enforced from the participating nodes
perspective.

The sourceEnd constraint represents the condition enforced by the source
node and is evaluated in the context of this node's domain element
referenced by 'self' variable. The destination node element is accessible
through the 'oppositeEnd' environment variable.
If not available, which is the case of starting the connection from the
source node while no target node has been selected yet,
the 'oppositeEnd' variable is undefined (null in java).

The targetEnd constraint is defined in the context of the target node
domain's element and 'oppositeEnd' denotes the source node element,
which is always defined here, unless
gmfgen::GenLink::incomingCreationAllowed attribute is 'true'.
If it's allowed to draw a link from the target to source, the target end may
become the source end and the corresponding target
constraint should also handle the case of 'oppositeEnd' being undefined
(just a reversed logic applies).

The following processing is applied for link creation constraints:
1) The connection is started by selecting the source node and the sourceEnd
constraint is evaluated to indicate whether the source node
element is in a state accepting this connection. The 'oppositeEnd' is
undefined at this moment.

2) The target node is selected, the sourceEnd constraint is evaluated again
in order to allow the source to accept/reject its target
available in 'oppositeEnd' variable.

3) If 2) passes, the targetEnd constraint is checked and if satisfied, the
connection is realized.

As an example let's define a constraint applying restriction on drawing the
generalization link in the well known ecore diagram editor.
Our use-case will enforce that every EClass can extend only a single EClass
element and must not extend itself or form a cycle.
The couple of constraints bellow should ensure this limitation.

sourceEnd:
eSuperTypes->isEmpty()

targetTarget:
self <> oppositeEnd and not self.eAllSuperTypes->includes(oppositeEnd)

It is worth to mention that the whole logic can be re-formulated in a single
sourceEnd constraint by differentiating the start and
completion phase by using the 'oppositeEnd' variable as following:

sourceEnd:
if oppositeEnd.oclIsUndefined() then
self.eSuperTypes->isEmpty()
else
self <> oppositeEnd and not oppositeEnd.eAllSuperTypes->includes(self)
endif


Regards,
/Radek

"tobias" <tobk@gmx.de> wrote in message
news:ef0bh5$8lv$1@utils.eclipse.org...
> Radek Dvorak wrote:
>
>> Concerning [1]:
>> There is a bug fix in 1.0.1
>> (https://bugs.eclipse.org/bugs/show_bug.cgi?id=148818).
>> This caused the source context mismatch if the a Link Mapping uses
>> sourceFeature, so please
>> use 1.0.1 maintenance build.
>
> I tried to install the latest maintenance build, but the configuration
> management showed an error...
>
> However, I was able to set up an OCL constraint for what I wanted, and now
> everything works fine using the OCL expression in a Link Constraint
> (Target
> End Constraint).
>
> By the way, is there any difference between a Source End Constraint and a
> Target End Constraint, other than that 'self' and 'oppositeEnd' are
> swapped? I'd guess that a source end constraint is evaluated already when
> you choose the connections source, but what would be oppositeEnd in that
> case?
>
> tobias
Previous Topic:Unfilled "Polygon Decoration"
Next Topic:Can't get XSD to work
Goto Forum:
  


Current Time: Sun Jun 30 13:54:04 GMT 2024

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

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

Back to the top