Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Part specific toolbar buttons
Part specific toolbar buttons [message #1005930] Tue, 29 January 2013 10:41 Go to next message
Martin  odloucký is currently offline Martin odlouckýFriend
Messages: 49
Registered: July 2010
Member
Hi you all,

I am growing fond of Eclipse 4 but there is not much documentation around except for some brief tutorials. Is there more thorough documentation on using the new workbench model available somewhere besides Lars Vogel's tutorials (which are totally cool) and several mostly incomplete pages on Eclipse's Wiki?

I am fighting with this issue. I would like to have an MPart which contributes its specific toolbar buttons to the main toolbar. So when the part is activated these buttons are visible and when deactivated they stop being visible. I did not figure out how to achieve this.

Thnaks for any help
Re: Part specific toolbar buttons [message #1006334 is a reply to message #1005930] Wed, 30 January 2013 21:23 Go to previous messageGo to next message
André van Kouwen is currently offline André van KouwenFriend
Messages: 2
Registered: January 2013
Junior Member
hi Martin,

may be off topic a bit but where can I find the source code of the Eclipse main UI?

can you also post a link to Lars tutorial?

Thanks

André
Re: Part specific toolbar buttons [message #1006381 is a reply to message #1006334] Thu, 31 January 2013 08:00 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Hi Martin,

I think I did something similar with menu items for the main menu of my application. But not for activation of parts. I changed the visible states after commands where executed. There are several steps to do:

1. In your plugin.xml add the extension point for org.eclipse.core.expressions.definitions and create a new definition. I was even able to use boolean for the definition:
   <extension
         point="org.eclipse.core.expressions.definitions">
      <definition
            id="debugenabled">
         <with
               variable="debugEnabled">
            <equals
                  value="true">
            </equals>
         </with>
      </definition>
   </extension>


2. In your application model add a Core Expression to your item that points to the id of your definition:
<children xsi:type="menu:HandledMenuItem" xmi:id="xxx" elementId="xxx" label="xxx" iconURI="xxx" command="xxx">
    <visibleWhen xsi:type="ui:CoreExpression" xmi:id="xxx" coreExpressionId="debugenabled"/>
</children>

With the Application Model Editor there is a field for Visible-When Expression where you need to select CoreExpression and then add the Core Expression via context menu on the item on the left side.


3. Set the value for your core expression variable to the context. As it should change at runtime I suggest to declare it modifieable:
	context.set("debugEnabled", Boolean.TRUE);
	context.declareModifiable("debugEnabled");

The only thing to determine now is where to run that code for activation/deactivation of a part. I think you need to listen to events send by the EventBroker like explained by Sopot Cela in this topic http://www.eclipse.org/forums/index.php/m/848560/ ... This way you would create an additional Addon that would put values for your core expressions to the context regarding the state of your parts.

Hope that helps,
Dirk

@André
Use a search engine of your choice to answer your questions. Wink
Just kidding:
Eclipse 4 Tutorial of Lars Vogel: http://www.vogella.com/articles/EclipseRCP/article.html
Why do you need the Eclipse Main UI sources? In fact they are delivered with the IDE usually, so you shouldn't have any issues with debugging. If you are searching with CTRL+SHIFT+T for source files, you need to enable the flag in Window -> Preferences -> Plug-In Development -> Include all plug-ins from target in Java search
Re: Part specific toolbar buttons [message #1772176 is a reply to message #1005930] Wed, 06 September 2017 11:05 Go to previous message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Remember to attach the variables to an Eclipse context that belongs to the hierarchy of contexts of the UI model otherwise things don't work out!

[Updated on: Wed, 06 September 2017 13:30]

Report message to a moderator

Previous Topic:Spring Beans accessable via IEclipseContext
Next Topic:Open DialectEditor programmatically outside of main editor area
Goto Forum:
  


Current Time: Wed Apr 24 22:02:11 GMT 2024

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

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

Back to the top