eclipse-efx / efxclipse-rt

Eclipse Public License 1.0
28 stars 29 forks source link

Make (Editor) Toolbar Alignment configurable (left to right instead of right to left) #244

Closed TheRealAnton closed 6 years ago

TheRealAnton commented 6 years ago

Currently, it is not possible to add a Trimbar to a PartDescriptor, it is just possible to check "Toolbar" in the fragment.e4xmi which gives you a single Toolbar. Hence, it is not possible to change the alignment of the content as you could do with the main Trimbar (i.e. add multiple Toolbars and add the "fillspace" tag to one of them).

So the editor toolbar seems to align all the buttons on the right side instead of the left side. And I can't find a way to change that e.g. via CSS or any other means.

Could this behavior be made configurable, e.g. by allowing a configuration via Tag ("align_left")?

Is there a workaround until the configuration is made possible? I can't even find the code where the alignment is set to right and via scenicView I can see there is no additional HBox that fills the space to the left of the toolbar...

tomsontom commented 6 years ago

well we currently have only a tag to render the toolbar on the bottom - https://wiki.eclipse.org/Efxclipse/Runtime/e4#MPart

The only workaround is to make the system use a custom renderer. Implementing left & right should be fairly easy because there's a border-pane in action holding the toolbar.

see https://github.com/eclipse/efxclipse-rt/blob/3.x/modules/ui/org.eclipse.fx.ui.workbench.renderers.fx/src/main/java/org/eclipse/fx/ui/workbench/renderers/fx/DefPartRenderer.java#L278

TheRealAnton commented 6 years ago

Thanks for the quick reply. However, I am afraid we are talking about different things here. I don't want the toolbar to be placed anywhere else. I want the buttons inside (!) the toolbar to be on the left side (as it is default with buttons within the main toolbar) instead of on the right side (as it is with buttons within the toolbar of an editor/part).

Example: https://wiki.eclipse.org/images/b/b2/Help_InstallNewSoftware.png Have a look at the package explorer: There is a toolbar (perfectly placed) having the buttons ( minus, double-arrows, separator, 3 circles, and a menu-triangle) placed on the right side. This may be okay for a narrow view, however if you have an editor that takes about 80% of your screen this is rather odd. I want them to be on the left side for my editor, just as they are in the main toolbar (same picture, containing e.g. the buttons for "new...", "save".)

Is it clear, what I mean? (I am rather new to eclipse/rcp/.. so I hope the vocabs are correct)

tomsontom commented 6 years ago

well we have that - if you look closely you notive the tag Part-Toolbar-FullSpan this makes the toolbar span the whole top area

TheRealAnton commented 6 years ago

Ah, now I can see my problem here: This Tag cannot be set on a "PartDescriptor", it has to be set on the "MPart" itself, that's why it did not work out of the box. However I can add the tag to the MPart in the Java code during instantiation, and this solves the issue.

Thank you very much for your help!

tomsontom commented 6 years ago

Are tags not cloned when a MPart is created from an MPartDescriptor? That sounds like a bug to me if it is not working

TheRealAnton commented 6 years ago

That's easy to prove: Add the tag to the part descriptor in the xmi file, let the part be created and read the tags. That's what I did, and I found the list of tags to be empty. Then I added the tag manually at runtime and it worked :)

You are right, it would be more convenient (and intuitive) if the tags would be cloned. Feel free to reopen this bug if you want to use it for this purpose, although I feel that this might rather be a core eclipse (e4) thing (?)

tomsontom commented 6 years ago

Looking at EModelService implementation in my workspace the tags are copied over from the MPartDescriptor what version of e(fx)clipse do you observe the problem?

TheRealAnton commented 6 years ago

I use efxclipse/runtime-released/3.4.0

Code is: MPartStack editorArea...

MPart myPart = ePartService.createPart("myEditorId"); // tags are empty myPart.getTags().add("Part-Toolbar-FullSpan"); // add tag manually in code, this works ... editorArea.getChildren.add(myPart); ePartService.showPart(myPart, PartState.VISIBLE);

tomsontom commented 6 years ago

This also calls out to EModelService. Can you look at your EModelService implementation. And just to make sure you always start with a clean state.

TheRealAnton commented 6 years ago

We use the "normal" EModelService that is provided by eclipse (releases/photon).

@Inject private EModelService modelService; // --> org.eclipse.e4.ui.internal.workbench.ModelServiceImp

I have set the clean persisted state flag.

However, though it being more convenient to rely on the tags in the part descriptor, I am quite ok with the current solution (though you might think of it being a workaround rather than a solution); so unless you have lots of spare time, don't feel obliged to dig into this issue too deeply. ;) I don't think it is on e(fx)clipse.

Thanks again for your help.