How can I change the buttons order of the main toolbar inside eclipse 4 application? - eclipse-plugin

Hey I have a normal toolbar inside the Application.e4xmi, which gets his elements from several other fragment.e4xmi / plugins. How can I change the order of these?
Current toolbar:
and how I want it:
The Plugins are here seperated by the spotted lines.
The whole thing is handeld by .e4xmi files and theire handler classes and each plugin has an toolbar with the main toolbar as parent.
Thanks for help :D

Related

Intellij IDEA hide empty middle folders

In the project view in Intellij IDEA, there is an option to "hide empty middle packages".
Is there an equivalent for folders? I don't want a sole "src/main/java" to take up 3 lines...
No, there isn't.
But if your folders are getting so long, you can always scroll the project pane to the right :)
It's also possible to use a different view (e.g. Packages) or define bookmarks and favourites to navigate around quickly, plus enable Auto-scroll from source.

How to reopen ViewPart?

I am working to make an Eclipse Plugin. I used a plugin project template that generated a View class which extends ViewPart. I think that it is part of SWT.
My problem is that the View is like a window inside of the main Frame which has buttons for close, minimize. I clicked on the X button of the View by mistake. Now I cannot make it visible again even if I relaunch the Eclipse Application.
Now, my Eclipse application looks like this:
It had some panels and buttons before. But I cannot make the View visible again. How should I make to bring it back? I have tried to delete the plugin project from Eclipse and import it again. But it did not work.
I bet that there it is an easy way to make the View visible again but I do not know how. Is there any setting through MANIFEST file? Or other file?
Specify the -clearPersistedState argument when you run the RCP (this assumes you are using Eclipse 4.x).
1) quick solution
restart workbench with clear workspace option checked under run configuration ..
2) Full Solution
you should add a menu in menu bar to open your view so that you can open your view when ever you want
create a command say openMyMenu
create a handler for it and call below code from handler execute method.
add that command to main menu bar..
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(<view ID>);

How to add a button to the main toolbar in Eclipse programmatically

I've a question. I cannot find the way, how to add buttons to main toolbar programmatically. My problem is, that I've the task to dynamically (based on XML configuration file) build menus and toolbar. I found how to add a menu item programmatically, but not toolbar button.
Tutorials mostly show how to create buttons and menus using plugin descriptor (plugin.xml), but not how to do it programatically. It seems, that it is out of bounds of Eclipse plugin philosophy.
I've just found this:
There might be layout problems with this approach. I also don't
believe the framework will try and re-create your dynamic item except
at random toolbarmanager updates. With Menus they can be updated on an
SWT.Show event, which is why CompoundContributionItem only applies to
Menus.
What shall I do? Can I say Sorry, there is no way to build toolbar dynamically. I can do it just for menus? Collegue says, that it must be possible, but he does neither know how.
The only way to be able to create main toolbar entries programmatically is in an RCP app, where you supply the ActionBarAdvisor for the workbench window. This isn't dynamic, however, just called on window creation.
Another way to do it would be to use org.eclipse.ui.menus and contribute org.eclipse.ui.menus.ExtensionContributionFactory. It also works only on workbench window creation (not really dynamic), but you could read your own XML and provide IContributionItems for the main menu or toolbar.
How dynamic are you trying to be? Most solutions work well on startup/window creation.
PW
Whenever you try to do something programmatically in Eclipse that is normally done through plugin definitions you are walking on thin ice. I've tried it on a few occasions and it rarely ended up being easy or good.
Instead, think of what it is that you only know at runtime and need to be able to change on the fly. Is it the name or icon of the button? That can be changed at runtime.
Take a look at runtime commands, they can be confusing to define properly, but with them you can for example create buttons that are only visible if a condition is active. That condition could be set at runtime.

Editor context Menu - Eclipse-RCP

I have an Eclipse RCP application. I have created an Editor. There are few context menu (default), when I right click on the Editor. I have not created these menus.
Please let me know, How to remove the context menu of the Editor?
It needs different approach by which editor you extends.
Let me know What you extends, than I can answer more efficient one.
In general way:
IWorkbenchParSite#registerContextMenu(...) will be used, So find where calls that, override it. It is not recommend. Because by doing this, Menu Extensions which is contributed for your editor will not work anymore.
If you mean the system menu that appears on editor tabs and view tabs, that menu is provided by the presentation (2.1, Classic, Default, etc). There is no tweak to simply modify it.
The 2 ways to remove it would be:
write your own presentation, using
the
org.eclipse.ui.presentations.StackPresentation
API and matching extension point.
Writing a presentation is a involved
undertaking.
Change the internal classes in the
org.eclipse.ui.workbench plugin
and patch that plugin in your RCP
app.
If you use Text or StyleText you will get the system default menu (cut,copy,paste, maybe something about encoding or input). If you are not going to supply your own menu, simply create an empty SWT Menu and set it:
Menu emptyMenu = new Menu(text);
text.setMenu(emptyMenu);
Eclipse also has a text editing framework, if you need more than a basic text box you should check it out. http://wiki.eclipse.org/The_Official_Eclipse_FAQs#Text_Editors

Display a pulldown item in Eclipse programatically

I know that I can declare actions in plugin.xml that specify style="pulldown" in order to make a pulldown style toolbar button, but I want to be able to do it programatically, using the IToolBarManager and IContributionItem interfaces.
I've looked through the interfaces, and the implementations of various things in eclipse, but I can't see how I'd do it. Ideally I want to add such a toolbar item from an IEditorActionBarContributor implementation.
Anyone got any ideas?
In answer to my own question, you need to create an Action object, and then call setMenuCreator on the action. Then when you add the action to the toolbar you'll get a drop down menu.