providing visual feedback depending on state during connection [message #896964] |
Fri, 20 July 2012 10:57  |
Eclipse User |
|
|
|
Hi,
I've tried the new feature with the connection state in eTrice.
I want to highlight ports that can be connected with the port where the connection starts.
Besides that I realized that the connection state wasn't properly implemented for dragging a connection (cf.
https://git.eclipse.org/r/6893) I'm facing further problems.
I want to turn the colors of all ports that can be connected to be shown in green.
This requires a change of the pictogram model and thus has to be done in a write transaction.
I used a RecordingCommand for this purpose.
Now when attachedToSource is called in my AbstractCreateConnectionFeature-derived class I execute this command on the command stack.
(I would have preferred not to put this on the stack but when I call execute directly on the command I receive an exception.)
This works fine, the ports turn green.
But now when the connection is created or the process of connecting is aborted (canceledAttaching/endConnecting) I want to revert
this change and show the ports in their original color.
So I do
editingDomain.getCommandStack().undo();
But this has no effect. The ports stay green. Maybe it interferes with the creation of the connection?
What would the proper way be to achieve what I want?
Thanks,
Henrik
|
|
|
|
Re: providing visual feedback depending on state during connection [message #902198 is a reply to message #900782] |
Thu, 16 August 2012 06:13   |
Eclipse User |
|
|
|
Hi.
I think this is going to against my need of visual feedback when I'm creating objects.
When I am creating an object I'm drawing some lines in diagram at the place where the object is really going to be placed. (Because I have a restrictive layout) - grid based - but I am not allowed to have "guide dashed"-lines allways in the diagram. My requirement is not to show any lines, unless the user is "creating an object"; In that situation I draw the lines at the right place. This is very tricky, but easily I could layout the lines when "canCreate" is invoked, however, undraw them when creation is cancelled or the mouse goes out of the diagram is difficult.
I got a solution with threads that is working fine (so far), that is when canCreate is not invoked after 2 seconds, one thing out of three happened ( or creation was cancelled, or mouse is out of diagram, or mouse is over diagram with no motion).In this case thread calls layout in order to "erase" the lines.
This is not ideal, but works.
Can you tell me how are you detecting that object creation (not connection) is cancelled or mouse is no longer over diagram?
Thanks. Any solution without threads (actually I use only one thread), is welcome, once I predict this is troubly. My question is how do you proceed to know when color must change, and how are you drawing and undrawing.
Thanks in advance
Rui.
[Updated on: Thu, 16 August 2012 06:34] by Moderator
|
|
|
|
|
|
|
|
|
Re: providing visual feedback depending on state during connection [message #903714 is a reply to message #902229] |
Fri, 24 August 2012 03:47  |
Eclipse User |
|
|
|
Hi Rui,
I think Michaels reply from 20.8. (news://news.eclipse.org:119/k0t73g$7ms$1@xxxxxxxxe.org) answers your question, right?
Henrik
Am 16.08.2012 14:55, schrieb Rui Domingues:
> Hi.
>
> I think there's something i'm not getting. The State callbacks you are talking about are canceledAttaching/endConnecting/.. I
> suppose, isn't it?
>
> So you would have problems if you wanted that behaviour on element creation (not connections), because there are no callbacks in
> that case. Am I right?
>
> Or you know someway of have callbacks for this case?
>
>
> Thanks in advance. I'm insisting in this question, because I don't see further way to implement this with Graphiti.
>
> Best regards
> rui
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.26082 seconds