Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Configure PartStack to be displayed minimized
Configure PartStack to be displayed minimized [message #990895] Fri, 14 December 2012 17:25 Go to next message
Benno Luthiger is currently offline Benno LuthigerFriend
Messages: 10
Registered: December 2012
Junior Member
I'd like to display a PartStack component minimized at startup.

Consulting the lifeeditor I noticed that a minimized PartStack is tagged "Minimized" and has it's visibility set to false.

However, if I configure my PartStack control this way, instead of displayed minimized it isn't visible at all.

I tried to produce the desired state programmatically. I first tried it in my lifecycle classe's @ProcessAdditions method using the EModelService:
===
MUIElement partStack = modelService.find("my.part.stack", application);
partStack.getTags().add(IPresentationEngine.MINIMIZED);
partStack.setVisible(false);
===
However, this has in exactly the same outcome as the model configuration.

As workaround, I succeeded to produce the desired state using a child element's @PostConstruct method.

I think this behavior far from intuitive. In addition, I see the following error in my console:
===
java.lang.IllegalStateException: Application does not have an active window
at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.getActiveWindowService(ApplicationPartServiceImpl.java:36)
at org.eclipse.e4.ui.internal.workbench.ApplicationPartServiceImpl.requestActivation(ApplicationPartServiceImpl.java:71)
at org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon.minimize(MinMaxAddon.java:540)
...
===
Is there a clean way to display a PartStack minimized a startup?

(I guess, this my post addresses the same issue as http://www.eclipse.org/forums/index.php/m/784379/?srch=partstack+minimized#msg_784379)

Regards,
Benno

Re: Configure PartStack to be displayed minimized [message #990977 is a reply to message #990895] Sat, 15 December 2012 23:19 Go to previous messageGo to next message
Benno Luthiger is currently offline Benno LuthigerFriend
Messages: 10
Registered: December 2012
Junior Member
Digging in the e4 code I found out that (in org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench()) the addons are initialized after the lifecycle @ProcessAdditions method is invoked. Since minimizing a PartStack by adding the "Minimize" tag to this element relies on the MinMaxAddon's tagChangeListener, there's no chance to set the PartStack to mimimized state in the application's lifecycle class.

The workaround to minimize the PartStack in an element's @PostConstruct method is a possible solution, albeit a rather ugly one (imo).
Still there's the problem with the "IllegalStateException: Application does not have an active window". This problem is caused by the command "partService.requestActivation()" in org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon.minimize() (line 540). To overcome this problem, this call could be enclosed by:
===
if (element.getTags().contains("active")) {
partService.requestActivation();
}
===
With this change, the requestActivation() is called only if the minimize event is triggered through the UI and not programmatically.
Re: Configure PartStack to be displayed minimized [message #991633 is a reply to message #990977] Wed, 19 December 2012 22:21 Go to previous messageGo to next message
Benno Luthiger is currently offline Benno LuthigerFriend
Messages: 10
Registered: December 2012
Junior Member
I found the proper solution to configure the e4 model (i.e. the Application.e4xmi) in a way that a part stack is displayed minimized right at startup.

Using the lifeeditor I noticed that there is a Trim created containing the ToolControl which is responsible to display the PartStack's minimized view.

Thus, the proper solution to display a PartStack (with an id "my.minimized.parts") consists of the following steps:


  1. Tagging the PartStack "Minimized" and setting it invisible.
  2. In the Trimmed Window -> TrimBars section create a "Window Trim" (e.g. at the left side).
  3. Add a ToolControl to this TrimBar with the following properties:

Id: my.minimized.parts(null)
Class URI: bundleclass://org.eclipse.e4.ui.workbench.addons.swt/org.eclipse.e4.ui.workbench.addons.minmax.TrimStack
Persisted State: XSize: 270, YSize: 400 (this will be the size of opened fast view)
Supplementary Tag: TrimStack

That's it,
Benno

Re: Configure PartStack to be displayed minimized [message #1066285 is a reply to message #991633] Mon, 01 July 2013 22:15 Go to previous messageGo to next message
G. Smith is currently offline G. SmithFriend
Messages: 12
Registered: August 2012
Junior Member
Thank you for the very helpful post, Benno- it saved me quite a bit of time. I had to make one small change to get my minimized PartStack to handle restore/maximize correctly, though:

Change the id from "my.minimized.parts(null)" to "my.minimized.parts(minimized)"

Re: Configure PartStack to be displayed minimized [message #1722049 is a reply to message #1066285] Tue, 02 February 2016 13:41 Go to previous message
Piero Campalani is currently offline Piero CampalaniFriend
Messages: 114
Registered: January 2015
Senior Member

Thanks a zillion for these instructions!

Beware that whenever you use the MinMax Addon, it assumes that the ID of the tool control where a stack should be minimized is "<stack.id>(<perspective.id>)".

@see org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon#createTrim(MUIElement element)
[...]
// Is there already a TrimControl there ?
String trimId = element.getElementId() + getMinimizedElementSuffix(element);
MToolControl trimStack = (MToolControl) modelService.find(trimId, window);

@see org.eclipse.e4.ui.workbench.addons.minmax.MinMaxAddon#getMinimizedElementSuffix(MUIElement element)
private String getMinimizedElementSuffix(MUIElement element) {
    String id = ID_SUFFIX;
    MPerspective persp = modelService.getPerspectiveFor(element);
    if (persp != null) {
        id = '(' + persp.getElementId() + ')'
    }
    return id;
}


Additionally, one can also programmatically maximize and minimize a stack by programmatically adding the tag:
myPartStack.getTags().add(<TAG>);

where TAG = { IPresentationEngine.MINIMIZED, IPresentationEngine.MAXIMIZED }.

[Updated on: Wed, 03 February 2016 10:51]

Report message to a moderator

Previous Topic:Toolbar Item layout Problem on Perspective Switch (comp layer)
Next Topic:Use of Jface TextViewer in E4 app
Goto Forum:
  


Current Time: Fri Mar 29 10:41:03 GMT 2024

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

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

Back to the top