| Closing a window seems to remove it from the model [message #903946] |
Mon, 27 August 2012 07:42  |
Ulrich Obst Messages: 12 Registered: August 2012 |
Junior Member |
|
|
Hi everybody
I have an e4 application with two windows. One is not visible at startup. In the first window I have a command handler that opens the second window:
@Execute
public void openWindow(EModelService modelService, MApplication application) {
MUIElement element = modelService.find(UIConstants.SECOND_WINDOW_ID, application);
MWindow window = (MWindow)element;
if (!window.isVisible()) {
window.setVisible(true);
}
window.setOnTop(true);
This works fine. But when I close the window and try to reopen it the second time, the call modelService.find(...) returns null. The windows is removed from the model.
What can I do to open the window the second time? Do I have to create it (How)? Can I force the model service to make the window invisible instead of removing it?
|
|
|
|
|
|
| Re: Closing a window seems to remove it from the model [message #1048460 is a reply to message #903946] |
Wed, 24 April 2013 09:54  |
Matthias F Messages: 9 Registered: June 2011 |
Junior Member |
|
|
Hi, I'm sorry to dig out and hijack this thread but I have the exact same problem but somehow specifying the Window as a Snipped did not solve it for me.
My 2nd window is defined in the model:
<snippets xsi:type="basic:TrimmedWindow" xmi:id="_aRu48PArEeG3DKBqtQNHNw" elementId="my.second.window.id" visible="false" label="Window2">
<...>
</snippets>
In a Handler I try to find the snippet or create a clone if the service can't find it.
@Execute
public void execute(MApplication application, EModelService modelService) {
MUIElement window = modelService.findSnippet(application,
"my.second.window.id");
if (window == null) {
window = modelService.cloneSnippet(application,
"my.second.window.id", null);
}
if (window != null) {
window.setVisible(true);
if (window.getParent() == null) {
application.getChildren().add((MWindow) window);
}
}
}
This works exactly one time. After I close the window once, findSnippet and cloneSnippet both return null. Do you have any suggestions on how to solve this?
Edit: To be clear, I only want one instance of the second window open at a time.
[Updated on: Wed, 24 April 2013 10:05] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01715 seconds