Jelajahi Sumber

Fixed Time Agenda Bug

Supermaniac101 10 tahun lalu
induk
melakukan
8fbfb9fcaa

+ 1 - 1
.classpath

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

+ 1 - 1
.project

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>AgendaGUI</name>
+	<name>FestivalPlanner</name>
 	<comment></comment>
 	<projects>
 	</projects>

+ 1 - 3
src/agenda/Act.java

@@ -1,14 +1,12 @@
 package agenda;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * Created by gjoosen on 06/02/15.
  */
-@SuppressWarnings("serial")
-public class Act implements Serializable {
+public class Act {
     
     private List<Artist> artists;
     private Stage stage;

+ 16 - 5
src/agenda/ActTime.java

@@ -1,14 +1,12 @@
 package agenda;
 
-import java.io.Serializable;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
 /**
  * Created by gjoosen on 06/02/15.
  */
-@SuppressWarnings("serial")
-public class ActTime implements Serializable {
+public class ActTime {
     
 	private GregorianCalendar beginTime, endTime;
     
@@ -32,19 +30,32 @@ public class ActTime implements Serializable {
     }
     
     public String getBeginTimeString(){
+    	String minutes = "";
+    	if(beginTime.get(Calendar.MINUTE)>=0 && beginTime.get(Calendar.MINUTE)<10){
+    		minutes = "0"+beginTime.get(Calendar.MINUTE);
+    	} else {
+    		minutes = ""+beginTime.get(Calendar.MINUTE);
+    	}
+    	
     	return 	beginTime.get(Calendar.YEAR) + "-" + 
     			(beginTime.get(Calendar.MONTH)+1) + "-" + 
     			beginTime.get(Calendar.DATE) + " " + 
     			beginTime.get(Calendar.HOUR_OF_DAY) + ":" +
-    			beginTime.get(Calendar.MINUTE);
+    			minutes;
     }
     
     public String getEndTimeString(){
+    	String minutes = "";
+    	if(endTime.get(Calendar.MINUTE)>=0 && endTime.get(Calendar.MINUTE)<10){
+    		minutes = "0"+endTime.get(Calendar.MINUTE);
+    	} else {
+    		minutes = ""+endTime.get(Calendar.MINUTE);
+    	}
     	return 	endTime.get(Calendar.YEAR) + "-" + 
     			(endTime.get(Calendar.MONTH)+1) + "-" + 
     			endTime.get(Calendar.DATE) + " " + 
     			endTime.get(Calendar.HOUR_OF_DAY) + ":" +
-    			endTime.get(Calendar.MINUTE);
+    			minutes;
     }
     
     public GregorianCalendar getBeginTime() {

+ 1 - 2
src/agenda/Agenda.java

@@ -1,13 +1,12 @@
 package agenda;
 
-import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
 /**
  * Created by gjoosen on 06/02/15.
  */
-public class Agenda implements Serializable {
+public class Agenda {
     
     private List<Stage> stages;
     private List<Artist> artists;

+ 1 - 3
src/agenda/Artist.java

@@ -1,11 +1,9 @@
 package agenda;
 
-import java.io.Serializable;
-
 /**
  * Created by gjoosen on 06/02/15.
  */
-public class Artist implements Serializable {
+public class Artist {
     
     private String name, genre;
     

+ 25 - 24
src/agenda/Io.java

@@ -10,50 +10,51 @@ import javax.swing.JFileChooser;
 
 
 public class Io {
-
+	
 	public static void main(String [] args) throws IOException{
 		Io io = new Io();
 	}
-
+	
 	public Io() throws IOException
 	{
 		writeIo();
 	}
-
-	public static void writeIo() throws IOException
+	
+	public void writeIo() throws IOException
 	{
 		JFileChooser fileChooser = new JFileChooser();
 		if(fileChooser.showSaveDialog(null)
 				== fileChooser.APPROVE_OPTION) {
 			java.io.File file = fileChooser.getSelectedFile();
+		
+		ObjectOutputStream output = null;
+		try{
+			output = new ObjectOutputStream(new FileOutputStream(file));
+		}catch(IOException e){ 
+			System.out.println("Could not open file." + e);
+			System.exit(0);
+		}
+		try{
+			output.writeObject(new Agenda());
 
-			ObjectOutputStream output = null;
-			try{
-				output = new ObjectOutputStream(new FileOutputStream(file));
-			}catch(IOException e){ 
-				System.out.println("Could not open file." + e);
-				System.exit(0);
-			}
-			try{
-				output.writeObject(new Agenda());
-
-				output.close();
-			}catch(IOException e){
-				System.out.println("Writing error.  " + e);
-				System.exit(0); 
-			}
+			output.close();
+		}catch(IOException e){
+			System.out.println("Writing error.  " + e);
+			System.exit(0); 
+		}
 		}
 
 	}
-	public static void readIo() throws IOException
+
+	public void readIo() throws IOException
 	{
 		JFileChooser fileChooser = new JFileChooser();
 		if(fileChooser.showOpenDialog(null)
 				== fileChooser.APPROVE_OPTION) {
 			java.io.File file = fileChooser.getSelectedFile();
-
+			
 			ObjectInputStream input = null;
-
+			
 			try{
 				input = new ObjectInputStream(new FileInputStream(file));
 			}catch(IOException e){
@@ -70,8 +71,8 @@ public class Io {
 				System.exit(0);
 			}
 			System.out.println("agenda's stuff is : " + agenda.getActs());
-		}
-
+	}
+			
 	}
 }
 

+ 1 - 3
src/agenda/Stage.java

@@ -1,11 +1,9 @@
 package agenda;
 
-import java.io.Serializable;
-
 /**
  * Created by gjoosen on 06/02/15.
  */
-public class Stage implements Serializable {
+public class Stage {
     
     private String name;
     

+ 1 - 3
src/agenda/Time.java

@@ -1,11 +1,9 @@
 package agenda;
 
-import java.io.Serializable;
-
 /**
  * Created by gjoosen on 07/02/15.
  */
-public class Time implements Serializable {
+public class Time {
     
     private int hours, minutes;
     

+ 5 - 6
src/gui/frames/MainFrame.java

@@ -3,17 +3,16 @@ package gui.frames;
 import gui.menubar.MenuBar;
 import gui.panels.agenda.AgendaPane;
 import gui.panels.edit.EditPane;
+import gui.panels.table.Table;
+
+import java.awt.Window;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
 import javax.swing.JFrame;
 import javax.swing.JPanel;
 
 import agenda.Agenda;
-import gui.panels.table.Table;
-import sun.tools.jconsole.Tab;
-
-import java.awt.*;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 
 @SuppressWarnings("serial")
 public class MainFrame extends JFrame{

+ 14 - 33
src/gui/menubar/MenuBar.java

@@ -1,19 +1,18 @@
 package gui.menubar;
 
 import gui.frames.MainFrame;
+import gui.main.Main;
+import javafx.stage.*;
 
-import java.awt.FlowLayout;
+import java.awt.*;
+import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
-import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.KeyStroke;
-
-import agenda.Io;
+import javax.swing.*;
 
 @SuppressWarnings("serial")
 public class MenuBar extends JMenuBar{
@@ -42,7 +41,7 @@ public class MenuBar extends JMenuBar{
         JMenuItem cutAction = new JMenuItem("Cut");
         JMenuItem copyAction = new JMenuItem("Copy");
         JMenuItem pasteAction = new JMenuItem("Paste");
-        JMenuItem saveAction = new JMenuItem("Save");
+        
         //view 
         JMenuItem editorView = new JMenuItem("Editor");
         JMenuItem agendaView = new JMenuItem("Agenda");
@@ -55,7 +54,6 @@ public class MenuBar extends JMenuBar{
         cutAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
         copyAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK));
         pasteAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK));
-        saveAction.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,ActionEvent.CTRL_MASK));
         
         fileMenu.add(newAction);
         newAction.addActionListener(new ActionListener() {
@@ -63,29 +61,12 @@ public class MenuBar extends JMenuBar{
                 System.out.println("You have clicked on the new action");
             }
         });
-        
-        fileMenu.add(saveAction);
-		saveAction.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent e) {
-				try {
-					Io.writeIo();
-				} catch (IOException e1) {
-					e1.printStackTrace();
-				}
-			}
-		});
-        
-		fileMenu.add(openAction);
-		openAction.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				try {
-					Io.readIo();
-				} catch (IOException e) {
-					e.printStackTrace();
-				}
-			}
-		});
-		
+        fileMenu.add(openAction);
+        openAction.addActionListener(new ActionListener() {
+            public void actionPerformed(ActionEvent arg0) {
+                System.out.println("You have clicked on the open action");
+            }
+        });
         fileMenu.addSeparator();
         fileMenu.add(exitAction);
         exitAction.addActionListener(new ActionListener() {