summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMürsel Türk2020-11-10 15:30:11 +0100
committerMürsel Türk2020-11-10 15:30:11 +0100
commitd07660b4f2c13380044694d0c8b651953df5a0da (patch)
tree4e148421dc94357bb6e2694968a29753eb5c0bcf
parent[client] Search in description (diff)
downloadtutor-module-d07660b4f2c13380044694d0c8b651953df5a0da.tar.gz
tutor-module-d07660b4f2c13380044694d0c8b651953df5a0da.tar.xz
tutor-module-d07660b4f2c13380044694d0c8b651953df5a0da.zip
[client] Fixed search in description
Issue: #3691
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageListViewer.java28
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureListWindow.java15
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java15
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/util/ObjectHelper.java16
4 files changed, 54 insertions, 20 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageListViewer.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageListViewer.java
index c34ba25b..4326b525 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageListViewer.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/ImageListViewer.java
@@ -8,13 +8,7 @@ import java.util.List;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import javax.swing.BoxLayout;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.RowFilter;
-import javax.swing.UIManager;
+import javax.swing.*;
import javax.swing.border.TitledBorder;
import org.apache.log4j.Logger;
@@ -30,6 +24,7 @@ import org.openslx.dozmod.permissions.ImagePerms;
import org.openslx.dozmod.thrift.Session;
import org.openslx.dozmod.thrift.cache.ImageCache;
import org.openslx.dozmod.thrift.cache.UserCache;
+import org.openslx.dozmod.util.ObjectHelper;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
@@ -42,6 +37,7 @@ public class ImageListViewer extends QLabel {
protected JTextField txtSearch;
protected JComboBox<FilterType> cboFilter;
protected JLabel imageCountLabel;
+ protected JCheckBox chkSearchInDescription;
// image table
protected ImageTable imageTable;
@@ -81,8 +77,11 @@ public class ImageListViewer extends QLabel {
ImageSummaryRead image = imageTable.getModelRow(entry.getIdentifier());
if (searchFieldPattern.matcher(image.imageName).find())
return true;
- if (searchFieldPattern.matcher(image.description).find())
- return true;
+ if (chkSearchInDescription.isSelected() && ObjectHelper.objectHasField(image, "description")) {
+ String description = image.getFieldValue(image.fieldForId(23)).toString();
+ if (searchFieldPattern.matcher(description).find())
+ return true;
+ }
UserInfo user = UserCache.find(image.ownerId);
if (user == null)
return false;
@@ -133,6 +132,10 @@ public class ImageListViewer extends QLabel {
filterPanel.add(txtSearch);
filterPanel.add(cboFilter);
+ // search in description
+ chkSearchInDescription = new JCheckBox("Suche in Beschreibung");
+ filterPanel.add(chkSearchInDescription);
+
// Panel for itemCount
JPanel imageCountPanel = new JPanel();
imageCountLabel = new JLabel();
@@ -178,6 +181,13 @@ public class ImageListViewer extends QLabel {
}
});
cboFilter.setSelectedItem(defaultFilter == null ? FilterType.USABLE : defaultFilter);
+
+ chkSearchInDescription.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ applyFilterOnTable();
+ }
+ });
}
/**
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 ddd8ffbd..c288a0aa 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
@@ -48,6 +48,7 @@ import org.openslx.dozmod.thrift.ThriftActions;
import org.openslx.dozmod.thrift.ThriftActions.DeleteLectureCallback;
import org.openslx.dozmod.thrift.cache.LectureCache;
import org.openslx.dozmod.thrift.cache.UserCache;
+import org.openslx.dozmod.util.ObjectHelper;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
import org.openslx.util.Util;
@@ -119,8 +120,11 @@ public class LectureListWindow extends LectureListWindowLayout {
LectureSummary lecture = tblLectures.getModelRow(entry.getIdentifier());
if (searchFieldPattern.matcher(lecture.lectureName).find())
return true;
- if (searchFieldPattern.matcher(lecture.description).find())
- return true;
+ if (chkSearchInDescription.isSelected() && ObjectHelper.objectHasField(lecture, "description")) {
+ String description = lecture.getFieldValue(lecture.fieldForId(18)).toString();
+ if (description != null && searchFieldPattern.matcher(description).find())
+ return true;
+ }
UserInfo user = UserCache.find(lecture.ownerId);
if (user == null)
return false;
@@ -175,6 +179,13 @@ public class LectureListWindow extends LectureListWindowLayout {
}
});
+ chkSearchInDescription.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ applyFilterOnTable();
+ }
+ });
+
btnNewLecture.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java
index 03847488..2ea17afe 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java
@@ -4,15 +4,7 @@ import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridBagLayout;
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.UIManager;
+import javax.swing.*;
import javax.swing.border.TitledBorder;
import org.openslx.dozmod.gui.Gui;
@@ -43,6 +35,7 @@ public abstract class LectureListWindowLayout extends CompositePage {
protected final JButton btnSwitchView;
protected final JComboBox<FilterType> cboFilter;
protected final QLabel lblVisibleLectureCount;
+ protected final JCheckBox chkSearchInDescription;
protected final JTextField txtSearch;
@@ -79,6 +72,10 @@ public abstract class LectureListWindowLayout extends CompositePage {
filterPanel.add(txtSearch);
filterPanel.add(cboFilter);
+ // search in description
+ chkSearchInDescription = new JCheckBox("Suche in Beschreibung");
+ filterPanel.add(chkSearchInDescription);
+
// Panel for itemCount
JPanel lectureCountPanel = new JPanel();
lblVisibleLectureCount = new QLabel();
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/ObjectHelper.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ObjectHelper.java
new file mode 100644
index 00000000..75f9dcce
--- /dev/null
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/util/ObjectHelper.java
@@ -0,0 +1,16 @@
+package org.openslx.dozmod.util;
+
+import java.lang.reflect.Field;
+
+public class ObjectHelper {
+
+ public static Boolean objectHasField(Object object, String fieldName) {
+ Class<?> clazz = object.getClass();
+ for (Field field : clazz.getFields()) {
+ if (field.getName().equals(fieldName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}