I am trying to update a RCP Eclipse 3 application to Eclipse 4.5 target platform. There are some differences depending on the compatibility layer.
One difference is the order of items in the toolbar in the main menu.
Old version:
New version:
The red marked icons are added with an ActionBarAdvisor, the other icons are added in the plugin.xml as toolbar commands.
Why does the order change? Do I need to add the toolbar items programmatically?
UPDATE:
If I use the option -clearPersistedState the toolbar are ordered like the in the old version. Removing the flag again creates the toolbar shown in the new version screenshot.
I have found the solution after some digging in various issues in the Eclipse Bugtracker.
In the method fillCoolBar(ICoolBarManager coolBar) add the toolbar items to an instance of ToolbarManager and then add it as ToolBarContributionItem with ID toolbar:org.eclipse.ui.main.toolbar
to the coolbar:
#Override
protected void fillCoolBar(ICoolBarManager coolBar)
{
IToolBarManager manager = new ToolBarManager(SWT.FLAT);
manager.add(action1);
...
coolBar.add(new ToolBarContributionItem(manager, "toolbar:org.eclipse.ui.main.toolbar"));
}
In the plugin.xml add the toolbars to a menuContribution with the same ID toolbar:org.eclipse.ui.main.toolbar. This causes the other toolbars to be added after the coolbar.
I had the same issue. When workspace is just created, toolbar is in the right order, on the next launch my button added by ActionBarAdvisor are on the right.
Your option -clearPersistedState worked for me. I'm interested to know the origin of this problem if anyone has the information
Related
JMSToolBox is an eclipse-rcp v4.5.2 based application.
I tried to upgraded to eclipse v4.6.0 but found a problem with popups menu as follows:
A part is defined in the e4 model as a Part Descriptor (PD). A popup menu is defined inside that PD
On a certain action, the PD descriptor is instanciated and the part is added and displayed in a Part Stack. The body of this part is a TabFolder with multiple tabs corresponding to a JMS Q browsed. Each tab body is basically composed of a TableViewer/Table to display JMS messages.
Each time a new tab is created, a new TableViewer/Table is created and the popupmenu is registered on the Table of the TableViewer with the following line of code:
menuService.registerContextMenu(table,<id of the popup menu in the part>);
This works perfectly with eclipse v4.5.2 (Mars) but not with v4.6.0 (Neon) !
With neon, the popup is working only for the first tab: the context menu is visible and #CanExecute methods associated to the handlers/commands of the menu items are called . For subsequent tabs created, no popup is displayed and #CanExecute methods for the menu items are not called
If I register a different menu with a different Id (previously added to the PD) for each tab, it works! So I suspect this may be due to the fact that a menu with the same element id is added to multiple TableViever/Table even if it is coming from a different instance of a PD...
Is it a bug in neon? a regression? or do I benefit of a bug in mars that makes the application is working Ok with this version?
For now I have to downgrade (or not upgrade) to eclipse v4.5.2..
For reference, I pushed some code to correct the problem. It will be in eclipse v4.6.1+ bug #496695
How do I remove the "Quick Access" text entry from Juno's CDT toolbar? I never use it and it consumes valuable space on my laptop screen.
This bug Make "Quick access" optional and hidden by default covers it. It looks like it is not currently possible, I suggest you add your interest to the bug.
I looked for an answer to this question because Quick Access took a full row in the toolbar. Instead of removing it (Which requires too much hacking for my taste), I just removed a few toolbar buttons that I didn't use anyway, and the Quick Access shifted up among the rest of the buttons taking only an acceptable amount of space.
There is really no need for that many buttons for any one perspective. They should fit unless your screen is tiny. Customise this in Window -> Customize Prespective...
Here is a quick hack which doesn't require any plugin installation, instead you just need to add a few lines to your current layout's CSS file. Works perfectly for me in v4.2.2
Navigate to <ECLIPSE_HOME>/plugins/org.eclipse.platform_<VERSION>/css then open up the CSS file of whichever layout you are using, e.g. mine was e4_default.css. Now append the following snippet to the file:
#SearchField {
visibility:hidden;
}
Now just restart Eclipse and the box is gone.
*Edit
It appears that the layout file e4_basestyle.css is used universally, regardless of your current layout. Thus you should be able to add the above snippet to that file and this fix will be persistent, even if you change layouts.
In Luna this has been fixed.
You can just right click on Quick Access toolbar and click hide to hide it. Refer last few comments in https://bugs.eclipse.org/bugs/show_bug.cgi?id=362420
A solution inspired from :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319991
(With eclipse Juno 4.2) Just add this piece of code to your ApplicationWorkbenchWindowAdvisor class and call the method from preWindowOpen().
private void hideQuickAccess() {
UIJob job = new UIJob("hide quick access") {
#Override
public IStatus runInUIThread(IProgressMonitor monitor) {
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
if (window instanceof WorkbenchWindow) {
MTrimBar topTrim = ((WorkbenchWindow) window).getTopTrim();
for (MTrimElement element : topTrim.getChildren()) {
if ("SearchField".equals(element.getElementId())) {
((Control) element.getWidget()).dispose();
break;
}
}
}
return Status.OK_STATUS;
}
};
job.schedule();
It might not work unless changing the accessibility rule of the org.eclipse.e4.ui.model.workbench.source_0.10.1.v20120523-1955.jar.
To change this option, go to the Java build Path menu, find the jar, expand it and the option will appear.
NB: I'm not sure about the entailment of this last change, it could be 'not clean'.
Check out this plugin: https://github.com/atlanto/eclipse-4.x-filler#hide-quick-access-plug-in
Works with Eclipse Kepler release.
This plug-in adds a functionality to hide/show Quick Access textbox in the main toolbar.
Window ☞ Hide Quick Access
Solution for Version: Oxygen Release (4.7.0):
Save the icons you are constantly using by dragging them off the "Toolbar" e.g. left/right/under to the Editor.
Then toggle: Window > Appearance > Hide/Show Toolbar
Done. :)
Type "toggle toolbar" in the quick access window (yes, that very thing that annoys us) and it'll be gone. C.f.
I am trying to remove "project" menu from menubar dynamically, means using code. Please help me out. It will be really helpful if someone can provide the exact code.
If you are writing an RCP application you can control what goes into the main menu. If you are adding plugins that you didn't write yourself and they are using extension points to contribute to the main menu, you can use Activities/Capabilities to remove them.
You cannot remove things from the main menu programmatically, unless your code contributed it.
Basically, I have an eclipse plug-in which, among other things, adds three tabs to the Properties View, by using the extension points provided by eclipse (org.eclipse.ui.views.properties.tabbed.propertyContributor, org.eclipse.ui.views.properties.tabbed.propertyTabs and org.eclipse.ui.views.properties.tabbed.propertySections).
I am creating a plug-in to add a new tab (and some different properties) (see image).
Can you please give me some indications on how to do this, considering that there are no extension points offered by this plug-in for this. Is it possible to create a new tab by using the extension points provided by eclipse (mentioned above) in such a way that my tab appears under the three already added?
(I am pretty new in the plug-in area... all the tutorials I found showed how to create some tabs from scratch, where there is nothing added in the Properties View already).
Many thanks!
Here is the solution I found so far (I still need to explore it a bit more - I might be able to add some more details):
I created a fragment - the trick with the fragment is to either set the "host plugin" the RCP plugin or, if you set the "host plugin" a different plugin than the RCP, but which is in the Dependencies list of the RCP, you have to export the product first; don't forget to include the fragment in the Dependencies list of the product.
I extended the plugin org.eclipse.ui.views.properties.tabbed.propertyTabs and set the same contributorId as in the original plugin (the one with the 3 tabs) and created my new tab ("My Tab" in the image)
I created the sections I needed for this tab, again setting the same contributorId
I am using eclipse 3.6. I created one sample plugin application. It is neither a eclipse rcp nor workbench. Now when I run the eclipse I want that plugin also to be loaded. But I dont want to use IStartUp. Because what I have found out is
IStartup will be called after the workbench is loaded. I want to refresh some menu. So Is there any way to activate my plugin while the eclipse loaded?
I tried to use Bundle Activation policy. But that is also not activating my Activator class. I just put one System.out. println("Inside start()"). So that is not called. Now can I make it activate my activator?
EDIT:
what my exact requirement is, I have created one workbench application.It is not eclipse rcp application. Now I want to remove the following menu and menu items from the eclipse before the eclipe is loaded.
1. File Menu
2.) Search Menu
3.)Run Menu
4.)Help->search,Dynamic Help,Key assist,Tips and trick,Report Bug,Cheat Sheet.
These menus are inbuilt menu of eclipse. So that is the reason I have to do in this way.
So I already implemented by using startup extension point. But the early startup is called after the eclipse is started.So I need to do some refreshment on the workbench.Then only the menu item will get removed.So I thought I need startup extension point will not satisfy my requirement as it doesnot refresh the workbench.I need to activate the my plugin and refresh the workbench before it is loaded.
Thanks
Bhanu
You can set the needed start level for your plugin using touch point instruction.
You are just a plugin that expects to run in the Eclipse IDE?
Then the answer is, you cannot do what you want.
If you start before the workbench has finished initializing, most of the services that could be used won't work: The workbench itself, menu service, command service, etc.
For most plugins in eclipse, the plugin.xml should be used to add menus, views, editors, etc to eclipse. When necessary, the framework will instantiate them.
org.eclipse.ui.IStartup is available and as you mentioned it will be called after the workbench has been initialized, but before any windows have been shown. It's not to be used lightly, and not by plugins contributing to the UI as it allows all extension from that plugin to be loaded.
EDIT:
If you are an RCP app, you control the main menu. As an RCP app, you have access to the ActionBarAdvisor, WorkbenchAdvisor, WorkbenchWindowAdvisor, which all have lifecycle methods.
If you are an an eclipse plugin, you can add to the main menu ... you cannot easily remove from the main menu. This is by design. Start levels and org.eclipse.ui.startup are 2 mechanisms that won't do what you want.
You still need to answer these questions:
There might still be a way. The crux of your problem is: "I want to refresh some menu"
What kind of menu (popup, main menu,
compound list of menu items in a
menu, etc)?
Where is the menu contribution coming from?
Which specific menu item is it?
Please edit your question (do not comment) and include the information from the above 3 questions, please.