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 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
Previous Topic:Eclipse 3.7 Logging facility without ui plugins
Next Topic:WorkbenchWindowControlContribution resize problem in trim area
Goto Forum:
  


Current Time: Sat Dec 20 13:00:30 GMT 2014

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

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