mouse location with a container drop tool [message #1398678] |
Fri, 11 July 2014 08:19  |
Eclipse User |
|
|
|
Hi,
I use a java external action to manage drag&drop (in a Container Drop tool).
In the java code, I try to retrieve the mouse location. For this I use
SiriusLayoutDataManager.INSTANCE.getData(abstractDNode);
but it always returns null.
Any idea why, see below full code ?
*****************************
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
Object diagram = parameters.get("diagram");
Object elementToLookFor = parameters.get("element");
if (diagram instanceof DNodeContainer) {
DNodeContainer dNodeContainer = (DNodeContainer) diagram;
DDiagramElement diagElt = lookForElementInContainerByEObject(dNodeContainer, elementToLookFor);
if (diagElt instanceof AbstractDNode) {
AbstractDNode abstractDNode = (AbstractDNode) diagElt;
//retrieve mouse drop location
LayoutData layoutData = SiriusLayoutDataManager.INSTANCE.getData(abstractDNode);
//set view location
View view = SiriusGMFHelper.getGmfView(abstractDNode);
Node gmfnode = (Node) view;
Bounds bounds = (Bounds) gmfnode.getLayoutConstraint();
bounds.setX(layoutData.getLocation().x);
bounds.setY(layoutData.getLocation().y);
}
return;
}
|
|
|
Re: mouse location with a container drop tool [message #1401976 is a reply to message #1398678] |
Wed, 16 July 2014 06:25   |
Eclipse User |
|
|
|
Le 11/07/2014 14:19, Benoit Ries a écrit :
> Hi,
Hi Benoit,
>
> I use a java external action to manage drag&drop (in a Container Drop
> tool).
>
> In the java code, I try to retrieve the mouse location. For this I use
> SiriusLayoutDataManager.INSTANCE.getData(abstractDNode);
>
> but it always returns null.
> Any idea why, see below full code ?
It seems that the SiriusLayoutDataManager si populated after the
execution of the VSM drop tool's tasks.
Could you report a bug on the bugzilla ?
However, I am not sure you should do this in the tool, could you precise
your need, because after the tool execution, the Sirius model will be
updated and then the GMF Canonical refresh will update the GMF Notation
model. So the gmfnode you want to modify in your tool could be deleted
during the canonical refresh. The SiriusLayoutDataManager is used during
this refresh to get some layout data for the new created views. Your
external java action suggest it might require some improvements if it is
not able to handle your case.
>
> *****************************
> public void execute(Collection<? extends EObject> selections,
> Map<String, Object> parameters) {
> Object diagram = parameters.get("diagram");
> Object elementToLookFor = parameters.get("element");
> if (diagram instanceof DNodeContainer) {
> DNodeContainer dNodeContainer = (DNodeContainer) diagram;
> DDiagramElement diagElt =
> lookForElementInContainerByEObject(dNodeContainer, elementToLookFor);
> if (diagElt instanceof AbstractDNode) {
> AbstractDNode abstractDNode = (AbstractDNode) diagElt;
> //retrieve mouse drop location
> LayoutData layoutData =
> SiriusLayoutDataManager.INSTANCE.getData(abstractDNode);
>
> //set view location
> View view = SiriusGMFHelper.getGmfView(abstractDNode);
> Node gmfnode = (Node) view;
> Bounds bounds = (Bounds) gmfnode.getLayoutConstraint();
> bounds.setX(layoutData.getLocation().x);
> bounds.setY(layoutData.getLocation().y);
>
> }
> return;
> }
Regards,
Maxime
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03939 seconds