Skip to main content



      Home
Home » Newcomers » Newcomers » Communication between a View and an Editor
Communication between a View and an Editor [message #251588] Fri, 14 March 2008 09:53 Go to next message
Eclipse UserFriend
Originally posted by: nospam.nospam.com

How to communicate between a View and an Editor?

My View creates an object and I want to pass that object to the Editor
when a Toolbar button of the Editor is pressed.

The View creates the objects in the background - no action required, it
doesn't have to be selected itself or anything inside the view.

I tried to make the View a ISelectionProvider and the Editor a
ISelectionListener and call:
setSelection(new StructuredSelection(theObject));
when the object is created.
But this only generates a selection event for the editor when the View is
actually selected. Just calling the setSelection method does not
immediately send the event to the editor.

All I really need is a reference to the View in the Editor... the
selection stuff is only making it difficult.
Re: Communication between a View and an Editor [message #251597 is a reply to message #251588] Fri, 14 March 2008 10:14 Go to previous message
Eclipse UserFriend
Originally posted by: nospam.nospam.com

OK nevermind, this is what I needed:
I press an editor toolbar button and the action for that button checks
what's the current object in the view.

With the selection provider it was enough to call setFocus() after
setSelection(...). That caused the View to get Focus and a selection event
was sent.

But the simpler solution is this to put this in the action for a button:

IViewReference viewReferences[] =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage().getViewReferences();
for (int i = 0; i < viewReferences.length; i++) {
if (viewReferences[i].getId().equals("my.view.id")) {
System.out.println(((RepositoryBrowser)
viewReferences[i].getView(true)).getMyObjectFromTheView);
}
}
Previous Topic:update on new linux 64 install fails
Next Topic:java.lang.nullpointerexception on OC4j standalone
Goto Forum:
  


Current Time: Sun May 11 17:58:28 EDT 2025

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

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

Back to the top