Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Selection Problem when two GEF editor instances are running
Selection Problem when two GEF editor instances are running [message #212257] Mon, 20 March 2006 15:54
John Bradley is currently offline John BradleyFriend
Messages: 14
Registered: July 2009
Junior Member
My GEF editor is having problems with selection when I have two instances
of it running. The problem arises when I switch from one instance of the
editor to the other and click on a GEF object contained in the 2nd editor
to select it. The object gets its marquee around it -- so GEF seems to
know about the selection -- but the Delete action, for example, may not be
told about it. Often, in these situations Delete is not available in the
menu bar, even though there is a Delete action in my code that works in
other situations.

It is, of course, probably something that I have missed out in setting up
the editor. To try to get some clues I added code for testing to override
the "selectionChanged" method from GEF's GraphicalEditor to see if I could
see what was happening:
------------------------------------------------------------
(from my Editor):

private static int count = 0;

public void selectionChanged(IWorkbenchPart part, ISelection selection){
count++;
System.out.println("====="+count+"\nActiveEditor: "+
getSite().getPage().getActiveEditor().getTitle()+
", this: "+this.getTitle()+", part: "+part.getTitle());
System.out.println("selectionChanged: "+part.getTitle()+", selection:
"+selection);
super.selectionChanged(part, selection);
}
------------------------------------------------------------

When I switched the "selectionChanged" object was invoked as I expected.
However, the console output from this would often show that the passed in
"part" and "this" were not the same thing. "part" always seemed to match
the activeEditor, but "this" was often the previous editor instance.
typical output from my "selectionChanged" would say:
------------------------------------------------------------
=====12
ActiveEditor: Vico Frontispiece, this: OCVE: Bar view, part: Vico
Frontispiece
selectionChanged: Vico Frontispiece, selection: [ImageLinkableObjectPart(
LinkableObject: rect:98,-17,140,18(67) )]
------------------------------------------------------------

It seemed to me that although the editor instance for "Vico Frontispiece"
as the active editor (and, indeed, the owner of the selected
"LinkableObject", that the instance for "OCVE: Bar view" was being asked
to handle it.

This would mean, in turn, that when the super.selectionChanged method was
invoked:
------------------------------------------------------------
(from org.eclipse.gef.ui.parts.GraphicalEditor)

public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// If not the active editor, ignore selection changed.
if (this.equals(getSite().getPage().getActiveEditor()))
updateActions(selectionActions);
}

------------------------------------------------------------
"this" would not, indeed, not match the active editor, and the
updateActions did not take place.

Clearly there is a synchonization problem between the instances of my
editor. Any thoughts on what I am doing wrong??

Thanks, in advance...
Previous Topic:Capturing drawing image WITHOUT showing it on screen
Next Topic:Is it possible to build stand alone application with GEF?
Goto Forum:
  


Current Time: Sat Jan 18 08:33:47 GMT 2025

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

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

Back to the top