Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » providing visual feedback depending on state during connection
providing visual feedback depending on state during connection [message #896964] Fri, 20 July 2012 10:57 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 211
Registered: July 2009
Senior Member
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 #900782 is a reply to message #896964] Wed, 08 August 2012 09:08 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1527
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Henrik,

sorry for the late reply...

changing the pictogram model to influence the visual representation without
influencing the command stack and dirty state of the editor is really
tricky, so I would suggest another way:

there is a new (in Graphiti 0.9.0) ColorDecorator that you might use to
decorate your ports (usage is just as the ImageDecorators). Simply set a
flag in the hook and if it is set return the decorators in getDecorators()
of your ToolBehaviorProvider. There's an example on this in the Chess
example tool.

Michael
Re: providing visual feedback depending on state during connection [message #902198 is a reply to message #900782] Thu, 16 August 2012 06:13 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
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]

Report message to a moderator

Re: providing visual feedback depending on state during connection [message #902199 is a reply to message #902198] Thu, 16 August 2012 06:26 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
I see in chess example that is done for connections.

It would be useful if the equivalent methods canceledAttaching, .., etc, were provided for AbstractCreateFeature and not only for ICreateConnection.
Methods such as:
canceledCreation
endCreation
etc

Dou you see that coming?

thks
Re: providing visual feedback depending on state during connection [message #902204 is a reply to message #900782] Thu, 16 August 2012 06:42 Go to previous messageGo to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 211
Registered: July 2009
Senior Member
Michael,

thanks for the hint.
My highlighting works quite nice now.

The problem is only that the Border and ColorDecorator apply to the top level GA which is invisible in my case.
It's not really a problem now but it indicates possibilities for future enhancements ;-)

BTW: is it possible to use those decorators also for Connections?

-Henrik


Am 08.08.2012 15:08, schrieb Michael Wenz:
> Henrik,
>
> sorry for the late reply...
>
> changing the pictogram model to influence the visual representation without influencing the command stack and dirty state of the
> editor is really tricky, so I would suggest another way:
>
> there is a new (in Graphiti 0.9.0) ColorDecorator that you might use to decorate your ports (usage is just as the
> ImageDecorators). Simply set a flag in the hook and if it is set return the decorators in getDecorators() of your
> ToolBehaviorProvider. There's an example on this in the Chess example tool.
>
> Michael
Re: providing visual feedback depending on state during connection [message #902205 is a reply to message #902204] Thu, 16 August 2012 07:04 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
But you are able to know when mouse is over and when it is not, when creation is cancelled, and so on...?
Re: providing visual feedback depending on state during connection [message #902207 is a reply to message #902205] Thu, 16 August 2012 07:21 Go to previous messageGo to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 211
Registered: July 2009
Senior Member
I don't need the mouse position. The state call backs are completely sufficient for my case.
It's only that I would prefer more degrees of freedom in the decoration...

Am 16.08.2012 13:04, schrieb Rui Domingues:
> But you are able to know when mouse is over and when it is not, when creation is cancelled, and so on...?
Re: providing visual feedback depending on state during connection [message #902229 is a reply to message #902207] Thu, 16 August 2012 08:55 Go to previous messageGo to next message
Rui Domingues is currently offline Rui Domingues
Messages: 186
Registered: October 2010
Senior Member
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

Re: providing visual feedback depending on state during connection [message #903700 is a reply to message #902199] Mon, 20 August 2012 07:29 Go to previous messageGo to next message
Michael Wenz is currently offline Michael Wenz
Messages: 1527
Registered: July 2009
Location: Walldorf, Germany
Senior Member
There's an open enhancement request for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384271

But I cannot (yet?) promise that it will be targeted in the Eclipse Kepler
timeframe.

Michael
Re: providing visual feedback depending on state during connection [message #903714 is a reply to message #902229] Fri, 24 August 2012 03:47 Go to previous message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 211
Registered: July 2009
Senior Member
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
>
>
Previous Topic:See business object instances in the package explorer
Next Topic:Graphiti and e4 / compatibility layer
Goto Forum:
  


Current Time: Thu Apr 17 23:45:50 EDT 2014

Powered by FUDForum. Page generated in 0.02733 seconds