Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Get in a figure event notifications from other figure(Is it possible from one figure to listen the modifications of another figure?)
Get in a figure event notifications from other figure [message #493995] Wed, 28 October 2009 16:50 Go to next message
Laura Hernández is currently offline Laura HernándezFriend
Messages: 22
Registered: September 2009
Junior Member
Hi all,

I have two types of figures placed in the same containment.

I need listen from one of these figures some graphical changes (in particular selection event or move event) of the OTHER figure.

Does anybody know if there is a way to do this?

Any idea would be very appreciated!!

Laura.
Re: Get in a figure event notifications from other figure [message #494107 is a reply to message #493995] Thu, 29 October 2009 09:04 Go to previous messageGo to next message
peter staelens is currently offline peter staelensFriend
Messages: 17
Registered: October 2009
Junior Member
Hi Laura,

I would solve it like this:
1) take the root of the tree where all your classes are connected to.
2) place an addMouseListener or take one of the functions of the EditPart classes on the figure that changes.
3) Search trough the root the figure that you want to change and the figure who had an event. You have now the two classes in your hands and should be able to implement what you describe.

hope this helps,

Peter
Re: Get in a figure event notifications from other figure [message #494168 is a reply to message #494107] Thu, 29 October 2009 13:12 Go to previous messageGo to next message
Laura Hernández is currently offline Laura HernándezFriend
Messages: 22
Registered: September 2009
Junior Member
Thanks a lot Peter!

The only problem than I have is when adding to the figure the MouseListener it works only when clicking in the border of the figure...I don't know why!!

If I click in the center of the figure it does not work Sad

The mouse listener can only be added to IFigures, I tried also FigureListener but with this I am not able to know the delta of the move action.

Any idea?

Thank you in advance.

Laura.
Re: Get in a figure event notifications from other figure [message #494312 is a reply to message #494168] Fri, 30 October 2009 08:42 Go to previous messageGo to next message
peter staelens is currently offline peter staelensFriend
Messages: 17
Registered: October 2009
Junior Member
Hi Laura,

At the bottom of your EditPart classes in de diagram project, you will find stuff as:

	public class ControlPanel extends RectangleFigure {

		public ControlPanel() {
                ....
		private void createContents() { /* <= here you have to be !*/
			
		       RectangleFigure stopIndicator0 = new RectangleFigure();


this stopIndicator0 you can for example use to catch a mouse event. I do it with a factory who gets a reference to this object. But in order to make it simple I will inline the code, and you organize it as you want:

                final RectangleFigure stopIndicator0 = new RectangleFigure();
		stopIndicator0.addMouseListener(new MouseListener.Stub()
		{
			public void mousePressed(MouseEvent me)
			{
				if(stopIndicator0.getBackgroundColor()== ColorConstants.red){
					stopIndicator0.setBackgroundColor(ColorConstants.darkGray);
				} 
				else{
					stopIndicator0.setBackgroundColor(ColorConstants.red);
				}
			}
		});

Re: Get in a figure event notifications from other figure [message #494435 is a reply to message #494312] Fri, 30 October 2009 15:54 Go to previous messageGo to next message
Laura Hernández is currently offline Laura HernándezFriend
Messages: 22
Registered: September 2009
Junior Member
Hi Peter,

I tried that but the problem persists.

i think maybe is the type of my figure.

Nevertheless I solved my problem in other way completely different...at least it works Smile

Thank you very much for your help!!

Re: Get in a figure event notifications from other figure [message #494641 is a reply to message #494435] Sun, 01 November 2009 16:41 Go to previous messageGo to next message
marco  is currently offline marco Friend
Messages: 82
Registered: September 2009
Member
hi laura

i have a problem similar to yours
please can you tell me how you solved your problem?


if you want you can write me a email

az2004@hotmail.it

thanks

marco
Re: Get in a figure event notifications from other figure [message #494681 is a reply to message #494641] Mon, 02 November 2009 07:53 Go to previous messageGo to next message
Laura Hernández is currently offline Laura HernándezFriend
Messages: 22
Registered: September 2009
Junior Member
Hi Marco,

if fact I had to detect when the user tried to move a figure inside another one.

I had installed a role policy "Drag&Drop" in the second figure and I receive this events in the this figure.

I don't know if it would suit you Smile

Best regards!

Laura.
Re: Get in a figure event notifications from other figure [message #494845 is a reply to message #494681] Mon, 02 November 2009 22:07 Go to previous messageGo to next message
marco  is currently offline marco Friend
Messages: 82
Registered: September 2009
Member
hi laura

thanks for your reply.

my problem is that I have indicated in the following post

http://www.eclipse.org/forums/index.php?t=msg&th=156872& amp;start=0&S=16d9e2f0ed4d04d463d9c4130652caa9

If you can not open it the title of the post is :

MOVE AN AFFIXED CHILD ON EDGS AND ROTATE THE FIGURE

is among the first post...

think I can solve my problem?

... think I can use a solution similar to yours?


thanks for the help
greetings marco



Re: Get in a figure event notifications from other figure [message #495138 is a reply to message #493995] Tue, 03 November 2009 21:30 Go to previous message
Alex Shatalin is currently offline Alex ShatalinFriend
Messages: 141
Registered: July 2009
Senior Member
Hello laura,

I suggest you installing listeners onto notation model objects so you'll
receive all the notifications concerning corresponding elements position/size..

-----------------
Alex Shatalin
Previous Topic:Keep a label always in the same location
Next Topic:visibility feature doesnt change
Goto Forum:
  


Current Time: Thu Apr 25 07:12:30 GMT 2024

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

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

Back to the top