Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Showing Multiple Windows(Showing and closing prepared windows)
Showing Multiple Windows [message #1077227] Thu, 01 August 2013 11:59 Go to next message
Johannes Spreemann is currently offline Johannes SpreemannFriend
Messages: 19
Registered: August 2013
Location: Germany/Netherlands
Junior Member
Hey everybody,

I'm new in e4 RCP development. With some tutorials I could get some basics. But unfortunately I ran into a problem. I have my main Trimmed Window with one perspective and some additional controls.

Now I created another window (Preferences) under Applications -> Windows -> Window - Preferences with several controls.
The standard visibility is set to false. I managed to add a menu button that changes the visibility of this window to true or false (in a dirty way).
	public void execute(@Named ("xyz.commandparameter.preferences") String WindowId, IWorkbench workbench) {
		List<MWindow> childWindows = workbench.getApplication().getChildren();
                for (int i = 0; i < childWindows.size(); i++) {
		MWindow configwindow = childWindows.get(i);		
		if (configwindow.getElementId().equals(WindowId))
			if (configwindow.isVisible())

When I close it (Click on red cross) the windwow object is destroyed and no longer available to "open". Is there a better/another way to create or show the window every time it is shown by button click?

Hope I described my problem understandable and that a fast solution for this exists.

icon3.gif  Re: Showing Multiple Windows [message #1078081 is a reply to message #1077227] Fri, 02 August 2013 14:15 Go to previous messageGo to next message
Johannes Spreemann is currently offline Johannes SpreemannFriend
Messages: 19
Registered: August 2013
Location: Germany/Netherlands
Junior Member

I decided to construct my window(s) manually.
So my Handler connected to the button creates my window with the general visual layout:
public void execute(@Named("xyz.commandparameter.preferences") String windowId,
			final MApplication application) {
        // Creating window
	final MTrimmedWindow configWindow = MBasicFactory.INSTANCE
	configWindow				.setIconURI("platform:/plugin/XYZ/icons/application/16x16/Edit.png");

        // Creates simple partstack with 2 parts
        MPartStack partStack = MBasicFactory.INSTANCE.createPartStack();

	MInputPart partMain = MBasicFactory.INSTANCE.createInputPart();
	partMain.setLabel("Main Config");
	partMain				.setContributionURI("bundleclass://XYZ/");

	MInputPart partNodes = MBasicFactory.INSTANCE.createInputPart();
	partNodes.setLabel("Node Config");
	partNodes				.setContributionURI("bundleclass://XYZ/");


The setContributionURI(...) points to the classes that define the content of the stack.

You can close the window with the standard close order button (In Windows the red button in the upper right window corner) and it's removed from the Children list of the main application window. I decided to add a toolbar with a close button. In this case I couldn't find a instruction/method to do this automatically. After some experimenting i found the following way within a handler to get the same result as with the standard close button:
public void execute(MWindow window, MApplication application) {

I hope this will help others or maybe someone can show a better solution.

Greeting Johannes
Re: Showing Multiple Windows [message #1698839 is a reply to message #1077227] Thu, 18 June 2015 09:55 Go to previous message
Arto Saari is currently offline Arto SaariFriend
Messages: 1
Registered: June 2015
Junior Member
You can also use "EModelService.cloneElement()".
So you create the second window in the Application Model as usual (setting "To Be Rendered" to false to be initially "closed").

	public void execute(@Named ("xyz.commandparameter.preferences") String WindowId, MApplication app) {
		MTrimmedWindow dummyWindow = (MTrimmedWindow) modelService.find(WindowId, app);
		MTrimmedWindow clonedWindow = (MTrimmedWindow)modelService.cloneElement(dummyWindow , app);

This essentially creates a new window copy like you did in your above code.
You HAVE to add you cloned window to the list of children of your application. Also, it might be necessary to change the Element ID of your newly cloned window, depending of what you do in your code.
Previous Topic:MultiPageEditor - Close option for Pages
Next Topic:RCP 3.x register alternate service implementation with locator
Goto Forum:

Current Time: Mon Jun 18 17:53:21 GMT 2018

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

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

Back to the top