Prechádzať zdrojové kódy

Adding/editing time added.

Gilian Joosen 10 rokov pred
rodič
commit
da0adab188

+ 4 - 1
src/agenda/Act.java

@@ -45,7 +45,10 @@ public class Act implements Serializable  {
     public void setStage(Stage stage) {
 		this.stage = stage;
 	}
-
+    public void setTime(ActTime actTime){
+        this.actTime = actTime;
+    }
+    
     /**
      * * returns the genre of the act.
      * @return the genre of the act.

+ 19 - 3
src/agenda/ActTime.java

@@ -10,7 +10,7 @@ import java.util.GregorianCalendar;
 public class ActTime implements Serializable {
     
 	private GregorianCalendar beginTime, endTime;
-    
+
     public ActTime(int y1, int m1, int d1, int hh1, int mm1, int y2, int m2, int d2, int hh2, int mm2){
     	beginTime = new GregorianCalendar();
     	endTime = new GregorianCalendar();
@@ -19,9 +19,26 @@ public class ActTime implements Serializable {
     }
     
     public ActTime(String beginTime, String endTime){
+        this.beginTime = new GregorianCalendar();
+        String[] timeParts = beginTime.split("-");
+        int y1 = Integer.valueOf(timeParts[0]);
+        int m1 = Integer.valueOf(timeParts[1]);
+        int d1 = Integer.valueOf(timeParts[2]);
+        int hh1 = Integer.valueOf(timeParts[3]);
+        int mm1 = Integer.valueOf(timeParts[4]);
+        
+        this.endTime = new GregorianCalendar();
+        String[] timeParts2 = endTime.split("-");
+        int y2 = Integer.valueOf(timeParts2[0]);
+        int m2 = Integer.valueOf(timeParts2[1]);
+        int d2 = Integer.valueOf(timeParts2[2]);
+        int hh2 = Integer.valueOf(timeParts2[3]);
+        int mm2 = Integer.valueOf(timeParts2[4]);
 
+        this.setBeginTime(y1, m1, d1, hh1, mm1);
+        this.setEndTime(y2, m2, d2, hh2, mm2);
     }
-
+    
     public void setBeginTime(int y, int m, int d, int hh, int mm){
     	beginTime.set(y,m-1,d,hh,mm);
     }
@@ -58,7 +75,6 @@ public class ActTime implements Serializable {
     			endTime.get(Calendar.HOUR_OF_DAY) + ":" +
     			minutes;
     }
-    
     public GregorianCalendar getBeginTime() {
 		return beginTime;
 	}

+ 3 - 3
src/agenda/Agenda.java

@@ -32,9 +32,9 @@ public class Agenda implements Serializable {
         this.artists.add(new Artist("Sabaton", "Power metal"));
 
         //acts
-        this.acts.add(new Act(this.artists.get(0).getName(), this.stages.get(0), "Heavy metal", new ActTime(2015,02,11,21,00  ,2015,02,11,23,00), this.artists.get(0)));
-        this.acts.add(new Act(this.artists.get(1).getName(), this.stages.get(1), "Test metal" , new ActTime(2015,02,11,23,00  ,2015,02,12,04,30), this.artists.get(1)));
-        this.acts.add(new Act(this.artists.get(2).getName(), this.stages.get(0), "Power metal" ,new ActTime(2015,02,11,20,00  ,2015,02,11,23,00), this.artists.get(2)));
+//        this.acts.add(new Act(this.artists.get(0).getName(), this.stages.get(0), "Heavy metal", new ActTime(2015,02,11,21,00  ,2015,02,11,23,00), this.artists.get(0)));
+//        this.acts.add(new Act(this.artists.get(1).getName(), this.stages.get(1), "Test metal" , new ActTime(2015,02,11,23,00  ,2015,02,12,04,30), this.artists.get(1)));
+//        this.acts.add(new Act(this.artists.get(2).getName(), this.stages.get(0), "Power metal" ,new ActTime(2015,02,11,20,00  ,2015,02,11,23,00), this.artists.get(2)));
         
         System.out.println(this);
     }

+ 4 - 3
src/gui/panels/edit/dialogs/ActDialogPanel.java

@@ -151,7 +151,7 @@ public class ActDialogPanel extends JDialog{
         JPanel panel = new JPanel();
         panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
         panel.add(new JLabel("begintijd"));
-        this.beginTime = new JTextField();
+        this.beginTime = new JTextField("2015-02-11-12-10");
         panel.add(this.beginTime);
         return panel;
     }
@@ -161,7 +161,7 @@ public class ActDialogPanel extends JDialog{
         panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
         panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
         panel.add(new JLabel("eindtijd"));
-        this.endTime = new JTextField();
+        this.endTime = new JTextField("2015-02-11-13-20");
         panel.add(this.endTime);
         
         return panel;
@@ -296,7 +296,7 @@ public class ActDialogPanel extends JDialog{
         
         
         if(this.act == null){
-            Act act = new Act(this.name.getText(), (Stage) this.stageComboBox.getSelectedItem(), this.genre.getText(), new ActTime(2015,02,11,21,00  ,2015,02,11,23,00), artists);
+            Act act = new Act(this.name.getText(), (Stage) this.stageComboBox.getSelectedItem(), this.genre.getText(), new ActTime(this.beginTime.getText(), this.endTime.getText()), artists);
             this.model.addElement(act);
             this.agenda.addAct(act);
         }else{
@@ -304,6 +304,7 @@ public class ActDialogPanel extends JDialog{
             this.act.setGenre(this.genre.getText());
             this.act.setStage((Stage) this.stageComboBox.getSelectedItem());
             this.act.setArtists(artists);
+            this.act.setTime(new ActTime(this.beginTime.getText(), this.endTime.getText()));
             this.model.removeElement(this.act);
             this.model.addElement(act);
         }