Supermaniac101 пре 10 година
родитељ
комит
8615e7a6b6

+ 0 - 0
Jeroen test.txt


+ 6 - 10
src/agenda/Act.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 Act implements Serializable {
+public class Act {
     
     private List<Artist> artists;
     private Stage stage;
@@ -72,14 +71,15 @@ public class Act implements Serializable {
     
     @Override
     public String toString(){
-        String string = "";
+        String string = "<html>";
         string+="Artists: ";
         for(Artist artist: this.artists){
-            string += artist.getName() + "\n";
+            string += artist.getName() + "<br/>";
         }
-        string+= "genre: " + this.genre + "\n";
-        string+= "stage: " + this.stage.getName() + "\n";
+        string+= "Genre: \n" + this.genre + "<br/>";
+        string+= "Stage: \n" + this.stage.getName() + "<br/>";
         string+= this.actTime;
+        string+= "</html>";
         return string;
     }
 
@@ -97,8 +97,4 @@ public class Act implements Serializable {
             this.artists.add(artist);
         }
     }
-
-    public void setActTime(ActTime actTime) {
-        this.actTime = actTime;
-    }
 }

+ 3 - 27
src/agenda/ActTime.java

@@ -1,17 +1,15 @@
 package agenda;
 
-import java.io.Serializable;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
 
 /**
  * Created by gjoosen on 06/02/15.
  */
-public class ActTime implements Serializable {
+public class ActTime {
     
 	private GregorianCalendar beginTime, endTime;
-    private String beginString, endString;
-
+    
     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();
@@ -20,27 +18,7 @@ public class ActTime implements Serializable {
     }
     
     public ActTime(String beginTime, String endTime){
-        this.beginTime = new GregorianCalendar();
-        this.endTime = new GregorianCalendar();
-        
-        this.beginString = beginTime;
-        this.endString = endTime;
-
-        int y1 = Integer.valueOf(beginTime.substring(0, 4));
-        int m1 = Integer.valueOf(beginTime.substring(5, 7));
-        int d1 = Integer.valueOf(beginTime.substring(8, 10));
-        int hh1 = Integer.valueOf(beginTime.substring(11, 13));
-        int mm1 = Integer.valueOf(beginTime.substring(14, 16));
-
-        int y2 = Integer.valueOf(endTime.substring(0, 4));
-        int m2 = Integer.valueOf(endTime.substring(5, 7));
-        int d2 = Integer.valueOf(endTime.substring(8, 10));
-        int hh2 = Integer.valueOf(endTime.substring(11, 13));
-        int mm2 = Integer.valueOf(endTime.substring(14, 16));
 
-        //2015,02,11,21,00
-        this.beginTime.set(y1, m1, d1, hh1, mm1);
-        this.endTime.set(y2, m2, d2, hh2, mm2);
     }
 
     public void setBeginTime(int y, int m, int d, int hh, int mm){
@@ -94,8 +72,6 @@ public class ActTime implements Serializable {
   
     @Override
     public String toString(){
-        
-        
-        return "start time: " + this.getBeginTimeString() + "\nend time: " + this.getEndTimeString() + "\nlength: " + getLength() + " Minuts";
+        return "Start time: " + this.getBeginTimeString() + "<br/>End time: " + this.getEndTimeString() + "<br/>Length: " + getLength() + " Minutes";
     }
 }

+ 5 - 6
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;
@@ -32,10 +31,10 @@ 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);
     }
     

+ 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;
     

+ 2 - 2
src/agenda/Io.java

@@ -20,7 +20,7 @@ public class Io {
 		writeIo();
 	}
 	
-	public static void writeIo() throws IOException
+	public void writeIo() throws IOException
 	{
 		JFileChooser fileChooser = new JFileChooser();
 		if(fileChooser.showSaveDialog(null)
@@ -46,7 +46,7 @@ public class Io {
 
 	}
 
-	public static void readIo() throws IOException
+	public void readIo() throws IOException
 	{
 		JFileChooser fileChooser = new JFileChooser();
 		if(fileChooser.showOpenDialog(null)

+ 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;
     

+ 1 - 1
src/gui/frames/MainFrame.java

@@ -24,7 +24,7 @@ public class MainFrame extends JFrame{
     
     public MainFrame(){
         this.agenda = new Agenda();
-        this.currentPanel = new EditPane(this.agenda);
+        this.currentPanel = new Table(this.agenda);
         this.add(this.currentPanel);
 		this.setResizable(true);
 		this.setBounds(100,100,1440,900);

+ 7 - 25
src/gui/menubar/MenuBar.java

@@ -9,14 +9,11 @@ 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.*;
 
-import agenda.Io;
-
 @SuppressWarnings("serial")
 public class MenuBar extends JMenuBar{
 
@@ -44,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");
@@ -57,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() {
@@ -65,26 +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() {

+ 17 - 2
src/gui/panels/agenda/AgendaPane.java

@@ -17,13 +17,19 @@ public class AgendaPane extends JPanel {
 	private	DaySelectorPane dayselector;
 	private InfoPane infopanel;
 	private final AgendaScrollPane agendapanel;
+	private String actName;
+	private String actInfo;
 	
 	public AgendaPane(Agenda agenda){
+		this.actName = "Act";
+		this.actInfo = "Act info";
+		
 		setLayout(new BorderLayout());
+		
+		infopanel = new InfoPane(actName, actInfo);
 
-		agendapanel = new AgendaScrollPane(agenda);
+		agendapanel = new AgendaScrollPane(agenda, infopanel);
 		dayselector = new DaySelectorPane();
-		infopanel = new InfoPane();
 		
 		JScrollPane scroll = new JScrollPane(agendapanel);
 		scroll.getVerticalScrollBar().setUnitIncrement(20);
@@ -61,4 +67,13 @@ public class AgendaPane extends JPanel {
 		agendapanel.setDate(currentdate);
 	}
 	
+	public void setActName(String name){
+		this.actName = name;
+	}
+	
+	public void setActInfo(String info){
+		this.actInfo = info;
+	}
+	
+	
 }

+ 7 - 1
src/gui/panels/agenda/AgendaScrollPane.java

@@ -21,6 +21,7 @@ import agenda.Agenda;
 @SuppressWarnings("serial")
 public class AgendaScrollPane extends JPanel {
 	ArrayList<AgendaItemShape> agendaItems;
+	private InfoPane infoPane;
 	private int clickedItem[];
 	private int xdifference, ydifference, xspacing;
 	private final int yspacing = 45;
@@ -29,7 +30,9 @@ public class AgendaScrollPane extends JPanel {
 	GregorianCalendar currentdate;
 	Agenda agenda;
 	
-	public AgendaScrollPane(final Agenda agenda){
+	
+	public AgendaScrollPane(final Agenda agenda, InfoPane pane){
+		this.infoPane = pane;
 		this.agenda = agenda;
 		this.setPreferredSize(new Dimension(600, yspacing*48+heightoffset));
 		agendaItems = new ArrayList<AgendaItemShape>();
@@ -47,6 +50,9 @@ public class AgendaScrollPane extends JPanel {
 				if(clickedItem[0] != -1){
 					xdifference = -1*((int)agendaItems.get(clickedItem[0]).getX() - e.getX());
 					ydifference = -1*((int)agendaItems.get(clickedItem[0]).getY() - e.getY())+heightoffset;	
+					
+					infoPane.setMiddleText(agendaItems.get(clickedItem[0]).getName(), agendaItems.get(clickedItem[0]).getAct().toString());
+					
 				}		
 				repaint();
 			}

+ 16 - 2
src/gui/panels/agenda/InfoField.java

@@ -6,8 +6,22 @@ import javax.swing.border.TitledBorder;
 
 @SuppressWarnings("serial")
 public class InfoField extends JPanel {
+	
+	private JLabel label;
+	private TitledBorder border;
+	
 	public InfoField(String title, String text){
-		this.add(new JLabel(text));
-		this.setBorder(new TitledBorder(title));
+		label = new JLabel(text);
+		border = new TitledBorder(title);
+		this.add(label);
+		this.setBorder(border);
+	}
+	
+	public void setLabel(String text){
+		label.setText(text);
+	}
+	
+	public void  setBorder(String title){
+		border.setTitle(title);
 	}
 }

+ 33 - 19
src/gui/panels/agenda/InfoPane.java

@@ -10,16 +10,25 @@ import javax.swing.border.LineBorder;
 
 @SuppressWarnings("serial")
 public class InfoPane extends JPanel{
-	public InfoPane(){
+	
+	private String festivalName;
+	private String festivalInfo;
+	private String actName;
+	private String actInfo;	
+	private InfoField upperPanel;
+	private InfoField middlePanel;
+	
+	public InfoPane(String actName, String actInfo){
+		
+		this.festivalName = "Festival";
+		this.festivalInfo = "Random Festival";
+		this.actName = actName;
+		this.actInfo = actInfo;
+		
 		this.setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
 		this.setLayout(new GridBagLayout());
 		
-		upperText();
-		middleText();
-	}
-	
-	public void upperText(){
-		InfoField upperPanel = new InfoField("Info upper","Blablablabla blablabla");
+		upperPanel = new InfoField(festivalName, festivalInfo);
 		GridBagConstraints c = new GridBagConstraints();
         c.fill = GridBagConstraints.HORIZONTAL;
         c.anchor = GridBagConstraints.NORTH;
@@ -29,19 +38,24 @@ public class InfoPane extends JPanel{
         c.weightx = 1.0;
         c.weighty = 0.0;   
 		this.add(upperPanel,c);
+		
+		middlePanel = new InfoField(actName, actInfo);
+		GridBagConstraints d = new GridBagConstraints();
+		d = new GridBagConstraints();
+		d.fill = GridBagConstraints.BOTH;
+		d.insets = new Insets(0,20,0,20);
+		d.gridx = 2;
+        d.gridy = 1;    
+        d.weightx = 1.0;
+        d.weighty = 1.0;        
+		this.add(middlePanel,d);
 	}
-	
-	public void middleText(){
-		InfoField middlePanel = new InfoField("Info mid","Blablablabla");
-		GridBagConstraints c = new GridBagConstraints();
-		c = new GridBagConstraints();
-		c.fill = GridBagConstraints.BOTH;
-		c.insets = new Insets(0,20,0,20);
-		c.gridx = 2;
-        c.gridy = 1;    
-        c.weightx = 1.0;
-        c.weighty = 1.0;        
 
-		this.add(middlePanel,c);
+
+	public void setMiddleText(String actName, String actInfo){
+		
+		middlePanel.setBorder(actName);
+		middlePanel.setLabel(actInfo);
+		
 	}
 }

+ 24 - 45
src/gui/panels/edit/dialogs/ActDialogPanel.java

@@ -1,23 +1,38 @@
 package gui.panels.edit.dialogs;
 
-import agenda.*;
-import com.sun.codemodel.internal.JOp;
-
-import javax.swing.*;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Label;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.ArrayList;
 
+import javax.swing.BoxLayout;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.ListCellRenderer;
+
+import agenda.Act;
+import agenda.ActTime;
+import agenda.Agenda;
+import agenda.Artist;
+import agenda.Stage;
+
 /**
  * Created by gjoosen on 20/02/15.
  */
 public class ActDialogPanel extends JDialog{
 
-
-
     private Agenda agenda;
-    private JTextField name, genre, beginTime, endTime;
+    private JTextField name, genre;
     private JComboBox stageComboBox;
 
     private DefaultListModel model;
@@ -39,7 +54,6 @@ public class ActDialogPanel extends JDialog{
         main.add(this.dates());
         main.add(this.artistsChooser());
         
-        main.add(timeSetter());
         main.add(this.buttons());
         super.add(main);
         super.setVisible(true);
@@ -68,7 +82,6 @@ public class ActDialogPanel extends JDialog{
         }
         
         main.add(this.artistsChooser());
-        main.add(this.timeSetter());
         main.add(this.buttons());
         super.add(main);
     }
@@ -209,39 +222,6 @@ public class ActDialogPanel extends JDialog{
         artists.add(buttonPanel);
         return artists;
     }
-    
-    private JPanel timeSetter(){
-        this.beginTime = new JTextField();
-        this.endTime = new JTextField();
-
-        JPanel time = new JPanel();
-        time.setLayout(new BoxLayout(time, BoxLayout.Y_AXIS));
-        
-        JPanel begin = new JPanel();
-        begin.setLayout(new GridLayout());
-        begin.add(new JLabel("begin time:"));
-        begin.add(this.beginTime);
-
-        JPanel end = new JPanel();
-        end.setLayout(new GridLayout());
-        end.add(new JLabel("end time:"));
-        end.add(this.endTime);
-        
-        time.add(begin);
-        time.add(end);
-
-        if(this.act == null){
-            System.out.println("default txt.");
-            this.beginTime.setText("2015-10-11-08-10");
-            this.endTime.setText("2015-10-11-12-20");
-        }else{
-            System.out.println("non txt.");
-
-            this.beginTime.setText(this.act.getActTime().getBeginTimeString());
-            this.endTime.setText(this.act.getActTime().getEndTimeString());
-        }
-        return time;
-    }
 
     private JPanel buttons(){
         JPanel buttons = new JPanel();
@@ -291,7 +271,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(this.beginTime.getText()  ,this.endTime.getText()), artists);
+            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);
             this.model.addElement(act);
             this.agenda.addAct(act);
         }else{
@@ -299,7 +279,6 @@ public class ActDialogPanel extends JDialog{
             this.act.setGenre(this.genre.getText());
             this.act.setStage((Stage) this.stageComboBox.getSelectedItem());
             this.act.setArtists(artists);
-            this.act.setActTime(new ActTime(this.beginTime.getText()  ,this.endTime.getText()));
             this.model.removeElement(this.act);
             this.model.addElement(act);
         }

+ 0 - 14
src/gui/panels/edit/dialogs/StageDialogPanel.java

@@ -89,12 +89,6 @@ public class StageDialogPanel extends JDialog{
                 return;
             }else{
                 this.model.removeElement(this.stage);
-                for(Stage stage: this.agenda.getStages()){
-                    if(this.name.getText().equals(stage.getName())){
-                        JOptionPane.showMessageDialog(null, "Name can't be used twice!", "Warning", JOptionPane.WARNING_MESSAGE);
-                        return;
-                    }
-                }
                 this.stage.setName(this.name.getText());
                 this.model.addElement(this.stage);
                 dispose();
@@ -104,14 +98,6 @@ public class StageDialogPanel extends JDialog{
                 JOptionPane.showMessageDialog(null, "Name can't be empty!", "Warning", JOptionPane.WARNING_MESSAGE);
                 return;
             }else{
-                
-                for(Stage stage: this.agenda.getStages()){
-                    if(this.name.getText().equals(stage.getName())){
-                        JOptionPane.showMessageDialog(null, "Name can't be used twice!", "Warning", JOptionPane.WARNING_MESSAGE);
-                        return;
-                    }
-                }
-
                 Stage stage = new Stage(this.name.getText());
                 this.agenda.addStage(stage);
                 this.model.addElement(stage);