Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How ViewPart response to some EditorPart Action(How ViewPart catch the EditorPart Action in a better design pattern)
How ViewPart response to some EditorPart Action [message #513830] Thu, 11 February 2010 12:43 Go to next message
Alex  is currently offline Alex Friend
Messages: 3
Registered: February 2010
Junior Member
Hi,

I am writing an RCP Application and new to RCP. Now I have a editor part with a Text Control..When I select text in the Text Control and right click , a pop up menu will pop up. When I push one of the menu, I want to another viewpart can respond it? Now I am using following code to achieve this:

//In Editor Part
Event drawTextEvent = new Event();
drawTextEvent.data = selectText;
handlerService.executeCommand(
"command.drawText",
drawTextEvent);

//In command handler
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IWorkbenchPage page = window.getActivePage();
GlyphLayoutView layout = (GlyphLayout)page.findView(GlyphLayout.ID);
layout.call(event.getTrigger().data);
............

I wonder if there is better way to achieve this between editor and viewpart? Because some parameter should be passed to viewpart.


Re: How ViewPart response to some EditorPart Action [message #513839 is a reply to message #513830] Thu, 11 February 2010 08:32 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

What you are doing is all API and will work fine.

One way to "communicate" between the editor and view is to have the
editor simply post its selection, and have the view react to selection
change events.

Another would be to simply move that code into your editor and call that
from your handler.

updateView() {
GlyphLayoutView layout = (GlyphLayout) getSite()
.getPage().findView(GlyphLayout.ID);
layout.call(selectedText);
}



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: How ViewPart response to some EditorPart Action [message #513841 is a reply to message #513839] Thu, 11 February 2010 13:37 Go to previous messageGo to next message
Alex  is currently offline Alex Friend
Messages: 3
Registered: February 2010
Junior Member
is the "One way to "communicate" between the editor and view is to have the
editor simply post its selection, and have the view react to selection
change events.
" means add a selection listener in the viewer and react the selection changed?

I am aim to look for a relative loose-coupled communication in the editor and viewer? Since the code I wrote is not very well-designed first my first sense and hard to transfer and refactor Smile.

Anyway, thanks a lot. I think your way is also good way and I will try it.
Re: How ViewPart response to some EditorPart Action [message #513914 is a reply to message #513841] Thu, 11 February 2010 11:24 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Alex wrote:
> is the "One way to "communicate" between the editor and view is to have the
> editor simply post its selection, and have the view react to selection
> change events.
> " means add a selection listener in the viewer and react the selection
> changed?

Yes, it's the most common way and provides a level of decoupling. See
http://www.eclipse.org/articles/Article-WorkbenchSelections/ article.html

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: How ViewPart response to some EditorPart Action [message #514005 is a reply to message #513914] Fri, 12 February 2010 03:02 Go to previous message
Alex  is currently offline Alex Friend
Messages: 3
Registered: February 2010
Junior Member
Thanks for your help . It's great for a freshmen to RCP Laughing
Previous Topic:Java Webstart problems
Next Topic:How do I find out if the content assist popup window is currently showing?
Goto Forum:
  


Current Time: Thu Apr 18 23:44:40 GMT 2024

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

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

Back to the top