Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e342d95bfe | ||
|
|
5b803a2cc4 | ||
|
|
9d3d3fa3d5 |
-55
@@ -1,55 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
|
|
||||||
import nl.kennyboy.EventSorter.Mode;
|
|
||||||
|
|
||||||
public class Agenda implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -383023632433640516L;
|
|
||||||
|
|
||||||
ArrayList<Event> afspraken;
|
|
||||||
EventSorter sort;
|
|
||||||
|
|
||||||
public Agenda()
|
|
||||||
{
|
|
||||||
afspraken = new ArrayList<Event>();
|
|
||||||
sort = new EventSorter(Mode.SORT_ASC);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Event afspraak)
|
|
||||||
{
|
|
||||||
afspraken.add(afspraak);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(GregorianCalendar startDate, GregorianCalendar endDate, String name, String desc)
|
|
||||||
{
|
|
||||||
new Event(startDate, endDate, name, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, String name, String desc)
|
|
||||||
{
|
|
||||||
new Event(startYear, startMonth,startDay, endYear, endMonth, endDay, name, desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sort(EventSorter.Mode mode)
|
|
||||||
{
|
|
||||||
sort.changeMode(mode);
|
|
||||||
Collections.sort(afspraken, sort);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
String str = "";
|
|
||||||
str += "All event sorted " + sort.getModeDesc() + ":\n";
|
|
||||||
for(Event asp : afspraken)
|
|
||||||
{
|
|
||||||
str += "\t" + asp + "\n";
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
public class Artist {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String genre;
|
||||||
|
private String image;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
|
||||||
|
public Artist(String name, String genre, String image, String description) {
|
||||||
|
this.setName(name);
|
||||||
|
this.genre = genre;
|
||||||
|
this.image = image;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is used to make a temporary abstracttableModel with selected data so later it can be passed to the JTable so it refreshes.
|
||||||
|
* @author Wesley
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class ContentTable extends AbstractTableModel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Object[][] data;
|
||||||
|
private String[] columnNames;
|
||||||
|
|
||||||
|
|
||||||
|
public ContentTable(Object[][] data,String[] columnNames) {
|
||||||
|
this.data = data;
|
||||||
|
this.columnNames = columnNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getColumnCount() {
|
||||||
|
return columnNames.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getRowCount() {
|
||||||
|
return data.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getValueAt(int rowIndex, int columnIndex) {
|
||||||
|
return data[rowIndex][columnIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getColumnName(int col) {
|
||||||
|
return columnNames[col];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
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);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
+39
-59
@@ -1,81 +1,61 @@
|
|||||||
package nl.kennyboy;
|
public class Event {
|
||||||
|
|
||||||
import java.io.Serializable;
|
private Artist artist;
|
||||||
import java.text.DateFormat;
|
private int startTime;
|
||||||
import java.text.SimpleDateFormat;
|
private int endTime;
|
||||||
import java.util.GregorianCalendar;
|
private String description;
|
||||||
|
private Stage stage;
|
||||||
|
private String name;
|
||||||
|
|
||||||
public class Event implements Serializable, Comparable<Event>
|
public Event(String name, Stage stage, Artist artist, int startTime, int endTime, String description) {
|
||||||
{
|
if(artist != null)
|
||||||
private static final long serialVersionUID = -8412700922907201793L;
|
this.setArtist(artist);
|
||||||
|
else
|
||||||
GregorianCalendar startDate;
|
this.setArtist(null);
|
||||||
GregorianCalendar endDate;
|
this.startTime = startTime;
|
||||||
String name;
|
this.setEndTime(endTime);
|
||||||
String desc;
|
this.description = description;
|
||||||
|
this.setName(name);
|
||||||
public Event(GregorianCalendar startDate, GregorianCalendar endDate, String name, String desc)
|
this.stage = stage;
|
||||||
{
|
|
||||||
this.startDate = startDate;
|
|
||||||
this.endDate = endDate;
|
|
||||||
this.name = name;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
public Event(int startYear, int startMonth, int startDay, int endYear, int endMonth, int endDay, String name, String desc)
|
|
||||||
{
|
|
||||||
this(new GregorianCalendar(startYear, startMonth-1, startDay), new GregorianCalendar(endYear, endMonth-1, endDay),name, desc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Getters and Setters
|
public int getStartTime() {
|
||||||
public GregorianCalendar getStartDate() {
|
return startTime;
|
||||||
return startDate;
|
|
||||||
}
|
}
|
||||||
public void setStartDate(GregorianCalendar startDate) {
|
|
||||||
this.startDate = startDate;
|
public int getEndTime() {
|
||||||
|
return endTime;
|
||||||
}
|
}
|
||||||
public GregorianCalendar getEndDate() {
|
|
||||||
return endDate;
|
public void setEndTime(int endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
public void setEndDate(GregorianCalendar endDate) {
|
|
||||||
this.endDate = endDate;
|
public Stage getStage() {
|
||||||
|
return stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStage(Stage stage) {
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
public String getDesc() {
|
|
||||||
return desc;
|
public Artist getArtist() {
|
||||||
}
|
return artist;
|
||||||
public void setDesc(String desc) {
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(Event o) {
|
public void setArtist(Artist artist) {
|
||||||
if(startDate.before(o.getStartDate()))
|
this.artist = artist;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(startDate.after(o.getStartDate()))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(startDate.equals(o.getStartDate()))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
||||||
formatter.setLenient(false);
|
|
||||||
|
|
||||||
return name + " from " + formatter.format(startDate.getTime()) + " to " + formatter.format(endDate.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
|
|
||||||
public class EventSorter implements Serializable, Comparator<Event> {
|
|
||||||
|
|
||||||
public enum Mode {
|
|
||||||
SORT_ASC,
|
|
||||||
SORT_DESC,
|
|
||||||
SORT_LENGTH_ASC,
|
|
||||||
SORT_LENGTH_DESC
|
|
||||||
}
|
|
||||||
|
|
||||||
Mode mode;
|
|
||||||
|
|
||||||
public EventSorter(Mode mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changeMode(Mode mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getModeDesc()
|
|
||||||
{
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case SORT_ASC:
|
|
||||||
return "alphabetically";
|
|
||||||
case SORT_DESC:
|
|
||||||
return "reverse alphabetically";
|
|
||||||
case SORT_LENGTH_ASC:
|
|
||||||
return "shortest first";
|
|
||||||
case SORT_LENGTH_DESC:
|
|
||||||
return "longstest first";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(Event asp1, Event asp2) {
|
|
||||||
|
|
||||||
switch(mode)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
case SORT_ASC:
|
|
||||||
return sortAsc(asp1, asp2);
|
|
||||||
case SORT_DESC:
|
|
||||||
return sortDesc(asp1, asp2);
|
|
||||||
case SORT_LENGTH_ASC:
|
|
||||||
return sortLenAsc(asp1, asp2);
|
|
||||||
case SORT_LENGTH_DESC:
|
|
||||||
return sortLenDesc(asp1, asp2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortAsc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
if(asp1.getStartDate().before(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().after(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().equals(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortDesc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
if(asp1.getStartDate().after(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().before(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(asp1.getStartDate().equals(asp2.getStartDate()))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortLenAsc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
long len1 = asp1.getEndDate().getTimeInMillis() - asp1.getStartDate().getTimeInMillis();
|
|
||||||
long len2 = asp2.getEndDate().getTimeInMillis() - asp2.getStartDate().getTimeInMillis();
|
|
||||||
|
|
||||||
if(len1 < len2)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(len2 < len1)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(len1 == len2)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int sortLenDesc(Event asp1, Event asp2)
|
|
||||||
{
|
|
||||||
long len1 = asp1.getEndDate().getTimeInMillis() - asp1.getStartDate().getTimeInMillis();
|
|
||||||
long len2 = asp2.getEndDate().getTimeInMillis() - asp2.getStartDate().getTimeInMillis();
|
|
||||||
|
|
||||||
if(len1 > len2)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if(len2 > len1)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(len1 == len2)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import nl.kennyboy.EventSorter.Mode;
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
new Main();
|
|
||||||
}
|
|
||||||
|
|
||||||
Agenda agenda;
|
|
||||||
Window window;
|
|
||||||
|
|
||||||
public Main()
|
|
||||||
{
|
|
||||||
agenda = new Agenda();
|
|
||||||
window = new Window();
|
|
||||||
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void test()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
agenda.add(new Event(2014, 12, 1, 2014, 12, 2, "School", "Doe iets op school"));
|
|
||||||
agenda.add(new Event(2014, 11, 2, 2014, 11, 4, "School2", "Doe nog iets op school"));
|
|
||||||
agenda.sort(Mode.SORT_LENGTH_DESC);
|
|
||||||
window.setText(agenda + "");
|
|
||||||
SaveLoad.saveFile(agenda);
|
|
||||||
*/
|
|
||||||
|
|
||||||
agenda = (Agenda) SaveLoad.loadFile();
|
|
||||||
window.setText(agenda + "");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
public class Preformance {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# FestivalPlanner
|
|
||||||
Avans - Technische Informatica - Periode 3 - Project Festival Planner
|
|
||||||
|
|
||||||
##Project Leden
|
|
||||||
* Kenneth van Ewijk
|
|
||||||
|
|
||||||
##Branch
|
|
||||||
Deze branch is van Kenneth van Ewijk
|
|
||||||
-127
@@ -1,127 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
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 SaveLoad() {
|
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Stage {
|
||||||
|
|
||||||
|
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;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEvent(Event event) {
|
||||||
|
events.add(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
+185
@@ -0,0 +1,185 @@
|
|||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a JTable in a ScrolPane.
|
||||||
|
* @author Wesley
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class TabelPanel extends JPanel {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JScrollPane scrollPane;
|
||||||
|
private Object[][] data;
|
||||||
|
private String[] columnNames = {"Stage",
|
||||||
|
"Event",
|
||||||
|
"Artist",
|
||||||
|
"Begin Time",
|
||||||
|
"End Time"};
|
||||||
|
private ArrayList<Event> events;
|
||||||
|
private ArrayList<Event> fullEvents;
|
||||||
|
private JTable table;
|
||||||
|
private JTable selectedCell;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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());
|
||||||
|
table= new JTable();
|
||||||
|
AbstractTableModel tableModel = new ContentTable(data,columnNames);
|
||||||
|
table.setModel(tableModel);
|
||||||
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
||||||
|
table.setAutoCreateRowSorter(true);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data from the events arrayList and makes a 2D-array of it.
|
||||||
|
* @param columnes
|
||||||
|
* @param rows
|
||||||
|
*/
|
||||||
|
public void compileData(int columnes, int rows) {
|
||||||
|
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[2] = events.get(x).getArtist().getName();
|
||||||
|
tempData[3] = new Integer(events.get(x).getStartTime());
|
||||||
|
tempData[4] = new Integer(events.get(x).getEndTime());
|
||||||
|
data[x] = tempData;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
this.events = events;
|
||||||
|
if(newList)
|
||||||
|
this.fullEvents = events;
|
||||||
|
compileData(columnNames.length,events.size());
|
||||||
|
AbstractTableModel tableModel = new ContentTable(data,columnNames);
|
||||||
|
table.setModel(tableModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for the action listener when a cell is clicked, opens dialog of the clicked cell.
|
||||||
|
* @param e
|
||||||
|
*/
|
||||||
|
private void cellClicked(MouseEvent e) {
|
||||||
|
JTable target = (JTable) e.getSource();
|
||||||
|
switch(target.getSelectedColumn()) {
|
||||||
|
case 0:
|
||||||
|
//A dialog for podia?
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
openEventDialog(target.getSelectedRow());
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
openArtistDialog(target.getSelectedRow());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a dialog with information of the selected event.
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a dialog with information of the selected artist
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter method which filters on the currently selected cell.
|
||||||
|
* Needs to be under a button action, also a reset button is needed so list can be restored.
|
||||||
|
*/
|
||||||
|
public void filter() {
|
||||||
|
if(selectedCell != null) {
|
||||||
|
if(fullEvents.isEmpty()) {
|
||||||
|
fullEvents = events;
|
||||||
|
}
|
||||||
|
ArrayList<Event> filteredList = new ArrayList<>();
|
||||||
|
switch(selectedCell.getSelectedColumn()) {
|
||||||
|
case 0:
|
||||||
|
for(Event event : fullEvents) {
|
||||||
|
if(event.getStage().equals(events.get(selectedCell.getSelectedRow()).getStage())) {
|
||||||
|
filteredList.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
for(Event event : fullEvents) {
|
||||||
|
if(event.equals(events.get(selectedCell.getSelectedRow()))) {
|
||||||
|
filteredList.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
for(Event event : fullEvents) {
|
||||||
|
if(event.getArtist().equals(events.get(selectedCell.getSelectedRow()).getArtist())) {
|
||||||
|
filteredList.add(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
refreshContent(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-33
@@ -1,33 +0,0 @@
|
|||||||
package nl.kennyboy;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
|
|
||||||
public class Window extends JFrame {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4468821981332661759L;
|
|
||||||
|
|
||||||
JTextArea tarea;
|
|
||||||
|
|
||||||
public Window()
|
|
||||||
{
|
|
||||||
super("Agenda");
|
|
||||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
|
||||||
setSize(500,600);
|
|
||||||
JPanel contentPanel = new JPanel();
|
|
||||||
|
|
||||||
tarea = new JTextArea(10,20);
|
|
||||||
tarea.setEditable(false);
|
|
||||||
|
|
||||||
contentPanel.add(tarea);
|
|
||||||
setContentPane(contentPanel);
|
|
||||||
setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setText(String str)
|
|
||||||
{
|
|
||||||
tarea.setText(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+88
@@ -0,0 +1,88 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user