Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a9a1c869f | ||
|
|
58dd8b21be | ||
|
|
f9c25f406c | ||
|
|
43e2dca06e | ||
|
|
18b9510f04 | ||
|
|
9c6b2b44e4 | ||
|
|
ac9ccd1abd | ||
|
|
047770950f | ||
|
|
3ece3588e6 | ||
|
|
18726278a5 | ||
|
|
9ee421b792 | ||
|
|
9739ead0df | ||
|
|
e50d7cf29d | ||
|
|
1a3e8871a6 | ||
|
|
e001163a74 | ||
|
|
7195152f7f | ||
|
|
81b49bc905 | ||
|
|
be35fd46e4 | ||
|
|
4e844bcd3b | ||
|
|
9a09338818 | ||
|
|
e8490956dd | ||
|
|
5363546c45 | ||
|
|
e0b9c991c8 | ||
|
|
056a8b36d1 | ||
|
|
677e9a7c43 | ||
|
|
a0d37e1039 | ||
|
|
9de7409bac | ||
|
|
c225c23d66 | ||
|
|
08b63eb2ec | ||
|
|
172b9a3470 | ||
|
|
26e31ed1c6 | ||
|
|
e8079862f4 | ||
|
|
2a10e0846d | ||
|
|
0e5a2ccb61 | ||
|
|
692e63f25c | ||
|
|
2e4e763ef7 | ||
|
|
3dafa12ba8 | ||
|
|
a15ecc78c0 | ||
|
|
d0b6bcdd74 | ||
|
|
29063703f6 | ||
|
|
4fe2761ab1 | ||
|
|
46be84245b | ||
|
|
755941598e | ||
|
|
54fe904cad | ||
|
|
b530a47a95 | ||
|
|
dc4a87a4b3 | ||
|
|
8f5ef939f6 | ||
|
|
e2b140f780 | ||
|
|
302703f6ea | ||
|
|
7fcab5a2a6 | ||
|
|
3764de4a8f | ||
|
|
8d4ffa48f1 | ||
|
|
70ac0560b1 | ||
|
|
a35af42dcf | ||
|
|
46829eff10 | ||
|
|
73493d1faa | ||
|
|
7ab04656b6 | ||
|
|
68c7392f2d | ||
|
|
b566007b77 | ||
|
|
a1520cf55c | ||
|
|
1ed16ab22f | ||
|
|
b5dbb8e058 | ||
|
|
ea3d16c533 | ||
|
|
f69ac37ea8 | ||
|
|
d065860c4b | ||
|
|
4e6abc1551 | ||
|
|
6d6c5cd153 | ||
|
|
63e6138e83 | ||
|
|
a0cdeb1794 | ||
|
|
c10341c403 | ||
|
|
0e78c56ad7 | ||
|
|
c232d6a01c | ||
|
|
451ae58a77 | ||
|
|
4e81a4aa30 | ||
|
|
ff5daf1da8 | ||
|
|
26d0fa1ff3 | ||
|
|
fc0539c6ab | ||
|
|
91f113e8e3 | ||
|
|
c27d44a559 |
@@ -0,0 +1,125 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
|
||||
public class AddArtistPanel extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public AddArtistPanel(Agenda agenda)
|
||||
{
|
||||
super("Artist addscreen!");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(5,2));
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Artist name: ");
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JTextField nameTF = new JTextField("",15);
|
||||
panel2.add(nameTF);
|
||||
center.add(panel2);
|
||||
|
||||
JLabel genre = new JLabel("Genre: ");
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(genre);
|
||||
center.add(panel3);
|
||||
|
||||
JTextField genreTF = new JTextField("",15);
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(genreTF);
|
||||
center.add(panel4);
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
JLabel image = new JLabel("Image: ");
|
||||
panel5.add(image);
|
||||
center.add(panel5);
|
||||
|
||||
JPanel panel6 = new JPanel();
|
||||
JTextField imageTF = new JTextField("null", 15);
|
||||
panel6.add(imageTF);
|
||||
center.add(panel6);
|
||||
|
||||
JPanel panel7 = new JPanel();
|
||||
JLabel description = new JLabel("Description: ");
|
||||
panel7.add(description);
|
||||
center.add(panel7);
|
||||
|
||||
JPanel panel8 = new JPanel();
|
||||
JTextField descriptionTF = new JTextField("", 15);
|
||||
panel8.add(descriptionTF);
|
||||
center.add(panel8);
|
||||
|
||||
JPanel panel9 = new JPanel();
|
||||
JLabel background = new JLabel("Background: ");
|
||||
panel9.add(background);
|
||||
center.add(panel9);
|
||||
|
||||
JPanel panel10 = new JPanel();
|
||||
JTextField backgroundTF = new JTextField("", 15);
|
||||
panel10.add(backgroundTF);
|
||||
center.add(panel10);
|
||||
|
||||
|
||||
|
||||
JButton add = new JButton("Add artist!");
|
||||
south.add(add);
|
||||
|
||||
add.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String name = nameTF.getText();
|
||||
String genre = genreTF.getText();
|
||||
String image = imageTF.getText();
|
||||
String description = descriptionTF.getText();
|
||||
String background = backgroundTF.getText();
|
||||
|
||||
boolean alreadyExists = false;
|
||||
for (Artist artist : agenda.getArtists())
|
||||
{
|
||||
if (artist.getName().equals(name))
|
||||
{
|
||||
alreadyExists = true;
|
||||
}
|
||||
}
|
||||
if (name.isEmpty() == true){
|
||||
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||
}
|
||||
else if (alreadyExists == false)
|
||||
{
|
||||
Artist a = new Artist(name,genre,image,description, background);
|
||||
agenda.addArtist(a);
|
||||
JOptionPane.showMessageDialog(null, "Artist added!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Choose a different artist name!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(500,320);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
|
||||
public class AddEventPanel extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public AddEventPanel(Agenda agenda)
|
||||
{
|
||||
super("Event addscreen!");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(7,2));
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
|
||||
GregorianCalendar today = new GregorianCalendar();
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Event name: ");
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JTextField nameTF = new JTextField("",15);
|
||||
panel2.add(nameTF);
|
||||
center.add(panel2);
|
||||
|
||||
JLabel starttime = new JLabel("Starttime: ");
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(starttime);
|
||||
center.add(panel3);
|
||||
|
||||
Integer[] hours = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 };
|
||||
JComboBox<Integer> hour = new JComboBox<Integer>(hours);
|
||||
hour.setSelectedIndex(today.get(GregorianCalendar.HOUR_OF_DAY));
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(hour);
|
||||
center.add(panel4);
|
||||
|
||||
Integer[] minutes = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59};
|
||||
JComboBox<Integer> minute = new JComboBox<Integer>(minutes);
|
||||
minute.setSelectedIndex(today.get(GregorianCalendar.MINUTE));
|
||||
panel4.add(minute);
|
||||
panel4.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
panel4.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
|
||||
|
||||
Integer[] days = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
|
||||
JComboBox<Integer> day = new JComboBox<Integer>(days);
|
||||
day.setSelectedIndex(today.get(GregorianCalendar.DAY_OF_MONTH) - 1);
|
||||
panel4.add(day);
|
||||
|
||||
String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
||||
JComboBox<String> month = new JComboBox<String>(months);
|
||||
month.setSelectedIndex(today.get(GregorianCalendar.MONTH));
|
||||
panel4.add(month);
|
||||
|
||||
|
||||
Integer[] years = { 2015,2016,2017,2018};
|
||||
JComboBox<Integer> year = new JComboBox<Integer>(years);
|
||||
panel4.add(year);
|
||||
|
||||
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
JLabel endtime = new JLabel("Endtime: ");
|
||||
panel5.add(endtime);
|
||||
center.add(panel5);
|
||||
|
||||
JComboBox<Integer> hourE = new JComboBox<Integer>(hours);
|
||||
hourE.setSelectedIndex(today.get(GregorianCalendar.HOUR_OF_DAY));
|
||||
JPanel panel6 = new JPanel();
|
||||
panel6.add(hourE);
|
||||
center.add(panel6);
|
||||
|
||||
JComboBox<Integer> minuteE = new JComboBox<Integer>(minutes);
|
||||
minuteE.setSelectedIndex(today.get(GregorianCalendar.MINUTE));
|
||||
panel6.add(minuteE);
|
||||
panel6.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
panel6.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
|
||||
|
||||
JComboBox<Integer> dayE = new JComboBox<Integer>(days);
|
||||
dayE.setSelectedIndex(today.get(GregorianCalendar.DAY_OF_MONTH) - 1);
|
||||
panel6.add(dayE);
|
||||
|
||||
JComboBox<String> monthE = new JComboBox<String>(months);
|
||||
monthE.setSelectedIndex(today.get(GregorianCalendar.MONTH));
|
||||
panel6.add(monthE);
|
||||
|
||||
|
||||
JComboBox<Integer> yearE = new JComboBox<Integer>(years);
|
||||
panel6.add(yearE);
|
||||
|
||||
|
||||
JPanel panel7 = new JPanel();
|
||||
JLabel artist2 = new JLabel("Artist: ");
|
||||
panel7.add(artist2);
|
||||
center.add(panel7);
|
||||
|
||||
JPanel panel8 = new JPanel();
|
||||
String[] artists = new String[agenda.getArtists().size()];
|
||||
|
||||
for ( int idx = 0; idx < agenda.getArtists().size(); idx ++)
|
||||
{
|
||||
artists[idx] = agenda.getArtists().get(idx).getName();
|
||||
}
|
||||
|
||||
JComboBox<String> artist = new JComboBox<String>(artists);
|
||||
panel8.add(artist);
|
||||
center.add(panel8);
|
||||
|
||||
JPanel panel9 = new JPanel();
|
||||
JLabel stage = new JLabel("Stage: ");
|
||||
panel9.add(stage);
|
||||
center.add(panel9);
|
||||
|
||||
JPanel panel10 = new JPanel();
|
||||
String[] stages = new String[agenda.getStages().size()];
|
||||
|
||||
for ( int idx = 0; idx < agenda.getStages().size(); idx ++)
|
||||
{
|
||||
stages[idx] = agenda.getStages().get(idx).getName();
|
||||
}
|
||||
|
||||
JComboBox<String> stage2 = new JComboBox<String>(stages);
|
||||
panel10.add(stage2);
|
||||
center.add(panel10);
|
||||
|
||||
JPanel panel11 = new JPanel();
|
||||
JLabel description = new JLabel("Description: ");
|
||||
panel11.add(description);
|
||||
center.add(panel11);
|
||||
|
||||
JPanel panel12 = new JPanel();
|
||||
JTextField descriptionTF = new JTextField("",15);
|
||||
panel12.add(descriptionTF);
|
||||
center.add(panel12);
|
||||
|
||||
JPanel panel13 = new JPanel();
|
||||
JLabel expectedPopularity = new JLabel("Expected Popularity: ");
|
||||
panel13.add(expectedPopularity);
|
||||
center.add(panel13);
|
||||
|
||||
JPanel panel14 = new JPanel();
|
||||
Integer[] eps= { 1,2,3,4,5,6,7,8,9,10};
|
||||
JComboBox<Integer> ep = new JComboBox<Integer>(eps);
|
||||
panel14.add(ep);
|
||||
center.add(panel14);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JButton add = new JButton("Add event!");
|
||||
south.add(add);
|
||||
|
||||
add.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
boolean everythingCorrect = true;
|
||||
String name = nameTF.getText();
|
||||
|
||||
int hourS = hour.getSelectedIndex();
|
||||
int minuteS = minute.getSelectedIndex();
|
||||
int dayS = day.getSelectedIndex() + 1;
|
||||
String monthS = (String) month.getSelectedItem();
|
||||
int yearS = year.getSelectedIndex() + 2015;
|
||||
|
||||
int hourEnd = hourE.getSelectedIndex();
|
||||
int minuteEnd = minuteE.getSelectedIndex();
|
||||
int dayEnd = dayE.getSelectedIndex() + 1;
|
||||
String monthEnd = (String) monthE.getSelectedItem();
|
||||
int yearEnd = yearE.getSelectedIndex() + 2015;
|
||||
|
||||
String artistName = (String)artist.getSelectedItem();
|
||||
|
||||
Artist artist = null;
|
||||
|
||||
for(Artist a : agenda.getArtists())
|
||||
{
|
||||
if (a.getName().equals(artistName))
|
||||
{
|
||||
artist = a;
|
||||
}
|
||||
}
|
||||
|
||||
String stageName = (String)stage2.getSelectedItem();
|
||||
|
||||
Stage stage = null;
|
||||
|
||||
for(Stage s : agenda.getStages())
|
||||
{
|
||||
if (s.getName().equals(stageName))
|
||||
{
|
||||
stage = s;
|
||||
}
|
||||
}
|
||||
|
||||
String description = descriptionTF.getText();
|
||||
|
||||
int popularity = ep.getSelectedIndex() + 1;
|
||||
|
||||
if (dayS > monthDays(monthS)){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Invalid Date!");
|
||||
}
|
||||
else if (yearS > yearEnd || monthToInt(monthS) > monthToInt(monthEnd) || dayS > dayEnd || hourS > hourEnd || minuteS > minuteEnd){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "End time is earlier then start time!");
|
||||
}
|
||||
else if (dayS != dayEnd || monthS.equals(monthEnd) == false || yearS != yearEnd){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Event is too long! It can't be longer than a single day.");
|
||||
} else if (name.isEmpty()){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||
} else if (stage == null){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Missing a stage!");
|
||||
} else if (artist == null){
|
||||
JOptionPane.showMessageDialog(null, "Missing a artist!");
|
||||
}
|
||||
|
||||
|
||||
if (everythingCorrect == true)
|
||||
{
|
||||
Event event = new Event(name,yearS,monthToInt(monthS),dayS,hourS,minuteS,yearEnd,monthToInt(monthEnd),dayEnd,hourEnd, minuteEnd, artist, stage,description, popularity);
|
||||
agenda.addEvent(event);
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Event added!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(700,320);
|
||||
|
||||
}
|
||||
|
||||
public int monthToInt(String month)
|
||||
{
|
||||
int number = 0;
|
||||
switch (month)
|
||||
{
|
||||
case "January": number = 1; break;
|
||||
case "February": number = 2; break;
|
||||
case "March": number = 3; break;
|
||||
case "April": number = 4; break;
|
||||
case "May": number = 5; break;
|
||||
case "June":number = 6; break;
|
||||
case "July": number = 7; break;
|
||||
case "August": number = 8; break;
|
||||
case "September":number = 9; break;
|
||||
case "October": number = 10; break;
|
||||
case "November": number = 11; break;
|
||||
case "December": number = 12; break;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
public int monthDays(String month)
|
||||
{
|
||||
int number = 0;
|
||||
switch (month)
|
||||
{
|
||||
case "January": number = 31; break;
|
||||
case "February": number = 28; break;
|
||||
case "March": number = 31; break;
|
||||
case "April": number = 30; break;
|
||||
case "May": number = 31; break;
|
||||
case "June":number = 30; break;
|
||||
case "July": number = 31; break;
|
||||
case "August": number = 31; break;
|
||||
case "September":number = 30; break;
|
||||
case "October": number = 31; break;
|
||||
case "November": number = 30; break;
|
||||
case "December": number = 31; break;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
|
||||
public class AddStagePanel extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public AddStagePanel(Agenda agenda)
|
||||
{
|
||||
super("Stage addscreen!");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(2,2));
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Stage name: ");
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JTextField nameTF = new JTextField("",15);
|
||||
panel2.add(nameTF);
|
||||
center.add(panel2);
|
||||
|
||||
JLabel description = new JLabel("Stage Description: ");
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(description);
|
||||
center.add(panel3);
|
||||
|
||||
JTextField descriptionTF = new JTextField("",15);
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(descriptionTF);
|
||||
center.add(panel4);
|
||||
|
||||
|
||||
JButton add = new JButton("Add stage!");
|
||||
south.add(add);
|
||||
|
||||
add.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String name = nameTF.getText();
|
||||
String description = descriptionTF.getText();
|
||||
|
||||
boolean alreadyExists = false;
|
||||
for (Stage stage : agenda.getStages())
|
||||
{
|
||||
if (stage.getName().equals(name))
|
||||
{
|
||||
alreadyExists = true;
|
||||
}
|
||||
}
|
||||
if (name.isEmpty()){
|
||||
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||
}
|
||||
else if ( alreadyExists == false )
|
||||
{
|
||||
Stage s = new Stage(name,description);
|
||||
agenda.addStage(s);
|
||||
JOptionPane.showMessageDialog(null, "Stage added!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(null, "Choose a different stage name!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(400,180);
|
||||
}
|
||||
|
||||
}
|
||||
+224
@@ -0,0 +1,224 @@
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
public class Agenda implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private ArrayList<Stage> stages;
|
||||
private ArrayList<Event> events;
|
||||
private ArrayList<Artist> artists;
|
||||
|
||||
public Agenda() {
|
||||
stages = new ArrayList<Stage>();
|
||||
events = new ArrayList<Event>();
|
||||
artists = new ArrayList<Artist>();
|
||||
}
|
||||
|
||||
public void addStage(Stage stage){
|
||||
stages.add(stage);
|
||||
}
|
||||
|
||||
public void addEvent(Event event) {
|
||||
events.add(event);
|
||||
}
|
||||
|
||||
public void addArtist(Artist artist) {
|
||||
artists.add(artist);
|
||||
}
|
||||
|
||||
public ArrayList<Event> getEvents()
|
||||
{
|
||||
return events;
|
||||
}
|
||||
public ArrayList<Artist> getArtists()
|
||||
{
|
||||
return artists;
|
||||
}
|
||||
public ArrayList<Stage> getStages()
|
||||
{
|
||||
return stages;
|
||||
}
|
||||
|
||||
public void saveAgenda()
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
||||
{
|
||||
return true;
|
||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ".agn";
|
||||
}
|
||||
|
||||
});
|
||||
fileChooser.setDialogTitle("Choose save location");
|
||||
int userSelection = fileChooser.showSaveDialog(null);
|
||||
|
||||
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
if(!file.getName().endsWith(".agn"))
|
||||
{
|
||||
file = new File(file.getAbsolutePath() + ".agn");
|
||||
}
|
||||
|
||||
if(file.exists())
|
||||
{
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to overwrite: " + file.getName(), "Overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
saveAgenda(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
saveAgenda(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadAgenda()
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
||||
{
|
||||
return true;
|
||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return ".agn";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
fileChooser.setDialogTitle("Choose file");
|
||||
int userSelection = fileChooser.showOpenDialog(null);
|
||||
|
||||
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
if(!file.exists())
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "This file does not exist: " + file.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
clearAgenda();
|
||||
fillAgenda(file);
|
||||
JOptionPane.showMessageDialog(null, "Loaded succesfully");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fillAgenda(File file) {
|
||||
FileInputStream fis = null;
|
||||
ObjectInputStream ois = null;
|
||||
|
||||
try {
|
||||
|
||||
fis = new FileInputStream(file);
|
||||
ois = new ObjectInputStream(fis);
|
||||
|
||||
Object object;
|
||||
object = ois.readObject();
|
||||
try {
|
||||
while (object != null) {
|
||||
events.add((Event) object);
|
||||
object = ois.readObject();
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void fillArtists()
|
||||
{
|
||||
for (Event e : events)
|
||||
{
|
||||
boolean exists = false;
|
||||
String name = e.getArtist().getName();
|
||||
for (Artist a : artists)
|
||||
{
|
||||
if ( a.getName().equals(name) ) {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
if ( exists == false) {
|
||||
addArtist(e.getArtist());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fillStages()
|
||||
{
|
||||
for (Event e : events)
|
||||
{
|
||||
boolean exists = false;
|
||||
String name = e.getStage().getName();
|
||||
for (Stage s : stages)
|
||||
{
|
||||
if ( s.getName().equals(name) ) {
|
||||
exists = true;
|
||||
}
|
||||
}
|
||||
if ( exists == false) {
|
||||
addStage(e.getStage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAgenda(File file) {
|
||||
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
for (Event event : events) {
|
||||
oos.writeObject(event);
|
||||
}
|
||||
oos.close();
|
||||
JOptionPane.showMessageDialog(null, "Saved succesfully");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAgenda()
|
||||
{
|
||||
events.clear();
|
||||
stages.clear();
|
||||
artists.clear();
|
||||
}
|
||||
|
||||
public void fillAllLists()
|
||||
{
|
||||
loadAgenda();
|
||||
fillStages();
|
||||
fillArtists();
|
||||
}
|
||||
}
|
||||
+69
-10
@@ -1,28 +1,87 @@
|
||||
public class Artist {
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
|
||||
public class Artist implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private String name;
|
||||
private String genre;
|
||||
private String image;
|
||||
private ImageIcon image;
|
||||
private String description;
|
||||
private String background;
|
||||
|
||||
|
||||
public Artist(String name, String genre, String image, String description) {
|
||||
this.setName(name);
|
||||
public Artist(String name, String genre, String image, String description, String background)
|
||||
{
|
||||
this.name = name;
|
||||
this.genre = genre;
|
||||
this.image = image;
|
||||
this.description = description;
|
||||
this.background = background;
|
||||
|
||||
if ( !image.equals("null")) {
|
||||
this.image = new ImageIcon(image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getGenre()
|
||||
{
|
||||
return this.genre;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public ImageIcon getImage()
|
||||
{
|
||||
return this.image;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public String getBackground()
|
||||
{
|
||||
return this.background;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setGenre(String genre)
|
||||
{
|
||||
this.genre = genre;
|
||||
}
|
||||
|
||||
public void setImageIconString(String image)
|
||||
{
|
||||
this.image = new ImageIcon(image);
|
||||
}
|
||||
|
||||
public void setImageIcon(ImageIcon image)
|
||||
{
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setBackground(String background)
|
||||
{
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class ArtistPanel extends JPanel{
|
||||
|
||||
public ArtistPanel(Event event, Agenda a, TabbedPane tab)
|
||||
{
|
||||
super(new BorderLayout());
|
||||
JLabel name = new JLabel(event.getArtist().getName());
|
||||
JButton edit = new JButton("Edit Info");
|
||||
edit.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
EditArtistPanel editter = new EditArtistPanel(a, event.getArtist(), tab);
|
||||
}
|
||||
});
|
||||
name.setFont(new Font("Dialog", Font.BOLD, 20));
|
||||
JLabel description = new JLabel("<html>" + " <b> Genre: </b> " + event.getArtist().getGenre() + "<br> <br> <b> Beschrijving </b> <br> <br>" + event.getArtist().getDescription() + " <br> <br> <b> achtergrondinfo </b> <br> <br>" + event.getArtist().getBackground() + "</html>");
|
||||
description.setFont(new Font("Dialog", Font.PLAIN, 12));
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
|
||||
JPanel panel2 = new JPanel();
|
||||
panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS));
|
||||
panel2.setAlignmentX(LEFT_ALIGNMENT);
|
||||
JLabel photo = new JLabel(event.getArtist().getImage());
|
||||
panel2.add(name);
|
||||
panel2.add(Box.createRigidArea(new Dimension(10,0)));
|
||||
panel2.add(edit);
|
||||
panel.add(panel2);
|
||||
panel.add(new JSeparator(SwingConstants.HORIZONTAL));
|
||||
add(photo, BorderLayout.EAST);
|
||||
add(description, BorderLayout.CENTER);
|
||||
add(panel, BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import javax.swing.AbstractListModel;
|
||||
|
||||
|
||||
public class ContentList extends AbstractListModel {
|
||||
|
||||
private static final long serialVersionUID = 9110016552017561529L;
|
||||
|
||||
Object[] data;
|
||||
|
||||
public ContentList(Object[] data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int arg0) {
|
||||
return data[arg0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return data.length;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Data {
|
||||
|
||||
private ArrayList<Stage> stages;
|
||||
private ArrayList<Event> events;
|
||||
private ArrayList<Artist> artists;
|
||||
|
||||
public Data() {
|
||||
stages = new ArrayList<>();
|
||||
events = new ArrayList<>();
|
||||
artists = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void addStage(Stage stage) {
|
||||
stages.add(stage);
|
||||
}
|
||||
|
||||
private void addEvent(Event event) {
|
||||
events.add(event);
|
||||
}
|
||||
|
||||
private void addArtist(Artist artist) {
|
||||
artists.add(artist);
|
||||
}
|
||||
|
||||
public void makeArtist(String name, String genre, String image, String description) {
|
||||
Artist artist = new Artist(name,genre,image,description);
|
||||
addArtist(artist);
|
||||
}
|
||||
|
||||
/*public void makeEvent(Artist artist, int startTime, int endTime, String description) {
|
||||
Event event = new Event(artist, startTime, endTime,description);
|
||||
addEvent(event);
|
||||
}
|
||||
|
||||
public void makeStage(int expectedPopularity, String description) {
|
||||
Stage stage = new Stage(expectedPopularity, description);
|
||||
addStage(stage);
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
public class EditArtistPanel extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public EditArtistPanel(Agenda agenda, Artist art, TabbedPane tab)
|
||||
{
|
||||
super("Artist editscreen!");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(5,2));
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Artist name: ");
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JTextField nameTF = new JTextField(art.getName(),15);
|
||||
panel2.add(nameTF);
|
||||
center.add(panel2);
|
||||
|
||||
JLabel genre = new JLabel("Genre: ");
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(genre);
|
||||
center.add(panel3);
|
||||
|
||||
JTextField genreTF = new JTextField(art.getGenre(),15);
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(genreTF);
|
||||
center.add(panel4);
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
JLabel image = new JLabel("Image: ");
|
||||
panel5.add(image);
|
||||
center.add(panel5);
|
||||
|
||||
JPanel panel6 = new JPanel();
|
||||
JTextField imageTF = new JTextField("null", 15);
|
||||
panel6.add(imageTF);
|
||||
center.add(panel6);
|
||||
|
||||
JPanel panel7 = new JPanel();
|
||||
JLabel description = new JLabel("Description: ");
|
||||
panel7.add(description);
|
||||
center.add(panel7);
|
||||
|
||||
JPanel panel8 = new JPanel();
|
||||
JTextField descriptionTF = new JTextField(art.getDescription(), 15);
|
||||
panel8.add(descriptionTF);
|
||||
center.add(panel8);
|
||||
|
||||
JPanel panel9 = new JPanel();
|
||||
JLabel background = new JLabel("Background: ");
|
||||
panel9.add(background);
|
||||
center.add(panel9);
|
||||
|
||||
JPanel panel10 = new JPanel();
|
||||
JTextField backgroundTF = new JTextField(art.getBackground(), 15);
|
||||
panel10.add(backgroundTF);
|
||||
center.add(panel10);
|
||||
|
||||
|
||||
|
||||
JButton edit = new JButton("Edit artist!");
|
||||
south.add(edit);
|
||||
|
||||
edit.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String name = nameTF.getText();
|
||||
String genre = genreTF.getText();
|
||||
String image = imageTF.getText();
|
||||
String description = descriptionTF.getText();
|
||||
String background = backgroundTF.getText();
|
||||
|
||||
boolean alreadyExists = false;
|
||||
for (Artist artist : agenda.getArtists())
|
||||
{
|
||||
if (artist.getName().equals(name) && !artist.equals(art))
|
||||
{
|
||||
alreadyExists = true;
|
||||
}
|
||||
}
|
||||
if (name.isEmpty() == true){
|
||||
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||
}
|
||||
else if (alreadyExists == false)
|
||||
{
|
||||
art.setName(name);
|
||||
art.setGenre(genre);
|
||||
art.setImageIconString(image);
|
||||
art.setDescription(description);
|
||||
art.setBackground(background);
|
||||
JOptionPane.showMessageDialog(null, "Artist edited!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
if(tab != null)
|
||||
{
|
||||
tab.setVisible(false);
|
||||
tab.dispose();
|
||||
Event eventartist = null;
|
||||
for(Event event: agenda.getEvents())
|
||||
{
|
||||
if (event.getArtist().getName().equals(name))
|
||||
{
|
||||
eventartist = event;
|
||||
}
|
||||
}
|
||||
TabbedPane panel = new TabbedPane(agenda, eventartist, false);
|
||||
}
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(null, "Choose a different artist name!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JButton remove = new JButton("Remove artist!");
|
||||
for(Event e : agenda.getEvents())
|
||||
{
|
||||
if(e.getArtist().equals(art))
|
||||
{
|
||||
remove.setEnabled(false);
|
||||
}
|
||||
}
|
||||
south.add(remove);
|
||||
|
||||
remove.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to remove this artist?", "Remove Artist", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
Iterator<Artist> it = agenda.getArtists().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Artist a = it.next();
|
||||
if(a.equals(art))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Artist removed!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
if(tab != null)
|
||||
{
|
||||
tab.setVisible(false);
|
||||
tab.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(500,320);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,375 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
|
||||
public class EditEventPanel extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public EditEventPanel(Agenda agenda, Event e, TabbedPane tab)
|
||||
{
|
||||
super("Event editscreen!");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(7,2));
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Event name: ");
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JTextField nameTF = new JTextField(e.getEventName(),15);
|
||||
panel2.add(nameTF);
|
||||
center.add(panel2);
|
||||
|
||||
JLabel starttime = new JLabel("Starttime: ");
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(starttime);
|
||||
center.add(panel3);
|
||||
|
||||
Integer[] hours = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 };
|
||||
JComboBox<Integer> hour = new JComboBox<Integer>(hours);
|
||||
hour.setSelectedIndex(e.getStartDate().get(GregorianCalendar.HOUR_OF_DAY));
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(hour);
|
||||
center.add(panel4);
|
||||
|
||||
Integer[] minutes = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59};
|
||||
JComboBox<Integer> minute = new JComboBox<Integer>(minutes);
|
||||
minute.setSelectedIndex(e.getStartDate().get(GregorianCalendar.MINUTE));
|
||||
panel4.add(minute);
|
||||
panel4.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
panel4.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
|
||||
|
||||
Integer[] days = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
|
||||
JComboBox<Integer> day = new JComboBox<Integer>(days);
|
||||
day.setSelectedIndex(e.getStartDate().get(GregorianCalendar.DAY_OF_MONTH) - 1);
|
||||
panel4.add(day);
|
||||
|
||||
String[] months = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
|
||||
JComboBox<String> month = new JComboBox<String>(months);
|
||||
month.setSelectedIndex(e.getStartDate().get(GregorianCalendar.MONTH));
|
||||
panel4.add(month);
|
||||
|
||||
|
||||
Integer[] years = { 2015,2016,2017,2018};
|
||||
JComboBox<Integer> year = new JComboBox<Integer>(years);
|
||||
year.setSelectedItem(e.getStartDate().get(GregorianCalendar.YEAR));
|
||||
panel4.add(year);
|
||||
|
||||
|
||||
|
||||
JPanel panel5 = new JPanel();
|
||||
JLabel endtime = new JLabel("Endtime: ");
|
||||
panel5.add(endtime);
|
||||
center.add(panel5);
|
||||
|
||||
JComboBox<Integer> hourE = new JComboBox<Integer>(hours);
|
||||
hourE.setSelectedIndex(e.getEndDate().get(GregorianCalendar.HOUR_OF_DAY));
|
||||
JPanel panel6 = new JPanel();
|
||||
panel6.add(hourE);
|
||||
center.add(panel6);
|
||||
|
||||
JComboBox<Integer> minuteE = new JComboBox<Integer>(minutes);
|
||||
minuteE.setSelectedIndex(e.getEndDate().get(GregorianCalendar.MINUTE));
|
||||
panel6.add(minuteE);
|
||||
panel6.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
panel6.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
|
||||
|
||||
JComboBox<Integer> dayE = new JComboBox<Integer>(days);
|
||||
dayE.setSelectedIndex(e.getEndDate().get(GregorianCalendar.DAY_OF_MONTH) - 1);
|
||||
panel6.add(dayE);
|
||||
|
||||
JComboBox<String> monthE = new JComboBox<String>(months);
|
||||
monthE.setSelectedIndex(e.getEndDate().get(GregorianCalendar.MONTH));
|
||||
panel6.add(monthE);
|
||||
|
||||
|
||||
JComboBox<Integer> yearE = new JComboBox<Integer>(years);
|
||||
yearE.setSelectedItem(e.getEndDate().get(GregorianCalendar.YEAR));
|
||||
panel6.add(yearE);
|
||||
|
||||
|
||||
JPanel panel7 = new JPanel();
|
||||
JLabel artist2 = new JLabel("Artist: ");
|
||||
panel7.add(artist2);
|
||||
center.add(panel7);
|
||||
|
||||
JPanel panel8 = new JPanel();
|
||||
String[] artists = new String[agenda.getArtists().size()];
|
||||
int artistIndex = 0;
|
||||
|
||||
for ( int idx = 0; idx < agenda.getArtists().size(); idx ++)
|
||||
{
|
||||
artists[idx] = agenda.getArtists().get(idx).getName();
|
||||
if(agenda.getArtists().get(idx).equals(e.getArtist()))
|
||||
{
|
||||
artistIndex = idx;
|
||||
}
|
||||
}
|
||||
|
||||
JComboBox<String> artist = new JComboBox<String>(artists);
|
||||
artist.setSelectedIndex(artistIndex);
|
||||
panel8.add(artist);
|
||||
center.add(panel8);
|
||||
|
||||
JPanel panel9 = new JPanel();
|
||||
JLabel stage = new JLabel("Stage: ");
|
||||
panel9.add(stage);
|
||||
center.add(panel9);
|
||||
|
||||
JPanel panel10 = new JPanel();
|
||||
String[] stages = new String[agenda.getStages().size()];
|
||||
|
||||
int stageIndex = 0;
|
||||
|
||||
for ( int idx = 0; idx < agenda.getStages().size(); idx ++)
|
||||
{
|
||||
stages[idx] = agenda.getStages().get(idx).getName();
|
||||
if(agenda.getStages().get(idx).equals(e.getStage()))
|
||||
{
|
||||
stageIndex = idx;
|
||||
}
|
||||
}
|
||||
|
||||
JComboBox<String> stage2 = new JComboBox<String>(stages);
|
||||
stage2.setSelectedIndex(stageIndex);
|
||||
panel10.add(stage2);
|
||||
center.add(panel10);
|
||||
|
||||
JPanel panel11 = new JPanel();
|
||||
JLabel description = new JLabel("Description: ");
|
||||
panel11.add(description);
|
||||
center.add(panel11);
|
||||
|
||||
JPanel panel12 = new JPanel();
|
||||
JTextField descriptionTF = new JTextField(e.getDescription(),15);
|
||||
panel12.add(descriptionTF);
|
||||
center.add(panel12);
|
||||
|
||||
JPanel panel13 = new JPanel();
|
||||
JLabel expectedPopularity = new JLabel("Expected Popularity: ");
|
||||
panel13.add(expectedPopularity);
|
||||
center.add(panel13);
|
||||
|
||||
JPanel panel14 = new JPanel();
|
||||
Integer[] eps= { 1,2,3,4,5,6,7,8,9,10};
|
||||
JComboBox<Integer> ep = new JComboBox<Integer>(eps);
|
||||
ep.setSelectedIndex(e.getExpectedPopularity() - 1);
|
||||
panel14.add(ep);
|
||||
center.add(panel14);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JButton add = new JButton("Edit event!");
|
||||
south.add(add);
|
||||
|
||||
add.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent f) {
|
||||
boolean everythingCorrect = true;
|
||||
String name = nameTF.getText();
|
||||
|
||||
int hourS = hour.getSelectedIndex();
|
||||
int minuteS = minute.getSelectedIndex();
|
||||
int dayS = day.getSelectedIndex() + 1;
|
||||
String monthS = (String) month.getSelectedItem();
|
||||
int yearS = year.getSelectedIndex() + 2015;
|
||||
|
||||
int hourEnd = hourE.getSelectedIndex();
|
||||
int minuteEnd = minuteE.getSelectedIndex();
|
||||
int dayEnd = dayE.getSelectedIndex() + 1;
|
||||
String monthEnd = (String) monthE.getSelectedItem();
|
||||
int yearEnd = yearE.getSelectedIndex() + 2015;
|
||||
|
||||
String artistName = (String)artist.getSelectedItem();
|
||||
|
||||
Artist artist = null;
|
||||
|
||||
for(Artist a : agenda.getArtists())
|
||||
{
|
||||
if (a.getName().equals(artistName))
|
||||
{
|
||||
artist = a;
|
||||
}
|
||||
}
|
||||
|
||||
String stageName = (String)stage2.getSelectedItem();
|
||||
|
||||
Stage stage = null;
|
||||
|
||||
for(Stage s : agenda.getStages())
|
||||
{
|
||||
if (s.getName().equals(stageName))
|
||||
{
|
||||
stage = s;
|
||||
}
|
||||
}
|
||||
|
||||
String description = descriptionTF.getText();
|
||||
|
||||
int popularity = ep.getSelectedIndex() + 1;
|
||||
|
||||
if (dayS > monthDays(monthS)){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Invalid Date!");
|
||||
}
|
||||
else if (yearS > yearEnd || monthToInt(monthS) > monthToInt(monthEnd) || dayS > dayEnd || hourS > hourEnd || minuteS > minuteEnd){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "End time is earlier then start time!");
|
||||
}
|
||||
else if (dayS != dayEnd || monthS.equals(monthEnd) == false || yearS != yearEnd){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Event is too long! It can't be longer than a single day.");
|
||||
} else if (name.isEmpty()){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||
} else if (stage == null){
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Missing a stage!");
|
||||
} else if (artist == null){
|
||||
JOptionPane.showMessageDialog(null, "Missing a artist!");
|
||||
}
|
||||
|
||||
|
||||
if (everythingCorrect == true)
|
||||
{
|
||||
e.setEventName(name);
|
||||
e.setDescription(description);
|
||||
e.setExpectedPopularity(popularity);
|
||||
e.setArtist(artist);
|
||||
e.setStage(stage);
|
||||
e.setStartDate(yearS, monthToInt(monthS), dayS, hourS, minuteS);
|
||||
e.setEndDate(yearEnd, monthToInt(monthEnd), dayEnd, hourEnd, minuteEnd);
|
||||
|
||||
everythingCorrect = false;
|
||||
JOptionPane.showMessageDialog(null, "Event edited!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
if(tab != null)
|
||||
{
|
||||
tab.setVisible(false);
|
||||
tab.dispose();
|
||||
Event eventartist = null;
|
||||
for(Event event: agenda.getEvents())
|
||||
{
|
||||
if (event.getEventName().equals(name))
|
||||
{
|
||||
eventartist = event;
|
||||
}
|
||||
}
|
||||
TabbedPane panel = new TabbedPane(agenda, eventartist, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JButton remove = new JButton("Remove event!");
|
||||
south.add(remove);
|
||||
|
||||
remove.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent f) {
|
||||
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to remove this event?", "Remove Event", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
Iterator<Event> it = agenda.getEvents().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Event ev = it.next();
|
||||
if(ev.equals(e))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Event removed!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
if(tab != null)
|
||||
{
|
||||
tab.setVisible(false);
|
||||
tab.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(700,320);
|
||||
}
|
||||
|
||||
public int monthToInt(String month)
|
||||
{
|
||||
int number = 0;
|
||||
switch (month)
|
||||
{
|
||||
case "January": number = 1; break;
|
||||
case "February": number = 2; break;
|
||||
case "March": number = 3; break;
|
||||
case "April": number = 4; break;
|
||||
case "May": number = 5; break;
|
||||
case "June":number = 6; break;
|
||||
case "July": number = 7; break;
|
||||
case "August": number = 8; break;
|
||||
case "September":number = 9; break;
|
||||
case "October": number = 10; break;
|
||||
case "November": number = 11; break;
|
||||
case "December": number = 12; break;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
public int monthDays(String month)
|
||||
{
|
||||
int number = 0;
|
||||
switch (month)
|
||||
{
|
||||
case "January": number = 31; break;
|
||||
case "February": number = 28; break;
|
||||
case "March": number = 31; break;
|
||||
case "April": number = 30; break;
|
||||
case "May": number = 31; break;
|
||||
case "June":number = 30; break;
|
||||
case "July": number = 31; break;
|
||||
case "August": number = 31; break;
|
||||
case "September":number = 30; break;
|
||||
case "October": number = 31; break;
|
||||
case "November": number = 30; break;
|
||||
case "December": number = 31; break;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
|
||||
|
||||
public class EditStagePanel extends JFrame{
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
public EditStagePanel(Agenda agenda, Stage sta)
|
||||
{
|
||||
super("Stage editscreen!");
|
||||
setDefaultCloseOperation(HIDE_ON_CLOSE);
|
||||
JPanel content = new JPanel(new BorderLayout());
|
||||
JPanel south = new JPanel(new FlowLayout());
|
||||
JPanel center = new JPanel(new GridLayout(2,2));
|
||||
content.add(south, BorderLayout.SOUTH);
|
||||
content.add(center, BorderLayout.CENTER);
|
||||
|
||||
JPanel panel1 = new JPanel();
|
||||
JLabel name = new JLabel("Stage name: ");
|
||||
panel1.add(name);
|
||||
center.add(panel1);
|
||||
|
||||
JPanel panel2 = new JPanel();
|
||||
JTextField nameTF = new JTextField(sta.getName(),15);
|
||||
panel2.add(nameTF);
|
||||
center.add(panel2);
|
||||
|
||||
JLabel description = new JLabel("Stage Description: ");
|
||||
JPanel panel3 = new JPanel();
|
||||
panel3.add(description);
|
||||
center.add(panel3);
|
||||
|
||||
JTextField descriptionTF = new JTextField(sta.getDescription(),15);
|
||||
JPanel panel4 = new JPanel();
|
||||
panel4.add(descriptionTF);
|
||||
center.add(panel4);
|
||||
|
||||
|
||||
JButton add = new JButton("Edit stage!");
|
||||
south.add(add);
|
||||
|
||||
add.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String name = nameTF.getText();
|
||||
String description = descriptionTF.getText();
|
||||
|
||||
boolean alreadyExists = false;
|
||||
for (Stage stage : agenda.getStages())
|
||||
{
|
||||
if (stage.getName().equals(name) && !stage.equals(sta))
|
||||
{
|
||||
alreadyExists = true;
|
||||
}
|
||||
}
|
||||
if (name.isEmpty()){
|
||||
JOptionPane.showMessageDialog(null, "Fill in a correct name!");
|
||||
}
|
||||
else if ( alreadyExists == false )
|
||||
{
|
||||
sta.setName(name);
|
||||
sta.setDescription(description);
|
||||
JOptionPane.showMessageDialog(null, "Stage edited!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(null, "Choose a different stage name!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
JButton remove = new JButton("Remove stage!");
|
||||
for(Event e : agenda.getEvents())
|
||||
{
|
||||
if(e.getStage().equals(sta))
|
||||
{
|
||||
remove.setEnabled(false);
|
||||
}
|
||||
}
|
||||
south.add(remove);
|
||||
|
||||
remove.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to remove this stage?", "Remove Stage", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
Iterator<Stage> it = agenda.getStages().iterator();
|
||||
while(it.hasNext())
|
||||
{
|
||||
Stage s = it.next();
|
||||
if(s.equals(sta))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Stage removed!");
|
||||
setVisible(false);
|
||||
dispose();
|
||||
Window.updatePanel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
setContentPane(content);
|
||||
setVisible(true);
|
||||
setSize(400,180);
|
||||
}
|
||||
|
||||
}
|
||||
+158
-30
@@ -1,61 +1,189 @@
|
||||
public class Event {
|
||||
import java.io.Serializable;
|
||||
import java.text.DateFormat;
|
||||
import java.text.Format;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
public class Event implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private String eventName;
|
||||
private GregorianCalendar startDate;
|
||||
private GregorianCalendar endDate;
|
||||
private Artist artist;
|
||||
private int startTime;
|
||||
private int endTime;
|
||||
private String description;
|
||||
private Stage stage;
|
||||
private String name;
|
||||
private String description;
|
||||
private int expectedPopularity;
|
||||
|
||||
public Event(String name, Stage stage, Artist artist, int startTime, int endTime, String description) {
|
||||
if(artist != null)
|
||||
this.setArtist(artist);
|
||||
else
|
||||
this.setArtist(null);
|
||||
this.startTime = startTime;
|
||||
this.setEndTime(endTime);
|
||||
this.description = description;
|
||||
this.setName(name);
|
||||
public Event(String eventName, int startYear, int startMonth, int startDay,
|
||||
int startHour, int startMinute, int endYear, int endMonth,
|
||||
int endDay, int endHour, int endMinute, Artist artist, Stage stage,
|
||||
String description, int expectedPopularity) {
|
||||
this.eventName = eventName;
|
||||
this.startDate = new GregorianCalendar(startYear, startMonth - 1,
|
||||
startDay, startHour, startMinute);
|
||||
this.endDate = new GregorianCalendar(endYear, endMonth - 1, endDay,
|
||||
endHour, endMinute);
|
||||
this.stage = stage;
|
||||
this.artist = artist;
|
||||
this.description = description;
|
||||
this.expectedPopularity = expectedPopularity;
|
||||
}
|
||||
|
||||
public int getStartTime() {
|
||||
return startTime;
|
||||
public Event(String eventName, GregorianCalendar startDate,
|
||||
GregorianCalendar endDate, Artist artist, Stage stage,
|
||||
String description, int expectedPopularity) {
|
||||
this.eventName = eventName;
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
this.artist = artist;
|
||||
this.stage = stage;
|
||||
this.description = description;
|
||||
this.expectedPopularity = expectedPopularity;
|
||||
}
|
||||
|
||||
public int getEndTime() {
|
||||
return endTime;
|
||||
public String getEventName() {
|
||||
return this.eventName;
|
||||
}
|
||||
|
||||
public void setEndTime(int endTime) {
|
||||
this.endTime = endTime;
|
||||
public GregorianCalendar getStartDate() {
|
||||
return this.startDate;
|
||||
}
|
||||
|
||||
public GregorianCalendar getEndDate() {
|
||||
return this.endDate;
|
||||
}
|
||||
|
||||
public Artist getArtist() {
|
||||
return this.artist;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public Stage getStage() {
|
||||
return stage;
|
||||
return this.stage;
|
||||
}
|
||||
|
||||
public int getExpectedPopularity() {
|
||||
return this.expectedPopularity;
|
||||
}
|
||||
|
||||
public void setEventName(String name) {
|
||||
this.eventName = name;
|
||||
}
|
||||
|
||||
public void setStartDate(int startYear, int startMonth, int startDay,
|
||||
int startHour, int startMinute) {
|
||||
startDate.set(startYear, startMonth - 1, startDay, startHour,
|
||||
startMinute);
|
||||
}
|
||||
|
||||
public void setStartDate(GregorianCalendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public void setEndDate(int endYear, int endMonth, int endDay, int endHour,
|
||||
int endMinute) {
|
||||
endDate.set(endYear, endMonth - 1, endDay, endHour, endMinute);
|
||||
}
|
||||
|
||||
public void setEndDate(GregorianCalendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public void setArtist(Artist artist) {
|
||||
this.artist.setName(artist.getName());
|
||||
this.artist.setGenre(artist.getGenre());
|
||||
this.artist.setImageIcon(artist.getImage());
|
||||
this.artist.setDescription(artist.getDescription());
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setExpectedPopularity(int popularity) {
|
||||
this.expectedPopularity = popularity;
|
||||
}
|
||||
|
||||
public void setStage(Stage stage) {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public int getLength()
|
||||
{
|
||||
return getEndTime() - getStartTime();
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
public int getStartTime()
|
||||
{
|
||||
DateFormat format = new SimpleDateFormat("kkmm");
|
||||
format.setLenient(false);
|
||||
// System.out.println(format.format(startDate.getTime()));
|
||||
|
||||
// System.out.println(date.get(Calendar.HOUR_OF_DAY));
|
||||
int time = Integer.valueOf(format.format(startDate.getTime()));
|
||||
int hours = time/100;
|
||||
int minutes = time%100;
|
||||
int finaltime;
|
||||
if(minutes != 0)
|
||||
{
|
||||
finaltime = hours*60 + minutes;
|
||||
}
|
||||
else
|
||||
{
|
||||
finaltime = hours*60;
|
||||
}
|
||||
return finaltime;
|
||||
}
|
||||
|
||||
public Artist getArtist() {
|
||||
return artist;
|
||||
public int getEndTime()
|
||||
{
|
||||
DateFormat format = new SimpleDateFormat("kkmm");
|
||||
format.setLenient(false);
|
||||
// System.out.println(format.format(endDate.getTime()));
|
||||
int time = Integer.valueOf(format.format(endDate.getTime()));
|
||||
int hours = time/100;
|
||||
int minutes = time%100;
|
||||
int finaltime;
|
||||
if(minutes != 0)
|
||||
{
|
||||
finaltime = hours*60 + minutes;
|
||||
}
|
||||
else
|
||||
{
|
||||
finaltime = hours*60;
|
||||
}
|
||||
|
||||
return finaltime;
|
||||
}
|
||||
|
||||
public void setArtist(Artist artist) {
|
||||
this.artist = artist;
|
||||
public void setStartTime(int hours, int minutes)
|
||||
{
|
||||
// System.out.println("Start:" + hours + ":" + minutes);
|
||||
startDate.set(Calendar.HOUR_OF_DAY, hours);
|
||||
startDate.set(Calendar.MINUTE, minutes);
|
||||
// System.out.println(startDate.getTime());
|
||||
}
|
||||
|
||||
public void setEndTime(int hours, int minutes)
|
||||
{
|
||||
// System.out.println("End:" + hours + ":" + minutes);
|
||||
endDate.set(Calendar.HOUR_OF_DAY, hours);
|
||||
endDate.set(Calendar.MINUTE, minutes);
|
||||
// System.out.println(endDate.getTime());
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
DateFormat format = new SimpleDateFormat("dd-MM-yyyy");
|
||||
format.setLenient(false);
|
||||
|
||||
|
||||
return artist.getName() + " plays from "
|
||||
+ format.format(startDate.getTime()) + " to "
|
||||
+ format.format(endDate.getTime()) + ".";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
public class EventPanel extends JPanel{
|
||||
|
||||
private static final long serialVersionUID = 504733981352439417L;
|
||||
|
||||
public EventPanel(Event event, Agenda a, TabbedPane tab)
|
||||
{
|
||||
super(new BorderLayout());
|
||||
SimpleDateFormat dateformatter = new SimpleDateFormat("dd-MM-yyyy");
|
||||
SimpleDateFormat timeformatter = new SimpleDateFormat("HH:mm");
|
||||
JPanel box1 = new JPanel();
|
||||
box1.setLayout(new BoxLayout(box1, BoxLayout.PAGE_AXIS));
|
||||
JPanel box2 = new JPanel();
|
||||
box2.setLayout(new BoxLayout(box2, BoxLayout.LINE_AXIS));
|
||||
JPanel box3 = new JPanel();
|
||||
box3.setLayout(new BoxLayout(box3, BoxLayout.PAGE_AXIS));
|
||||
JPanel row = new JPanel();
|
||||
row.setLayout(new BoxLayout(row, BoxLayout.LINE_AXIS));
|
||||
JPanel panel = new JPanel();
|
||||
JButton edit = new JButton("Edit Info");
|
||||
edit.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
EditEventPanel edit = new EditEventPanel(a, event, tab);
|
||||
}
|
||||
});
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
|
||||
JLabel title = new JLabel(event.getEventName());
|
||||
JLabel date = new JLabel("<html>" + dateformatter.format(event.getEndDate().getTime()) + "</html>");
|
||||
JLabel data = new JLabel("<html> " + event.getStage().getName() + "<br> <br>" + event.getArtist().getName() + "<br> <br>" + event.getExpectedPopularity() + "<br> <br>" + timeformatter.format(event.getStartDate().getTime()) + " - " + timeformatter.format(event.getEndDate().getTime()) + "<br> <br> </html>");
|
||||
JLabel text = new JLabel("<html> Podium: <br> <br> Artiest: <br> <br> Populariteit: <br> <br> Tijd: <br> <br> </html>");
|
||||
box2.setAlignmentX(LEFT_ALIGNMENT);
|
||||
date.setFont(new Font("Dialog", Font.BOLD, 15));
|
||||
row.setAlignmentX(LEFT_ALIGNMENT);
|
||||
date.setAlignmentX(RIGHT_ALIGNMENT);
|
||||
title.setFont(new Font("Dialog", Font.BOLD, 20));
|
||||
text.setFont(new Font("Dialog", Font.BOLD, 15));
|
||||
data.setFont(new Font("Dialog", Font.PLAIN, 15));
|
||||
JLabel description = new JLabel("<html> <b> Beschrijving </b> <br> <br>" + event.getDescription() + "</html>");
|
||||
description.setFont(new Font("Dialog", Font.PLAIN, 12));
|
||||
row.add(title);
|
||||
row.add(Box.createRigidArea(new Dimension(10,0)));
|
||||
row.add(edit);
|
||||
row.add(Box.createRigidArea(new Dimension(30,0)));
|
||||
row.add(date);
|
||||
box1.add(row);
|
||||
box1.add(new JSeparator(SwingConstants.HORIZONTAL));
|
||||
box2.add(text);
|
||||
box2.add(data);
|
||||
box3.add(new JSeparator(SwingConstants.HORIZONTAL));
|
||||
box3.add(description);
|
||||
panel.add(box1);
|
||||
panel.add(box2);
|
||||
panel.add(box3);
|
||||
add(panel, BorderLayout.CENTER);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public class IO {
|
||||
|
||||
private ObjectInputStream objectInput;
|
||||
private ObjectOutputStream objectOutput;
|
||||
|
||||
|
||||
public IO(File file) throws IOException {
|
||||
objectInput = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
|
||||
objectOutput = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
|
||||
}
|
||||
|
||||
public void saveObject(Object o) throws IOException {
|
||||
objectOutput.writeObject(o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//new Window();
|
||||
|
||||
Window w = new Window();
|
||||
Agenda agn = w.getAgenda();
|
||||
|
||||
Artist a1 = new Artist("Coldplay", "Alternative Rock", "null", "A band", "more important information");
|
||||
Artist a2 = new Artist("Nirvana", "Alternative Rock", "null", "A band whose lead singer is dead", "more important information");
|
||||
Artist a3 = new Artist("Eminem", "Rap", "null", "A very famous rapper", "more important information");
|
||||
Stage s1 = new Stage("Rock Stage", "Stage for Rock and Alternative Rock concerts");
|
||||
Stage s2 = new Stage("Rap Stage", "Stage for Rap concerts");
|
||||
|
||||
Event e1 = new Event("Coldplay Live", 2015, 2, 24, 21, 00, 2015, 2, 24, 23, 00, a1, s1, "A concert from a very famous band", 2);
|
||||
Event e2 = new Event("Coldplay Live", 2015, 2, 25, 20, 00, 2015, 2, 25, 22, 00, a1, s1, "A concert from a very famous band", 1);
|
||||
Event e3 = new Event("Nirvana in memory", 2015, 2, 24, 16, 30, 2015, 2, 24, 20, 45, a2, s1, "A concert in memory of a once very famous band", 4);
|
||||
Event e4 = new Event("Epic Rap Battles of History", 2015, 3, 3, 12, 30, 2015, 3, 12, 18, 45, a3, s2, "Rap battle with Eminem and ERP", 3);
|
||||
Event e5 = new Event("Coldplay Live", 2015, 2, 26, 21, 00, 2015, 2, 26, 23, 00, a1, s1, "A concert from a very famous band", 2);
|
||||
Event e6 = new Event("Coldplay Live", 2015, 2, 27, 20, 00, 2015, 2, 27, 22, 00, a1, s1, "A concert from a very famous band", 1);
|
||||
Event e7 = new Event("Nirvana in memory", 2015, 2, 28, 16, 30, 2015, 2, 28, 20, 45, a2, s1, "A concert in memory of a once very famous band", 4);
|
||||
Event e8 = new Event("Epic Rap Battles of History", 2015, 3, 2, 12, 30, 2015, 3, 12, 18, 45, a3, s2, "Rap battle with Eminem and ERP", 3);
|
||||
|
||||
agn.addEvent(e1);
|
||||
agn.addEvent(e2);
|
||||
agn.addEvent(e3);
|
||||
agn.addEvent(e4);
|
||||
agn.addEvent(e5);
|
||||
agn.addEvent(e6);
|
||||
agn.addEvent(e7);
|
||||
agn.addEvent(e8);
|
||||
|
||||
agn.fillArtists();
|
||||
agn.fillStages();
|
||||
|
||||
w.updatePanel();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
|
||||
public class MenuBar extends JMenuBar {
|
||||
|
||||
private static final long serialVersionUID = -2095136277753179215L;
|
||||
|
||||
|
||||
public MenuBar(Window w)
|
||||
{
|
||||
super();
|
||||
|
||||
/*
|
||||
* FILE
|
||||
*/
|
||||
JMenu file = new JMenu("File");
|
||||
|
||||
JMenuItem newEvent = new JMenuItem("New Event");
|
||||
newEvent.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
|
||||
newEvent.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AddEventPanel(w.getAgenda());
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem newArtist = new JMenuItem("New Artist");
|
||||
newArtist.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AddArtistPanel(w.getAgenda());
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem newStage = new JMenuItem("New Stage");
|
||||
newStage.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
new AddStagePanel(w.getAgenda());
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem newAgenda = new JMenuItem("New Agenda");
|
||||
newAgenda.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to create a new agenda?", "New Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
Agenda ag = w.getAgenda();
|
||||
ag.clearAgenda();
|
||||
Window.updatePanel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem open = new JMenuItem("Open");
|
||||
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
|
||||
open.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
w.getAgenda().loadAgenda();
|
||||
Window.updatePanel();
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem save = new JMenuItem("Save");
|
||||
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
|
||||
save.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
w.getAgenda().saveAgenda();
|
||||
Window.updatePanel();
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem exit = new JMenuItem("Exit");
|
||||
exit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
file.add(newEvent);
|
||||
file.add(newArtist);
|
||||
file.add(newStage);
|
||||
file.addSeparator();
|
||||
file.add(newAgenda);
|
||||
file.addSeparator();
|
||||
file.add(open);
|
||||
file.add(save);
|
||||
file.addSeparator();
|
||||
file.add(exit);
|
||||
add(file);
|
||||
|
||||
|
||||
/*
|
||||
* VIEW
|
||||
*/
|
||||
|
||||
JMenu view = new JMenu("View");
|
||||
|
||||
JMenuItem timeline = new JMenuItem("Timeline");
|
||||
timeline.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Window.changePanel("timeline");
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem table = new JMenuItem("Table");
|
||||
table.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Window.changePanel("table");
|
||||
}
|
||||
});
|
||||
|
||||
JMenuItem art_sta = new JMenuItem("Artists and Stages");
|
||||
art_sta.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Window.changePanel("art_sta");
|
||||
}
|
||||
});
|
||||
|
||||
view.add(timeline);
|
||||
view.add(table);
|
||||
view.add(art_sta);
|
||||
add(view);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface Panel{
|
||||
public void update(ArrayList<Event> event);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import java.awt.Dimension;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
public class PanelArtSta extends JPanel implements Panel{
|
||||
|
||||
private Agenda a;
|
||||
JList artists;
|
||||
JList stages;
|
||||
Object[] dataArtist;
|
||||
Object[] dataStage;
|
||||
Window w;
|
||||
|
||||
public PanelArtSta(Window w)
|
||||
{
|
||||
super();
|
||||
a = w.getAgenda();
|
||||
this.w = w;
|
||||
|
||||
artists = new JList();
|
||||
artists.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
artists.setLayoutOrientation(JList.VERTICAL_WRAP);
|
||||
artists.setVisibleRowCount(-1);
|
||||
artists.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting() == false) {
|
||||
|
||||
if (artists.getSelectedIndex() == -1) {
|
||||
} else {
|
||||
new EditArtistPanel(w.getAgenda(), a.getArtists().get(artists.getSelectedIndex()), null);
|
||||
artists.clearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
JScrollPane artistScroller = new JScrollPane(artists);
|
||||
artistScroller.setPreferredSize(new Dimension(250, 80));
|
||||
|
||||
stages = new JList();
|
||||
stages.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
|
||||
stages.setLayoutOrientation(JList.VERTICAL_WRAP);
|
||||
stages.setVisibleRowCount(-1);
|
||||
stages.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
if (e.getValueIsAdjusting() == false) {
|
||||
|
||||
if (stages.getSelectedIndex() == -1) {
|
||||
} else {
|
||||
new EditStagePanel(w.getAgenda(), a.getStages().get(stages.getSelectedIndex()));
|
||||
stages.clearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
JScrollPane stageScroller = new JScrollPane(stages);
|
||||
stageScroller.setPreferredSize(new Dimension(250, 80));
|
||||
|
||||
add(artistScroller);
|
||||
add(stageScroller);
|
||||
}
|
||||
|
||||
|
||||
public void compileData()
|
||||
{
|
||||
int artistsList = a.getArtists().size();
|
||||
int stagesList = a.getStages().size();
|
||||
|
||||
if(artistsList > 0)
|
||||
{
|
||||
dataArtist = new Object[artistsList];
|
||||
for(int i = 0; i < artistsList; i++)
|
||||
{
|
||||
dataArtist[i] = a.getArtists().get(i);
|
||||
}
|
||||
artists.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataArtist = new Object[1];
|
||||
dataArtist[0] = new Artist("Geen Artists", "Geen Artists", "null", "Geen Artists", "Geen Artists");
|
||||
artists.setEnabled(false);
|
||||
}
|
||||
|
||||
if(stagesList > 0)
|
||||
{
|
||||
dataStage = new Object[stagesList];
|
||||
|
||||
for(int i = 0; i < stagesList; i++)
|
||||
{
|
||||
dataStage[i] = a.getStages().get(i);
|
||||
}
|
||||
stages.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataStage = new Object[1];
|
||||
dataStage[0] = new Stage("Geen Stages", "Geen Stages");
|
||||
stages.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void update(ArrayList<Event> event) {
|
||||
a = w.getAgenda();
|
||||
compileData();
|
||||
AbstractListModel artistsList = new ContentList(dataArtist);
|
||||
AbstractListModel stagesList = new ContentList(dataStage);
|
||||
artists.setModel(artistsList);
|
||||
stages.setModel(stagesList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
@@ -18,9 +24,9 @@ import javax.swing.table.AbstractTableModel;
|
||||
/**
|
||||
* Constructs a JTable in a ScrolPane.
|
||||
* @author Wesley
|
||||
* @version 1.0
|
||||
* @version 1.3
|
||||
*/
|
||||
public class TabelPanel extends JPanel {
|
||||
public class PanelTable extends JPanel implements Panel{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private JScrollPane scrollPane;
|
||||
@@ -34,33 +40,44 @@ public class TabelPanel extends JPanel {
|
||||
private ArrayList<Event> fullEvents;
|
||||
private JTable table;
|
||||
private JTable selectedCell;
|
||||
private Agenda a;
|
||||
|
||||
/**
|
||||
* Constructor makes the table and adds it to a scrollPane.
|
||||
* @param events
|
||||
*/
|
||||
public TabelPanel(ArrayList<Event> events) {
|
||||
this.events = events;
|
||||
fullEvents = new ArrayList<>();
|
||||
compileData(columnNames.length,events.size());
|
||||
public PanelTable(Agenda a) {
|
||||
super.setLayout(new BorderLayout());
|
||||
this.a = a;
|
||||
table= new JTable();
|
||||
AbstractTableModel tableModel = new ContentTable(data,columnNames);
|
||||
table.setModel(tableModel);
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||
table.setAutoCreateRowSorter(true);
|
||||
table.setAutoResizeMode(table.AUTO_RESIZE_ALL_COLUMNS);
|
||||
table.getTableHeader().setReorderingAllowed(false);
|
||||
table.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) { if(e.getClickCount() > 1 ) cellClicked(e); else selectedCell = (JTable) e.getSource(); }
|
||||
});
|
||||
scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
scrollPane.setBorder(null);
|
||||
add(scrollPane);
|
||||
add(scrollPane,BorderLayout.SOUTH);
|
||||
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
|
||||
JButton button;
|
||||
button = new JButton("Filter");
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) { filter(); }
|
||||
});
|
||||
buttonPanel.add(button);
|
||||
button = new JButton(new ImageIcon("src/sprites/sprite0.png"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) { update(fullEvents, true); }
|
||||
});
|
||||
buttonPanel.add(button);
|
||||
add(buttonPanel,BorderLayout.NORTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the size of the scrollPane, in which the table is placed to fill out its container panel (not sure if this is needed?)
|
||||
*/
|
||||
public void paintComponent(Graphics g) {
|
||||
scrollPane.setPreferredSize(new Dimension(getWidth(),getHeight()));
|
||||
scrollPane.setPreferredSize(new Dimension(getWidth(),getHeight()-35));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,14 +86,15 @@ public class TabelPanel extends JPanel {
|
||||
* @param rows
|
||||
*/
|
||||
public void compileData(int columnes, int rows) {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm");
|
||||
data = new Object[rows][columnes];
|
||||
for(int x = 0; x < rows; x++) {
|
||||
Object[] tempData = new Object[columnes];
|
||||
tempData[0] = events.get(x).getStage().getName();
|
||||
tempData[1] = events.get(x).getName();
|
||||
tempData[1] = events.get(x).getEventName();
|
||||
tempData[2] = events.get(x).getArtist().getName();
|
||||
tempData[3] = new Integer(events.get(x).getStartTime());
|
||||
tempData[4] = new Integer(events.get(x).getEndTime());
|
||||
tempData[3] = formatter.format(events.get(x).getStartDate().getTime());
|
||||
tempData[4] = formatter.format(events.get(x).getEndDate().getTime());
|
||||
data[x] = tempData;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +103,12 @@ public class TabelPanel extends JPanel {
|
||||
* Refreshes the content on the table with a fresh ArrayList of events, useful when things are removed and added and should be called every time you update the list.
|
||||
* @param events
|
||||
*/
|
||||
public void refreshContent(ArrayList<Event> events, boolean newList) {
|
||||
public void update(ArrayList<Event> events)
|
||||
{
|
||||
update(events, true);
|
||||
}
|
||||
|
||||
public void update(ArrayList<Event> events, boolean newList) {
|
||||
this.events = events;
|
||||
if(newList)
|
||||
this.fullEvents = events;
|
||||
@@ -118,13 +141,8 @@ public class TabelPanel extends JPanel {
|
||||
* @param row
|
||||
*/
|
||||
private void openEventDialog(int row) {
|
||||
JFrame frame = new JFrame();
|
||||
Event event = events.get(row);
|
||||
//the dialog
|
||||
frame.pack();
|
||||
frame.setSize(300, 200);
|
||||
frame.setLocationRelativeTo(this);
|
||||
frame.setVisible(true);
|
||||
new TabbedPane(a, event, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,13 +150,8 @@ public class TabelPanel extends JPanel {
|
||||
* @param row
|
||||
*/
|
||||
private void openArtistDialog(int row) {
|
||||
JFrame frame = new JFrame();
|
||||
Artist artsit = events.get(row).getArtist();
|
||||
//the dialog
|
||||
frame.pack();
|
||||
frame.setSize(300, 200);
|
||||
frame.setLocationRelativeTo(this);
|
||||
frame.setVisible(true);
|
||||
Event event = events.get(row);
|
||||
new TabbedPane(a, event, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +174,7 @@ public class TabelPanel extends JPanel {
|
||||
break;
|
||||
case 1:
|
||||
for(Event event : fullEvents) {
|
||||
if(event.equals(events.get(selectedCell.getSelectedRow()))) {
|
||||
if(event.getEventName().equals(events.get(selectedCell.getSelectedRow()).getEventName())) {
|
||||
filteredList.add(event);
|
||||
}
|
||||
}
|
||||
@@ -173,13 +186,39 @@ public class TabelPanel extends JPanel {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
int selectedCellStartTime = events.get(selectedCell.getSelectedRow()).getStartDate().getTime().getHours()*100;
|
||||
selectedCellStartTime += events.get(selectedCell.getSelectedRow()).getStartDate().getTime().getMinutes();
|
||||
int selectedCellEndTime = events.get(selectedCell.getSelectedRow()).getEndDate().getTime().getHours()*100;
|
||||
selectedCellEndTime += events.get(selectedCell.getSelectedRow()).getEndDate().getTime().getMinutes();
|
||||
for(Event event : fullEvents) {
|
||||
int time = event.getStartDate().getTime().getHours()*100;
|
||||
time += event.getStartDate().getTime().getMinutes();
|
||||
if(time >= selectedCellStartTime && time <= selectedCellEndTime) {
|
||||
filteredList.add(event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
selectedCellStartTime = events.get(selectedCell.getSelectedRow()).getStartDate().getTime().getHours()*100;
|
||||
selectedCellStartTime += events.get(selectedCell.getSelectedRow()).getStartDate().getTime().getMinutes();
|
||||
selectedCellEndTime = events.get(selectedCell.getSelectedRow()).getEndDate().getTime().getHours()*100;
|
||||
selectedCellEndTime += events.get(selectedCell.getSelectedRow()).getEndDate().getTime().getMinutes();
|
||||
for(Event event : fullEvents) {
|
||||
int time = event.getEndDate().getTime().getHours()*100;
|
||||
time += event.getEndDate().getTime().getMinutes();
|
||||
if(time >= selectedCellStartTime && time <= selectedCellEndTime) {
|
||||
filteredList.add(event);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
refreshContent(filteredList,false);
|
||||
update(filteredList,false);
|
||||
selectedCell = null;
|
||||
}
|
||||
else {
|
||||
JOptionPane.showMessageDialog(this, "Select a cell with the value u want to filter on","No cell selected",JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
public class Preformance {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# BELANGRIJK
|
||||
De .jar file moet als externe Library toegevoegd worden.
|
||||
De sprites folder moet in de root van het project.
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
public class SaveLoad {
|
||||
|
||||
public static void saveFile(Object obj)
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
||||
{
|
||||
return true;
|
||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Agenda (.agn)";
|
||||
}
|
||||
|
||||
});
|
||||
fileChooser.setDialogTitle("Choose save location");
|
||||
int userSelection = fileChooser.showSaveDialog(null);
|
||||
|
||||
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
if(!file.getName().endsWith(".agn"))
|
||||
{
|
||||
file = new File(file.getAbsolutePath() + ".agn");
|
||||
}
|
||||
|
||||
if(file.exists())
|
||||
{
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to overwrite: " + file.getName(), "Overwrite", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
save(obj, file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
save(obj, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Object loadFile()
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
fileChooser.setFileFilter(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(File pathname) {
|
||||
if(pathname.isFile() && pathname.getName().endsWith(".agn"))
|
||||
{
|
||||
return true;
|
||||
}else if(pathname.isDirectory()){return true;}else{return false;}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Agenda (.agn)";
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
fileChooser.setDialogTitle("Choose file");
|
||||
int userSelection = fileChooser.showOpenDialog(null);
|
||||
|
||||
if(userSelection == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
if(!file.exists())
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "This file does not exist: " + file.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
return load(file);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void save(Object obj, File file)
|
||||
{
|
||||
ObjectOutputStream oostr = null;
|
||||
try {
|
||||
oostr = new ObjectOutputStream(new FileOutputStream(file));
|
||||
oostr.writeObject(obj);
|
||||
oostr.flush();
|
||||
oostr.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Object load(File file)
|
||||
{
|
||||
ObjectInputStream oistr = null;
|
||||
try {
|
||||
oistr = new ObjectInputStream(new FileInputStream(file));
|
||||
Object obj = oistr.readObject();
|
||||
oistr.close();
|
||||
return obj;
|
||||
} catch (IOException | ClassNotFoundException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
-13
@@ -1,28 +1,40 @@
|
||||
import java.util.ArrayList;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Stage {
|
||||
public class Stage implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1;
|
||||
|
||||
private ArrayList<Event> events;
|
||||
private String name;
|
||||
private String description;
|
||||
private int expectedPopularity;
|
||||
|
||||
public Stage(String name, int expectedPopularity, String description) {
|
||||
events = new ArrayList<>();
|
||||
this.setName(name);
|
||||
this.expectedPopularity = expectedPopularity;
|
||||
public Stage(String name, String description)
|
||||
{
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void addEvent(Event event) {
|
||||
events.add(event);
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public String getDescription()
|
||||
{
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.LayoutManager;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
public class StagePanel extends JPanel
|
||||
{
|
||||
private BufferedImage image;
|
||||
private int width, height, posX;
|
||||
private double widthD, posXD;
|
||||
private Event event;
|
||||
public StagePanel(int width, int height, int posX, Event event, double widthD, double posXD)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.posX = posX;
|
||||
this.event = event;
|
||||
this.widthD = widthD;
|
||||
this.posXD = posXD;
|
||||
image = new BufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2 = image.createGraphics();
|
||||
g2.setColor(Color.blue);
|
||||
g2.fillRect(0, 0, image.getWidth(), image.getHeight());
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
{
|
||||
super.paint(g);
|
||||
((Graphics2D)g).drawImage(image, this.posX, 0, this);
|
||||
}
|
||||
|
||||
public StagePanel(LayoutManager arg0)
|
||||
{
|
||||
super(arg0);
|
||||
|
||||
}
|
||||
|
||||
public StagePanel(boolean arg0)
|
||||
{
|
||||
super(arg0);
|
||||
|
||||
}
|
||||
|
||||
public void update(int posx, double posXD)
|
||||
{
|
||||
this.posX = posx;
|
||||
this.posXD = posXD;
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
||||
public StagePanel(LayoutManager arg0, boolean arg1)
|
||||
{
|
||||
super(arg0, arg1);
|
||||
|
||||
}
|
||||
|
||||
public double getPosX()
|
||||
{
|
||||
return this.posXD;
|
||||
}
|
||||
|
||||
public void setLength(int length, double widthD)
|
||||
{
|
||||
this.width = length;
|
||||
this.widthD = widthD;
|
||||
}
|
||||
|
||||
public void setStageStartTime(int hours, int minutes)
|
||||
{
|
||||
event.setStartTime(hours, minutes);
|
||||
}
|
||||
|
||||
public void setStageEndTime(int hours, int minutes)
|
||||
{
|
||||
event.setEndTime(hours, minutes);
|
||||
}
|
||||
|
||||
public int getStageStartTime()
|
||||
{
|
||||
return event.getStartTime();
|
||||
}
|
||||
|
||||
public double getImageWidth()
|
||||
{
|
||||
return this.widthD;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
//een jframe met info, heeft alleen een agenda object, event object (het desbetreffende event) en een boolean met daarin true of false (slaande op je wel of niet met het event wilt starten) nodig.
|
||||
//Voorderest heeft dit niks nodig en is het een apart openend JFrame wat gewoon weer afgesloten kan worden.
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JTabbedPane;
|
||||
|
||||
public class TabbedPane extends JFrame{
|
||||
|
||||
public TabbedPane(Agenda a, Event event, boolean eventSelected)
|
||||
{
|
||||
super("info GUI");
|
||||
JTabbedPane tab = new JTabbedPane();
|
||||
tab.add("Event", new EventPanel(event, a, this));
|
||||
tab.add("Artist", new ArtistPanel(event, a, this));
|
||||
if(eventSelected)
|
||||
{
|
||||
tab.setSelectedIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
tab.setSelectedIndex(1);
|
||||
}
|
||||
setContentPane(tab);
|
||||
setSize(480, 410);
|
||||
setVisible(true);
|
||||
}
|
||||
}
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.ComponentListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
@SuppressWarnings({ "serial" })
|
||||
public class Timeline extends JPanel
|
||||
{
|
||||
private ArrayList<Event> events = new ArrayList<Event>();
|
||||
private JPanel frame;
|
||||
|
||||
// Geef dit object je JFrame mee, en zet in je JFrame de volgende code:
|
||||
// this.setContentPane(timeline.getTimeline());
|
||||
// this.getRootPane().addComponentListener(new ComponentAdapter()
|
||||
// {
|
||||
// public void componentResized(ComponentEvent e) {
|
||||
// timeline.refresh();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
public Timeline(JPanel frame)
|
||||
{
|
||||
super();
|
||||
this.frame = frame;
|
||||
|
||||
genStages();
|
||||
this.setSize(frame.getWidth(), frame.getHeight());
|
||||
// refresh();
|
||||
|
||||
}
|
||||
|
||||
public void setEvents(ArrayList<Event> events)
|
||||
{
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
this.removeAll();
|
||||
createMainPanel();
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
public JPanel createMainPanel()
|
||||
{
|
||||
// this.setSize(frame.getWidth(), frame.getHeight());
|
||||
JPanel mainPanel = new JPanel();
|
||||
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
|
||||
Container topContainer = createTopPanel();
|
||||
Dimension dim = new Dimension(this.getWidth(), 60);
|
||||
topContainer.setMaximumSize(dim);
|
||||
mainPanel.add(topContainer);
|
||||
|
||||
Dimension centerDim = new Dimension(this.getWidth(), this.getHeight());
|
||||
|
||||
// Container centerContainer = createCenterPanel();
|
||||
JPanel centerContainer = createCenterPanel();
|
||||
centerContainer.setPreferredSize(centerDim);
|
||||
|
||||
centerContainer.setMaximumSize(centerDim);
|
||||
// System.out.println(centerDim);
|
||||
mainPanel.add(centerContainer);
|
||||
this.add(mainPanel, BorderLayout.CENTER);
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
private JPanel createCenterPanel()
|
||||
{
|
||||
|
||||
JPanel centerPanel = new JPanel();
|
||||
centerPanel.setBackground(Color.lightGray);
|
||||
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
|
||||
centerPanel.add(Box.createRigidArea(new Dimension(0, 30)));
|
||||
|
||||
for(Event event : events)
|
||||
{
|
||||
StagePanel stagepanel = new StagePanel((int)calcLengthOfStage(event.getLength()), 30, (int)calcPositionOfStage(event.getStartTime()), event,calcLengthOfStage(event.getLength()),calcPositionOfStage(event.getStartTime()));
|
||||
Container content = stagepanel;
|
||||
content.setMaximumSize(new Dimension(this.getWidth(),30));
|
||||
content.addMouseListener(new MouseListener() {
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
resizeTimeline(stagepanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
|
||||
}
|
||||
});
|
||||
content.addMouseMotionListener(new MouseMotionListener() {
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
int value = (int)(e.getX() - stagepanel.getImageWidth() / 2);
|
||||
double value2 = (e.getX() - stagepanel.getImageWidth() / 2);
|
||||
// System.out.println("Value1: " + value);
|
||||
// System.out.println("Value2: " + value2);
|
||||
stagepanel.update(value, value2);
|
||||
}
|
||||
});
|
||||
centerPanel.add(content);
|
||||
centerPanel.add(Box.createRigidArea(new Dimension(0,15)));
|
||||
}
|
||||
|
||||
// this.add(centerPanel, BorderLayout.CENTER);
|
||||
return centerPanel;
|
||||
}
|
||||
|
||||
public void resizeTimeline(StagePanel stagepanel)
|
||||
{
|
||||
// System.out.println(stagepanel.getStageStartTime());
|
||||
// System.out.println(calcStartTimeOfStagePanel(stagepanel.getPosX()));
|
||||
stagepanel.setStageStartTime(calcStartTimeOfStagePanelHours(stagepanel.getPosX()),calcStartTimeOfStagePanelMinutes(stagepanel.getPosX()));
|
||||
stagepanel.setStageEndTime(calcEndTimeOfStagePanelHours(stagepanel.getPosX(), stagepanel.getImageWidth()),calcEndTimeOfStagePanelMinutes(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||
// stagepanel.setLength(calcLengthOfStagePanel(stagepanel.getImageWidth()));
|
||||
// System.out.println("HOURS: " + calcEndTimeOfStagePanelHours(stagepanel.getPosX(), stagepanel.getImageWidth()));
|
||||
// System.out.println("MINUTES: " + calcEndTimeOfStagePanelMinutes(stagepanel.getPosX(), stagepanel.getImageWidth()) );
|
||||
// TimelinePanel tempPanel = (TimelinePanel) frame;
|
||||
// tempPanel.refresh();
|
||||
refresh();
|
||||
// System.out.println(stagepanel.getPosX());
|
||||
}
|
||||
|
||||
public double calcLengthOfStage(double length)
|
||||
{
|
||||
double lengthOfStage = 0;
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
|
||||
double frameWidth = this.getWidth();
|
||||
double minmax = max-min;
|
||||
double pixelsPerLength = frameWidth / minmax;
|
||||
lengthOfStage = pixelsPerLength * (double)length;
|
||||
// System.out.println("LengthOfStage: " + lengthOfStage);
|
||||
//
|
||||
// System.out.println("MAX: " + max);
|
||||
// System.out.println("MIN: " + min);
|
||||
// System.out.println("LENGTH: " + length);
|
||||
// System.out.println("FRAME: " + frameWidth);
|
||||
// System.out.println("PixelsPerLEngth: " + pixelsPerLength);
|
||||
|
||||
return lengthOfStage;
|
||||
}
|
||||
|
||||
public double calcLengthOfStagePanel(double length)
|
||||
{
|
||||
double lengthOfStagePanel = 0;
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
// System.out.println(length);
|
||||
double frameWidth = this.getWidth();
|
||||
double minmax = max-min;
|
||||
double pixelsPerLength = frameWidth / minmax;
|
||||
// System.out.println(pixelsPerLength);
|
||||
lengthOfStagePanel = (double)length / pixelsPerLength;
|
||||
// System.out.println(lengthOfStagePanel);
|
||||
|
||||
|
||||
// System.out.println("LengthOfStagePane: " + (int)lengthOfStagePanel);
|
||||
|
||||
return lengthOfStagePanel;
|
||||
}
|
||||
|
||||
public double calcPositionOfStage(int startTime)
|
||||
{
|
||||
double posx;
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
double minmax = max-min;
|
||||
posx = startTime - min;
|
||||
posx = posx * this.getWidth() / minmax;
|
||||
// System.out.println("Frame: " + this.getWidth());
|
||||
// System.out.println("startTime: " + startTime);
|
||||
// System.out.println("Max: " + max + " min: " + min);
|
||||
// System.out.println("Posx: " + posx);
|
||||
return posx;
|
||||
}
|
||||
|
||||
public int calcStartTimeOfStagePanelHours(double posx)
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
// System.out.println("MIN: " + min);
|
||||
// System.out.println("max: " + max);
|
||||
// double startTime = (posx / (this.getWidth() / (max - min )) ) + min;
|
||||
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
||||
double minmax = max-min;
|
||||
double bottom = this.getWidth() / minmax;
|
||||
double all = posx / bottom;
|
||||
double startTime = all + min;
|
||||
// System.out.println("STPH: " + this.getWidth());
|
||||
|
||||
|
||||
|
||||
|
||||
return ((int)startTime / 60);
|
||||
}
|
||||
|
||||
public int calcStartTimeOfStagePanelMinutes(double posx)
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
// double startTime = (posx / (this.getWidth() / (max - min )) ) + min;
|
||||
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
||||
double minmax = max-min;
|
||||
double bottom = this.getWidth() / minmax;
|
||||
double all = posx / bottom;
|
||||
double startTime = all + min;
|
||||
// System.out.println("STPM: " + this.getWidth());
|
||||
|
||||
return ((int)startTime % 60);
|
||||
}
|
||||
|
||||
public int calcEndTimeOfStagePanelHours(double posx, double imageWidth)
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
||||
double minmax = max-min;
|
||||
double bottom = this.getWidth() / minmax;
|
||||
double all = posx / bottom;
|
||||
double endTime = all + min + calcLengthOfStagePanel(imageWidth);
|
||||
// System.out.println("ETPH: " + this.getWidth());
|
||||
return (int)endTime / 60;
|
||||
}
|
||||
|
||||
public int calcEndTimeOfStagePanelMinutes(double posx, double imageWidth)
|
||||
{
|
||||
int min = findMinMax(1);
|
||||
int max = findMinMax(2);
|
||||
//Omdat het anders onnodig afgerond wordt, alles apart in doubles.
|
||||
double minmax = max-min;
|
||||
double bottom = this.getWidth() / minmax;
|
||||
double all = posx / bottom;
|
||||
double endTime = all + min + calcLengthOfStagePanel(imageWidth);
|
||||
// System.out.println("ETPM: " + this.getWidth());
|
||||
return (int)endTime % 60;
|
||||
}
|
||||
|
||||
public int minutesToHours(int minutes)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
public int intToTime(int time, String option)
|
||||
{
|
||||
if(option == "hours")
|
||||
{
|
||||
time = time % 24;
|
||||
}
|
||||
else if(option == "minutes")
|
||||
{
|
||||
time = time % 60;
|
||||
}
|
||||
// System.out.println(time);
|
||||
return time;
|
||||
}
|
||||
|
||||
public int toHours(int minutesTot)
|
||||
{
|
||||
int hours = minutesTot / 60;
|
||||
int minutes = minutesTot % 60;
|
||||
int finaltime;
|
||||
|
||||
finaltime = hours * 100 + minutes;
|
||||
|
||||
return finaltime;
|
||||
}
|
||||
|
||||
public int findMinMax(int i)
|
||||
{
|
||||
// Event oldevent = new Event(0, 0, null, "Base", 0);
|
||||
// ArrayList<Event> oldevents = new ArrayList<Event>();
|
||||
// oldevents.add(oldevent);
|
||||
// Steage oldstage = new Stage(oldevents,0,null, 0, 0);
|
||||
ArrayList<Event> eventscopy = (ArrayList<Event>) events.clone();
|
||||
|
||||
Integer earliestStartTime = null;
|
||||
Integer lastEndTime = null;
|
||||
|
||||
for(Event event : eventscopy)
|
||||
{
|
||||
if(i == 1)
|
||||
{
|
||||
if(earliestStartTime == null)
|
||||
{
|
||||
|
||||
earliestStartTime = event.getStartTime();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(event.getStartTime() < earliestStartTime)
|
||||
{
|
||||
earliestStartTime = event.getStartTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( i == 2)
|
||||
{
|
||||
if(lastEndTime == null)
|
||||
{
|
||||
lastEndTime = event.getEndTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(event.getEndTime() > lastEndTime)
|
||||
{
|
||||
lastEndTime = event.getEndTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(i == 1)
|
||||
{
|
||||
return earliestStartTime;
|
||||
}
|
||||
else if(i == 2)
|
||||
{
|
||||
return lastEndTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Return -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private JPanel createTopPanel()
|
||||
{
|
||||
JPanel topPane = new JPanel();
|
||||
topPane.setLayout(new BoxLayout(topPane, BoxLayout.Y_AXIS));
|
||||
JPanel topPanel = new JPanel(new FlowLayout());
|
||||
for(int i = 0; i <= this.getWidth() / 10; i++)
|
||||
{
|
||||
ImageIcon topImageIcon = new ImageIcon("src/sprites/block.png");
|
||||
JLabel topImage = new JLabel(topImageIcon);
|
||||
topPanel.add(topImage);
|
||||
}
|
||||
topPane.add(Box.createRigidArea(new Dimension(0,20)));
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
|
||||
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
||||
panel.add(new JLabel(Integer.toString(toHours(findMinMax(1)))));
|
||||
panel.add(Box.createHorizontalGlue());
|
||||
panel.add(new JLabel(Integer.toString(toHours(findMinMax(2)))));
|
||||
panel.add(Box.createRigidArea(new Dimension(50, 10)));
|
||||
topPane.add(panel);
|
||||
topPane.add(topPanel);
|
||||
// this.add(topPane, BorderLayout.NORTH);
|
||||
return topPane;
|
||||
}
|
||||
|
||||
public JPanel createWestPanel()
|
||||
{
|
||||
this.setSize(frame.getWidth(), frame.getHeight());
|
||||
JPanel westPanel = new JPanel();
|
||||
westPanel.setLayout(new BoxLayout(westPanel, BoxLayout.Y_AXIS));
|
||||
westPanel.add(Box.createRigidArea(new Dimension(0, 100)));
|
||||
// for(int i = 0; i < events.size(); i++)
|
||||
// {
|
||||
// JLabel stageText = new JLabel("Stage: " + (i+1) + " ");
|
||||
// westPanel.add(stageText);
|
||||
// westPanel.add(Box.createRigidArea(new Dimension(0, 30 )));
|
||||
// }
|
||||
for(Event event : events)
|
||||
{
|
||||
JLabel stageText = new JLabel(event.getStage().getName() + ": " + " ");
|
||||
|
||||
westPanel.add(stageText);
|
||||
westPanel.add(Box.createRigidArea(new Dimension(0, 30 )));
|
||||
}
|
||||
// this.add(westPanel, BorderLayout.WEST);
|
||||
return westPanel;
|
||||
}
|
||||
|
||||
private void genStages()
|
||||
{
|
||||
// ImageIcon image = new ImageIcon();
|
||||
// Artist artist2 = new Artist("Henk", "paul2", "kaas", image, 2);
|
||||
// Artist artist1 = new Artist("Kaas", "Paul", "Lala", image, 1);
|
||||
// Event event2 = new Event(1900, 2000, artist2, "hi2", 2);
|
||||
// Event event1 = new Event(600, 1800, artist1, "hi", 1);
|
||||
// ArrayList<Event> performances = new ArrayList<Event>();
|
||||
// performances.add(event1);
|
||||
// performances.add(event2);
|
||||
// Stage stage1 = new Stage(performances, 100, null, 1800, 2100);
|
||||
// events.add(stage1);
|
||||
// Stage stage2 = new Stage(performances, 100, null, 1700, 1900);
|
||||
// Stage stage3 = new Stage(performances, 100, null, 1600, 1800);
|
||||
// Stage stage4 = new Stage(performances, 100, null, 1600, 2100);
|
||||
// events.add(stage3);
|
||||
// events.add(stage2);
|
||||
//// stages.add(stage4);
|
||||
|
||||
}
|
||||
|
||||
public void createNull()
|
||||
{
|
||||
this.removeAll();
|
||||
this.add(new JLabel("No events for this day"));
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
public JPanel getTimeline()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
public class TimelinePanel extends JPanel implements Panel {
|
||||
|
||||
private Timeline timeline;
|
||||
// private WestPanel westPanel;
|
||||
|
||||
public TimelinePanel()
|
||||
{
|
||||
super(new BorderLayout());
|
||||
|
||||
this.setSize(600, 600);
|
||||
this.setVisible(true);
|
||||
timeline = new Timeline(this);
|
||||
// westPanel = new WestPanel();
|
||||
// this.add(timeline.createMainPanel(),BorderLayout.CENTER);
|
||||
// this.add(new JButton());
|
||||
// this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||
}
|
||||
|
||||
public void refresh()
|
||||
{
|
||||
this.removeAll();
|
||||
timeline.refresh();
|
||||
// westPanel.refresh();
|
||||
this.add(timeline,BorderLayout.CENTER);
|
||||
this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||
this.revalidate();
|
||||
// timeline.refresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ArrayList<Event> events)
|
||||
{
|
||||
timeline.setEvents(events);
|
||||
// System.out.println(events.size());
|
||||
// westPanel.setEvents(events);
|
||||
// refresh();
|
||||
// this.add(timeline.createMainPanel(),BorderLayout.CENTER);
|
||||
// this.add(new JButton());
|
||||
// this.add(timeline.createWestPanel(), BorderLayout.WEST);
|
||||
|
||||
//dit fixt het half
|
||||
if(events.size() != 0)
|
||||
{
|
||||
this.removeAll();
|
||||
timeline.refresh();
|
||||
this.add(timeline.createWestPanel(),BorderLayout.WEST);
|
||||
this.add(timeline, BorderLayout.CENTER);
|
||||
this.revalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.removeAll();
|
||||
timeline.createNull();
|
||||
this.add(timeline);
|
||||
this.revalidate();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public TimelinePanel getTimelinePanel()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+236
@@ -0,0 +1,236 @@
|
||||
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
|
||||
public class Window extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 9023061329829975662L;
|
||||
private static HashMap<String, Panel> panels = new HashMap<String, Panel>();
|
||||
private static JPanel centerPanel;
|
||||
private static GregorianCalendar date;
|
||||
private static Agenda agenda;
|
||||
private static String currentPanel = "table";
|
||||
|
||||
public Window()
|
||||
{
|
||||
/*
|
||||
* Initialize window
|
||||
*/
|
||||
super("Agenda");
|
||||
agenda = new Agenda();
|
||||
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent evt) {
|
||||
onExit();
|
||||
}
|
||||
});
|
||||
setSize(1200, 800);
|
||||
|
||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
|
||||
} catch (ClassNotFoundException | InstantiationException
|
||||
| IllegalAccessException | UnsupportedLookAndFeelException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
setJMenuBar(new MenuBar(this));
|
||||
|
||||
|
||||
/*
|
||||
* Create Panels
|
||||
*/
|
||||
|
||||
//Agenda Panels
|
||||
Panel tablePanel = new PanelTable(agenda);
|
||||
panels.put("table", tablePanel);
|
||||
|
||||
Panel art_staPanel = new PanelArtSta(this);
|
||||
panels.put("art_sta", art_staPanel);
|
||||
|
||||
Panel timeline = new TimelinePanel();
|
||||
panels.put("timeline", timeline);
|
||||
|
||||
//Main Panels
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
centerPanel = new JPanel(new BorderLayout());
|
||||
centerPanel.setBackground(Color.WHITE);
|
||||
JPanel bottomPanel = new JPanel();
|
||||
bottomPanel.setBackground(Color.DARK_GRAY);
|
||||
|
||||
date = new GregorianCalendar();
|
||||
SimpleDateFormat formatter=new SimpleDateFormat("dd-MM-yyyy");
|
||||
JLabel dateLabel = new JLabel(formatter.format(date.getTime()));
|
||||
dateLabel.setForeground(Color.WHITE);
|
||||
bottomPanel.add(dateLabel);
|
||||
|
||||
JButton backWeekButton = new JButton("<<");
|
||||
backWeekButton.setToolTipText("Go one week back");
|
||||
backWeekButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) - 7);
|
||||
dateLabel.setText(formatter.format(date.getTime()));
|
||||
updatePanel();
|
||||
}
|
||||
});
|
||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
bottomPanel.add(backWeekButton);
|
||||
|
||||
JButton backDayButton = new JButton("<");
|
||||
backDayButton.setToolTipText("Go one day back");
|
||||
backDayButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) - 1);
|
||||
dateLabel.setText(formatter.format(date.getTime()));
|
||||
updatePanel();
|
||||
}
|
||||
});
|
||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
bottomPanel.add(backDayButton);
|
||||
|
||||
JButton todayButton = new JButton("||");
|
||||
todayButton.setToolTipText("Go to today");
|
||||
todayButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
date = new GregorianCalendar();
|
||||
dateLabel.setText(formatter.format(date.getTime()));
|
||||
updatePanel();
|
||||
}
|
||||
});
|
||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
bottomPanel.add(todayButton);
|
||||
|
||||
JButton forwardDayButton = new JButton(">");
|
||||
forwardDayButton.setToolTipText("Go one day forward");
|
||||
forwardDayButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) + 1);
|
||||
dateLabel.setText(formatter.format(date.getTime()));
|
||||
updatePanel();
|
||||
}
|
||||
});
|
||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
bottomPanel.add(forwardDayButton);
|
||||
|
||||
JButton forwardWeekButton = new JButton(">>");
|
||||
forwardWeekButton.setToolTipText("Go one week forward");
|
||||
forwardWeekButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
date.set(GregorianCalendar.DAY_OF_MONTH, date.get(GregorianCalendar.DAY_OF_MONTH) + 7);
|
||||
dateLabel.setText(formatter.format(date.getTime()));
|
||||
updatePanel();
|
||||
}
|
||||
});
|
||||
bottomPanel.add(new JSeparator(SwingConstants.VERTICAL));
|
||||
bottomPanel.add(forwardWeekButton);
|
||||
|
||||
//Add panels
|
||||
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
||||
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
|
||||
|
||||
setContentPane(mainPanel);
|
||||
|
||||
updatePanel();
|
||||
|
||||
//Show window
|
||||
setVisible(true);
|
||||
this.getRootPane().addComponentListener(new ComponentAdapter()
|
||||
{
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if(currentPanel == "timeline")
|
||||
{
|
||||
TimelinePanel tempTimeLine = (TimelinePanel) timeline;
|
||||
tempTimeLine.refresh();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void changePanel(String panel)
|
||||
{
|
||||
currentPanel = panel;
|
||||
updatePanel();
|
||||
}
|
||||
|
||||
public static void updatePanel()
|
||||
{
|
||||
centerPanel.removeAll();
|
||||
Panel p = panels.get(currentPanel);
|
||||
p.update(getEvents());
|
||||
JPanel p1 = (JPanel) p;
|
||||
p1.setPreferredSize(centerPanel.getSize());
|
||||
centerPanel.add(p1, BorderLayout.CENTER);
|
||||
centerPanel.revalidate();
|
||||
centerPanel.repaint();
|
||||
p1.repaint();
|
||||
}
|
||||
|
||||
public void onExit() {
|
||||
if(JOptionPane.showConfirmDialog(null, "Are you sure you want to close this program?", "Close Agenda", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION)
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Event> getEvents()
|
||||
{
|
||||
ArrayList<Event> events = new ArrayList<Event>();
|
||||
for(Event e : agenda.getEvents())
|
||||
{
|
||||
if(DateUtils.isSameDay(e.getStartDate(), date) || DateUtils.isSameDay(e.getEndDate(), date))
|
||||
{
|
||||
events.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
return events;
|
||||
}
|
||||
|
||||
public Agenda getAgenda()
|
||||
{
|
||||
return agenda;
|
||||
}
|
||||
|
||||
public void setAgenda(Agenda a)
|
||||
{
|
||||
agenda = a;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
-88
@@ -1,88 +0,0 @@
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
public class frame extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private ArrayList<Event> events;
|
||||
private TabelPanel paneel;
|
||||
|
||||
public static void main(String args[]) {
|
||||
frame frameee = new frame();
|
||||
|
||||
}
|
||||
|
||||
public frame() {
|
||||
fillArray();
|
||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||
paneel = new TabelPanel(events);
|
||||
getContentPane().add(paneel);
|
||||
JButton button;
|
||||
JPanel botPanel = new JPanel();
|
||||
button = new JButton("Filta");
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) { paneel.filter(); }
|
||||
});
|
||||
botPanel.add(button);
|
||||
button = new JButton("Reset filta");
|
||||
button.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) { paneel.refreshContent(events,true); }
|
||||
});
|
||||
botPanel.add(button);
|
||||
add(botPanel,BorderLayout.SOUTH);
|
||||
pack();
|
||||
setSize(800,600);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
private void fillArray() {
|
||||
Artist artist1 = new Artist("John","","","");
|
||||
Artist artist2 = new Artist("Jan","","","");
|
||||
Artist artist3 = new Artist("Jaap","","","");
|
||||
Artist artist4 = new Artist("Banaan","","","");
|
||||
Artist artist5 = new Artist("Josti","","","");
|
||||
Stage stage1 = new Stage("podia1",1,"");
|
||||
Stage stage2 = new Stage("podia2",1,"");
|
||||
Stage stage3 = new Stage("podia3",1,"");
|
||||
Stage stage4 = new Stage("podia4",1,"");
|
||||
Stage stage5 = new Stage("podia5",1,"");
|
||||
events = new ArrayList<>();
|
||||
events.add(new Event("event1",stage1,artist1,1605,1640,""));
|
||||
events.add(new Event("event2",stage1,artist2,1605,1640,""));
|
||||
events.add(new Event("event3",stage3,artist3,1605,1640,""));
|
||||
events.add(new Event("event4",stage1,artist4,1605,1640,""));
|
||||
events.add(new Event("event5",stage5,artist5,1605,1640,""));
|
||||
}
|
||||
|
||||
private void fillArray2() {
|
||||
Artist artist1 = new Artist("2","","","");
|
||||
Artist artist2 = new Artist("2","","","");
|
||||
Artist artist3 = new Artist("2","","","");
|
||||
Artist artist4 = new Artist("2","","","");
|
||||
Artist artist5 = new Artist("2","","","");
|
||||
Stage stage1 = new Stage("podia1",1,"");
|
||||
Stage stage2 = new Stage("podia2",1,"");
|
||||
Stage stage3 = new Stage("podia3",1,"");
|
||||
Stage stage4 = new Stage("podia4",1,"");
|
||||
Stage stage5 = new Stage("podia5",1,"");
|
||||
events = new ArrayList<>();
|
||||
events.add(new Event("event1",stage1,artist1,1605,1640,""));
|
||||
events.add(new Event("event2",stage1,artist2,1605,1640,""));
|
||||
events.add(new Event("event3",stage3,artist3,1605,1640,""));
|
||||
events.add(new Event("event4",stage4,artist4,1605,1640,""));
|
||||
events.add(new Event("event5",stage1,artist5,1605,1640,""));
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
fillArray2();
|
||||
paneel.refreshContent(events,true);
|
||||
}
|
||||
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 155 B |
Binary file not shown.
|
After Width: | Height: | Size: 197 B |
Reference in New Issue
Block a user