Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Add a listener to ViewPart title or title image?(Looking for way to add a listener (mouse or event) to view's title)
icon5.gif  Add a listener to ViewPart title or title image? [message #696402] Wed, 13 July 2011 21:58 Go to next message
Thomas Hatley is currently offline Thomas Hatley
Messages: 3
Registered: July 2009
Junior Member
Am trying to replicate an "add" tab that would appear at the end of a group of stacked Views, similar to what you'll see at the top of FireFox or IE (last tab has no text, just a 'plus sign' icon). I have several ViewParts added to an IFolderLayout, which gives a nice row of tabs, each with a title and icon. To simulate a "New View" tab, I created another ViewPart instance, with a name of "" <empty string>, and a default icon showing the 'plus sign', and added this view to the same stack. I'd like to add a listener of some sort (MouseListener or EventListener) to catch a mouse-click on this tab, and fire an Action or Handler.

My initial attempts were adding the Handler call in the view's getFocus() method, but that doesn't get triggered until the view is brought to the top of the stack...ideally I'd like to catch it before the view is brought to the top. Replicating the FF/IE behavior, the "new window" tab never actually gets displayed, it gets clicked and then moves to the right of the new tab being opened; I'd like to have that same behavior.

I've also tried adding an icon to the toolbar (which a listener can be added to), but the toolbar doesn't show on the ViewPart's tab, it is displayed to the far right, next to the minimize/Maximize buttons, and only when the View it at the front/top of the stack, which I'd like to avoid.

Here's a sketch of what I'm trying to put together (see attachments for screen shots):

 _________ _________ __________ ____
 | View 1| | View 2| | View 3 | |+ | <--------- "Add View" button  
-         -----------------------------
|                                     |
|        View 1 Contents Here         |
|                                     |



Thanks to all in advance for any thoughts/ideas/suggestions on how this might be accomplished. I've spent quite a bit of time Googling and exploring the Eclipse API & forums for something in the title area that I can attach a listener to. I'm currently on my second RCP project, and will say up front that I'm having a lot of fun and enjoying getting my hands into the inner working of Eclipse Surprised

[Updated on: Wed, 13 July 2011 21:59]

Report message to a moderator

Re: Add a listener to ViewPart title or title image? [message #696771 is a reply to message #696402] Thu, 14 July 2011 19:43 Go to previous messageGo to next message
Alfred  is currently offline Alfred
Messages: 4
Registered: June 2011
Junior Member
I'm pretty new to this stuff, too, but have you looked at Mail RCP example? It's built into New Project Wizard in the Eclipse RCP build. When you compile the project, you can see that there is a "+" button in the toolbar, which adds a view (message) each time it's pressed. You can check that code to see if it helps you. I'm not sure if that helps...

Re: Add a listener to ViewPart title or title image? [message #696815 is a reply to message #696771] Thu, 14 July 2011 21:31 Go to previous messageGo to next message
Thomas Hatley is currently offline Thomas Hatley
Messages: 3
Registered: July 2009
Junior Member
Hi Alfred - I checked the Mail application, and yes it does have a "+" button, but it's on the toolbar of the app, which appears above the ViewPart tabs, rather than on the same level. I've also tried adding the icon to the toolbar which belongs to each ViewPart in the IFolderLayout, and this effect comes close: I now have an icon on the same perceived row as the ViewPart tabs/titles, but the icon doesn't appear as a tab and is shifted over next to the minimize/maximize buttons (see attached image).

I suppose I can see if I can work with the toolbar's layout (?) and try to shift the "+" icon to the far left (up next to the tabs), and if successful perhaps create a .gif that might look similar to the tabs....

I'd still love to hear from others if they have an idea on how to attach a Listener of some sort to the titleIcon of a ViewPart.

Many thanks Alfred for your response =)
Re: Add a listener to ViewPart title or title image? [message #698061 is a reply to message #696815] Mon, 18 July 2011 17:44 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You cannot effect the tabs that contain editors or views unless you write the entire presentation. In eclipse, it's the default presentation creating TabbedStackPresentations. See org.eclipse.ui.internal.presentations.defaultpresentation.NativePresentationFactory and org.eclipse.ui.internal.presentations.util.TabbedStackPresentation

PW


Re: Add a listener to ViewPart title or title image? [message #698094 is a reply to message #698061] Mon, 18 July 2011 18:50 Go to previous message
Thomas Hatley is currently offline Thomas Hatley
Messages: 3
Registered: July 2009
Junior Member
Thanks Paul, appreciate the response. Based on your post and references (TabbedStackPresentation in particular), it doesn't look like there's a straightforward way to attach a listener to the IPresentablePart other than a PropertyChangeListener (which isn't what I'm after) without some serious heavy lifting.

Again, very useful information and thanks for your time =)

Thomas
Previous Topic:Key binding in a perspectives
Next Topic:Changing a Viewpart from a Menu item
Goto Forum:
  


Current Time: Thu Oct 02 12:45:52 GMT 2014

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

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