Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Drag & drop of (text)elements?(Drag and drop, but not a connection)
Drag & drop of (text)elements? [message #1087306] Thu, 15 August 2013 08:50 Go to next message
Albert Hofkamp is currently offline Albert Hofkamp
Messages: 41
Registered: August 2009
Member
Hello,

I am looking for a way to add events to my edges (see the image)
index.php/fa/15916/0/
At the right are locations, with edges between them. At the left are events known to this automaton. The user must attach one or more events to the edges.

My idea is to use drag and drop for this (pick up an event from the left, and drag it to the edge at the right). I have looked at the Graphiti features, but the only form of drag & drop seems to be to add a connection from a context-button (as done with an edge between locations). However, I don't want to display a connection, the name of the event should just be added to a decorator of the edge.

(Ideally, "pick up" an event name from the left, move it to the edge, and let it "fall" on the edge.)

The question is, can this be done, and how?

It seems to me that I need to make create and add features for events attached to edges (that is, create and add event-references). I have not done that yet, but it seems easy to do. What I am stuck at however, is how to make this drag & drop behavior.

Is this possible, or should I do something else, eg a popup of some sort??

Re: Drag & drop of (text)elements? [message #1090762 is a reply to message #1087306] Tue, 20 August 2013 11:57 Go to previous messageGo to next message
Eclipse User
Hi Albert,

Just an idea: maybe the Move feature can be overridden to achieve this
effect? It is used with drag-and-drop.

Kind regards,
Koen


On 15/08/13 14:50, Albert Hofkamp wrote:
> Hello,
>
> I am looking for a way to add events to my edges (see the image)
>
> At the right are locations, with edges between them. At the left are events known to this automaton. The user must attach one or more events to the edges.
>
> My idea is to use drag and drop for this (pick up an event from the left, and drag it to the edge at the right). I have looked at the Graphiti features, but the only form of drag & drop seems to be to add a connection from a context-button (as done with an edge between locations). However, I don't want to display a connection, the name of the event should just be added to a decorator of the edge.
>
> (Ideally, "pick up" an event name from the left, move it to the edge, and let it "fall" on the edge.)
>
> The question is, can this be done, and how?
>
> It seems to me that I need to make create and add features for events attached to edges (that is, create and add event-references). I have not done that yet, but it seems easy to do. What I am stuck at however, is how to make this drag & drop behavior.
>
> Is this possible, or should I do something else, eg a popup of some sort??
>
>
Re: Drag & drop of (text)elements? [message #1091288 is a reply to message #1090762] Wed, 21 August 2013 05:50 Go to previous messageGo to next message
Albert Hofkamp is currently offline Albert Hofkamp
Messages: 41
Registered: August 2009
Member
I pondered about that too. Looking at the code, it might even work.

In the Graphiti framework however, I don't really expect to have to do this. They have all these clean separate features for semantically different operations where you can extend some basic functionality to get your behavior.
Then for a copy/link operation you suddenly have to use a move operation where you have to disable the location move part of the graphical elements?

So I agree with you that your suggestion may provide the visual behavior that I want.
I am however having a lot of doubts, jumping to such a somewhat hack-ish solution for such a quite common Gui operation doesn't feel like the right solution.
The question thus boils down to whether I am missing some alternative way of solving this thing, or is my feeling all wrong.

For now I opted for adding a dialog window to set the events that you want, which will be useful anyway for the cases where you need to add a lot of events.
Re: Drag & drop of (text)elements? [message #1092247 is a reply to message #1091288] Thu, 22 August 2013 10:07 Go to previous messageGo to next message
Eclipse User
Hi Albert,

While I agree it may sound a bit hack-ish at first, I don't immediately
see how the framework could distinguish a move operation from the
copy/link operation that you're looking for (except if the user would
need to press the control/shift/alt key while dragging, for example).
The user actually interacts as if he/she moves the event to the link,
with the exception that the list of events still contains the event
afterwards. In that sense, I think it truly is a special case of moving,
and extending the move feature for that is not really far-fetched.

Otherwise, you would need a custom feature, but I don't think you can
easily combine that with drag and drop.

Koen



On 21/08/13 11:50, Albert Hofkamp wrote:
> I pondered about that too. Looking at the code, it might even work.
>
> In the Graphiti framework however, I don't really expect to have to do
> this. They have all these clean separate features for semantically
> different operations where you can extend some basic functionality to
> get your behavior.
> Then for a copy/link operation you suddenly have to use a move operation
> where you have to disable the location move part of the graphical elements?
>
> So I agree with you that your suggestion may provide the visual behavior
> that I want.
> I am however having a lot of doubts, jumping to such a somewhat hack-ish
> solution for such a quite common Gui operation doesn't feel like the
> right solution.
> The question thus boils down to whether I am missing some alternative
> way of solving this thing, or is my feeling all wrong.
>
> For now I opted for adding a dialog window to set the events that you
> want, which will be useful anyway for the cases where you need to add a
> lot of events.
>
Re: Drag & drop of (text)elements? [message #1092827 is a reply to message #1092247] Fri, 23 August 2013 04:43 Go to previous messageGo to next message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi,

Not a user-expert, but I also think that using a MoveFeature is a good solution.

But how to capture the edge on which the event has to fall ? The MoveContext may not provide this information, as the same way the AddContext provides the "targetContainer" information.

My assumption is one can use the getLocationInfo of the PeService to obtain the pictogramElement on which the mouse is located.

The implementation would be:

	@Override
	public boolean canMoveShape(IMoveShapeContext context) {
		ILocationInfo info = Graphiti.getPeService().getLocationInfo(getDiagram(), context.getX(), context.getY());
		info.getShape();
		info.getPictogramElement();
		return youCondition;
	}
	@Override
	public void moveShape(IMoveShapeContext context) {
		// Your constrained move operation
	}


Am I using a sledge-hammer to crack a nut ?
Re: Drag & drop of (text)elements? [message #1095029 is a reply to message #1092827] Mon, 26 August 2013 10:22 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1577
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Nicolas,

the field targetConnection in the MoveShapeContext should contain the
connection you moved the shape onto. That should reduce the size a the
hammer needed... ;-)

Michael
Re: Drag & drop of (text)elements? [message #1095555 is a reply to message #1095029] Tue, 27 August 2013 04:00 Go to previous message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Oh god,

You're right.

I was in mind this thread where there is no either "MoveShapeContext" or "DefaultMoveShapeFeature" available.

I mixed up the both thread I'm sorry.

Thanks you for your reply,


--
Nicolas H
Previous Topic:Integration with eclipse launch fwk
Next Topic:Integration of the KIELER Framework
Goto Forum:
  


Current Time: Wed Aug 20 10:41:34 EDT 2014

Powered by FUDForum. Page generated in 0.01764 seconds