diff options
Diffstat (limited to 'Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java')
| -rw-r--r-- | Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java | 165 |
1 files changed, 108 insertions, 57 deletions
diff --git a/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java b/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java index 58329ae2..9dc4b36c 100644 --- a/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java +++ b/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java @@ -70,13 +70,13 @@ public class EditLectureSearch_GUI extends JFrame { JTable tableAllLectures; JTable tablemyLectures; JTable tableCoopImages; - JTable tablePublicVorlagen; JTable tablePublicImages; private JTextField textFieldName; JTabbedPane tabbedPane; + boolean activeSearch=false; String[] titles = { "Veranstaltungsname", "Beschreibung", "G\u00fcltigkeitsdatum", "Aktiv", "Letzte Benutzung", - "Verantwortlicher", "Image", "Schlagwort", "ID" }; + "Verantwortlicher", "Image", "ID" }; ThriftConnection con = new ThriftConnection(); Client client = models.Client.clientcon.getClient(); final DefaultTableModel modelAll = new DefaultTableModel(titles, 0){ @@ -94,6 +94,7 @@ public class EditLectureSearch_GUI extends JFrame { final TableRowSorter<TableModel> rowSorterMyLectures = new TableRowSorter<TableModel>( modelMyLectures); + /** * Create the dialog. @@ -106,6 +107,12 @@ public class EditLectureSearch_GUI extends JFrame { con.closeThriftConnection(); System.exit(0); } + @Override + public void windowOpened(WindowEvent arg0) { + initTableModel(modelAll); + initTableModel(modelMyLectures); + textFieldName.requestFocusInWindow(); + } }); // Verhindert das Vergroessern Des Fensters setResizable(false); @@ -158,7 +165,7 @@ public class EditLectureSearch_GUI extends JFrame { panel_1.setBackground(SystemColor.menu); panel_1.setBorder(new TitledBorder(null, "Filterfunktionen", TitledBorder.LEADING, TitledBorder.TOP, null, null)); - panel_1.setBounds(10, 49, 557, 131); + panel_1.setBounds(10, 49, 557, 66); contentPanel.add(panel_1); panel_1.setLayout(null); @@ -173,15 +180,22 @@ public class EditLectureSearch_GUI extends JFrame { public void keyReleased(KeyEvent e) { // Textfield eingabe auslesen String stext = textFieldName.getText(); - // Wenn Textfield nicht leer if (stext != "") { + activeSearch=true; // Filtere nach der Eingabe rowSorterAll.setRowFilter(RowFilter.regexFilter( textFieldName.getText(), 0)); rowSorterMyLectures.setRowFilter(RowFilter.regexFilter( textFieldName.getText(), 0)); + }else{ + activeSearch=false; + String username = person.verantwortlicher.getName() + " " + + person.verantwortlicher.getVorname(); + rowSorterMyLectures.setRowFilter(RowFilter.regexFilter( + username, 5)); + rowSorterAll.setRowFilter(null); } } }); @@ -190,22 +204,6 @@ public class EditLectureSearch_GUI extends JFrame { panel_1.add(textFieldName); textFieldName.setColumns(10); - JLabel lblErweiterteSuche = new JLabel( - "<html><u>Erweiterte Suche *Folgt noch*</u></html>"); - lblErweiterteSuche.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent arg0) { - // oeffnet das Fenster Extended GUI - - //ExtendedSearchForImages_GUI es = new ExtendedSearchForImages_GUI(); - //es.setVisible(true); - } - }); - lblErweiterteSuche.setForeground(Color.BLUE); - - lblErweiterteSuche.setBounds(326, 106, 194, 14); - panel_1.add(lblErweiterteSuche); - JLabel lblHauptmen = new JLabel("Hauptmen\u00FC"); lblHauptmen.addMouseListener(new MouseAdapter() { @Override @@ -248,15 +246,15 @@ public class EditLectureSearch_GUI extends JFrame { rowSorterMyLectures.setRowFilter(RowFilter.regexFilter( username, 5)); } else if (tabbedPane.getSelectedIndex() == 1) { - + rowSorterAll.setRowFilter(null); } } }); - tabbedPane.setBounds(10, 197, 557, 323); + tabbedPane.setBounds(10, 126, 557, 394); contentPanel.add(tabbedPane); - initTableModel(modelMyLectures); + JScrollPane scrollPaneAllImages = new JScrollPane(); tableAllLectures = new JTable(); @@ -266,7 +264,7 @@ public class EditLectureSearch_GUI extends JFrame { tableAllLectures.getColumnModel().getColumn(3).sizeWidthToFit(); tableAllLectures.getColumnModel().getColumn(4).sizeWidthToFit(); tableAllLectures.getColumnModel().getColumn(5).sizeWidthToFit(); - initTableModel(modelAll); + JScrollPane scrollPaneMyImage = new JScrollPane(); tablemyLectures = new JTable(); @@ -311,23 +309,9 @@ public class EditLectureSearch_GUI extends JFrame { tablePublicImages.getColumnModel().getColumn(5).sizeWidthToFit(); scrollPanePublicImages.setViewportView(tablePublicImages); - tabbedPane.addTab("\u00D6ffentliche Images", null, + tabbedPane.addTab("\u00D6ffentliche Veranstaltungen", null, scrollPanePublicImages, null); tabbedPane.setEnabledAt(3, false); - - JScrollPane scrollPanePublicVorlagen = new JScrollPane(); - tablePublicVorlagen = new JTable(); - tablePublicVorlagen.setModel(model); - tablePublicVorlagen.getColumnModel().getColumn(1).sizeWidthToFit(); - tablePublicVorlagen.getColumnModel().getColumn(2).sizeWidthToFit(); - tablePublicVorlagen.getColumnModel().getColumn(3).sizeWidthToFit(); - tablePublicVorlagen.getColumnModel().getColumn(4).sizeWidthToFit(); - tablePublicVorlagen.getColumnModel().getColumn(5).sizeWidthToFit(); - - scrollPanePublicVorlagen.setViewportView(tablePublicVorlagen); - tabbedPane.addTab("\u00D6ffentliche Vorlagen", null, - scrollPanePublicVorlagen, null); - tabbedPane.setEnabledAt(4, false); { JPanel buttonPane = new JPanel(); buttonPane.setBounds(0, 640, 597, 33); @@ -353,23 +337,21 @@ public class EditLectureSearch_GUI extends JFrame { JButton btnContinue = new JButton("Weiter"); btnContinue.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { + String username = person.verantwortlicher.getName() + " " + + person.verantwortlicher.getVorname(); // check if a row is selected - if ((tableAllLectures.getSelectedRow() != -1) - || (tablemyLectures.getSelectedRow() != -1) - || (tableCoopImages.getSelectedRow() != -1) - || (tablePublicImages.getSelectedRow() != -1) - || (tablePublicVorlagen.getSelectedRow() != -1)) { + if (tablemyLectures.getSelectedRow() != -1) { // a row is selected, do operations - if (tabbedPane.getSelectedIndex() == 0) { + Lecture.lecture.setid(modelMyLectures .getValueAt( tablemyLectures .convertRowIndexToModel(tablemyLectures .getSelectedRow()), - 8).toString()); + 7).toString()); Lecture.lecture.setName(modelMyLectures .getValueAt( tablemyLectures @@ -433,7 +415,82 @@ public class EditLectureSearch_GUI extends JFrame { EditLectureAllgemein_GUI el = new EditLectureAllgemein_GUI(); el.setVisible(true); dispose(); - } else { + } if (tableAllLectures.getSelectedRow() != -1 && tableAllLectures.getValueAt(tableAllLectures.getSelectedRow(), 5).toString().equals(username)) { + + // a row is selected, do operations + + + + Lecture.lecture.setid(modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), + 7).toString()); + Lecture.lecture.setName(modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), + 0).toString()); + Lecture.lecture.setDesc(modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), + 1).toString()); + String date = modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), + 2).toString(); + + Lecture.lecture.setLinkedImagename(modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), + 6).toString()); + + int zweitesLeerzeichen = date.indexOf(" ", + date.indexOf(" ") + 1); + + String startdate = date.substring(0, + zweitesLeerzeichen); + String enddate = date + .substring(zweitesLeerzeichen); + 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)); + } catch (ParseException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), + 3).toString().equals("1")) { + Lecture.lecture.setActive(true); + } else { + Lecture.lecture.setActive(false); + } + + + // EditImageAllgemein_GUI ea=new + // EditImageAllgemein_GUI(); + EditLectureAllgemein_GUI el = new EditLectureAllgemein_GUI(); + el.setVisible(true); + dispose(); + }else { JOptionPane .showMessageDialog( null, @@ -441,15 +498,9 @@ public class EditLectureSearch_GUI extends JFrame { "Message", JOptionPane.INFORMATION_MESSAGE); } - } else { - // nothing selected - JOptionPane.showMessageDialog(null, - "Bitte w\u00f4hlen Sie ein Image aus.", - "Image Auswahl", - JOptionPane.INFORMATION_MESSAGE); - }// end check if a row is selected + } - } + }); btnContinue.setActionCommand("Cancel"); buttonPane.add(btnContinue); @@ -543,8 +594,8 @@ public class EditLectureSearch_GUI extends JFrame { lectures.get(x).starttime + " " + lectures.get(x).endtime, lectures.get(x).isActive, lectures.get(x).lastused, - lectures.get(x).username, " ", - lectures.get(x).imagename, lectures.get(x).id }; + lectures.get(x).username, + lectures.get(x).imagename ,lectures.get(x).id }; // Fuege diese Objekte der Tabelle hinzu model.addRow(obj); x++; |
