diff options
author | Simon Rettberg | 2015-07-17 17:20:38 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-07-17 17:20:38 +0200 |
commit | 7844be5e4d74612e9aff44c5aab09d4f6e5d2631 (patch) | |
tree | 2605abdf19b146b22feda18a3256e3e031c677eb /dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java | |
parent | [client] first steps in ImagePermissions page (diff) | |
download | tutor-module-7844be5e4d74612e9aff44c5aab09d4f6e5d2631.tar.gz tutor-module-7844be5e4d74612e9aff44c5aab09d4f6e5d2631.tar.xz tutor-module-7844be5e4d74612e9aff44c5aab09d4f6e5d2631.zip |
[client] Add image details window
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java index e048a135..bcf2b738 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/MainWindow.java @@ -80,8 +80,10 @@ public abstract class MainWindow { * @param modal modal mode - other windows will be blocked until this popup * is closed * @param noclose don't allow closing the popup via the (X) in the title bar + * @return The composite that is opened as a popup, or <code>null</code> on + * error */ - public static void openPopup(Class<? extends Composite> clazz, boolean modal, boolean noclose) { + public static <T extends Composite> T openPopup(Class<T> clazz, boolean modal, boolean noclose) { int style = SWT.TITLE | SWT.BORDER | SWT.RESIZE; if (modal) style |= SWT.APPLICATION_MODAL; @@ -90,14 +92,14 @@ public abstract class MainWindow { Shell dialogShell = Gui.newShell(mainShell, style); // populate dialogShell dialogShell.setLayout(new GridLayout(1, false)); - Constructor<?> con = null; + final T comp; try { - con = clazz.getConstructor(Shell.class); - con.newInstance(dialogShell); + Constructor<T> con = clazz.getConstructor(Shell.class); + comp = con.newInstance(dialogShell); } catch (Exception e1) { Gui.showMessageBox(mainShell, "Cannot show popup " + clazz.getName(), MessageType.DEBUG, LOGGER, e1); - return; + return null; } if (noclose) { @@ -114,7 +116,13 @@ public abstract class MainWindow { dialogShell.layout(); dialogShell.pack(); Gui.limitShellSize(dialogShell); + Gui.centerShellOverShell(mainShell, dialogShell); dialogShell.open(); + return comp; + } + + public static void centerShell(Shell shell) { + Gui.centerShellOverShell(mainShell, shell); } /** |