summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java
diff options
context:
space:
mode:
authorSimon Rettberg2015-09-07 15:24:55 +0200
committerSimon Rettberg2015-09-07 15:24:55 +0200
commit96af3d00c2a1b5086f08961c56e43d2c708bd5d3 (patch)
tree3256c70f07b7911376659b751f2f28832b764054 /dozentenmodul/src/main/java
parent[client] Clean up lecture list window layout (diff)
downloadtutor-module-96af3d00c2a1b5086f08961c56e43d2c708bd5d3.tar.gz
tutor-module-96af3d00c2a1b5086f08961c56e43d2c708bd5d3.tar.xz
tutor-module-96af3d00c2a1b5086f08961c56e43d2c708bd5d3.zip
[client] Show only own lectures by default
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/LectureTable.java8
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java9
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java9
3 files changed, 22 insertions, 4 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/LectureTable.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/LectureTable.java
index 4d7c793a..2ef37880 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/LectureTable.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/LectureTable.java
@@ -26,6 +26,8 @@ public class LectureTable extends ListTable<LectureSummary> {
private final Font boldFont;
private final Color invalidColor;
+
+ private boolean highlightOwn = false;
public LectureTable() {
super(COL_NAME, COL_OWNER, COL_STARTTIME, COL_ENDTIME, COL_ENABLED, COL_VALID);
@@ -56,7 +58,7 @@ public class LectureTable extends ListTable<LectureSummary> {
public void prepareRenderHook(Component component, LectureSummary row, ListTableColumn column,
boolean isSelected) {
Color fgOverride = null;
- if (Session.getUserId().equals(row.ownerId)) {
+ if (highlightOwn && column == COL_OWNER && Session.getUserId().equals(row.ownerId)) {
component.setFont(boldFont);
}
long now = System.currentTimeMillis() / 1000;
@@ -87,5 +89,9 @@ public class LectureTable extends ListTable<LectureSummary> {
return FormatHelper.shortDate((long) value);
throw new IndexOutOfBoundsException();
}
+
+ public void setHighlightOwn(boolean enabled) {
+ highlightOwn = enabled;
+ }
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java
index d8832f54..87f69264 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java
@@ -9,6 +9,8 @@ import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
+import javax.swing.event.RowSorterEvent;
+import javax.swing.event.RowSorterListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
@@ -50,6 +52,7 @@ public abstract class ListTable<T> extends JTable {
}
}
this.adjuster = new TableColumnAdjuster(this, 5);
+ this.adjuster.setOnlyAdjustLarger(true);
this.itemComparator = itemComparator;
this.setModel(model);
this.setRowSorter(sorter);
@@ -65,6 +68,12 @@ public abstract class ListTable<T> extends JTable {
this.setDefaultEditor(Boolean.class, getDefaultEditor(Boolean.class));
this.setRowSelectionAllowed(true);
this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ sorter.addRowSorterListener(new RowSorterListener() {
+ @Override
+ public void sorterChanged(RowSorterEvent e) {
+ adjuster.adjustColumns();
+ }
+ });
}
protected abstract Object getValueAtInternal(T item, ListTableColumn column);
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java
index beb2e3f2..c9bcd658 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java
@@ -59,10 +59,10 @@ public class LectureListWindow extends LectureListWindowLayout {
// Filter types as an enum
public static enum FilterType {
ALL("Alle anzeigen"),
- OWN("Nur eigene Anzeigen"),
+ OWN("Nur eigene/zugewiesene Anzeigen"),
ACTIVE("Nur aktive anzeigen"),
EDITABLE("Nur editierbare anzeigen"),
- EXPIRING("Bald auslaufende");
+ EXPIRING("Bald auslaufende anzeigen");
private final String name;
@@ -98,7 +98,8 @@ public class LectureListWindow extends LectureListWindowLayout {
// filter for own lectures
private final RowFilter<ListModel<LectureSummary>, Integer> filterOwn = new RowFilter<ListModel<LectureSummary>, Integer>() {
public boolean include(Entry<? extends ListModel<LectureSummary>, ? extends Integer> entry) {
- return lectureTable.getModelRow(entry.getIdentifier()).ownerId.equals(Session.getUserId());
+ LectureSummary lecture = lectureTable.getModelRow(entry.getIdentifier());
+ return lecture.userPermissions.admin || lecture.ownerId.equals(Session.getUserId());
}
};
// filter for active lectures
@@ -278,6 +279,7 @@ public class LectureListWindow extends LectureListWindowLayout {
updateAvailableOptions(item);
}
});
+ filterCbo.setSelectedItem(FilterType.OWN);
updateAvailableOptions(null);
}
/**
@@ -335,6 +337,7 @@ public class LectureListWindow extends LectureListWindowLayout {
// filters from the combobox
FilterType filterType = (FilterType) filterCbo.getSelectedItem();
+ lectureTable.setHighlightOwn(filterType != FilterType.OWN);
switch (filterType) {
case ALL:
// no additional filters