summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Bauer2016-01-05 14:11:28 +0100
committerJonathan Bauer2016-01-05 14:11:28 +0100
commitaf93df1939c5c319456608bdc04c09c32cbe084a (patch)
tree7e64bacc7f21a86cbfdba46bdd249a3635afe196
parent[client] room selection widget [wip] (diff)
downloadtutor-module-af93df1939c5c319456608bdc04c09c32cbe084a.tar.gz
tutor-module-af93df1939c5c319456608bdc04c09c32cbe084a.tar.xz
tutor-module-af93df1939c5c319456608bdc04c09c32cbe084a.zip
[client] checkbox to show the lecture only in the selected rooms
functionality still wip renamed room -> locations
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java391
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/RoomSelector.java294
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java12
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LocationSelectionWindow.java62
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/RoomSelectorWindow.java41
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java6
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LocationSelectionWindowLayout.java37
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/RoomSelectorWindowLayout.java37
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java6
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java (renamed from dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureRoomSelectionPageLayout.java)12
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java (renamed from dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureRoomSelectionPage.java)21
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java3
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java7
13 files changed, 528 insertions, 401 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java
new file mode 100644
index 00000000..a780c1cb
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java
@@ -0,0 +1,391 @@
+package org.openslx.dozmod.gui.control;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+
+import org.apache.log4j.Logger;
+import org.openslx.bwlp.thrift.iface.Location;
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.helper.GridManager;
+import org.openslx.dozmod.thrift.cache.MetaDataCache;
+import org.openslx.util.QuickTimer;
+import org.openslx.util.QuickTimer.Task;
+
+/**
+ *
+ * Widget to select the locations of a lecture. The UI is simply two JLists and
+ * a button panel to move the elements from one list to the other. Use the
+ * getters to read the values of the lists/checkbox: get
+ *
+ * @author Jonathan Bauer
+ *
+ */
+public class LocationSelector extends JPanel {
+ private final static Logger LOGGER = Logger
+ .getLogger(LocationSelector.class);
+
+ private DefaultListModel<Location> availableLocationModel = new DefaultListModel<Location>();
+ private DefaultListModel<Location> selectedLocationModel = new DefaultListModel<Location>();
+
+ private JButton addAllButton = new JButton(">>");
+ private JButton addButton = new JButton(">");
+ private JButton removeButton = new JButton("<");
+ private JButton removeAllButton = new JButton("<<");
+
+ private JCheckBox onlyInSelection = new JCheckBox(
+ "Veranstaltung ausschließlich in den ausgewählten Räumen anzeigen");
+
+ private boolean initDone = false;
+ private List<Integer> preselection;
+
+ /**
+ * Getter for the available location model
+ *
+ * @return the locationModel of the "available location" list
+ */
+ public DefaultListModel<Location> getLocationModel() {
+ return availableLocationModel;
+ }
+
+ /**
+ * Getter for the selected location model
+ *
+ * @return the locationModel of the "selected location" list
+ */
+ public DefaultListModel<Location> getSelectedLocationModel() {
+ return selectedLocationModel;
+ }
+
+ /**
+ * Getter for the "show only in selection" checkbox
+ *
+ * @return true if checked, false otherwise
+ */
+ public boolean getOnlyInSelection() {
+ return onlyInSelection.isSelected();
+ }
+
+ /**
+ * Sets the selection to the locations corresponding to the given list of
+ * id's
+ *
+ * @param list
+ * of integers to set the locations to
+ */
+ public void setSelectedLocationsAsIds(List<Integer> list) {
+ if (list == null) {
+ LOGGER.error("No list given!");
+ return;
+ }
+ preselection = list;
+ // if we are initialised, we need to explicitly set the selection
+ if (initDone)
+ setSelectionInternal(preselection);
+ }
+
+ /**
+ * Sets the list of available locations. Should be called with the list
+ * given by the server
+ *
+ * @param list
+ * of locations to set the available list to
+ * @return true if setting the list worked, false otherwise
+ */
+ public boolean fillLocationsList(final List<Location> locations) {
+ if (locations == null) {
+ LOGGER.error("No locations returned from the metadata cache.");
+ return false;
+ }
+ for (Location loc : locations) {
+ if (loc != null) {
+ LOGGER.debug("Adding: " + loc.getLocationName());
+ availableLocationModel.addElement(loc);
+ } else {
+ LOGGER.error("One location returned from the server was null");
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Constructor. Initializes the grid layout, the location lists and
+ * initializes the data
+ */
+ public LocationSelector() {
+ GridManager grid = new GridManager(this, 3);
+ LocationRenderer locationRenderer = new LocationRenderer();
+
+ // the available list of locations
+ final JList<Location> availableLocationList = new JList<Location>();
+ availableLocationList.setCellRenderer(locationRenderer);
+ availableLocationList.setModel(availableLocationModel);
+
+ // the selected list of locations
+ final JList<Location> selectedLocationList = new JList<Location>();
+ selectedLocationList.setCellRenderer(locationRenderer);
+ selectedLocationList.setModel(selectedLocationModel);
+
+ // the listeners
+ selectedLocationList.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ Location selection = selectedLocationList.getSelectedValue();
+ if (selection != null) {
+ // LOGGER.debug("Removing: " + selection);
+ if (selectedLocationModel.contains(selection)) {
+ selectedLocationModel.removeElement(selection);
+ if (!availableLocationModel.contains(selection)) {
+ availableLocationModel.addElement(selection);
+ }
+ sortLists();
+ }
+ }
+ }
+ }
+ });
+
+ availableLocationList.addMouseListener(new MouseAdapter() {
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2) {
+ Location selection = availableLocationList.getSelectedValue();
+ if (selection != null) {
+ // LOGGER.debug("Adding: " + selection);
+ if (!selectedLocationModel.contains(selection)) {
+ selectedLocationModel.addElement(selection);
+ availableLocationModel.removeElement(selection);
+ }
+ sortLists();
+ }
+ }
+ }
+ });
+
+ addAllButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ moveAll(availableLocationModel, selectedLocationModel);
+ }
+ });
+ addButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addToSelection(availableLocationList.getSelectedValuesList());
+
+ }
+ });
+ removeButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ removeFromSelection(selectedLocationList.getSelectedValuesList());
+
+ }
+ });
+ removeAllButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ moveAll(selectedLocationModel, availableLocationModel);
+ }
+ });
+
+ grid.add(new QLabel("Verfügbare Räume"));
+ grid.skip();
+ grid.add(new QLabel("Ausgewählte Räume"));
+ grid.nextRow();
+ JScrollPane availableScrollPane = new JScrollPane(availableLocationList);
+ availableScrollPane.setPreferredSize(new Dimension(1, 1));
+ grid.add(availableScrollPane).fill(true, true).expand(true, true);
+ // Vertical BoxLayout for buttons
+ JPanel buttonPanel = new JPanel();
+ GridManager buttonGrid = new GridManager(buttonPanel, 1);
+ buttonGrid.add(addAllButton).fill(true, false);
+ buttonGrid.nextRow();
+ buttonGrid.add(addButton).fill(true, false);
+ buttonGrid.nextRow();
+ buttonGrid.add(removeButton).fill(true, false);
+ buttonGrid.nextRow();
+ buttonGrid.add(removeAllButton).fill(true, false);
+ buttonGrid.nextRow();
+ buttonGrid.finish(true);
+ grid.add(buttonPanel).fill(false, false).expand(false, false);
+ JScrollPane selectionScrollPane = new JScrollPane(selectedLocationList);
+ selectionScrollPane.setPreferredSize(new Dimension(1, 1));
+ grid.add(selectionScrollPane).fill(true, true).expand(true, true);
+ grid.nextRow();
+ grid.add(onlyInSelection, 3).fill(false, false).expand(false, false);
+ grid.finish(true);
+
+ // initialise the data
+ init();
+ }
+
+ /**
+ * Async initialization of the data models by fetching the list of the
+ * locations from the server
+ */
+ public void init() {
+ QuickTimer.scheduleOnce(new Task() {
+ List<Location> locsList = null;
+
+ @Override
+ public void fire() {
+ locsList = MetaDataCache.getLocations();
+ Gui.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ initDone = fillLocationsList(locsList);
+ // check if preselection was set before we were done
+ // initialising
+ if (initDone && preselection != null) {
+ setSelectionInternal(preselection);
+ }
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * Moves all elements from the available to the selected list
+ *
+ * @param model
+ * to move from
+ * @param model
+ * to move to
+ */
+ private void moveAll(DefaultListModel<Location> from,
+ DefaultListModel<Location> to) {
+ for (Enumeration<Location> location = from.elements(); location
+ .hasMoreElements();) {
+ Location current = location.nextElement();
+ to.addElement(current);
+ }
+ from.clear();
+ sortLists();
+ }
+
+ /**
+ * Adds the given location to the selection
+ *
+ * @param location
+ * to add to selection
+ */
+ private void addToSelection(Location location) {
+ if (location == null) {
+ return;
+ }
+ List<Location> newLocations = new ArrayList<Location>();
+ newLocations.add(location);
+ addToSelection(newLocations);
+ }
+
+ /**
+ * Adds the given list of locations to the selection
+ *
+ * @param list
+ * of locations to add to the selection
+ */
+ private void addToSelection(List<Location> locations) {
+ if (locations == null)
+ return;
+ // LOGGER.debug("AddToSelection: " + locations);
+ for (Location location : locations) {
+ selectedLocationModel.addElement(location);
+ availableLocationModel.removeElement(location);
+ }
+ sortLists();
+ }
+
+ /**
+ * Removes the given list of locations from the selections
+ *
+ * @param locations
+ * to remove from the selection
+ */
+ private void removeFromSelection(List<Location> locations) {
+ if (locations == null)
+ return;
+ // LOGGER.debug("RemoveFromSelection: " + locations);
+ for (Location location : locations) {
+ selectedLocationModel.removeElement(location);
+ availableLocationModel.addElement(location);
+ }
+ sortLists();
+ }
+
+ /**
+ * Helper to sort both lists when changes occur. TODO: doing this via model
+ * change listeners?
+ */
+ private void sortLists() {
+ // sort the available location list
+ List<Location> list = Collections.list(availableLocationModel.elements());
+ Collections.sort(list);
+ availableLocationModel.clear();
+ for (Location loc : list) {
+ availableLocationModel.addElement(loc);
+ }
+ // sort the selected location list
+ list = Collections.list(selectedLocationModel.elements());
+ Collections.sort(list);
+ selectedLocationModel.clear();
+ for (Location loc : list) {
+ selectedLocationModel.addElement(loc);
+ }
+ }
+
+ /**
+ * Internal helper to set the selection of the list of location
+ * corresponding the the given list of ids
+ *
+ * @param list of id's to set the selected locations to
+ */
+ private void setSelectionInternal(List<Integer> list) {
+ if (list == null || list.isEmpty()) {
+ LOGGER.error("No list given for preselection!");
+ return;
+ }
+ LOGGER.debug("Setting to: " + preselection);
+ moveAll(selectedLocationModel, availableLocationModel);
+
+ for (Integer id : preselection) {
+ LOGGER.debug("Searching: " + id);
+ Location loc = MetaDataCache.getLocationById(id);
+ LOGGER.debug("Found: " + loc);
+ if (loc != null) {
+ addToSelection(loc);
+ LOGGER.debug("Added: " + loc);
+ }
+ }
+ }
+}
+
+@SuppressWarnings("serial")
+class LocationRenderer extends DefaultListCellRenderer {
+ @Override
+ public Component getListCellRendererComponent(JList<? extends Object> list,
+ Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ if (value instanceof Location) {
+ return super.getListCellRendererComponent(list,
+ ((Location) value).getLocationName(), index, isSelected,
+ cellHasFocus);
+ }
+ return super.getListCellRendererComponent(list, value, index,
+ isSelected, cellHasFocus);
+ }
+} \ No newline at end of file
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/RoomSelector.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/RoomSelector.java
deleted file mode 100644
index ae1afc5e..00000000
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/RoomSelector.java
+++ /dev/null
@@ -1,294 +0,0 @@
-package org.openslx.dozmod.gui.control;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.DefaultListModel;
-import javax.swing.JButton;
-import javax.swing.JList;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-
-import org.apache.log4j.Logger;
-import org.openslx.bwlp.thrift.iface.Location;
-import org.openslx.dozmod.gui.Gui;
-import org.openslx.dozmod.gui.helper.GridManager;
-import org.openslx.dozmod.thrift.cache.MetaDataCache;
-import org.openslx.util.QuickTimer;
-import org.openslx.util.QuickTimer.Task;
-
-public class RoomSelector extends QLabel {
- private final static Logger LOGGER = Logger.getLogger(RoomSelector.class);
-
- private DefaultListModel<Location> roomModel = new DefaultListModel<Location>();
- private DefaultListModel<Location> selectedRoomModel = new DefaultListModel<Location>();
-
- private JButton addAllButton = new JButton(">>");
- private JButton addButton = new JButton(">");
- private JButton removeButton = new JButton("<");
- private JButton removeAllButton = new JButton("<<");
-
- private boolean initDone = false;
- private List<Integer> preselection;
-
- public RoomSelector() {
- GridManager grid = new GridManager(this, 3);
- LocationRenderer locationRenderer = new LocationRenderer();
-
- // the available list of rooms
- final JList<Location> roomList = new JList<Location>();
- roomList.setCellRenderer(locationRenderer);
- roomList.setModel(roomModel);
-
- // the selected list of rooms
- final JList<Location> selectedRoomList = new JList<Location>();
- selectedRoomList.setCellRenderer(locationRenderer);
- selectedRoomList.setModel(selectedRoomModel);
-
- // the listeners
- selectedRoomList.addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- Location selection = selectedRoomList.getSelectedValue();
- if (selection != null) {
- // LOGGER.debug("Removing: " + selection);
- if (selectedRoomModel.contains(selection)) {
- selectedRoomModel.removeElement(selection);
- if (!roomModel.contains(selection)) {
- roomModel.addElement(selection);
- }
- sortLists();
- }
- }
- }
- }
- });
-
- roomList.addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent e) {
- if (e.getClickCount() == 2) {
- Location selection = roomList.getSelectedValue();
- if (selection != null) {
- // LOGGER.debug("Adding: " + selection);
- if (!selectedRoomModel.contains(selection)) {
- selectedRoomModel.addElement(selection);
- roomModel.removeElement(selection);
- }
- sortLists();
- }
- }
- }
- });
-
- addAllButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- moveAll(roomModel, selectedRoomModel);
- }
- });
- addButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addToSelection(roomList.getSelectedValuesList());
-
- }
- });
- removeButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- removeFromSelection(selectedRoomList.getSelectedValuesList());
-
- }
- });
- removeAllButton.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- moveAll(selectedRoomModel, roomModel);
- }
- });
-
- grid.add(new QLabel("Verfügbare Räume"));
- grid.skip();
- grid.add(new QLabel("Ausgewählte Räume"));
- grid.nextRow();
- grid.add(new JScrollPane(roomList)).fill(true, true).expand(true, true);
- // Vertical BoxLayout for buttons
- JPanel buttonPanel = new JPanel();
- GridManager buttonGrid = new GridManager(buttonPanel, 1);
- buttonGrid.add(addAllButton).fill(true, false);
- buttonGrid.nextRow();
- buttonGrid.add(addButton).fill(true, false);
- buttonGrid.nextRow();
- buttonGrid.add(removeButton).fill(true, false);
- buttonGrid.nextRow();
- buttonGrid.add(removeAllButton).fill(true, false);
- buttonGrid.nextRow();
- buttonGrid.finish(true);
- grid.add(buttonPanel).fill(false, false).expand(false, false);
- grid.add(new JScrollPane(selectedRoomList)).fill(true, true)
- .expand(true, true);
- grid.nextRow();
- grid.finish(true);
-
- // initialise the data
- init();
- }
-
- public void init() {
- QuickTimer.scheduleOnce(new Task() {
- List<Location> locsList = null;
-
- @Override
- public void fire() {
- locsList = MetaDataCache.getLocations();
- Gui.asyncExec(new Runnable() {
- @Override
- public void run() {
- initDone = fillRoomList(locsList);
- // check if preselection was set before we were done initialising
- if (initDone && preselection != null) {
- setSelectionInternal(preselection);
- }
- }
- });
- }
- });
- }
-
- public boolean fillRoomList(final List<Location> locations) {
- if (locations == null) {
- LOGGER.error("No locations returned from the metadata cache.");
- return false;
- }
- for (Location loc : locations) {
- if (loc != null) {
- LOGGER.debug("Adding: " + loc.getLocationName());
- roomModel.addElement(loc);
- } else {
- LOGGER.error("One location returned from the server was null");
- }
- }
- return true;
- }
-
- private void moveAll(DefaultListModel<Location> from,
- DefaultListModel<Location> to) {
- for (Enumeration<Location> rooms = from.elements(); rooms
- .hasMoreElements();) {
- Location current = rooms.nextElement();
- to.addElement(current);
- }
- from.clear();
- sortLists();
- }
-
- // convenience
- private void addToSelection(Location location) {
- if (location == null) {
- return;
- }
- List<Location> newLocations = new ArrayList<Location>();
- newLocations.add(location);
- addToSelection(newLocations);
- }
-
- private void addToSelection(List<Location> locations) {
- if (locations == null)
- return;
- // LOGGER.debug("AddToSelection: " + locations);
- for (Location location : locations) {
- selectedRoomModel.addElement(location);
- roomModel.removeElement(location);
- }
- sortLists();
- }
-
- private void removeFromSelection(List<Location> locations) {
- if (locations == null)
- return;
- // LOGGER.debug("RemoveFromSelection: " + locations);
- for (Location location : locations) {
- selectedRoomModel.removeElement(location);
- roomModel.addElement(location);
- }
- sortLists();
- }
-
- private void sortLists() {
- // sort the available room list
- List<Location> list = Collections.list(roomModel.elements());
- Collections.sort(list);
- roomModel.clear();
- for (Location loc : list) {
- roomModel.addElement(loc);
- }
- // sort the selected room list
- list = Collections.list(selectedRoomModel.elements());
- Collections.sort(list);
- selectedRoomModel.clear();
- for (Location loc : list) {
- selectedRoomModel.addElement(loc);
- }
- }
-
- public DefaultListModel<Location> getRoomModel() {
- return roomModel;
- }
-
- public DefaultListModel<Location> getSelectedRoomModel() {
- return selectedRoomModel;
- }
-
- public void setSelectedRoomsAsIds(List<Integer> list) {
- if (list == null) {
- LOGGER.error("No list given!");
- return;
- }
- preselection = list;
- // if we are initialised, we need to explicitly set the selection
- if (initDone)
- setSelectionInternal(preselection);
- }
- private void setSelectionInternal(List<Integer> list){
- if (list == null || list.isEmpty()) {
- LOGGER.error("No list given for preselection!");
- return;
- }
- LOGGER.debug("Setting to: " + preselection);
- moveAll(selectedRoomModel, roomModel);
-
- for (Integer id : preselection) {
- LOGGER.debug("Searching: " + id);
- Location loc = MetaDataCache
- .getLocationById(id);
- LOGGER.debug("Found: " + loc);
- if (loc != null) {
- addToSelection(loc);
- LOGGER.debug("Added: " + loc);
- }
- }
- }
-}
-
-@SuppressWarnings("serial")
-class LocationRenderer extends DefaultListCellRenderer {
- @Override
- public Component getListCellRendererComponent(JList<? extends Object> list,
- Object value, int index, boolean isSelected, boolean cellHasFocus) {
- if (value instanceof Location) {
- return super.getListCellRendererComponent(list,
- ((Location) value).getLocationName(), index, isSelected,
- cellHasFocus);
- }
- return super.getListCellRendererComponent(list, value, index,
- isSelected, cellHasFocus);
- }
-} \ No newline at end of file
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 5118ebcf..e7a08115 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
@@ -196,12 +196,12 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
reactToChange();
}
});
- btnRooms.addActionListener(new ActionListener() {
+ btnLocations.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
- List<Integer> roomList = new ArrayList<Integer>();
- // TODO load the room list from the LectureSummary
- List<Integer> newRoomList = RoomSelectorWindow.open(me, roomList);
+ List<Integer> locationsList = new ArrayList<Integer>();
+ // TODO load the location list from the LectureSummary
+ List<Integer> newLocationsList = LocationSelectionWindow.open(me, locationsList);
// TODO check if something changed and if so save the change
}
});
@@ -477,7 +477,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
DateTimeHelper.getDateFrom(startDate, startTime).getTime() / 1000L,
DateTimeHelper.getDateFrom(endDate, endTime).getTime() / 1000L, null, null,
chkIsExam.isSelected(), chkHasInternetAccess.isSelected(),
- lecture.getDefaultPermissions(), null);
+ lecture.getDefaultPermissions(), null, false);
// now trigger the actual action
try {
ThriftManager.getSatClient().updateLecture(Session.getSatelliteToken(),
@@ -594,7 +594,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements
lblError.setText("Ungültiger Zeitraum!");
return false;
}
- // TODO check if rooms changed
+ // TODO check if locations changed
// done with mandatory checks, remove error message
lblError.setText(null);
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LocationSelectionWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LocationSelectionWindow.java
new file mode 100644
index 00000000..e178a9c3
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LocationSelectionWindow.java
@@ -0,0 +1,62 @@
+package org.openslx.dozmod.gui.window;
+
+import java.awt.Window;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.Gui.GuiCallable;
+import org.openslx.dozmod.gui.helper.UiFeedback;
+import org.openslx.dozmod.gui.window.layout.LocationSelectionWindowLayout;
+
+/**
+ * Minimal window containing a LocationSelector widget
+ *
+ * @author Jonathan Bauer
+ *
+ */
+public class LocationSelectionWindow extends LocationSelectionWindowLayout implements UiFeedback {
+
+ /**
+ * @param modalParent parent to this window
+ * @param list of locations to preselect in the LocationSelector
+ */
+ public LocationSelectionWindow(Window modalParent, List<Integer> locations) {
+ super(modalParent, locations);
+ Gui.centerShellOverShell(modalParent, this);
+ }
+
+ /**
+ * @return list of ids of the selected locations
+ */
+ public List<Integer> runAndReturn() {
+ setVisible(true);
+ return new ArrayList<Integer>();
+ }
+
+ /**
+ * Static method to open this window with
+ *
+ * @param modalParent parent to this window
+ * @param locations locations to preselect in the LocationSelector
+ * @return forwards the return value of the window itself: list of ids of the selected locations
+ */
+ public static List<Integer> open(final Window modalParent, final List<Integer> locations) {
+ return Gui.syncExec(new GuiCallable<List<Integer>>() {
+ @Override
+ public List<Integer> run() {
+ return new LocationSelectionWindow(modalParent, locations).runAndReturn();
+ }
+ });
+ }
+
+ @Override
+ public boolean wantConfirmQuit() {
+ return false;
+ }
+
+ @Override
+ public void escapePressed() {
+ dispose();
+ }
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/RoomSelectorWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/RoomSelectorWindow.java
deleted file mode 100644
index 00c74251..00000000
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/RoomSelectorWindow.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.openslx.dozmod.gui.window;
-
-import java.awt.Window;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openslx.dozmod.gui.Gui;
-import org.openslx.dozmod.gui.Gui.GuiCallable;
-import org.openslx.dozmod.gui.helper.UiFeedback;
-import org.openslx.dozmod.gui.window.layout.RoomSelectorWindowLayout;
-
-public class RoomSelectorWindow extends RoomSelectorWindowLayout implements UiFeedback {
-
- public RoomSelectorWindow(Window modalParent, List<Integer> roomList) {
- super(modalParent, roomList);
- Gui.centerShellOverShell(modalParent, this);
- }
- public List<Integer> runAndReturn() {
- setVisible(true);
- return new ArrayList<Integer>();
- }
-
- public static List<Integer> open(final Window modalParent, final List<Integer> roomList) {
- return Gui.syncExec(new GuiCallable<List<Integer>>() {
- @Override
- public List<Integer> run() {
- return new RoomSelectorWindow(modalParent, roomList).runAndReturn();
- }
- });
- }
-
- @Override
- public boolean wantConfirmQuit() {
- return false;
- }
-
- @Override
- public void escapePressed() {
- dispose();
- }
-}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
index 388f3605..e87400f8 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java
@@ -63,7 +63,7 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
protected final QLabel lblUseCount;
protected final JButton btnPermissions;
- protected final JButton btnRooms;
+ protected final JButton btnLocations;
protected QLabel lblError;
protected final JButton btnSaveChanges;
@@ -240,10 +240,10 @@ public abstract class LectureDetailsWindowLayout extends JDialog {
// button for the custom permissions
JPanel bottomButtonPanel = new JPanel();
btnPermissions = new JButton("Berechtigungen");
- btnRooms = new JButton("Raumauswahl");
+ btnLocations = new JButton("Raumauswahl");
grid.skip();
bottomButtonPanel.add(btnPermissions);
- bottomButtonPanel.add(btnRooms);
+ bottomButtonPanel.add(btnLocations);
grid.add(bottomButtonPanel);
grid.skip();
grid.nextRow();
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LocationSelectionWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LocationSelectionWindowLayout.java
new file mode 100644
index 00000000..979531ff
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LocationSelectionWindowLayout.java
@@ -0,0 +1,37 @@
+package org.openslx.dozmod.gui.window.layout;
+
+import java.awt.Window;
+import java.util.List;
+
+import javax.swing.BorderFactory;
+import javax.swing.JDialog;
+import javax.swing.JSeparator;
+
+import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.control.LocationSelector;
+import org.openslx.dozmod.gui.control.WordWrapLabel;
+import org.openslx.dozmod.gui.helper.GridManager;
+
+public class LocationSelectionWindowLayout extends JDialog {
+
+ protected LocationSelector locationSelector;
+
+ public LocationSelectionWindowLayout(Window modalParent, List<Integer> locationList) {
+ super(modalParent);
+
+ getRootPane().setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ GridManager grid = new GridManager(this, 1);
+ WordWrapLabel header = new WordWrapLabel("Hier können Sie die Räume auswählen, in denen diese Veranstaltung sichtbar sein soll.");
+ locationSelector = new LocationSelector();
+ locationSelector.setSelectedLocationsAsIds(locationList);
+ grid.add(header).fill(true, false).expand(true, false);
+ grid.nextRow();
+ grid.add(new JSeparator());
+ grid.nextRow();
+ grid.add(locationSelector).fill(true, true).expand(true, true);
+ grid.finish(false);
+ setPreferredSize(Gui.getScaledDimension(520, 350));
+ pack();
+ Gui.centerShellOverShell(modalParent, this);
+ }
+}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/RoomSelectorWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/RoomSelectorWindowLayout.java
deleted file mode 100644
index e00d00a7..00000000
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/RoomSelectorWindowLayout.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.openslx.dozmod.gui.window.layout;
-
-import java.awt.Window;
-import java.util.List;
-
-import javax.swing.BorderFactory;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JSeparator;
-
-import org.openslx.dozmod.gui.Gui;
-import org.openslx.dozmod.gui.control.RoomSelector;
-import org.openslx.dozmod.gui.helper.GridManager;
-
-public class RoomSelectorWindowLayout extends JDialog {
-
- protected RoomSelector roomSelector;
-
- public RoomSelectorWindowLayout(Window modalParent, List<Integer> roomList) {
- super(modalParent);
-
- getRootPane().setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- GridManager grid = new GridManager(this, 1);
- JLabel header = new JLabel("<html>Hier können Sie die Räume auswählen, in denen diese Veranstaltung sichtbar sein soll.<html>");
- roomSelector = new RoomSelector();
- roomSelector.setSelectedRoomsAsIds(roomList);
- grid.add(header).fill(true, false).expand(true, false);
- grid.nextRow();
- grid.add(new JSeparator());
- grid.nextRow();
- grid.add(roomSelector).fill(true, true).expand(true, true);
- grid.finish(false);
- setPreferredSize(Gui.getScaledDimension(480, 350));
- pack();
- Gui.centerShellOverShell(modalParent, this);
- }
-}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
index 11797d2a..f774fb2a 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
@@ -16,7 +16,7 @@ import org.openslx.dozmod.gui.wizard.page.LectureCreationPage;
import org.openslx.dozmod.gui.wizard.page.LectureCustomPermissionPage;
import org.openslx.dozmod.gui.wizard.page.LectureImageListPage;
import org.openslx.dozmod.gui.wizard.page.LectureOptionsPage;
-import org.openslx.dozmod.gui.wizard.page.LectureRoomSelectionPage;
+import org.openslx.dozmod.gui.wizard.page.LectureLocationSelectionPage;
import org.openslx.dozmod.state.LectureWizardState;
import org.openslx.dozmod.thrift.Session;
import org.openslx.dozmod.thrift.ThriftActions;
@@ -53,7 +53,7 @@ public class LectureWizard extends Wizard implements UiFeedback {
addPage(new LectureImageListPage(this, state));
addPage(new LectureOptionsPage(this, state));
addPage(new LectureCustomPermissionPage(this, state));
- addPage(new LectureRoomSelectionPage(this, state));
+ addPage(new LectureLocationSelectionPage(this, state));
}
@Override
@@ -138,6 +138,6 @@ public class LectureWizard extends Wizard implements UiFeedback {
private LectureWrite lectureWriteFromState() {
return new LectureWrite(state.name, state.description, state.imageVersionId, state.autoUpdate,
state.isEnabled, state.start.getTime() / 1000L, state.end.getTime() / 1000L, null, null,
- state.isExam, state.internetAccess, state.defaultPermissions, state.locations);
+ state.isExam, state.internetAccess, state.defaultPermissions, state.locations, state.onlyInSelectedLocations);
}
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureRoomSelectionPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java
index b0c00ea7..28c415d0 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureRoomSelectionPageLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java
@@ -1,23 +1,23 @@
package org.openslx.dozmod.gui.wizard.layout;
import org.apache.log4j.Logger;
-import org.openslx.dozmod.gui.control.RoomSelector;
+import org.openslx.dozmod.gui.control.LocationSelector;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.wizard.Wizard;
import org.openslx.dozmod.gui.wizard.WizardPage;
@SuppressWarnings("serial")
-public class LectureRoomSelectionPageLayout extends WizardPage {
+public class LectureLocationSelectionPageLayout extends WizardPage {
- private final static Logger LOGGER = Logger.getLogger(LectureRoomSelectionPageLayout.class);
+ private final static Logger LOGGER = Logger.getLogger(LectureLocationSelectionPageLayout.class);
- protected RoomSelector roomSelector = new RoomSelector();
+ protected LocationSelector locationSelector = new LocationSelector();
- public LectureRoomSelectionPageLayout(Wizard wizard) {
+ public LectureLocationSelectionPageLayout(Wizard wizard) {
super(wizard, "Raumauswahl");
setDescription("Bitte wählen Sie die Räume für diese Veranstaltung aus");
GridManager grid = new GridManager(this, 1);
- grid.add(roomSelector).fill(true, true).expand(true, true);
+ grid.add(locationSelector).fill(true, true).expand(true, true);
grid.finish(false);
}
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureRoomSelectionPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java
index 7ea2e46b..e02f2829 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureRoomSelectionPage.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java
@@ -10,24 +10,23 @@ import org.apache.log4j.Logger;
import org.openslx.bwlp.thrift.iface.Location;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.wizard.Wizard;
-import org.openslx.dozmod.gui.wizard.layout.LectureRoomSelectionPageLayout;
+import org.openslx.dozmod.gui.wizard.layout.LectureLocationSelectionPageLayout;
import org.openslx.dozmod.state.LectureWizardState;
import org.openslx.dozmod.thrift.cache.MetaDataCache;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
@SuppressWarnings("serial")
-public class LectureRoomSelectionPage extends LectureRoomSelectionPageLayout {
+public class LectureLocationSelectionPage extends LectureLocationSelectionPageLayout {
- private final static Logger LOGGER = Logger.getLogger(LectureRoomSelectionPage.class);
+ private final static Logger LOGGER = Logger.getLogger(LectureLocationSelectionPage.class);
private LectureWizardState state = null;
- public LectureRoomSelectionPage(Wizard wizard, LectureWizardState state) {
+ public LectureLocationSelectionPage(Wizard wizard, LectureWizardState state) {
super(wizard);
setPageComplete(true);
this.state = state;
-
}
@Override
@@ -36,20 +35,22 @@ public class LectureRoomSelectionPage extends LectureRoomSelectionPageLayout {
}
private boolean updateState() {
- DefaultListModel<Location> selectedRoomModel = roomSelector.getSelectedRoomModel();
- if (selectedRoomModel != null && selectedRoomModel.elements() != null) {
+ DefaultListModel<Location> selectedLocationModel = locationSelector.getSelectedLocationModel();
+ if (selectedLocationModel != null && selectedLocationModel.elements() != null) {
// prepare the final list
if (state.locations == null) {
state.locations = new ArrayList<Integer>();
} else {
state.locations.clear();
}
- List<Location> selectedRoomList = Collections.list(selectedRoomModel.elements());
- for (Location loc : selectedRoomList) {
+ List<Location> selectedLocationList = Collections.list(selectedLocationModel.elements());
+ for (Location loc : selectedLocationList) {
state.locations.add(loc.getLocationId());
}
+ // check the state of the checkbox only if we have a selection
+ state.onlyInSelectedLocations = locationSelector.getOnlyInSelection();
} else {
- // allow empty room selection?
+ // allow empty location selection?
return false;
}
return true;
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java
index 54d462ac..c5237daa 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/state/LectureWizardState.java
@@ -25,8 +25,9 @@ public class LectureWizardState {
public LecturePermissions defaultPermissions = Session.getSatelliteConfig().defaultLecturePermissions;
// explicit permissions per user as set by the creator
public Map<String, LecturePermissions> permissionMap = null;
- // list of rooms for the lecture
+ // list of locations for the lecture
public List<Integer> locations;
+ public boolean onlyInSelectedLocations = false;
// -- thrift internal stuff --
public String uuid = null;
}
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
index ce74680d..a1a9dacf 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/thrift/ServerHandler.java
@@ -44,6 +44,7 @@ import org.openslx.bwlp.thrift.iface.LecturePermissions;
import org.openslx.bwlp.thrift.iface.LectureRead;
import org.openslx.bwlp.thrift.iface.LectureSummary;
import org.openslx.bwlp.thrift.iface.LectureWrite;
+import org.openslx.bwlp.thrift.iface.Location;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.Organization;
import org.openslx.bwlp.thrift.iface.SatelliteConfig;
@@ -632,4 +633,10 @@ public class ServerHandler implements SatelliteServer.Iface {
}
}
+ @Override
+ public List<Location> getLocations() throws TException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}