diff options
author | Jonathan Bauer | 2018-06-25 13:24:40 +0200 |
---|---|---|
committer | Jonathan Bauer | 2018-06-25 13:24:40 +0200 |
commit | aeb7e3b4acdc7601e3a789c0ca8557ca9ae923e3 (patch) | |
tree | 0834ffa930feca85c038b5473b84c08e1bbfb853 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java | |
parent | [client] Fix change detection for lecture permissions (diff) | |
download | tutor-module-aeb7e3b4acdc7601e3a789c0ca8557ca9ae923e3.tar.gz tutor-module-aeb7e3b4acdc7601e3a789c0ca8557ca9ae923e3.tar.xz tutor-module-aeb7e3b4acdc7601e3a789c0ca8557ca9ae923e3.zip |
[client] reworked ImageDetailsWindow
* switch to tab layout
* support for new dialog monitor
* simplified (hah!) permissions handling
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java | 187 |
1 files changed, 119 insertions, 68 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java index 43904c42..b556f4e8 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java @@ -12,18 +12,19 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JSplitPane; +import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.ShareMode; import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.configurator.ImagePermissionConfigurator; import org.openslx.dozmod.gui.control.ComboBox; import org.openslx.dozmod.gui.control.ComboBox.ComboBoxRenderer; import org.openslx.dozmod.gui.control.PersonLabel; @@ -35,7 +36,7 @@ import org.openslx.thrifthelper.Comparators; @SuppressWarnings("serial") public abstract class ImageDetailsWindowLayout extends JDialog { - + private static final int ICON_SIZE_Y = 24; protected final JTextField txtTitle; @@ -52,38 +53,49 @@ public abstract class ImageDetailsWindowLayout extends JDialog { protected final QLabel lblVirtualizer; protected final JTextField txtTags; protected final JCheckBox chkIsTemplate; - protected final JComboBox<ShareMode> cboShareMode; + protected final ComboBox<ShareMode> cboShareMode; protected final JTextField txtId; protected final JTextField txtVersion; - protected final JButton btnPermissions; - protected final JButton btnSaveChanges; protected final JButton btnUpdateImage; protected final JButton btnUploadToMaster; protected final JButton btnClose; + protected final JCheckBox chkDefaultPermAdmin; + protected final JCheckBox chkDefaultPermEdit; + protected final JCheckBox chkDefaultPermDownload; + protected final JCheckBox chkDefaultPermLink; + protected final JButton btnShowLinkingLectures; protected final QLabel lblLinkedLectureCount; protected final ImageVersionTable tblVersions; protected final QScrollPane scpVersions; + protected JTabbedPane pnlTabs; + + protected ImagePermissionConfigurator ctlImagePermissionConfigurator; + + private static String infoTextDefPerms = "<html><body style='width:100%'>" + + "Hier können Sie Rechte für nicht in der Liste angegebene Nutzer festlegen:" + "</body></html>"; + public ImageDetailsWindowLayout(Frame modalParent) { super(modalParent, "<init>", ModalityType.APPLICATION_MODAL); setResizable(true); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); - - // create left panel for info and buttons and right panel for the table and add - // them to split pane - - // use panel to put every info related widget in it - // then we we'll set the panel with BorderLayout.CENTER - JPanel infoPanel = new JPanel(); - GridManager grid = new GridManager(infoPanel, 3, true, new Insets(2, 2, 2, 2)); - infoPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - // -- name -- + setPreferredSize(Gui.getScaledDimension(650, 600)); + ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + + /* ******************************************************************************* + * + * Tab: Overview + * + ********************************************************************************/ + JPanel pnlTabOverview = new JPanel(); + GridManager grid = new GridManager(pnlTabOverview, 3, true, new Insets(2, 2, 2, 2)); + // name txtTitle = new JTextField(); txtTitle.setFont(txtTitle.getFont().deriveFont(Font.BOLD, txtTitle.getFont().getSize2D() * 2)); grid.add(txtTitle, 3).expand(true, false).fill(true, false); @@ -127,7 +139,6 @@ public abstract class ImageDetailsWindowLayout extends JDialog { grid.add(lblUpdateTime, 2); grid.nextRow(); - // os cboOperatingSystem = new ComboBox<OperatingSystem>(Comparators.operatingSystem, new ComboBoxRenderer<OperatingSystem>() { @Override @@ -145,14 +156,16 @@ public abstract class ImageDetailsWindowLayout extends JDialog { // tags txtTags = new JTextField(); - /* TODO - grid.add(new QLabel("Tags"), GridPos.get(0, row, false, false)); - grid.add(txtTags, GridPos.get(1, row++, true, false)); - grid.nextRow(); - */ // share mode - cboShareMode = new JComboBox<ShareMode>(); + cboShareMode = new ComboBox<ShareMode>(Comparators.shareModeById, new ComboBoxRenderer<ShareMode>() { + @Override + public String renderItem(ShareMode item) { + if (item == null) + return null; + return item.name(); + } + }); grid.add(new QLabel("Freigabemodus")); grid.add(cboShareMode, 2).expand(true, false).fill(true, false); grid.nextRow(); @@ -182,11 +195,6 @@ public abstract class ImageDetailsWindowLayout extends JDialog { grid.add(lblVirtualizer, 2).expand(true, false).fill(true, false); grid.nextRow(); - btnPermissions = new JButton("Berechtigungen"); - grid.skip(); - grid.add(btnPermissions, 2); - grid.nextRow(); - grid.add(new QLabel("Veranstaltungen")); lblLinkedLectureCount = new QLabel(); grid.add(lblLinkedLectureCount).expand(true, false); @@ -197,51 +205,94 @@ public abstract class ImageDetailsWindowLayout extends JDialog { grid.nextRow(); grid.finish(true); - infoPanel.setPreferredSize(Gui.getScaledDimension(500, 400)); - infoPanel.setMinimumSize(Gui.getScaledDimension(350, 300)); + pnlTabOverview.setPreferredSize(Gui.getScaledDimension(500, 400)); + pnlTabOverview.setMinimumSize(Gui.getScaledDimension(350, 300)); - // finally add the infoPanel itself to the left panel - // button panel at the bottom - JPanel buttonPanel = new JPanel(); - buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); + /* ******************************************************************************* + * + * Tab: VM versions + * + ********************************************************************************/ + JPanel pnlTabVersions = new JPanel(); + tblVersions = new ImageVersionTable(); + scpVersions = new QScrollPane(tblVersions); + GridManager grdVersions = new GridManager(pnlTabVersions, 1, false, new Insets(8, 2, 8, 2)); + grdVersions.add(scpVersions).fill(true, true).expand(true, true); + grdVersions.finish(false); + + /* ******************************************************************************* + * + * Tab: Permissions + * + ********************************************************************************/ + JPanel pnlTabPermissions = new JPanel(); + ctlImagePermissionConfigurator = new ImagePermissionConfigurator(); + GridManager grdImagePermissionConfigurator = new GridManager(pnlTabPermissions, 1, false, new Insets(8, 2, 8, 2)); + grdImagePermissionConfigurator.add(ctlImagePermissionConfigurator).fill(true, true).expand(true, true); + // Panel with the permissions for other users + JPanel defaultPermissionPane = new JPanel(); + defaultPermissionPane.setBorder(BorderFactory.createTitledBorder("Andere Nutzer")); + defaultPermissionPane.setLayout(new BoxLayout(defaultPermissionPane, BoxLayout.PAGE_AXIS)); + JLabel txtDefaultPerms = new JLabel(infoTextDefPerms); + + JPanel txtDefaultPermsPanel = new JPanel(); + // Panel + BoxLayout + Label = wordwrap + txtDefaultPermsPanel.setLayout(new BoxLayout(txtDefaultPermsPanel, BoxLayout.LINE_AXIS)); + txtDefaultPermsPanel.add(txtDefaultPerms); + JPanel defaultPermsSubPanel = new JPanel(); + defaultPermsSubPanel.setLayout(new BoxLayout(defaultPermsSubPanel, BoxLayout.LINE_AXIS)); + chkDefaultPermAdmin = new JCheckBox("Admin"); + chkDefaultPermDownload = new JCheckBox("Download"); + chkDefaultPermEdit = new JCheckBox("Bearbeiten"); + chkDefaultPermLink = new JCheckBox("Verlinken"); + + defaultPermsSubPanel.add(chkDefaultPermLink); + defaultPermsSubPanel.add(chkDefaultPermDownload); + defaultPermsSubPanel.add(chkDefaultPermEdit); + defaultPermsSubPanel.add(chkDefaultPermAdmin); + + defaultPermissionPane.add(txtDefaultPermsPanel); + defaultPermissionPane.add(Box.createVerticalStrut(10)); + defaultPermissionPane.add(defaultPermsSubPanel); + grdImagePermissionConfigurator.add(defaultPermissionPane).fill(true, false).expand(false, false); + grdImagePermissionConfigurator.finish(false); + + /* ******************************************************************************* + * + * Bottom panel for buttons + * + ********************************************************************************/ + JPanel pnlButtons = new JPanel(); + pnlButtons.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.LINE_AXIS)); btnSaveChanges = new JButton("Speichern"); btnClose = new JButton("Schließen"); - btnUpdateImage = new JButton("Neue VM-Version hochladen", Gui.getScaledIconResource("/img/upload-icon.png", "New VM", ICON_SIZE_Y, buttonPanel)); - buttonPanel.add(btnUpdateImage); - btnUploadToMaster = new JButton("Landesweit veröffentlichen", Gui.getScaledIconResource("/img/publish-icon.png", "Publish VM", ICON_SIZE_Y, buttonPanel)); - buttonPanel.add(btnUploadToMaster); - buttonPanel.add(Box.createGlue()); + btnUpdateImage = new JButton("Neue VM-Version hochladen", + Gui.getScaledIconResource("/img/upload-icon.png", "New VM", ICON_SIZE_Y, pnlButtons)); + pnlButtons.add(btnUpdateImage); + btnUploadToMaster = new JButton("Landesweit veröffentlichen", + Gui.getScaledIconResource("/img/publish-icon.png", "Publish VM", ICON_SIZE_Y, pnlButtons)); + pnlButtons.add(btnUploadToMaster); + pnlButtons.add(Box.createGlue()); // user feedback slot lblError = new QLabel(""); lblError.setForeground(Color.RED); - buttonPanel.add(lblError); - buttonPanel.add(Box.createGlue()); - buttonPanel.add(btnClose); - buttonPanel.add(btnSaveChanges); - - // --- Version table on the right (EAST) side - JPanel versionTablePanel = new JPanel(); - versionTablePanel.setLayout(new BorderLayout()); - versionTablePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - QLabel lblVersion = new QLabel("VM-Versionen"); - lblVersion.setFont(lblVersion.getFont().deriveFont(Font.BOLD)); - versionTablePanel.add(lblVersion, BorderLayout.PAGE_START); - tblVersions = new ImageVersionTable(); - scpVersions = new QScrollPane(tblVersions); - scpVersions.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - versionTablePanel.add(scpVersions, BorderLayout.CENTER); - - // add the tabel panel to the right panel - JPanel rightPanel = new JPanel(); - rightPanel.setLayout(new BorderLayout()); - rightPanel.add(versionTablePanel, BorderLayout.CENTER); - - // add left and right panel to the split pane - JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, infoPanel, rightPanel); - splitPane.setResizeWeight(0.5); - // add the split pane - add(splitPane, BorderLayout.CENTER); - add(buttonPanel, BorderLayout.PAGE_END); + pnlButtons.add(lblError); + pnlButtons.add(Box.createGlue()); + pnlButtons.add(btnClose); + pnlButtons.add(btnSaveChanges); + + /* ******************************************************************************* + * + * Main panel containing the tabs + * + ********************************************************************************/ + pnlTabs = new JTabbedPane(); + pnlTabs.addTab("Übersicht", pnlTabOverview); + pnlTabs.addTab("VM-Versions", pnlTabVersions); + pnlTabs.addTab("Berechtigungen", pnlTabPermissions); + + add(pnlTabs, BorderLayout.CENTER); + add(pnlButtons, BorderLayout.PAGE_END); } } |