Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Custom toolbar for plugin perspective
Custom toolbar for plugin perspective [message #1838519] Sat, 27 February 2021 01:16 Go to next message
Eclipse UserFriend
Hello everyone,
I am currently working on a plug-in project, in which I want to customize certain aspects of eclipse. I managed to add a perspective with some views, that get displayed fine in the runtime eclipse.
My problem is customization of the toolbar: I want to remove / rearrange some of the buttons of the "default" toolbar (org.eclipse.ui.main.toolbar), but I dont know how.
I am able to add elements to the toolbar via the org.eclipse.ui.menus extension point and adding a command in the plugin.xml (or add elements to the toolbar by using actionSets). But these get just added to the main toolbar, the default toolbar elements like 'open task' or 'search' remain.
Is there a way to remove (/hide ?) them using the plug-in project?
Or is it maybe possible to start with a entirely blank toolbar, where I just add the things I want?

To clarify this, I dont want to have any "really custom" elements in the toolbar, just things like 'run', 'debug', 'save', ... , that are already part of eclipse, so maybe the explicit definition of commands / actions isnt even necessary, since these actions are already "somewhere there" ?
I tried to manually customize the perspective in the runtime eclipse instance (Window -> Perspective -> Customize Perspective -> in the Toolbar Visibility tab (un-)checking the elements I want), which works fine and gives me the result I want. I think that such customizations are stored in "workspace/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xmi", but I dont know, how I could programatically restore them from the workbench.xmi file, to use them permanently in the plugin definition.

As a code example I can give literally an empty plug-in project with just the eclipse-own "Hello world command contribution" sample and as we see, in the runtime eclipse instance the toolbar consists of more buttons than just the "Say hello world"-button defined in the plugin.xml:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.commands">
      <category
            id="ToolbarCustom.commands.category"
            name="Sample Category">
      </category>
      <command
            categoryId="ToolbarCustom.commands.category"
            id="ToolbarCustom.commands.sampleCommand"
            name="Sample Command">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="toolbarcustom.handlers.SampleHandler"
            commandId="ToolbarCustom.commands.sampleCommand">
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="ToolbarCustom.commands.sampleCommand"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            sequence="M1+6">
      </key>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu?after=additions">
         <menu
               id="ToolbarCustom.menus.sampleMenu"
               label="Sample Menu"
               mnemonic="M">
            <command
                  commandId="ToolbarCustom.commands.sampleCommand"
                  id="ToolbarCustom.menus.sampleCommand"
                  mnemonic="S">
            </command>
         </menu>
      </menuContribution>
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
         <toolbar
               id="ToolbarCustom.toolbars.sampleToolbar">
            <command
                  commandId="ToolbarCustom.commands.sampleCommand"
                  icon="icons/sample.png"
                  id="ToolbarCustom.toolbars.sampleCommand"
                  tooltip="Say hello world">
            </command>
         </toolbar>
      </menuContribution>
   </extension>

</plugin>


I also had a look at the Eclipse 4 application model that looks like I could define my toolbar using it, however my plugin is the ui plugin of a Xtext project, so I dont know, whether the e4 solution can be integrated there easily.

Any comments/suggestions on my thoughts would be nice,
thank you
Re: Custom toolbar for plugin perspective [message #1839132 is a reply to message #1838519] Mon, 15 March 2021 13:33 Go to previous message
Thomas Barth is currently offline Thomas BarthFriend
Messages: 22
Registered: March 2021
Junior Member
Hi, I'm also fighting with the same issue for an entire day now. Any results?
Previous Topic:Plugin Development unresolved 'org.eclipse.ui'
Next Topic:JNA call hangs until OSGI exit
Goto Forum:
  


Current Time: Thu Apr 25 10:10:54 GMT 2024

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

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

Back to the top