|
|
Re: How to use dialog in e4 application model [message #1749818 is a reply to message #1749694] |
Mon, 12 December 2016 20:23 |
Ken Keefe Messages: 41 Registered: April 2012 |
Member |
|
|
After much experimenting and digging on the web, I came up with a solution that works. I still haven't found a concrete way for opening and reopening windows that are defined in the application model xmi. Hopefully, the way I am doing it is a good and stable way.
First, I had to move my Dialog XMI from Application.dialogs to Application.snippets. I did this with a model fragment, but it could be done directly in Application.e4xmi. Anyway, once my Dialog was living under Application.snippets, this code allowed me to open the dialog every time it was executed:
@Execute
public void execute(MApplication application, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell, EModelService modelService) {
MUIElement dia = modelService.cloneSnippet(application, "dialog.appPreferences", null);
if(dia instanceof MDialog) {
MDialog d = (MDialog) dia;
Monitor mon = shell.getMonitor();
Rectangle monitorRect = mon.getBounds();
d.setX(monitorRect.x + (monitorRect.width - d.getWidth())/2);
d.setY(monitorRect.y + (monitorRect.height - d.getHeight())/2);
application.getChildren().add(d);
d.setOnTop(true);
}
}
The shell argument and the lines that set the X and Y of the dialog are obviously optional, but it is useful for centering the dialog on the screen.
|
|
|
Powered by
FUDForum. Page generated in 0.03997 seconds