diff options
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java | 82 |
1 files changed, 19 insertions, 63 deletions
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 2f3aa76b..026057fd 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 @@ -1,7 +1,5 @@ package org.openslx.dozmod.gui.window; -import java.text.SimpleDateFormat; -import java.util.Date; import java.util.List; import org.apache.log4j.Logger; @@ -13,8 +11,8 @@ import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; import org.openslx.bwlp.thrift.iface.LectureSummary; -import org.openslx.bwlp.thrift.iface.UserInfo; import org.openslx.dozmod.gui.MainWindow; import org.openslx.dozmod.gui.helper.LectureListComparator; import org.openslx.dozmod.gui.helper.LectureListFilter; @@ -22,6 +20,7 @@ import org.openslx.dozmod.gui.helper.TableHelper; import org.openslx.dozmod.gui.window.layout.LectureListWindowLayout; import org.openslx.dozmod.thrift.LectureCache; import org.openslx.dozmod.thrift.UserCache; +import org.openslx.dozmod.util.FormatHelper; public class LectureListWindow extends LectureListWindowLayout { @@ -56,73 +55,31 @@ public class LectureListWindow extends LectureListWindowLayout { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection(); LectureSummary lecture = (LectureSummary) selection.getFirstElement(); - if (lecture == null) return; - String leName = lecture.getLectureName(); - if (leName == null) { - lectureName.setText("Unknown"); - } else { - lectureName.setText(leName); - } - - + if (lecture == null) + return; + // Fill detail information fields + // Lecture name + setFieldText(lectureName, lecture.getLectureName()); // id of the lecture - String lectureBaseId = lecture.getLectureId(); - if (lectureBaseId == null) { - idInfo.setText("Unknown"); - } else { - idInfo.setText(lectureBaseId); - } - + setFieldText(idInfo, lecture.getLectureId()); // id of the image linked to the lecture - String baseId = lecture.getImageBaseId(); - if (baseId == null) { - imageBaseId.setText("Unknown"); - } else { - imageBaseId.setText(baseId); - } - + setFieldText(imageBaseId, lecture.getImageBaseId()); + // the owner of the selected lecture + setFieldText(ownerInfo, FormatHelper.userName(UserCache.find(lecture.getOwnerId()))); // set the time, the lecture has last been used - long lastUsedTimestamp = lecture.getLastUsed(); - if (lastUsedTimestamp == 0) { - lastusedInfo.setText("Unknown"); - } else { - Date date = new Date(lastUsedTimestamp * 1000L); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); - String formattedDate = sdf.format(date); - lastusedInfo.setText(formattedDate); - } - + lastusedInfo.setText(FormatHelper.longDate(lecture.getLastUsed())); // set the start time of the lecture - long startTimestamp = lecture.getStartTime(); - if (startTimestamp == 0) { - startTime.setText("Unknown"); - } else { - Date date = new Date(startTimestamp * 1000L); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); - String formattedDate = sdf.format(date); - startTime.setText(formattedDate); - } - + startTime.setText(FormatHelper.longDate(lecture.getStartTime())); // set the end time of the lecture - long endTimestamp = lecture.getEndTime(); - if (endTimestamp == 0) { - endTime.setText("Unknown"); - } else { - Date date = new Date(endTimestamp * 1000L); - SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); - String formattedDate = sdf.format(date); - endTime.setText(formattedDate); - } + endTime.setText(FormatHelper.longDate(lecture.getEndTime())); + } - // the owner id of the selected lecture - String ownerId = lecture.getOwnerId(); - UserInfo user = UserCache.find(ownerId); - if (user != null) { - ownerInfo.setText(user.getLastName() + ", " + user.getFirstName()); + private void setFieldText(Text control, String content) { + if (content == null) { + control.setText("<null>"); } else { - ownerInfo.setText("Unknown"); + control.setText(content); } - } }); @@ -154,7 +111,6 @@ public class LectureListWindow extends LectureListWindowLayout { private boolean refreshList() { List<LectureSummary> lectureList = LectureCache.get(false); - tableViewer.setInput(lectureList); tableViewer.refresh(); return true; |