Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Put one shape above another using dnd
Put one shape above another using dnd [message #563813] Tue, 21 September 2010 16:27 Go to next message
Romain Raugi is currently offline Romain RaugiFriend
Messages: 15
Registered: July 2009
Junior Member
Hi,

I would like to prevent some ContainerShapes from being recognized as potential new containers when I do a drag n' drop, to be able to put one shape above another. This is the default behaviour of GEF I think.

Using move features' canMove(context), I can only forbid or allow the dnd gesture. But I can't indicate that the target shape is still the container, although there is another shape under the mouse.

Is it possible with the Graphiti API?
Re: Put one shape above another using dnd [message #625287 is a reply to message #563813] Wed, 22 September 2010 08:04 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi,

i am not sure of i understand your problem.
for a move, the shape under the mouse
is the target container, so dependent on the shape under the mouse the enablement of the dnd gesture should be computed. you can do this in the move feature's canMove method.

You can achieve arbitrarily strange behavior (not recommended) if you return the move feature with a changed context in your feature provider etc...

Best regards, Tim
Re: Put one shape above another using dnd [message #625448 is a reply to message #625287] Wed, 22 September 2010 08:34 Go to previous messageGo to next message
Romain Raugi is currently offline Romain RaugiFriend
Messages: 15
Registered: July 2009
Junior Member
Hi Tim,

Thanks a lot.

My need is the following, I want to have these behaviours in my editor:

- A drag & drop is enabled when the target container is a shape of type
X: dropping a shape A above a shape B (of type X) will have for effect
to put the shape A inside the shape B. Handled perfectly by Graphiti.

- A drag & drop is not allowed when the target container is a shape of
type Y: dropping a shape A above a shape B (of type Y) has for effect to
put the shape A above the shape B. I don't want to notify the user that
the drag n' drop is forbidden.

Regards,

Romain

Le 22/09/2010 10:04, Tim Kaiser a écrit :
> Hi,
>
> i am not sure of i understand your problem.
> for a move, the shape under the mouse
> is the target container, so dependent on the shape under the mouse the
> enablement of the dnd gesture should be computed. you can do this in the
> move feature's canMove method.
>
> You can achieve arbitrarily strange behavior (not recommended) if you
> return the move feature with a changed context in your feature provider
> etc...
>
> Best regards, Tim
Re: Put one shape above another using dnd [message #625845 is a reply to message #563813] Wed, 22 September 2010 10:37 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Romain,

now i understand what you intend.

You can achieve the special behavior
(move and drop on containershape of type Y without change of container for dropped shape) if you overwrite
the DefaultShapeMoveFeature as shown below.

This method normally adapts to the new container and sets the new coordinates relative to the container.

You have to change the behavior in such a way that there happens no container change and that the new coordinates are set relative to the diagram.

Clearly, you have to add a switch for the standard behavior which you want for type X (call super).

Does it help?

Best regards, Tim


type Y move behavior implementation:

@Override
protected void internalMove(IMoveShapeContext context) {
if (!getUserDecision()) {
return;
}
Shape shapeToMove = context.getShape();
PictogramElement[] currentSelection = getDiagramEditor().getSelectedPictogramElements();
ILocation relToDia = Graphiti.getLayoutService().getLocationRelativeToDiagram(con text.getTargetContainer());
int x = relToDia.getX() + context.getX();
int y = relToDia.getY() + context.getY();
if (shapeToMove.getGraphicsAlgorithm() != null) {
Graphiti.getGaService().setLocation(shapeToMove.getGraphicsA lgorithm(), x, y, avoidNegativeCoordinates());
}
// restore selection
getDiagramEditor().setPictogramElementsForSelection(currentS election);
}

Re: Put one shape above another using dnd [message #627091 is a reply to message #625845] Wed, 22 September 2010 20:42 Go to previous messageGo to next message
Romain Raugi is currently offline Romain RaugiFriend
Messages: 15
Registered: July 2009
Junior Member
Hi,

The interaction works nicely Tim, thanks a lot :)

Remains a little usability issue. The shape under the mouse is still
highlighted (what could suggest it can host the shape being dropped).

How can we disable this?

Regards,

Romain

Le 22/09/2010 12:37, Tim Kaiser a écrit :
> Hi Romain,
>
> now i understand what you intend.
>
> You can achieve the special behavior
> (move and drop on containershape of type Y without change of container
> for dropped shape) if you overwrite
> the DefaultShapeMoveFeature as shown below.
>
> This method normally adapts to the new container and sets the new
> coordinates relative to the container.
>
> You have to change the behavior in such a way that there happens no
> container change and that the new coordinates are set relative to the
> diagram.
>
> Clearly, you have to add a switch for the standard behavior which you
> want for type X (call super).
>
> Does it help?
>
> Best regards, Tim
>
>
> type Y move behavior implementation:
>
> @Override
> protected void internalMove(IMoveShapeContext context) {
> if (!getUserDecision()) {
> return;
> }
> Shape shapeToMove = context.getShape();
> PictogramElement[] currentSelection =
> getDiagramEditor().getSelectedPictogramElements();
> ILocation relToDia =
> Graphiti.getLayoutService().getLocationRelativeToDiagram(con
> text.getTargetContainer());
> int x = relToDia.getX() + context.getX();
> int y = relToDia.getY() + context.getY();
> if (shapeToMove.getGraphicsAlgorithm() != null) {
> Graphiti.getGaService().setLocation(shapeToMove.getGraphicsA lgorithm(),
> x, y, avoidNegativeCoordinates());
> }
> // restore selection
> getDiagramEditor().setPictogramElementsForSelection(currentS election);
> }
>
>
Re: Put one shape above another using dnd [message #628654 is a reply to message #563813] Thu, 23 September 2010 14:42 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Romain,

in a little example i wrote to test the behavior
and can not observe highlighting.

What kind of highlighting do you observe?
When does it appear, when does it cease to appear etc?

Best regards, Tim
Re: Put one shape above another using dnd [message #628801 is a reply to message #628654] Fri, 24 September 2010 08:10 Go to previous messageGo to next message
Romain Raugi is currently offline Romain RaugiFriend
Messages: 15
Registered: July 2009
Junior Member
Hello Tim,

I understand why you didn't notice it. I've tried using the rendering
style: PredefinedColoredAreas.getLightGrayAdaptions().

When you drop a shape A above a shape B and when the cursor is above B,
B is then highlighted (if it has this rendering style).

So, this is only a question of rendering styles.

Regards,

Romain

Le 23/09/2010 16:42, Tim Kaiser a écrit :
> Hi Romain,
>
> in a little example i wrote to test the behavior
> and can not observe highlighting.
>
> What kind of highlighting do you observe?
> When does it appear, when does it cease to appear etc?
>
> Best regards, Tim
Re: Put one shape above another using dnd [message #629217 is a reply to message #563813] Mon, 27 September 2010 13:49 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim KaiserFriend
Messages: 118
Registered: July 2009
Senior Member
Hi Romain,

i can reproduce it with a rendering style set.
It is difficult to suppress the highlighting since
this is woven into the framework rendering and interaction component.
You would have to exchange the
ShapeHighlightEditPolicy to achieve your ends.
Doing this would involve touching non-public classes of the framework
with the danger of complex side-effects.

Probably it is better to tolerate the highlighting than to
interfere with framework internals!?

If you think it is important to open up the framework wrt
edit policies, please post an enhancement request at our
bugzilla.

Best, Tim
Re: Put one shape above another using dnd [message #629419 is a reply to message #629217] Tue, 28 September 2010 08:19 Go to previous message
Romain Raugi is currently offline Romain RaugiFriend
Messages: 15
Registered: July 2009
Junior Member
Hi Tim,

It will be fine, I will not use the provided rendering styles (although
it is nice feature).

I have registered an enhancement request some time ago related to the
opening of the framework to be able to customize the editors at the GEF
level: https://bugs.eclipse.org/bugs/show_bug.cgi?id=325873

I reported it mainly for two reasons:

1- To program the Draw2D figures directly (I need this)
2- Maybe to add some custom interactions, but I have not a clear idea of
what I will need and can't do with the Graphiti API

Meanwhile, for 1), I discovered the IGraphicsAlgorithmRendererFactory
and the IGraphicsAlgorithmRenderer capabilities. I use them with
PlatformGraphicsAlgorithm notational objects (they are designed to be
used conjointly aren't they?). I've some refresh issues (subject of my
last posts) but it is a nice answer to my need.

To come back to the highlighting issue, for the moment I don't change my
Draw2D figures according to IVisualState changes so it is fine.

Thanks a lot Tim,

Regards,

Romain

Le 27/09/2010 15:49, Tim Kaiser a écrit :
> Hi Romain,
>
> i can reproduce it with a rendering style set.
> It is difficult to suppress the highlighting since
> this is woven into the framework rendering and interaction component.
> You would have to exchange the
> ShapeHighlightEditPolicy to achieve your ends.
> Doing this would involve touching non-public classes of the framework
> with the danger of complex side-effects.
>
> Probably it is better to tolerate the highlighting than to
> interfere with framework internals!?
>
> If you think it is important to open up the framework wrt edit policies,
> please post an enhancement request at our
> bugzilla.
>
> Best, Tim
>
Previous Topic:Rendering decorators for connections
Next Topic:Connection with multiple target (destinations)
Goto Forum:
  


Current Time: Fri Apr 19 23:49:02 GMT 2024

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

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

Back to the top