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).
	@Execute
	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())
				configwindow.setVisible(false);
			else
				configwindow.setVisible(true);
		}
	}

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.

Greetings
Johannes
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
Hi,

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

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

	MInputPart partMain = MBasicFactory.INSTANCE.createInputPart();
	partMain.setDirty(false);
	partMain.setLabel("Main Config");
	partMain				.setContributionURI("bundleclass://XYZ/com.xxx.parts.preferences.configMain");
	partStack.getChildren().add(partMain);

	MInputPart partNodes = MBasicFactory.INSTANCE.createInputPart();
	partNodes.setDirty(false);
	partNodes.setLabel("Node Config");
	partNodes				.setContributionURI("bundleclass://XYZ/com.xxx.parts.preferences.configNodes");
	partStack.getChildren().add(partNodes);

	window.getChildren().add(partStack);
}


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:
@Execute
public void execute(MWindow window, MApplication application) {
	window.setVisible(false);
	window.setToBeRendered(false);
	application.getChildren().remove(window);
}


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").

@Execute
	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);
		app.getChildren().add(clonedWindow);
		
		clonedWindow.setToBeRendered(true);
	}


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: Thu Apr 25 07:24:56 GMT 2024

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

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

Back to the top