diff options
Diffstat (limited to 'dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java')
| -rw-r--r-- | dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java | 256 |
1 files changed, 84 insertions, 172 deletions
diff --git a/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java b/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java index e83c4bc3..9e7c40e5 100644 --- a/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java +++ b/dozentenmodul/src/main/java/gui/lecture/EditLectureSearch_GUI.java @@ -1,9 +1,9 @@ package gui.lecture; +import gui.helper.TableFiller; import gui.intro.MainMenue_GUI; import java.awt.Color; -import java.awt.Component; import java.awt.FlowLayout; import java.awt.Font; import java.awt.SystemColor; @@ -18,7 +18,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -26,7 +25,6 @@ import javax.swing.JButton; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JSeparator; import javax.swing.JTable; @@ -35,8 +33,6 @@ import javax.swing.JTextField; import javax.swing.JTextPane; import javax.swing.ListSelectionModel; import javax.swing.RowFilter; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; import javax.swing.event.InternalFrameAdapter; @@ -61,48 +57,40 @@ import util.GuiManager; public class EditLectureSearch_GUI extends JInternalFrame { private final JPanel contentPanel = new JPanel(); - String[] result; - JRadioButton rdbtnInternetJa; - JRadioButton rdbtnInternetNein; - JLabel labelAktiv; - JLabel labelstartdate; - JLabel labelenddate; - JLabel labelimageversion; - JTextArea labelName; - JTextArea labelimage; - JTextArea labeldesc; - JLabel labelVerantwortlicher; - JTable tablemyLectures; + private JLabel labelAktiv; + private JLabel labelstartdate; + private JLabel labelenddate; + private JLabel labelimageversion; + private JTextArea labelName; + private JTextArea labelimage; + private JTextArea labeldesc; + private JLabel labelVerantwortlicher; + private JTable tablemyLectures; private JTextField textFieldName; private JLabel lblTotalResults; - boolean activeSearch = false; - Component c = null; - String[] titles = { "Veranstaltungsname", "Beschreibung", - "Gültigkeitsdatum", "Aktiv", "Letzte Benutzung", - "Verantwortlicher", "Image", "Schlagwort", "ID" }; + private String[] titles = { "Veranstaltungsname", "Beschreibung", "Gültigkeitsdatum", "Aktiv", + "Letzte Benutzung", "Verantwortlicher", "Image", "Schlagwort", "ID" }; public static final String HELP_MESSAGE = "<html><div align=\"center\">" + "Suchen Sie hier Ihre Veranstaltungen und wählen Sie sie für weitere Schritte aus.<br />" + "Klicken Sie anschließend auf \"Weiter\", um die Details der Veranstaltung sowie die Berechtigungen zu ändern." + "</div></html>"; - final DefaultTableModel modelMyLectures = new DefaultTableModel(titles, 0) { + private final DefaultTableModel modelMyLectures = new DefaultTableModel(titles, 0) { public boolean isCellEditable(int rowIndex, int mColIndex) { return false; } }; - final TableRowSorter<TableModel> rowSorterMyLectures = new TableRowSorter<TableModel>( + private final TableRowSorter<TableModel> rowSorterMyLectures = new TableRowSorter<TableModel>( modelMyLectures); - RowFilter<Object, Object> rf = null; - List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>( - 2); + private RowFilter<Object, Object> rf = null; + private List<RowFilter<Object, Object>> filters = new ArrayList<RowFilter<Object, Object>>(2); /** * Create the dialog. */ public EditLectureSearch_GUI() { - filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); @@ -111,14 +99,7 @@ public class EditLectureSearch_GUI extends JInternalFrame { @Override public void internalFrameActivated(InternalFrameEvent arg0) { textFieldName.requestFocusInWindow(); - try { - initTableModel(modelMyLectures); - // initTableModel(modelAll); - - } catch (ParseException e) { - - e.printStackTrace(); - } + initTableModel(modelMyLectures); // auszublendende Angaben // 1=Beschreibung @@ -145,7 +126,7 @@ public class EditLectureSearch_GUI extends JInternalFrame { tablemyLectures.getColumnModel().getColumn(8).setWidth(0); tablemyLectures.getColumnModel().getColumn(8).setMinWidth(0); tablemyLectures.getColumnModel().getColumn(8).setMaxWidth(0); - + tablemyLectures.getTableHeader().setReorderingAllowed(false); tablemyLectures.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tablemyLectures.addMouseListener(new MouseAdapter() { @@ -154,7 +135,8 @@ public class EditLectureSearch_GUI extends JInternalFrame { public void mouseReleased(MouseEvent e) { tablemyLectures.clearSelection(); //just one row is selectablemyLectures - tablemyLectures.setRowSelectionInterval(tablemyLectures.rowAtPoint(e.getPoint()), tablemyLectures.rowAtPoint(e.getPoint())); + tablemyLectures.setRowSelectionInterval(tablemyLectures.rowAtPoint(e.getPoint()), + tablemyLectures.rowAtPoint(e.getPoint())); } }); } @@ -163,16 +145,8 @@ public class EditLectureSearch_GUI extends JInternalFrame { // Verhindert das Vergroessern Des Fensters setResizable(false); - try { - // Setzt das Look & Feel auf System - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (ClassNotFoundException | InstantiationException - | IllegalAccessException | UnsupportedLookAndFeelException e) { - - e.printStackTrace(); - } // Setzt den Fenstertitel - setTitle("bwLehrpool Suite - Veranstaltung bearbeiten - "+person.verantwortlicher.getUserID()); + setTitle("bwLehrpool Suite - Veranstaltung bearbeiten - " + person.verantwortlicher.getUserID()); // Zentriert das Fenster in die Bildmitte setBounds(0, 0, 842, 722); @@ -206,8 +180,8 @@ public class EditLectureSearch_GUI extends JInternalFrame { JPanel panel_1 = new JPanel(); panel_1.setBackground(SystemColor.menu); - panel_1.setBorder(new TitledBorder(null, "Filterfunktionen", - TitledBorder.LEADING, TitledBorder.TOP, null, null)); + panel_1.setBorder(new TitledBorder(null, "Filterfunktionen", TitledBorder.LEADING, TitledBorder.TOP, + null, null)); panel_1.setBounds(10, 49, 557, 66); contentPanel.add(panel_1); panel_1.setLayout(null); @@ -224,26 +198,18 @@ public class EditLectureSearch_GUI extends JInternalFrame { // Textfield eingabe auslesen String stext = textFieldName.getText().trim(); // Wenn Textfield nicht leer - if (stext != "") { - activeSearch = true; + if (!stext.isEmpty()) { // Filtere nach der Eingabe filters.clear(); - filters.add(RowFilter.regexFilter("(?i)" + stext, 0)); // case - // insensitive - filters.add(RowFilter.regexFilter("(?i)" + stext, 1)); // case - // insensitive + filters.add(RowFilter.regexFilter("(?i)" + stext, 0)); + filters.add(RowFilter.regexFilter("(?i)" + stext, 1)); rf = RowFilter.orFilter(filters); rowSorterMyLectures.setRowFilter(rf); } else { - activeSearch = false; - activeSearch = false; filters.clear(); - filters.add(RowFilter.regexFilter(".", 0)); // case - // insensitive, - // filter for - // anything + filters.add(RowFilter.regexFilter(".", 0)); rf = RowFilter.orFilter(filters); rowSorterMyLectures.setRowFilter(rf); @@ -291,39 +257,35 @@ public class EditLectureSearch_GUI extends JInternalFrame { scrollPaneMyImage.setBounds(10, 120, 552, 369); contentPanel.add(scrollPaneMyImage); tablemyLectures = new JTable(); - tablemyLectures.getSelectionModel().addListSelectionListener( - new ListSelectionListener() { - public void valueChanged(ListSelectionEvent e) { + tablemyLectures.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + public void valueChanged(ListSelectionEvent e) { - if (tablemyLectures.getSelectedRow() != -1) { - String lectureid = modelMyLectures - .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 8).toString(); + if (tablemyLectures.getSelectedRow() != -1) { + String lectureid = modelMyLectures.getValueAt( + tablemyLectures.convertRowIndexToModel(tablemyLectures.getSelectedRow()), 8) + .toString(); - try { + try { - // write the values into the information pane on - // the right hand side - writeLectureData(lectureid); + // write the values into the information pane on + // the right hand side + writeLectureData(lectureid); - // fill the itemOwnder model with information - // from selected item - setItemOwnerInformation(lectureid); + // fill the itemOwnder model with information + // from selected item + setItemOwnerInformation(lectureid); - } catch (TException e1) { + } catch (TException e1) { - e1.printStackTrace(); - } catch (ParseException e1) { + e1.printStackTrace(); + } catch (ParseException e1) { - e1.printStackTrace(); - } - } + e1.printStackTrace(); } + } + } - }); + }); tablemyLectures.setModel(modelMyLectures); tablemyLectures.getColumnModel().getColumn(1).sizeWidthToFit(); @@ -334,11 +296,11 @@ public class EditLectureSearch_GUI extends JInternalFrame { tablemyLectures.setRowSorter(rowSorterMyLectures); scrollPaneMyImage.setViewportView(tablemyLectures); - + lblTotalResults = new JLabel("Anzahl:"); lblTotalResults.setBounds(10, 512, 131, 20); contentPanel.add(lblTotalResults); - + { JPanel buttonPane = new JPanel(); buttonPane.setBounds(0, 640, 826, 33); @@ -366,48 +328,29 @@ public class EditLectureSearch_GUI extends JInternalFrame { // a row is selected, do operations - Lecture.lecture.setid(modelMyLectures - .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 8).toString()); - Lecture.lecture.setName(modelMyLectures - .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 0).toString()); - Lecture.lecture.setDesc(modelMyLectures - .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 1).toString()); - String date = modelMyLectures - .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 2).toString(); - - Lecture.lecture.setLinkedImagename(modelMyLectures - .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 6).toString()); - - int zweitesLeerzeichen = date.indexOf(" ", - date.indexOf(" ") + 1); - - String startdate = date.substring(0, - zweitesLeerzeichen); + Lecture.lecture.setid(modelMyLectures.getValueAt( + tablemyLectures.convertRowIndexToModel(tablemyLectures.getSelectedRow()), + 8).toString()); + Lecture.lecture.setName(modelMyLectures.getValueAt( + tablemyLectures.convertRowIndexToModel(tablemyLectures.getSelectedRow()), + 0).toString()); + Lecture.lecture.setDesc(modelMyLectures.getValueAt( + tablemyLectures.convertRowIndexToModel(tablemyLectures.getSelectedRow()), + 1).toString()); + String date = modelMyLectures.getValueAt( + tablemyLectures.convertRowIndexToModel(tablemyLectures.getSelectedRow()), + 2).toString(); + + Lecture.lecture.setLinkedImagename(modelMyLectures.getValueAt( + tablemyLectures.convertRowIndexToModel(tablemyLectures.getSelectedRow()), + 6).toString()); + + int zweitesLeerzeichen = date.indexOf(" ", date.indexOf(" ") + 1); + + String startdate = date.substring(0, zweitesLeerzeichen); String enddate = date.substring(zweitesLeerzeichen); - SimpleDateFormat out = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat in = new SimpleDateFormat( - "dd.MM.yyyy HH:mm:ss"); + SimpleDateFormat out = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + SimpleDateFormat in = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); try { enddate = out.format(in.parse(enddate)); startdate = out.format(in.parse(startdate)); @@ -416,24 +359,20 @@ public class EditLectureSearch_GUI extends JInternalFrame { e2.printStackTrace(); } - DateFormat df = new SimpleDateFormat( - "yyyy-MM-dd HH:mm:ss"); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { // Format has to be "yyyy-MM-dd HH:mm:ss" Lecture.lecture.setEnddate(df.parse(enddate)); - Lecture.lecture.setStartdate(df - .parse(startdate)); + Lecture.lecture.setStartdate(df.parse(startdate)); } catch (ParseException e1) { e1.printStackTrace(); } if (modelMyLectures .getValueAt( - tablemyLectures - .convertRowIndexToModel(tablemyLectures - .getSelectedRow()), - 3).toString().equals("1")) { + tablemyLectures.convertRowIndexToModel(tablemyLectures + .getSelectedRow()), 3).toString().equals("1")) { Lecture.lecture.setActive(true); } else { Lecture.lecture.setActive(false); @@ -549,56 +488,30 @@ public class EditLectureSearch_GUI extends JInternalFrame { scrollPaneName.setBounds(10, 40, 218, 55); panel.add(scrollPaneName); - } // Initiale Beffuelung eines Table models - public DefaultTableModel initTableModel(DefaultTableModel model) - throws ParseException { + public DefaultTableModel initTableModel(DefaultTableModel model) { List<org.openslx.sat.thrift.iface.Lecture> lectures; try { - + // Hole eine Liste der erlaubten Images für die diese Person - if(person.verantwortlicher.getRole()=="Admin"){ + if (person.verantwortlicher.getRole().equals("Admin")) { //get complete list lectures = ThriftManager.getSatClient().getLectureList(SessionData.authToken); } else { //get permitted list lectures = ThriftManager.getSatClient().getLectureListPermissionWrite(SessionData.authToken); } - - Iterator<org.openslx.sat.thrift.iface.Lecture> i = lectures.iterator(); - SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); - int x = 0; - - while (i.hasNext()) { - // erzeuge Objekte fuer die Tabelle - - Object[] obj = { - lectures.get(x).lecturename, - lectures.get(x).desc, - out.format(in.parse(lectures.get(x).starttime)) + " " - + out.format(in.parse(lectures.get(x).endtime)), - lectures.get(x).isActive, - out.format(in.parse(lectures.get(x).lastused)), - lectures.get(x).username, lectures.get(x).imagename, - " ", lectures.get(x).id }; - // Fuege diese Objekte der Tabelle hinzu - model.addRow(obj); - - x++; - i.next(); - } - + TableFiller.fillModelWithLectureList(model, lectures); + //show number if rows in GUI - lblTotalResults.setText(lblTotalResults.getText()+" "+model.getRowCount()); + lblTotalResults.setText(lblTotalResults.getText() + " " + model.getRowCount()); return model; } catch (TException e1) { - e1.printStackTrace(); } return model; } @@ -623,15 +536,14 @@ public class EditLectureSearch_GUI extends JInternalFrame { SimpleDateFormat in = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat out = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); - Map<String, String> res = ThriftManager.getSatClient().getLectureData(id,SessionData.authToken); + Map<String, String> res = ThriftManager.getSatClient().getLectureData(id, SessionData.authToken); labelName.setText(res.get("name")); labelAktiv.setText(res.get("isActive")); labeldesc.setText(res.get("desc")); labelVerantwortlicher.setText(res.get("owner")); labelstartdate.setText(out.format(in.parse(res.get("startTime")))); labelenddate.setText(out.format(in.parse(res.get("endTime")))); - labelimage.setText(res.get("imagepath").substring( - res.get("imagepath").indexOf("/") + 1)); + labelimage.setText(res.get("imagepath").substring(res.get("imagepath").indexOf("/") + 1)); labelimageversion.setText(res.get("imageversion")); }// end writeLectureData @@ -641,7 +553,7 @@ public class EditLectureSearch_GUI extends JInternalFrame { try { // get values from server and set them in model - map = ThriftManager.getSatClient().getItemOwner(lectureid,SessionData.authToken); + map = ThriftManager.getSatClient().getItemOwner(lectureid, SessionData.authToken); ItemOwner.itemOwner.setUserID(map.get("userID")); ItemOwner.itemOwner.setUsername(map.get("loginName")); |
