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 05:41 Go to next message
Martin  odloucký is currently offline Martin odloucký
Messages: 45
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 16:23 Go to previous messageGo to next message
André van Kouwen is currently offline André van Kouwen
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 03:00 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1066
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
Previous Topic:Dynamic Help and Infopops
Next Topic:Memory leak in TrackableComputaionExt
Goto Forum:
  


Current Time: Fri Apr 18 01:48:59 EDT 2014

Powered by FUDForum. Page generated in 0.02119 seconds