diff options
| author | Michael Wilson | 2014-08-26 10:26:08 +0200 |
|---|---|---|
| committer | Michael Wilson | 2014-08-26 10:26:08 +0200 |
| commit | 3f7da72d00e6027097cec8de2cd1462eecf2cbb5 (patch) | |
| tree | 3aca78877f124d0d469ea477e145332e487420ba /Dozentenmodul | |
| parent | Datum angepasst wenn es zu weit in der Zukunft liegt (diff) | |
| download | tutor-module-3f7da72d00e6027097cec8de2cd1462eecf2cbb5.tar.gz tutor-module-3f7da72d00e6027097cec8de2cd1462eecf2cbb5.tar.xz tutor-module-3f7da72d00e6027097cec8de2cd1462eecf2cbb5.zip | |
-Bearbeiten einer Veranstaltung möglich
-Datumsformate bei Veranstlatung in 24h-Modus geändert
Diffstat (limited to 'Dozentenmodul')
| -rw-r--r-- | Dozentenmodul/bin/gui/lecture/CreateLectureAllgemein_GUI.class | bin | 10739 -> 10739 bytes | |||
| -rw-r--r-- | Dozentenmodul/bin/gui/lecture/EditLectureAllgemein_GUI.class | bin | 9781 -> 10814 bytes | |||
| -rw-r--r-- | Dozentenmodul/src/gui/lecture/CreateLectureAllgemein_GUI.java | 7 | ||||
| -rw-r--r-- | Dozentenmodul/src/gui/lecture/EditLectureAllgemein_GUI.java | 165 | ||||
| -rw-r--r-- | Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java | 16 |
5 files changed, 151 insertions, 37 deletions
diff --git a/Dozentenmodul/bin/gui/lecture/CreateLectureAllgemein_GUI.class b/Dozentenmodul/bin/gui/lecture/CreateLectureAllgemein_GUI.class Binary files differindex a2a12096..7b954623 100644 --- a/Dozentenmodul/bin/gui/lecture/CreateLectureAllgemein_GUI.class +++ b/Dozentenmodul/bin/gui/lecture/CreateLectureAllgemein_GUI.class diff --git a/Dozentenmodul/bin/gui/lecture/EditLectureAllgemein_GUI.class b/Dozentenmodul/bin/gui/lecture/EditLectureAllgemein_GUI.class Binary files differindex 6f2112b6..136f0f74 100644 --- a/Dozentenmodul/bin/gui/lecture/EditLectureAllgemein_GUI.class +++ b/Dozentenmodul/bin/gui/lecture/EditLectureAllgemein_GUI.class diff --git a/Dozentenmodul/src/gui/lecture/CreateLectureAllgemein_GUI.java b/Dozentenmodul/src/gui/lecture/CreateLectureAllgemein_GUI.java index ad1383e7..8caab7d2 100644 --- a/Dozentenmodul/src/gui/lecture/CreateLectureAllgemein_GUI.java +++ b/Dozentenmodul/src/gui/lecture/CreateLectureAllgemein_GUI.java @@ -500,15 +500,11 @@ public class CreateLectureAllgemein_GUI extends JFrame { mntmFaq.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent arg0) { - OpenLinks open = new OpenLinks(); - URI windows; try { windows = new URI(Links.getFAQ()); - open.openWebpage(windows); - } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -528,14 +524,11 @@ public class CreateLectureAllgemein_GUI extends JFrame { URI windows; try { windows = new URI(Links.getOTRS()); - open.openWebpage(windows); - } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } }); mnNewMenu_1.add(mntmOtrs); diff --git a/Dozentenmodul/src/gui/lecture/EditLectureAllgemein_GUI.java b/Dozentenmodul/src/gui/lecture/EditLectureAllgemein_GUI.java index 48cbedc9..78744a18 100644 --- a/Dozentenmodul/src/gui/lecture/EditLectureAllgemein_GUI.java +++ b/Dozentenmodul/src/gui/lecture/EditLectureAllgemein_GUI.java @@ -17,6 +17,8 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.net.URI; import java.net.URISyntaxException; +import java.util.Calendar; +import java.util.Date; import javax.swing.ButtonGroup; import javax.swing.JButton; @@ -25,6 +27,7 @@ import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSeparator; @@ -44,6 +47,8 @@ import util.GuiOrganizer; import util.OpenLinks; import com.toedter.calendar.JDateChooser; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; @SuppressWarnings("serial") @@ -61,8 +66,15 @@ public class EditLectureAllgemein_GUI extends JFrame { JDateChooser dateChooserend; JDateChooser dateChooserstart; JRadioButton radioButtonno; + Date startDate = new Date(); + Date endDate; private final ButtonGroup buttonGroup = new ButtonGroup(); + int maxLifeTime = 180; // Anzahl Tage, die eine Veranstaltung in der Zukunft + // aktiv sein darf +boolean isDateOrderCorrect, isDateMaxLifeTimeCorrect, +isAllInformationReady = false; + /** * Create the dialog. @@ -258,19 +270,44 @@ public class EditLectureAllgemein_GUI extends JFrame { scrollPane.add(description); dateChooserend = new JDateChooser(); - dateChooserend.setDateFormatString("dd-MM-yyyy hh:mm:ss"); + dateChooserend.setDateFormatString("dd-MM-yyyy HH:mm:ss"); dateChooserend.setDate(Lecture.lecture.getEnddate()); - dateChooserend.setBounds(385, 188, 100, 20); + dateChooserend.setBounds(404, 188, 143, 20); panel_2.add(dateChooserend); JLabel label_5 = new JLabel("bis"); - label_5.setBounds(351, 188, 24, 20); + label_5.setBounds(378, 188, 21, 20); panel_2.add(label_5); dateChooserstart = new JDateChooser(); - dateChooserstart.setDateFormatString("yyyy-MM-dd hh:mm:ss"); + dateChooserstart.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent arg0) { + endDate = addDays(dateChooserstart.getDate(), maxLifeTime); // Datum darf weiter als 6 + // Monate in der Zukunft + // liegen + } + }); + + //initialize + if (Lecture.lecture.getStartdate() == null) { + // is not defined yet + dateChooserstart.setDate(startDate); + } else { + // already defined from last visit on this page + dateChooserstart.setDate(Lecture.lecture.getStartdate()); + } + + if (Lecture.lecture.getEnddate() == null) { + // is not defined yet + dateChooserend.setDate(endDate); + } else { + // already defined from last visit on this page + dateChooserend.setDate(Lecture.lecture.getEnddate()); + } + + dateChooserstart.setDateFormatString("yyyy-MM-dd HH:mm:ss"); dateChooserstart.setDate(Lecture.lecture.getStartdate()); - dateChooserstart.setBounds(240, 188, 101, 20); + dateChooserstart.setBounds(226, 188, 143, 20); panel_2.add(dateChooserstart); JLabel label_6 = new JLabel("von:"); @@ -294,13 +331,18 @@ public class EditLectureAllgemein_GUI extends JFrame { radioButtonno.setBounds(385, 225, 109, 23); panel_2.add(radioButtonno); - if(Lecture.lecture.isActive()==true) - { - radioButtonyes.setSelected(true); - }else - { - radioButtonno.setSelected(true); - } + radioButtonyes.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + radioButtonyes.setSelected(true); + radioButtonno.setSelected(false); + } + }); + radioButtonno.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + radioButtonno.setSelected(true); + radioButtonyes.setSelected(false); + } + }); @@ -309,6 +351,11 @@ public class EditLectureAllgemein_GUI extends JFrame { JLabel label_12 = new JLabel("(Im VMChooser sichtbar)"); label_12.setBounds(10, 254, 250, 14); panel_2.add(label_12); + + JLabel lblmaxMonate = new JLabel("(max. 6 Monate)"); + lblmaxMonate.setBounds(10, 208, 127, 14); + panel_2.add(lblmaxMonate); + { JPanel buttonPane = new JPanel(); buttonPane.setBounds(0, 640, 597, 33); @@ -347,7 +394,7 @@ public class EditLectureAllgemein_GUI extends JFrame { { JButton cancelButton = new JButton("Weiter"); cancelButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + /*public void actionPerformed(ActionEvent e) { if(radioButtonyes.isSelected()==true) { Lecture.lecture.setActive(true); @@ -368,7 +415,84 @@ public class EditLectureAllgemein_GUI extends JFrame { PermissionEditLecture_GUI ev=new PermissionEditLecture_GUI(); ev.setVisible(true); dispose(); + }*/ + public void actionPerformed(ActionEvent e) { + // liegt das End-Datum vor dem Start-Datum? + if (dateChooserend.getDate().before( + dateChooserstart.getDate())) { + // datum ist falsch rum + isDateOrderCorrect = false; + JOptionPane + .showMessageDialog( + null, + "Das End-Datum liegt vor dem Start-Datum. Bitte \u00e4ndern.", + "Datum fehlerhaft", + JOptionPane.INFORMATION_MESSAGE); + } else { + // bereit + isDateOrderCorrect = true; + } + // liegt das eingegebene Datum nach dem erlaubten + // End-Datum? + if (dateChooserend.getDate().after(endDate)) { + // Datum zu weit weg + isDateMaxLifeTimeCorrect = false; + JOptionPane.showMessageDialog(null, + "Das End-Datum liegt zu weit in der Zukunft. Erlaubt ist maximal:\n" + + endDate, "Datum fehlerhaft", + JOptionPane.INFORMATION_MESSAGE); + + + dateChooserend.setDate(endDate); //setze Datum auf maximum + } else { + // bereit + isDateMaxLifeTimeCorrect = true; + } + // Pruefen ob alles eingegeben wurde + if (textFieldLaborname.getText().isEmpty() == true + || description.getText().isEmpty() == true) { + // mind 1 Textfeld ist leer + isAllInformationReady = false; + JOptionPane + .showMessageDialog( + null, + "Bitte geben Sie einen Veranstaltungsnamen und eine Beschreibung ein.", + "Datum fehlerhaft", + JOptionPane.INFORMATION_MESSAGE); + } else { + // Textfelder bereit + isAllInformationReady = true; + } + + // welcher Radiobutton ist geklickt? + if (radioButtonyes.isSelected() == true) { + Lecture.lecture.setActive(true); + } else { + Lecture.lecture.setActive(false); + } + // Pruefe ob alle Eingaben korrekt sind, dann mache + // weiter + if (isAllInformationReady == true + && isDateMaxLifeTimeCorrect == true + && isDateOrderCorrect == true) { + // everything is ok, proceed + Lecture.lecture.setName(textFieldLaborname + .getText()); + Lecture.lecture.setDesc(description.getText()); + Lecture.lecture.setEnddate(dateChooserend.getDate()); + Lecture.lecture.setStartdate(dateChooserstart + .getDate()); + + Image.image.setImagename(textFieldLaborname + .getText()); + + PermissionCreateLecture_GUI ev = new PermissionCreateLecture_GUI(); + ev.setVisible(true); + dispose(); + } + } + }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); @@ -403,15 +527,11 @@ public class EditLectureAllgemein_GUI extends JFrame { mntmFaq.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent arg0) { - OpenLinks open = new OpenLinks(); - URI windows; try { windows = new URI(Links.getFAQ()); - open.openWebpage(windows); - } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -425,20 +545,15 @@ public class EditLectureAllgemein_GUI extends JFrame { mntmOtrs.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent arg0) { - OpenLinks open = new OpenLinks(); - URI windows; try { windows = new URI(Links.getOTRS()); - open.openWebpage(windows); - } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } - } }); mnNewMenu_1.add(mntmOtrs); @@ -454,5 +569,11 @@ public class EditLectureAllgemein_GUI extends JFrame { } + public Date addDays(Date date, int days) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.DATE, days); // minus number would decrement the days + return cal.getTime(); + } }
\ No newline at end of file diff --git a/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java b/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java index ff35ad43..0b0bc4d8 100644 --- a/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java +++ b/Dozentenmodul/src/gui/lecture/EditLectureSearch_GUI.java @@ -454,8 +454,8 @@ public class EditLectureSearch_GUI extends JFrame { 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)); @@ -465,10 +465,10 @@ public class EditLectureSearch_GUI extends JFrame { } DateFormat df = new SimpleDateFormat( - "yyyy-MM-dd hh:mm:ss"); + "yyyy-MM-dd HH:mm:ss"); try { - // Format has to be "yyyy-MM-dd hh:mm:ss" + // Format has to be "yyyy-MM-dd HH:mm:ss" Lecture.lecture.setEnddate(df .parse(enddate)); Lecture.lecture.setStartdate(df @@ -539,8 +539,8 @@ public class EditLectureSearch_GUI extends JFrame { 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)); @@ -549,10 +549,10 @@ public class EditLectureSearch_GUI extends JFrame { e2.printStackTrace(); } DateFormat df = new SimpleDateFormat( - "yyyy-MM-dd hh:mm:ss"); + "yyyy-MM-dd HH:mm:ss"); try { - // Format has to be "yyyy-MM-dd hh:mm:ss" + // Format has to be "yyyy-MM-dd HH:mm:ss" Lecture.lecture.setEnddate(df .parse(enddate)); Lecture.lecture.setStartdate(df |
