From 515e5b984f573d8ff2f5d3253a1ffc2b8b450ce3 Mon Sep 17 00:00:00 2001 From: Tobias Spitzer Date: Wed, 20 Aug 2014 11:20:24 +0200 Subject: Neueste Version --- .../src/gui/lecture/SearchLecture_GUI.java | 239 +++++++++++++++++---- 1 file changed, 199 insertions(+), 40 deletions(-) (limited to 'Dozentenmodul/src/gui/lecture/SearchLecture_GUI.java') diff --git a/Dozentenmodul/src/gui/lecture/SearchLecture_GUI.java b/Dozentenmodul/src/gui/lecture/SearchLecture_GUI.java index a0276f6c..07a48925 100644 --- a/Dozentenmodul/src/gui/lecture/SearchLecture_GUI.java +++ b/Dozentenmodul/src/gui/lecture/SearchLecture_GUI.java @@ -6,6 +6,7 @@ import gui.intro.MainMenue_GUI; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Font; +import java.awt.Point; import java.awt.SystemColor; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -17,8 +18,11 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.net.URI; import java.net.URISyntaxException; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Iterator; import java.util.List; +import java.util.Map; import javax.swing.JButton; import javax.swing.JFrame; @@ -41,6 +45,8 @@ import javax.swing.border.EmptyBorder; import javax.swing.border.TitledBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; @@ -54,6 +60,8 @@ import server.Server.Client; import thrift.ThriftConnection; import util.GuiOrganizer; import util.OpenLinks; +import javax.swing.JTextArea; +import javax.swing.ScrollPaneConstants; @SuppressWarnings("serial") public class SearchLecture_GUI extends JFrame { @@ -62,10 +70,19 @@ public class SearchLecture_GUI extends JFrame { String[] result; JRadioButton rdbtnInternetJa; JRadioButton rdbtnInternetNein; + JLabel labelAktiv; + JLabel labelstartdate; + JLabel labelenddate; + JLabel labelimageversion; + JTextArea labelName; + JTextArea labelimage; + JTextArea labeldesc; + JLabel labelVerantwortlicher; JTable tableAllLectures; JTable tablemyLectures; private JTextField textFieldName; JTabbedPane tabbedPane; + boolean activeSearch=false; String[] titles = { "Veranstaltungsname", "Beschreibung", "G\u00fcltigkeitsdatum", "Aktiv", "Letzte Benutzung", "Verantwortlicher", "Image", "Schlagwort", "ID" }; @@ -98,6 +115,53 @@ public class SearchLecture_GUI extends JFrame { con.closeThriftConnection(); System.exit(0); } + @Override + public void windowOpened(WindowEvent arg0) { + try { + initTableModel(modelMyLectures); + initTableModel(modelAll); + + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + tablemyLectures.getColumnModel().getColumn(1).setWidth(0); + tablemyLectures.getColumnModel().getColumn(1).setMinWidth(0); + tablemyLectures.getColumnModel().getColumn(1).setMaxWidth(0); + tablemyLectures.getColumnModel().getColumn(2).setWidth(0); + tablemyLectures.getColumnModel().getColumn(2).setMinWidth(0); + tablemyLectures.getColumnModel().getColumn(2).setMaxWidth(0); + tablemyLectures.getColumnModel().getColumn(3).setWidth(0); + tablemyLectures.getColumnModel().getColumn(3).setMinWidth(0); + tablemyLectures.getColumnModel().getColumn(3).setMaxWidth(0); + tablemyLectures.getColumnModel().getColumn(6).setWidth(0); + tablemyLectures.getColumnModel().getColumn(6).setMinWidth(0); + tablemyLectures.getColumnModel().getColumn(6).setMaxWidth(0); + tablemyLectures.getColumnModel().getColumn(7).setWidth(0); + tablemyLectures.getColumnModel().getColumn(7).setMinWidth(0); + tablemyLectures.getColumnModel().getColumn(7).setMaxWidth(0); + tablemyLectures.getColumnModel().getColumn(8).setWidth(0); + tablemyLectures.getColumnModel().getColumn(8).setMinWidth(0); + tablemyLectures.getColumnModel().getColumn(8).setMaxWidth(0); + tableAllLectures.getColumnModel().getColumn(1).setWidth(0); + tableAllLectures.getColumnModel().getColumn(1).setMinWidth(0); + tableAllLectures.getColumnModel().getColumn(1).setMaxWidth(0); + tableAllLectures.getColumnModel().getColumn(2).setWidth(0); + tableAllLectures.getColumnModel().getColumn(2).setMinWidth(0); + tableAllLectures.getColumnModel().getColumn(2).setMaxWidth(0); + tableAllLectures.getColumnModel().getColumn(3).setWidth(0); + tableAllLectures.getColumnModel().getColumn(3).setMinWidth(0); + tableAllLectures.getColumnModel().getColumn(3).setMaxWidth(0); + tableAllLectures.getColumnModel().getColumn(6).setWidth(0); + tableAllLectures.getColumnModel().getColumn(6).setMinWidth(0); + tableAllLectures.getColumnModel().getColumn(6).setMaxWidth(0); + tableAllLectures.getColumnModel().getColumn(7).setWidth(0); + tableAllLectures.getColumnModel().getColumn(7).setMinWidth(0); + tableAllLectures.getColumnModel().getColumn(7).setMaxWidth(0); + tableAllLectures.getColumnModel().getColumn(8).setWidth(0); + tableAllLectures.getColumnModel().getColumn(8).setMinWidth(0); + tableAllLectures.getColumnModel().getColumn(8).setMaxWidth(0); + } }); // Verhindert das Vergroessern Des Fensters setResizable(false); @@ -116,8 +180,6 @@ public class SearchLecture_GUI extends JFrame { setBounds(0, 0, 842, 722); GuiOrganizer.centerGUI(this); - final DefaultTableModel model = new DefaultTableModel(titles, 0); - getContentPane().setLayout(null); { JPanel panel = new JPanel(); @@ -136,7 +198,7 @@ public class SearchLecture_GUI extends JFrame { txtpnBitteWhlenSie.setEditable(false); txtpnBitteWhlenSie.setBackground(SystemColor.menu); txtpnBitteWhlenSie - .setText("Hier k\u00F6nnen Sie nach Ihrem gew\u00FCnschten VL-Image suchen und dieses f\u00FCr weitere Schritte ausw\u00E4hlen"); + .setText("Hier k\u00F6nnen Sie nach Ihrer gew\u00FCnschten Veranstaltung suchen und diese f\u00FCr weitere Schritte ausw\u00E4hlen"); txtpnBitteWhlenSie.setBounds(10, 36, 509, 32); panel.add(txtpnBitteWhlenSie); } @@ -165,15 +227,22 @@ public class SearchLecture_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); } } }); @@ -232,20 +301,65 @@ public class SearchLecture_GUI extends JFrame { tabbedPane.setBounds(10, 123, 557, 397); contentPanel.add(tabbedPane); - initTableModel(modelMyLectures); + JScrollPane scrollPaneAllImages = new JScrollPane(); tableAllLectures = new JTable(); + tableAllLectures.getSelectionModel().addListSelectionListener( new ListSelectionListener() + { + public void valueChanged(ListSelectionEvent e) + { + String imageid = modelAll + .getValueAt( + tableAllLectures + .convertRowIndexToModel(tableAllLectures + .getSelectedRow()), 8) + .toString(); + System.out.println(imageid); + + try { + writeLectureData(imageid); + } catch (TException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ParseException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); tableAllLectures.setModel(modelAll); tableAllLectures.getColumnModel().getColumn(1).sizeWidthToFit(); tableAllLectures.getColumnModel().getColumn(2).sizeWidthToFit(); tableAllLectures.getColumnModel().getColumn(3).sizeWidthToFit(); tableAllLectures.getColumnModel().getColumn(4).sizeWidthToFit(); tableAllLectures.getColumnModel().getColumn(5).sizeWidthToFit(); - initTableModel(modelAll); JScrollPane scrollPaneMyImage = new JScrollPane(); tablemyLectures = new JTable(); + tablemyLectures.getSelectionModel().addListSelectionListener( new ListSelectionListener() + { + public void valueChanged(ListSelectionEvent e) + { + String imageid = modelMyLectures + .getValueAt( + tablemyLectures + .convertRowIndexToModel(tablemyLectures + .getSelectedRow()), 8) + .toString(); + System.out.println(imageid); + + try { + writeLectureData(imageid); + } catch (TException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (ParseException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); tablemyLectures.setModel(modelMyLectures); tablemyLectures.getColumnModel().getColumn(1).sizeWidthToFit(); @@ -305,65 +419,91 @@ public class SearchLecture_GUI extends JFrame { lblNewLabel_3.setBounds(10, 27, 104, 14); panel.add(lblNewLabel_3); - JLabel labelName = new JLabel(""); - labelName.setBounds(124, 27, 104, 14); - panel.add(labelName); - JLabel lblAktiv = new JLabel("Aktiv:"); - lblAktiv.setBounds(10, 52, 104, 14); + lblAktiv.setBounds(10, 88, 104, 14); panel.add(lblAktiv); - JLabel labelAktiv = new JLabel(""); - labelAktiv.setBounds(124, 52, 104, 14); + labelAktiv = new JLabel(""); + labelAktiv.setBounds(124, 88, 104, 14); panel.add(labelAktiv); - JLabel labelstartdate = new JLabel(""); - labelstartdate.setBounds(124, 77, 104, 14); + labelstartdate = new JLabel(""); + labelstartdate.setBounds(124, 113, 104, 14); panel.add(labelstartdate); JLabel lblStartdatum = new JLabel("Startdatum:"); - lblStartdatum.setBounds(10, 77, 104, 14); + lblStartdatum.setBounds(10, 113, 104, 14); panel.add(lblStartdatum); - JLabel labelenddate = new JLabel(""); - labelenddate.setBounds(124, 102, 104, 14); + labelenddate = new JLabel(""); + labelenddate.setBounds(124, 138, 104, 14); panel.add(labelenddate); JLabel lblEnddatum = new JLabel("Enddatum:"); - lblEnddatum.setBounds(10, 102, 104, 14); + lblEnddatum.setBounds(10, 138, 104, 14); panel.add(lblEnddatum); JLabel lblBeschreibung = new JLabel("Beschreibung:"); - lblBeschreibung.setBounds(10, 127, 104, 14); + lblBeschreibung.setBounds(10, 163, 104, 14); panel.add(lblBeschreibung); - JLabel labeldesc = new JLabel(""); - labeldesc.setBounds(124, 127, 104, 110); - panel.add(labeldesc); - JLabel lblImage = new JLabel("Image:"); - lblImage.setBounds(10, 248, 104, 14); + lblImage.setBounds(10, 284, 104, 14); panel.add(lblImage); - JLabel labelimage = new JLabel(""); - labelimage.setBounds(124, 248, 104, 14); - panel.add(labelimage); - - JLabel labelVerantwortlicher = new JLabel(""); - labelVerantwortlicher.setBounds(124, 298, 104, 14); + labelVerantwortlicher = new JLabel(""); + labelVerantwortlicher.setBounds(124, 401, 104, 14); panel.add(labelVerantwortlicher); JLabel lblVerantwortlicher = new JLabel("Verantwortlicher:"); - lblVerantwortlicher.setBounds(10, 298, 104, 14); + lblVerantwortlicher.setBounds(10, 401, 104, 14); panel.add(lblVerantwortlicher); JLabel lblImageversion = new JLabel("Imageversion:"); - lblImageversion.setBounds(10, 273, 104, 14); + lblImageversion.setBounds(10, 376, 104, 14); panel.add(lblImageversion); - JLabel labelimageversion = new JLabel(""); - labelimageversion.setBounds(124, 273, 104, 14); + labelimageversion = new JLabel(""); + labelimageversion.setBounds(124, 376, 104, 14); panel.add(labelimageversion); + + + labeldesc = new JTextArea(); + labeldesc.setFont(new Font("Tahoma", Font.PLAIN, 11)); + labeldesc.setEditable(false); + labeldesc.setLineWrap(true); + labeldesc.setBackground(SystemColor.menu); + labeldesc.setBounds(124, 127, 104, 110); + JScrollPane scrollPane = new JScrollPane(labeldesc); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane.setBounds(124, 163, 104, 110); + panel.add(scrollPane); + //panel.add(labeldesc); + + labelimage = new JTextArea(); + labelimage.setLineWrap(true); + labelimage.setFont(new Font("Tahoma", Font.PLAIN, 11)); + labelimage.setEditable(false); + labelimage.setBackground(SystemColor.menu); + labelimage.setBounds(124, 248, 101, 81); + JScrollPane scrollPaneImage = new JScrollPane(labelimage); + scrollPaneImage.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPaneImage.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPaneImage.setBounds(124, 284, 101, 81); + panel.add(scrollPaneImage); + + labelName = new JTextArea(); + labelName.setFont(new Font("Tahoma", Font.PLAIN, 11)); + labelName.setBackground(SystemColor.menu); + labelName.setBounds(124, 22, 101, 55); + JScrollPane scrollPaneName = new JScrollPane(labelName); + scrollPaneName.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + scrollPaneName.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPaneName.setBounds(124, 22, 101, 55); + panel.add(scrollPaneName); + //panel.add(labelName); + //panel.add(labelimage); JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); @@ -373,6 +513,7 @@ public class SearchLecture_GUI extends JFrame { JMenuItem mntmFaq = new JMenuItem("FAQ"); mntmFaq.addMouseListener(new MouseAdapter() { + @SuppressWarnings("static-access") @Override public void mousePressed(MouseEvent arg0) { @@ -395,6 +536,7 @@ public class SearchLecture_GUI extends JFrame { JMenuItem mntmOtrs = new JMenuItem("OTRS"); mntmOtrs.addMouseListener(new MouseAdapter() { + @SuppressWarnings("static-access") @Override public void mousePressed(MouseEvent arg0) { @@ -427,13 +569,14 @@ public class SearchLecture_GUI extends JFrame { } // Initiale Beffuelung eines Table models - public DefaultTableModel initTableModel(DefaultTableModel model) { + public DefaultTableModel initTableModel(DefaultTableModel model) throws ParseException { List lectures; try { // Hole eine Liste der Images lectures = client.getLectureList(); Iterator 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()) { @@ -441,9 +584,9 @@ public class SearchLecture_GUI extends JFrame { Object[] obj = { lectures.get(x).lecturename, lectures.get(x).desc, - lectures.get(x).starttime + " " - + lectures.get(x).endtime, - lectures.get(x).isActive, lectures.get(x).lastused, + 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 @@ -460,4 +603,20 @@ public class SearchLecture_GUI extends JFrame { } return model; } + public void writeLectureData(String id) throws TException, ParseException{ + + SimpleDateFormat in=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + SimpleDateFormat out=new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); + Map res=client.getLectureData(id); + 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)); + labelimageversion.setText(res.get("imageversion")); + + + } } -- cgit v1.2.3-55-g7522