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 Luthiger
Messages: 8
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 Luthiger
Messages: 8
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 Luthiger
Messages: 8
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 message
G. Smith is currently offline G. Smith
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)"

Previous Topic:NullPointerException with DaD Parts
Next Topic:MainMenu isn't persisted
Goto Forum:
  


Current Time: Sat Oct 25 00:53:29 GMT 2014

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

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