diff options
| author | Simon Rettberg | 2015-08-25 19:26:06 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-08-25 19:26:06 +0200 |
| commit | 56bdc1ad354e94a3af8d33d3be23fdb48e169cc4 (patch) | |
| tree | ade7b774f78f05a6dd910c8c3ab9134996d8ecc6 | |
| parent | [server] Reduce spam when fetching OS and Virt list from master (diff) | |
| download | tutor-module-56bdc1ad354e94a3af8d33d3be23fdb48e169cc4.tar.gz tutor-module-56bdc1ad354e94a3af8d33d3be23fdb48e169cc4.tar.xz tutor-module-56bdc1ad354e94a3af8d33d3be23fdb48e169cc4.zip | |
[client] Mark lectures that are out of their validity date range, mark own lectures
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/LectureTable.java | 81 | ||||
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ListTable.java | 2 |
2 files changed, 57 insertions, 26 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 ae29304a..a1147567 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 @@ -1,10 +1,12 @@ package org.openslx.dozmod.gui.control.table; import java.awt.Component; +import java.awt.Font; import javax.swing.JTable; import org.openslx.bwlp.thrift.iface.LectureSummary; +import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.Sorters; import org.openslx.dozmod.thrift.cache.UserCache; import org.openslx.dozmod.util.FormatHelper; @@ -12,13 +14,13 @@ import org.openslx.dozmod.util.FormatHelper; @SuppressWarnings("serial") public class LectureTable extends ListTable<LectureSummary> { - private static String[] columnNames = { "Name", "Besitzer", "Startzeit", "Endzeit" }; - private static Class<?>[] columnClasses = { String.class, String.class, Long.class, Long.class }; - + private static String[] columnNames = { "Name", "Besitzer", "Startzeit", "Endzeit", "Aktiviert", "Gültig" }; + private static Class<?>[] columnClasses = { String.class, String.class, Long.class, Long.class, + Boolean.class, Boolean.class }; public LectureTable() { super(columnNames, columnClasses); - this.setDefaultRenderer(Object.class, new LectureTableRenderer()); + this.setDefaultRenderer(Object.class, new LectureTableRenderer(this)); // --------- set comparators for different columns ------------------------------ // first column doesn't have to be set, because standard comparator already compares strings @@ -39,30 +41,59 @@ public class LectureTable extends ListTable<LectureSummary> { return row.getStartTime(); if (columnIndex == 3) return row.getEndTime(); + if (columnIndex == 4) + return row.isIsEnabled(); + if (columnIndex == 5) + return row.isIsImageVersionUsable(); throw new IndexOutOfBoundsException(); } -} -/** - * This renderer formats the given value to a readable string for the table cell, depending on the column - */ -@SuppressWarnings("serial") -class LectureTableRenderer extends TableRenderer { - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, - boolean hasFocus, int row, int column) { - if (value == null) - value = "-"; - if (column == 1) - value = FormatHelper.userName(UserCache.find((String) value)); - if (column == 2) - value = FormatHelper.longDate((Long) value); - if (column == 3) - value = FormatHelper.longDate((Long) value); - if( column > 3 || column < 0) - throw new IndexOutOfBoundsException(); + /** + * This renderer formats the given value to a readable string for the table + * cell, depending on the column + */ + private static class LectureTableRenderer extends TableRenderer { + + private final Font bold; + + private LectureTableRenderer(JTable table) { + bold = table.getFont().deriveFont(Font.BOLD); + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, + boolean hasFocus, int row, int column) { + boolean setBold = false; + switch (column) { + case 0: // Image name + case 4: // isEnabled + case 5: // hasValidImage + break; + case 1: // Owner + String ownerId = (String) value; + value = FormatHelper.userName(UserCache.find(ownerId)); + if (Session.getUserId().equals(ownerId)) { + setBold = true; + } + break; + case 2: // Start time + case 3: // End time + long columnDate = (long) value; + long now = System.currentTimeMillis() / 1000; + value = FormatHelper.shortDate(columnDate); + if ((column == 2 && columnDate > now) || (column == 3 && columnDate < now)) { + setBold = true; + } + break; + default: + throw new IndexOutOfBoundsException(); + } + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - return this; + if (setBold) { + setFont(bold); + } + return this; + } } } 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 a23a52ef..741e2b77 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 @@ -202,7 +202,7 @@ class TableRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - setBorder(noFocusBorder); + setBorder(null); return this; } } |
