Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Reseting the Window Layout
Reseting the Window Layout [message #674021] Wed, 25 May 2011 10:29 Go to next message
Christoph Keimel is currently offline Christoph Keimel
Messages: 328
Registered: December 2010
Location: Germany
Senior Member
Hello everybody,

this was discussed a little bit in Topic 207437. I'm opening a new topic for a more specific discussion on the following:

I am searching for a way to Reset the Layout of an Application Window.

I realize that there is currently probably no way of doing this without introducing a Perspective (Bug 343512), although my request hasn't been commented on. Using a Perspective I looked at EModelService.resetPerspectiveModel to do the trick, but I can't see any effect of calling the function.

Is there any way to do this in a pure e4 Application? How does the Compat-Layer handle the "Reset Perpective..." in the SDK?

Thanks for the help,
Christoph
Re: Reseting the Window Layout [message #1209165 is a reply to message #674021] Mon, 25 November 2013 06:18 Go to previous messageGo to next message
Roman Dawydkin is currently offline Roman Dawydkin
Messages: 3
Registered: July 2009
Junior Member
Is there any updates on this? 2 years passed. I don't see clear way to reset perspective in pure e4.
(The only solution found so far it to place perspective in snippets)
Re: Reseting the Window Layout [message #1210024 is a reply to message #1209165] Mon, 25 November 2013 15:37 Go to previous messageGo to next message
Eric Moffatt is currently offline Eric Moffatt
Messages: 117
Registered: July 2009
Senior Member
Since there's no IPerspectiveFactory to delegate the 'initial' layout to the *only* way to store a version of a perspective that you could revert to is in the snippets (like we do when you save a perspective in Eclipse 4).

[Updated on: Mon, 25 November 2013 15:37]

Report message to a moderator

Re: Reseting the Window Layout [message #1218423 is a reply to message #674021] Fri, 29 November 2013 04:09 Go to previous messageGo to next message
Tuan Anh Nguyen is currently offline Tuan Anh Nguyen
Messages: 7
Registered: June 2013
Junior Member
Eric's solution is the only way now for an pure e4 application. You can choose to mix eclipse rcp 3x and e4 to use some convinient things.
Here some starting points you should take a look

h tt p://dirksmetric.wordpress.com/2012/08/01/tutorial-eclipse-rcp-e4-with-3-x-views-like-project-explorer-properties-etc/
Also the vogella website, both are good!

In case you still want to develope a pure e4, i have successfully create a handler for reset the perspective by storing the perspective as a snippet. Here the way to go:
1. Store a copy of every perspective to a snippet with the same id, don't forget to make contribution to the snippet while you contribute to the real perspective.
2. Using the bellow code to reset the perspective.
@Execute
	public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,
			EModelService modelService, MApplication app,
			EPartService partService) {
		
		MWindow window = (MWindow) modelService.find("Main", app);

		final MPerspective perspective = modelService
				.getActivePerspective(window);

		final MUIElement snippet = modelService.cloneSnippet(app,
				perspective.getElementId(), window);
		snippet.setToBeRendered(true);
		if (snippet != null) {
			MElementContainer<MUIElement> parent = perspective.getParent();
			perspective.setToBeRendered(false);

			List<MWindow> existingDetachedWindows = new ArrayList<MWindow>();
			existingDetachedWindows.addAll(perspective.getWindows());

			MPerspective dummyPerspective = (MPerspective) snippet;
			while (dummyPerspective.getWindows().size() > 0) {
				MWindow detachedWindow = dummyPerspective.getWindows()
						.remove(0);
				perspective.getWindows().add(detachedWindow);
			}

			parent.getChildren().remove(perspective);

			parent.getChildren().add(snippet);
			System.out.println(parent.getChildren().get(0).getElementId());
			partService.switchPerspective((MPerspective) snippet);
		}
	}

This piece of code i make by analyze the RCP source code. Try it!

[Updated on: Fri, 29 November 2013 04:30]

Report message to a moderator

Re: Reseting the Window Layout [message #1218449 is a reply to message #674021] Fri, 29 November 2013 04:22 Go to previous messageGo to next message
Tuan Anh Nguyen is currently offline Tuan Anh Nguyen
Messages: 7
Registered: June 2013
Junior Member
Sorry i duplicated the post

[Updated on: Fri, 29 November 2013 04:30]

Report message to a moderator

Re: Reseting the Window Layout [message #1220842 is a reply to message #674021] Sat, 14 December 2013 00:25 Go to previous message
Tuan Anh Nguyen is currently offline Tuan Anh Nguyen
Messages: 7
Registered: June 2013
Junior Member
Hi, today i found a solution on Stackoverflow. Here is the link
http ://stackoverflow.com/questions/19717154/how-do-i-reset-perspective-for-eclipse-e4-rcp-application/20106360#20106360
Previous Topic:Eclipse 4.2 GUI is very slow
Next Topic:RCP 4 + Webstart - Fails to load workbench
Goto Forum:
  


Current Time: Fri Jul 25 05:07:22 EDT 2014

Powered by FUDForum. Page generated in 0.02014 seconds