Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » How to implement 'Close All' and 'Close Others' (need to listen to these events, how?)
How to implement 'Close All' and 'Close Others' [message #1006732] Fri, 01 February 2013 16:13 Go to next message
Erik Vande Velde is currently offline Erik Vande VeldeFriend
Messages: 82
Registered: September 2012
Member
I'm dynamically adding detail parts to a MPartStack at runtime, and happy to see that I get a popup menu with items 'Close All'/'Close Others' for free as soon as I have two entries or more. Sadly there is no default implementation for these menu items. I would be happy to implement the required handlers myself. What listeners do I have to put in which location to handle these popup menu entries?
Re: How to implement 'Close All' and 'Close Others' [message #1007290 is a reply to message #1006732] Tue, 05 February 2013 11:46 Go to previous messageGo to next message
Eclipse UserFriend
What do you mean "no default implementation"? You click them and nothing happens? If you see the org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer#createTabMenu (either checkout the source or browse it on git.eclipse.org) you will notice that they have default behavior (closeSiblings or something similar) so if you are using the default StackRenderer you would have the closing functionality out of the box.
Re: How to implement 'Close All' and 'Close Others' [message #1007388 is a reply to message #1007290] Tue, 05 February 2013 17:21 Go to previous messageGo to next message
Vinnie Hoang is currently offline Vinnie HoangFriend
Messages: 2
Registered: September 2012
Junior Member
Conversely, I am wanting to remove the same "Close All" and "Close Others" menus that show up when I right-click on the part's tab.

I've been trying to define activities and pattern bindings to do so with no such luck.

In my plugin.xml, I have the following:

<extension
point="org.eclipse.ui.activities">
<activity
id="com.test.rcp.dataCard.activity1"
name="Disable Close Others">
</activity>
<activityPatternBinding
activityId="com.test.rcp.dataCard.activity1"
isEqualityPattern="false"
pattern="org\.eclipse\.ui/org.eclipse.ui.file.close.*">
</activityPatternBinding>
<defaultEnablement
id="com.test.rcp.dataCard.activity1">
</defaultEnablement>
</extension>

Has anyone gotten this to work before?

Re: How to implement 'Close All' and 'Close Others' [message #1007400 is a reply to message #1007388] Tue, 05 February 2013 18:14 Go to previous messageGo to next message
Eclipse UserFriend
Provide your own StackRenderer implementation which will be like 90% of the default one but make the context menu more flexible or make it disappear alltogether. Providing your own renderer is something which has been done a lot before. Check out online for tutorials.
Re: How to implement 'Close All' and 'Close Others' [message #1007401 is a reply to message #1007290] Tue, 05 February 2013 18:15 Go to previous messageGo to next message
Vinnie Hoang is currently offline Vinnie HoangFriend
Messages: 2
Registered: September 2012
Junior Member
Conversely, I am wanting to remove the same "Close All" and "Close Others" menus that show up when I right-click on the part's tab.

I've been trying to define activities and pattern bindings to do so with no such luck.

In my plugin.xml, I have the following:

<extension
point="org.eclipse.ui.activities">
<activity
id="com.test.rcp.dataCard.activity1"
name="Disable Close Others">
</activity>
<activityPatternBinding
activityId="com.test.rcp.dataCard.activity1"
isEqualityPattern="false"
pattern="org\.eclipse\.ui/org.eclipse.ui.file.close.*">
</activityPatternBinding>
<defaultEnablement
id="com.test.rcp.dataCard.activity1">
</defaultEnablement>
</extension>

Has anyone gotten this to work before?

Re: How to implement 'Close All' and 'Close Others' [message #1007403 is a reply to message #1007401] Tue, 05 February 2013 18:17 Go to previous messageGo to next message
Eclipse UserFriend
I got it the first time.
Re: How to implement 'Close All' and 'Close Others' [message #1007538 is a reply to message #1006732] Wed, 06 February 2013 11:04 Go to previous messageGo to next message
Erik Vande Velde is currently offline Erik Vande VeldeFriend
Messages: 82
Registered: September 2012
Member
Thanks Sopot! I debugged my code with the source of org.eclipse.e4.ui.workbench.renderers.swt.StackRenderer at hand, and it soon became clear that the 'closable' attribute of my detailparts were false, where i would expect the default to be 'true'. Setting it explicitly to true did the job. Our detailparts are dynamically created at runtime with a MBasicFactory.INSTANCE.createPart() call, and maybe that's the reason why they're not closable right away? In any case, the problem is solved thanks to your apt reaction ...
Re: How to implement 'Close All' and 'Close Others' [message #1007568 is a reply to message #1007538] Wed, 06 February 2013 14:11 Go to previous message
Eclipse UserFriend
Glad it worked.
Previous Topic:XWT: custom LabelProvider for dynamic row coloring
Next Topic:Variables in e4xmi
Goto Forum:
  


Current Time: Thu Mar 28 09:17:28 GMT 2024

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

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

Back to the top