Reseting the Window Layout [message #674021] |
Wed, 25 May 2011 10:29  |
Eclipse User |
|
|
|
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 #1218423 is a reply to message #674021] |
Fri, 29 November 2013 04:09   |
Eclipse User |
|
|
|
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] by Moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09752 seconds