diff options
Diffstat (limited to 'dozentenmodul')
7 files changed, 46 insertions, 90 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 index 0d522e44..52fe9753 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/LocationSelector.java @@ -40,16 +40,13 @@ import org.openslx.util.QuickTimer.Task; */ @SuppressWarnings("serial") public class LocationSelector extends JPanel { - private final static Logger LOGGER = Logger - .getLogger(LocationSelector.class); + private final static Logger LOGGER = Logger.getLogger(LocationSelector.class); private JLabel lblError = new JLabel(); private JRadioButton exclusivelyButton = new JRadioButton( "Veranstaltung ausschließlich in den ausgewählten Räumen anzeigen"); private JRadioButton prioritizedButton = new JRadioButton( "Veranstaltung mit höherer Priorität in den ausgewählten Räumen anzeigen"); - // private JCheckBox limitToAllowedUsers = new - // JCheckBox("Nur für die ausgewählten Benutzern anzeigen", false); /** * Flag for the initialization state @@ -96,6 +93,7 @@ public class LocationSelector extends JPanel { // initialise the data init(); } + public JCheckBoxTree getTree() { return locationTree; } @@ -140,15 +138,13 @@ public class LocationSelector extends JPanel { if (locations == null) return false; - DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode( - Config.getLastSatellite()); + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(Config.getLastSatellite()); DefaultTreeModel treeModel = new DefaultTreeModel(rootNode, true); // build map containing the node object for each location for (Location loc : locations) { if (loc == null) continue; - locationNodesMap.put(loc.getLocationId(), - new DefaultMutableTreeNode(loc, true)); + locationNodesMap.put(loc.getLocationId(), new DefaultMutableTreeNode(loc, true)); } // now go over nodes and insert em for (Integer id : locationNodesMap.keySet()) { @@ -160,11 +156,9 @@ public class LocationSelector extends JPanel { if (location.getParentLocationId() == 0) parentNode = rootNode; else - parentNode = locationNodesMap.get(location - .getParentLocationId()); + parentNode = locationNodesMap.get(location.getParentLocationId()); // insert the current node in the tree model - treeModel.insertNodeInto( - locationNodesMap.get(location.getLocationId()), // what + treeModel.insertNodeInto(locationNodesMap.get(location.getLocationId()), // what parentNode, // parent? parentNode.getChildCount()); // index @@ -234,8 +228,7 @@ public class LocationSelector extends JPanel { for (TreePath path : treePathList) { if (path == null) continue; - DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path - .getLastPathComponent(); + DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path.getLastPathComponent(); if (currentNode == null) continue; Object currentDataObject = currentNode.getUserObject(); @@ -252,27 +245,23 @@ public class LocationSelector extends JPanel { // transform the array of paths to a list of leaf nodes List<TreePath> leavesPathsList = new ArrayList<TreePath>(); for (TreePath path : paths) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode) path - .getLastPathComponent(); + DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent(); if (node != null && node.isLeaf()) { leavesPathsList.add(path); } } // now get the root node of the tree and start a depth-first search for // leaves - DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) locationTree - .getModel().getRoot(); + DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) locationTree.getModel().getRoot(); Enumeration<?> depthEnum = rootNode.depthFirstEnumeration(); while (depthEnum.hasMoreElements()) { - DefaultMutableTreeNode current = (DefaultMutableTreeNode) depthEnum - .nextElement(); + DefaultMutableTreeNode current = (DefaultMutableTreeNode) depthEnum.nextElement(); // descend til we found a leaf if (!current.isLeaf()) { continue; } // got a leaf, check the children of its parent - DefaultMutableTreeNode parent = (DefaultMutableTreeNode) current - .getParent(); + DefaultMutableTreeNode parent = (DefaultMutableTreeNode) current.getParent(); // this shouldnt happen but lets be safe... if (parent == null || parent.isLeaf()) continue; @@ -280,8 +269,7 @@ public class LocationSelector extends JPanel { boolean allChildrenSelected = true; Enumeration<?> children = parent.children(); while (children.hasMoreElements()) { - DefaultMutableTreeNode child = (DefaultMutableTreeNode) children - .nextElement(); + DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); // check if this child is in our paths list if (!leavesPathsList.contains(getPath(child))) { // current child not in selection, we can stop the search of @@ -295,8 +283,7 @@ public class LocationSelector extends JPanel { LOGGER.debug("EXCLUDING FROM: " + getPath(parent)); Enumeration<?> enumeration = parent.children(); while (enumeration.hasMoreElements()) { - DefaultMutableTreeNode nod = (DefaultMutableTreeNode) enumeration - .nextElement(); + DefaultMutableTreeNode nod = (DefaultMutableTreeNode) enumeration.nextElement(); leavesPathsList.remove(getPath(nod)); // remove already // checks for // existence @@ -311,6 +298,7 @@ public class LocationSelector extends JPanel { /** * Helper to get the TreePath of the given TreeNode + * * @param treeNode * @return */ @@ -355,14 +343,12 @@ public class LocationSelector extends JPanel { @SuppressWarnings("serial") class LocationRenderer extends DefaultListCellRenderer { @Override - public Component getListCellRendererComponent(JList<? extends Object> list, - Object value, int index, boolean isSelected, boolean cellHasFocus) { + 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, ((Location) value).getLocationName(), index, + isSelected, cellHasFocus); } - return super.getListCellRendererComponent(list, value, 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 00c35381..ce5e532f 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 @@ -36,7 +36,6 @@ import org.openslx.bwlp.thrift.iface.LectureWrite; import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.MainWindow; -import org.openslx.dozmod.gui.control.JCheckBoxTree; import org.openslx.dozmod.gui.helper.DateTimeHelper; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.TextChangeListener; 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 index ce308d90..0db81df1 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LocationSelectionWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LocationSelectionWindow.java @@ -5,7 +5,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.List; -import org.apache.log4j.Logger; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.Gui.GuiCallable; import org.openslx.dozmod.gui.control.JCheckBoxTree.CheckChangeEvent; @@ -20,15 +19,12 @@ import org.openslx.dozmod.thrift.Session; * @author Jonathan Bauer * */ -public class LocationSelectionWindow extends LocationSelectionWindowLayout - implements UiFeedback { +public class LocationSelectionWindow extends LocationSelectionWindowLayout implements UiFeedback { /** * */ private static final long serialVersionUID = -5898656786160024212L; - private static final Logger LOGGER = Logger - .getLogger(LocationSelectionWindow.class); private boolean apply = false; /** @@ -59,8 +55,7 @@ public class LocationSelectionWindow extends LocationSelectionWindowLayout dispose(); } }); - - + // addCheckChangeEventListener locationSelector.getTree().addCheckChangeEventListener(new CheckChangeEventListener() { @Override @@ -78,7 +73,7 @@ public class LocationSelectionWindow extends LocationSelectionWindowLayout } } }); - + // btnSaveChanges.setEnabled(false); Gui.centerShellOverShell(modalParent, this); } @@ -91,7 +86,8 @@ public class LocationSelectionWindow extends LocationSelectionWindowLayout setVisible(true); if (!apply) return null; - return new LocationInfo(locationSelector.getSelectedLocationsAsIds(), locationSelector.getOnlyInSelection()); + return new LocationInfo(locationSelector.getSelectedLocationsAsIds(), + locationSelector.getOnlyInSelection()); } /** @@ -104,13 +100,12 @@ public class LocationSelectionWindow extends LocationSelectionWindowLayout * @return forwards the return value of the window itself: list of ids of * the selected locations */ - public static LocationInfo open(final Window modalParent, - final List<Integer> locations, final boolean limitToLocations) { + public static LocationInfo open(final Window modalParent, final List<Integer> locations, + final boolean limitToLocations) { return Gui.syncExec(new GuiCallable<LocationInfo>() { @Override public LocationInfo run() { - return new LocationSelectionWindow(modalParent, locations, limitToLocations) - .runAndReturn(); + return new LocationSelectionWindow(modalParent, locations, limitToLocations).runAndReturn(); } }); } @@ -129,6 +124,7 @@ public class LocationSelectionWindow extends LocationSelectionWindowLayout class LocationInfo { public List<Integer> locationList; public boolean limitToLocations; + public LocationInfo(List<Integer> locs, boolean limited) { this.locationList = locs; this.limitToLocations = limited; 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 index 3a3b8a5b..0187dca6 100644 --- 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 @@ -29,13 +29,11 @@ public class LocationSelectionWindowLayout extends JDialog { protected JButton btnClose; protected JLabel lblError; - public LocationSelectionWindowLayout(Window modalParent, - List<Integer> locationList, boolean limitToLocations) { - super(modalParent, modalParent != null ? ModalityType.APPLICATION_MODAL - : ModalityType.MODELESS); + public LocationSelectionWindowLayout(Window modalParent, List<Integer> locationList, + boolean limitToLocations) { + super(modalParent, modalParent != null ? ModalityType.APPLICATION_MODAL : ModalityType.MODELESS); - getRootPane() - .setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + 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."); 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 31469ff3..6d88cb90 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 @@ -54,8 +54,9 @@ public class LectureWizard extends Wizard implements UiFeedback { addPage(new LectureImageListPage(this, state)); addPage(new LectureOptionsPage(this, state)); addPage(new LectureCustomPermissionPage(this, state)); - if (MetaDataCache.getLocations() != null && !MetaDataCache.getLocations().isEmpty()) + if (MetaDataCache.getLocations() != null && !MetaDataCache.getLocations().isEmpty()) { addPage(new LectureLocationSelectionPage(this, state)); + } } @Override @@ -97,13 +98,15 @@ public class LectureWizard extends Wizard implements UiFeedback { uuid = ThriftActions.createLecture(JOptionPane.getFrameForComponent(this), lectureWriteFromState()); if (uuid == null) return false; - else - state.uuid = uuid; + + state.uuid = uuid; // now push the permissions if we have any - if (state.permissionMap != null && !state.permissionMap.isEmpty()) + if (state.permissionMap != null && !state.permissionMap.isEmpty()) { if (!ThriftActions.writeLecturePermissions(JOptionPane.getFrameForComponent(this), state.uuid, - state.permissionMap)) + state.permissionMap)) { return false; + } + } // all good, refresh cache and change to LectureList Gui.showMessageBox(this, "Veranstaltung erstellt!", MessageType.INFO, null, null); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java index 28c415d0..5ee2a671 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureLocationSelectionPageLayout.java @@ -11,11 +11,12 @@ public class LectureLocationSelectionPageLayout extends WizardPage { private final static Logger LOGGER = Logger.getLogger(LectureLocationSelectionPageLayout.class); - protected LocationSelector locationSelector = new LocationSelector(); + protected final LocationSelector locationSelector; public LectureLocationSelectionPageLayout(Wizard wizard) { super(wizard, "Raumauswahl"); setDescription("Bitte wählen Sie die Räume für diese Veranstaltung aus"); + locationSelector = new LocationSelector(); GridManager grid = new GridManager(this, 1); 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/LectureLocationSelectionPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java index 40e1110c..f8f10d27 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureLocationSelectionPage.java @@ -1,20 +1,9 @@ package org.openslx.dozmod.gui.wizard.page; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.swing.DefaultListModel; - 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.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 LectureLocationSelectionPage extends LectureLocationSelectionPageLayout { @@ -22,7 +11,7 @@ public class LectureLocationSelectionPage extends LectureLocationSelectionPageLa private final static Logger LOGGER = Logger.getLogger(LectureLocationSelectionPage.class); private LectureWizardState state = null; - + public LectureLocationSelectionPage(Wizard wizard, LectureWizardState state) { super(wizard); setPageComplete(true); @@ -33,26 +22,10 @@ public class LectureLocationSelectionPage extends LectureLocationSelectionPageLa protected boolean wantNextOrFinish() { return updateState(); } - + private boolean updateState() { -// 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> 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 location selection? -// return false; -// } + // TODO return true; } + } |