diff options
author | Jonathan Bauer | 2015-08-27 17:57:19 +0200 |
---|---|---|
committer | Jonathan Bauer | 2015-08-27 17:57:19 +0200 |
commit | 4d3d83fd2ae78659ebc2218e853c2b35ee47192c (patch) | |
tree | 5d240ab09989e504c717cb1b0b7c1bbbe728bf77 /dozentenmodul | |
parent | [client] make image list in lecture wizard resizable (FOR THIS PAGE ONLY) (diff) | |
parent | [client] Added functionality to change linked image of a lecture. (diff) | |
download | tutor-module-4d3d83fd2ae78659ebc2218e853c2b35ee47192c.tar.gz tutor-module-4d3d83fd2ae78659ebc2218e853c2b35ee47192c.tar.xz tutor-module-4d3d83fd2ae78659ebc2218e853c2b35ee47192c.zip |
Merge branch 'v1.1' of git.openslx.org:openslx-ng/tutor-module into v1.1
Diffstat (limited to 'dozentenmodul')
5 files changed, 276 insertions, 43 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageCustomPermissionManager.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageCustomPermissionManager.java index a2655434..ae77394c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageCustomPermissionManager.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageCustomPermissionManager.java @@ -57,7 +57,7 @@ public class ImageCustomPermissionManager extends JPanel { userButtonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); userButtonPane.setLayout(new BoxLayout(userButtonPane, BoxLayout.LINE_AXIS)); - btnAddUser = new JButton("Benutzer hinzufügern"); + btnAddUser = new JButton("Benutzer hinzufügen"); userButtonPane.add(btnAddUser); btnRemoveUser = new JButton("Benutzer entfernen"); userButtonPane.add(btnRemoveUser); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LectureCustomPermissionManager.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LectureCustomPermissionManager.java index 8d8e5806..1d566ff6 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LectureCustomPermissionManager.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LectureCustomPermissionManager.java @@ -62,7 +62,7 @@ public class LectureCustomPermissionManager extends JPanel{ userButtonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); userButtonPane.setLayout(new BoxLayout(userButtonPane, BoxLayout.LINE_AXIS)); - btnAddUser = new JButton("Benutzer hinzufügern"); + btnAddUser = new JButton("Benutzer hinzufügen"); userButtonPane.add(btnAddUser); btnRemoveUser = new JButton("Benutzer entfernen"); userButtonPane.add(btnRemoveUser); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeLinkedImage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeLinkedImage.java new file mode 100644 index 00000000..1da67079 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureChangeLinkedImage.java @@ -0,0 +1,133 @@ +package org.openslx.dozmod.gui.window; + +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.apache.log4j.Logger; +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.control.table.ImageTable; +import org.openslx.dozmod.gui.helper.MessageType; +import org.openslx.dozmod.gui.window.layout.LectureChangeLinkedImageLayout; + +/** + * Window for modifying the custom permissions of an lecture. + */ +@SuppressWarnings("serial") +public class LectureChangeLinkedImage extends LectureChangeLinkedImageLayout { + + private static final Logger LOGGER = Logger.getLogger(LectureChangeLinkedImage.class); + + private boolean okUsed = false; + private ImageTable imageTable; + + private LectureChangeLinkedImage me; + + + + /** + * Don't use this constructor, use static function open instead. + */ + protected LectureChangeLinkedImage(final Window modalParent) { + super(modalParent); + me = this; + + /** + * initialise the ImageListViewer + */ + imageListViewer.refreshList(false, 1); + imageTable = imageListViewer.getImageTable(); + + imageTable.setColumnVisible(ImageTable.COL_LASTCHANGE , false); + imageTable.setColumnVisible(ImageTable.COL_OS , false); + imageTable.setColumnVisible(ImageTable.COL_SIZE , false); + imageTable.setColumnVisible(ImageTable.COL_TEMPLATE , false); + + // finally the table listeners + imageTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + + } + @Override + public void mousePressed(MouseEvent e) { + processClick(e); + } + @Override + public void mouseReleased(MouseEvent e) { + processClick(e); + } + private void processClick(MouseEvent e) { + // left double click => open details + if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) { + if (imageIsValid()) { + okUsed = true; + dispose(); + } else + { + Gui.showMessageBox(me, "Ausgewähltes Image ist ungültig!", MessageType.ERROR, LOGGER , null); + } + } + + } + }); + + + imageTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + btnOk.setEnabled(imageIsValid()); + } + }); + + /** + * ActionListeners for the buttons. + */ + btnOk.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + okUsed = true; + dispose(); + } + }); + btnClose.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + dispose(); + } + }); + } + + private boolean imageIsValid(){ + return imageTable.getSelectedItem().isValid; + } + + /** + * Set window visible and return resulting ImageSummaryRead + * @return ImageSummaryRead of selected Image + */ + private ImageSummaryRead runAndReturn(){ + setVisible(true); + if (okUsed){ + return imageTable.getSelectedItem(); + } else { + return null; + } + } + + /** + * Create new LectureChangeLinkedImage + * @param modalParent parent window of the popup window + * @return ImageSummaryRead of selected image or null, if abort has been used + */ + public static ImageSummaryRead open(Window modalParent) { + return new LectureChangeLinkedImage(modalParent).runAndReturn(); + } +} diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java index c84f5d54..9c96816c 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java @@ -24,6 +24,7 @@ import javax.swing.event.DocumentListener; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; +import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.bwlp.thrift.iface.ImageVersionDetails; import org.openslx.bwlp.thrift.iface.LecturePermissions; import org.openslx.bwlp.thrift.iface.LectureRead; @@ -90,6 +91,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements */ private boolean permissionsChanged = false; + private boolean imageLinkChanged = false; + private Task dateChecker; private boolean reactive = false; @@ -115,8 +118,22 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements btnLinkImage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - // TODO Auto-generated method stub - + ImageSummaryRead newImage = LectureChangeLinkedImage.open(me); + if(newImage != null) { + try { + image = ThriftManager.getSatClient().getImageDetails(Session.getSatelliteToken(), newImage.imageBaseId); + } catch (TException e1) { + LOGGER.error("Failed to retrieve details of new image: ", e1); + return; + } + lecture.imageBaseId = newImage.imageBaseId; + lecture.imageVersionId = newImage.latestVersionId; + fillVersionsCombo(); + cboVersions.setEnabled(false); + btnAutoUpdate.setSelected(true); + imageLinkChanged = true; + reactToChange(); + } } }); /** @@ -145,12 +162,12 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements public void actionPerformed(ActionEvent e) { UserListWindow.open(me, new UserAddedCallback() { - @Override - public void userAdded(UserInfo user, UserListWindow window) { - window.dispose(); - setLectureOwner(user); - } - }, "Besitzer festlegen"); + @Override + public void userAdded(UserInfo user, UserListWindow window) { + window.dispose(); + setLectureOwner(user); + } + }, "Besitzer festlegen"); } }); btnPermissions.addActionListener(new ActionListener() { @@ -195,23 +212,23 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements public void setLecture(final String lectureId) { ThriftActions.getLectureWithImageDetails(JOptionPane.getFrameForComponent(me), lectureId, new LectureMetaCallback() { - @Override - public void fetchedLectureDetails(LectureRead lectureDetails, - ImageDetailsRead imageDetails) { - synchronized (me) { - lecture = lectureDetails; - image = imageDetails; - permissionMap = ThriftActions.getLecturePermissions( - JOptionPane.getFrameForComponent(me), lecture.lectureId); - } - fill(); - } + @Override + public void fetchedLectureDetails(LectureRead lectureDetails, + ImageDetailsRead imageDetails) { + synchronized (me) { + lecture = lectureDetails; + image = imageDetails; + permissionMap = ThriftActions.getLecturePermissions( + JOptionPane.getFrameForComponent(me), lecture.lectureId); + } + fill(); + } - @Override - public void fetchedLecturePermissions(Map<String, LecturePermissions> permissions) { - return; - } - }); + @Override + public void fetchedLecturePermissions(Map<String, LecturePermissions> permissions) { + return; + } + }); } @@ -240,9 +257,28 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements lblUseCount.setText(Integer.toString(lecture.useCount)); + fillVersionsCombo(); + + Calendar startCal = Calendar.getInstance(); + startCal.setTime(new Date(lecture.getStartTime() * 1000l)); + startDate.getModel().setDate(startCal.get(Calendar.YEAR), startCal.get(Calendar.MONTH), + startCal.get(Calendar.DATE)); + startTime.getModel().setValue(startCal.getTime()); + + Calendar endCal = Calendar.getInstance(); + endCal.setTime(new Date(lecture.getEndTime() * 1000l)); + endDate.getModel().setDate(endCal.get(Calendar.YEAR), endCal.get(Calendar.MONTH), + endCal.get(Calendar.DATE)); + endTime.getModel().setValue(endCal.getTime()); + + listenToChange(); + makeEditable(true); + setVisible(true); + } + + private void fillVersionsCombo(){ // version combo List<ImageVersionDetails> versions = image.getVersions(); - for (Iterator<ImageVersionDetails> it = image.getVersions().iterator(); it.hasNext();) { ImageVersionDetails version = it.next(); if (!version.isValid && !lecture.imageVersionId.equals(version.versionId)) { @@ -261,22 +297,6 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements versions.toArray(new ImageVersionDetails[versions.size()]))); cboVersions.setSelectedItem(new ImageVersionDetails(lecture.getImageVersionId(), 0, 0, 0, null, true, true, true, null)); - - Calendar startCal = Calendar.getInstance(); - startCal.setTime(new Date(lecture.getStartTime() * 1000l)); - startDate.getModel().setDate(startCal.get(Calendar.YEAR), startCal.get(Calendar.MONTH), - startCal.get(Calendar.DATE)); - startTime.getModel().setValue(startCal.getTime()); - - Calendar endCal = Calendar.getInstance(); - endCal.setTime(new Date(lecture.getEndTime() * 1000l)); - endDate.getModel().setDate(endCal.get(Calendar.YEAR), endCal.get(Calendar.MONTH), - endCal.get(Calendar.DATE)); - endTime.getModel().setValue(endCal.getTime()); - - listenToChange(); - makeEditable(true); - setVisible(true); } /** @@ -476,6 +496,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements changed = true; } else if (permissionsChanged) { changed = true; + } else if(imageLinkChanged) { + changed = true; } btnSaveChanges.setEnabled(changed); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureChangeLinkedImageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureChangeLinkedImageLayout.java new file mode 100644 index 00000000..808b524a --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureChangeLinkedImageLayout.java @@ -0,0 +1,78 @@ +package org.openslx.dozmod.gui.window.layout; + +import java.awt.Dimension; +import java.awt.Window; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; + +import org.apache.log4j.Logger; +import org.openslx.dozmod.gui.control.ImageListViewer; +import org.openslx.dozmod.gui.helper.GridManager; + + +/** + * Layout for the ChangeLinkedImage of a lecture + */ +@SuppressWarnings("serial") +public class LectureChangeLinkedImageLayout extends JDialog { + + private static final Logger LOGGER = Logger.getLogger(LectureChangeLinkedImageLayout.class); + + /** + * Buttons + */ + protected final JButton btnOk; + protected final JButton btnClose; + + + /** + * The ListViewer to use. + */ + protected final ImageListViewer imageListViewer; + + /** + * The title of the window. + */ + private static String title = "Image zum verlinken auswählen"; + + protected LectureChangeLinkedImageLayout(Window modalParent) { + super(modalParent, title, modalParent != null ? ModalityType.APPLICATION_MODAL + : ModalityType.MODELESS); + + // Panel to add everything into, needed for the border. + JPanel contentPanel = new JPanel(); + contentPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + add(contentPanel); + + GridManager grid = new GridManager(contentPanel, 1); + + // create the imageListViewer and add it to the pane. + imageListViewer = new ImageListViewer(); + + // Panel for the buttons at the bottom + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); + btnOk = new JButton("Übernehmen"); + buttonPane.add(Box.createGlue()); + buttonPane.add(btnOk); + btnClose = new JButton("Abbrechen"); + buttonPane.add(btnClose); + + // Put everything into the grid + grid.add(imageListViewer).fill(true, true).expand(true, true); + grid.nextRow(); + grid.add(buttonPane).fill(true, false).expand(false, false); + grid.nextRow(); + grid.finish(false); + + contentPanel.setPreferredSize(new Dimension(480, 350)); + + pack(); + setLocationRelativeTo( modalParent ); + } +} |