Task
parent
bcbaa03c9b
commit
81d4e75abd
|
@ -18,6 +18,12 @@ public class ProgrammSystem {
|
||||||
return tasks.printAllTask();
|
return tasks.printAllTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean removeTask(String title) {
|
||||||
|
return tasks.removeTask(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean markTaskAsDone(String title) {
|
||||||
|
return tasks.markTaskAsDone(title);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ public class Task {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "title=" + title + ", beschreibung=" + beschreibung + ((istGemacht == false) ? ", istGemacht = Nein" : ", istGemacht = Ja")
|
return "Title= " + title + ", Beschreibung= " + beschreibung + ((istGemacht == false) ? ", istGemacht = Nein" : ", istGemacht = Ja")
|
||||||
+ ", taskprioritaet=" + taskprioritaet;
|
+ ", Priorität= " + taskprioritaet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,56 +5,56 @@ import TodoListApp.Domain.*;
|
||||||
import TodoListApp.Domain.KlassenException.*;
|
import TodoListApp.Domain.KlassenException.*;
|
||||||
|
|
||||||
public class TaskList {
|
public class TaskList {
|
||||||
|
|
||||||
private ArrayList<Task> alleTasks;
|
private ArrayList<Task> alleTasks;
|
||||||
|
|
||||||
public TaskList() {
|
public TaskList() {
|
||||||
|
|
||||||
this.alleTasks = new ArrayList<>();
|
this.alleTasks = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addTaskZuList(String title, String beschreibung, String eingabeTaskprioritaet) {
|
public boolean addTaskZuList(String title, String beschreibung, String eingabeTaskprioritaet) {
|
||||||
Prioritaet taskPrioritaet = null;
|
Prioritaet taskPrioritaet = null;
|
||||||
switch (eingabeTaskprioritaet) {
|
switch (eingabeTaskprioritaet) {
|
||||||
case "niedrig":
|
case "niedrig":
|
||||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "mittel":
|
case "mittel":
|
||||||
taskPrioritaet = taskPrioritaet.Mittel;
|
taskPrioritaet = taskPrioritaet.Mittel;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "hoch":
|
case "hoch":
|
||||||
taskPrioritaet = taskPrioritaet.Hoch;
|
taskPrioritaet = taskPrioritaet.Hoch;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||||
}
|
|
||||||
|
|
||||||
alleTasks.add(new Task(title,beschreibung,taskPrioritaet));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
alleTasks.add(new Task(title, beschreibung, taskPrioritaet));
|
||||||
public boolean removeTask(Task task) {
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeTask(String title) {
|
||||||
|
|
||||||
for (Task t : alleTasks) {
|
for (Task t : alleTasks) {
|
||||||
if (t.getTitle().equalsIgnoreCase(task.getTitle())) {
|
if (t.getTitle().equalsIgnoreCase(title)) {
|
||||||
alleTasks.remove(task);
|
alleTasks.remove(t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String findeTaskByTitle(String title) throws TaskNichtGefundenException {
|
public String findeTaskByTitle(String title) throws TaskNichtGefundenException {
|
||||||
|
|
||||||
for (Task t : alleTasks) {
|
for (Task t : alleTasks) {
|
||||||
if (t.getTitle() == title)
|
if (t.getTitle() == title)
|
||||||
return t.toString();
|
return t.toString();
|
||||||
}
|
}
|
||||||
throw new TaskNichtGefundenException("Task wurde nicht gefunden" );
|
throw new TaskNichtGefundenException("Task wurde nicht gefunden");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> printAlleGemachteTasks() {
|
public ArrayList<String> printAlleGemachteTasks() {
|
||||||
ArrayList<String> alleGemachteTasks = new ArrayList<>();
|
ArrayList<String> alleGemachteTasks = new ArrayList<>();
|
||||||
for (Task t : alleTasks) {
|
for (Task t : alleTasks) {
|
||||||
|
@ -63,7 +63,7 @@ public class TaskList {
|
||||||
}
|
}
|
||||||
return alleGemachteTasks;
|
return alleGemachteTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> printAllTask() {
|
public ArrayList<String> printAllTask() {
|
||||||
ArrayList<String> printallTasks = new ArrayList<>();
|
ArrayList<String> printallTasks = new ArrayList<>();
|
||||||
int index = 1;
|
int index = 1;
|
||||||
|
@ -73,4 +73,13 @@ public class TaskList {
|
||||||
return printallTasks;
|
return printallTasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean markTaskAsDone(String title) {
|
||||||
|
for (Task t : alleTasks)
|
||||||
|
if (t.getTitle().equalsIgnoreCase(title)) {
|
||||||
|
t.setIstGemacht(true);
|
||||||
|
return t.isIstGemacht();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ public class GUI_UserInterface extends JFrame {
|
||||||
private JButton zeigeAlleTasks;
|
private JButton zeigeAlleTasks;
|
||||||
private JTextArea AllTasksArea;
|
private JTextArea AllTasksArea;
|
||||||
private JButton clear;
|
private JButton clear;
|
||||||
|
private JButton removeTask;
|
||||||
|
private JButton taskDone;
|
||||||
|
|
||||||
public GUI_UserInterface() {
|
public GUI_UserInterface() {
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
|
||||||
|
@ -43,7 +45,6 @@ public class GUI_UserInterface extends JFrame {
|
||||||
panel_1.setLayout(null);
|
panel_1.setLayout(null);
|
||||||
|
|
||||||
AllTasksArea = new JTextArea();
|
AllTasksArea = new JTextArea();
|
||||||
AllTasksArea.setEnabled(false);
|
|
||||||
AllTasksArea.setEditable(false);
|
AllTasksArea.setEditable(false);
|
||||||
AllTasksArea.setForeground(new Color(0, 0, 0));
|
AllTasksArea.setForeground(new Color(0, 0, 0));
|
||||||
AllTasksArea.setFont(new Font("Arial", Font.BOLD, 14));
|
AllTasksArea.setFont(new Font("Arial", Font.BOLD, 14));
|
||||||
|
@ -61,6 +62,14 @@ public class GUI_UserInterface extends JFrame {
|
||||||
clear = new JButton("Clear TextArea");
|
clear = new JButton("Clear TextArea");
|
||||||
clear.setBounds(384, 506, 159, 29);
|
clear.setBounds(384, 506, 159, 29);
|
||||||
panel.add(clear);
|
panel.add(clear);
|
||||||
|
|
||||||
|
removeTask = new JButton("Task Löschen");
|
||||||
|
removeTask.setBounds(10, 547, 159, 27);
|
||||||
|
panel.add(removeTask);
|
||||||
|
|
||||||
|
taskDone = new JButton("Gemacht!");
|
||||||
|
taskDone.setBounds(193, 549, 159, 25);
|
||||||
|
panel.add(taskDone);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
|
|
||||||
|
@ -88,7 +97,14 @@ public class GUI_UserInterface extends JFrame {
|
||||||
public JButton getClear() {
|
public JButton getClear() {
|
||||||
return clear;
|
return clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JButton getRemoveTask() {
|
||||||
|
return removeTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JButton getTaskDone() {
|
||||||
|
return taskDone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package TodoListApp.GUI_UserInterface;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
public class MarkTask extends JFrame {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JTextField markTaskEingabe;
|
||||||
|
private JButton markTaskButton;
|
||||||
|
|
||||||
|
public MarkTask() {
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 417, 424);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
|
setContentPane(contentPane);
|
||||||
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBackground(new Color(0, 128, 192));
|
||||||
|
panel.setBounds(40, 48, 333, 263);
|
||||||
|
contentPane.add(panel);
|
||||||
|
panel.setLayout(null);
|
||||||
|
|
||||||
|
JLabel lblNewLabel = new JLabel("Task markieren");
|
||||||
|
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||||
|
lblNewLabel.setForeground(new Color(255, 255, 255));
|
||||||
|
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
lblNewLabel.setBounds(28, 11, 256, 29);
|
||||||
|
panel.add(lblNewLabel);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_1 = new JLabel("Title: ");
|
||||||
|
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||||
|
lblNewLabel_1.setForeground(new Color(255, 255, 255));
|
||||||
|
lblNewLabel_1.setBounds(65, 69, 77, 17);
|
||||||
|
panel.add(lblNewLabel_1);
|
||||||
|
|
||||||
|
markTaskEingabe = new JTextField();
|
||||||
|
markTaskEingabe.setBounds(128, 67, 114, 21);
|
||||||
|
panel.add(markTaskEingabe);
|
||||||
|
markTaskEingabe.setColumns(10);
|
||||||
|
|
||||||
|
markTaskButton = new JButton("Submit");
|
||||||
|
markTaskButton.setBounds(65, 121, 105, 27);
|
||||||
|
panel.add(markTaskButton);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zeigeFenster() {
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public JTextField getMarkTaskEingabe() {
|
||||||
|
return markTaskEingabe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarkTaskEingabe(JTextField markTaskEingabe) {
|
||||||
|
this.markTaskEingabe = markTaskEingabe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JButton getMarkTaskButton() {
|
||||||
|
return markTaskButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showInfo(String message) {
|
||||||
|
JOptionPane.showMessageDialog(null, message, "Task gelöscht", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
public void showError(String message) {
|
||||||
|
JOptionPane.showMessageDialog(null, message, "Task gelöscht", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
package TodoListApp.GUI_UserInterface;
|
||||||
|
|
||||||
|
import java.awt.EventQueue;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import java.awt.Color;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import java.awt.Font;
|
||||||
|
|
||||||
|
public class RemoveTask extends JFrame {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private JPanel contentPane;
|
||||||
|
private JTextField removeTaskEingabe;
|
||||||
|
private JButton removeTaskButton;
|
||||||
|
|
||||||
|
public RemoveTask() {
|
||||||
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
setBounds(100, 100, 417, 424);
|
||||||
|
contentPane = new JPanel();
|
||||||
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
|
||||||
|
setContentPane(contentPane);
|
||||||
|
contentPane.setLayout(null);
|
||||||
|
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setBackground(new Color(0, 128, 192));
|
||||||
|
panel.setBounds(40, 48, 333, 263);
|
||||||
|
contentPane.add(panel);
|
||||||
|
panel.setLayout(null);
|
||||||
|
|
||||||
|
JLabel lblNewLabel = new JLabel("Task Löschen");
|
||||||
|
lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||||
|
lblNewLabel.setForeground(new Color(255, 255, 255));
|
||||||
|
lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
lblNewLabel.setBounds(28, 11, 256, 29);
|
||||||
|
panel.add(lblNewLabel);
|
||||||
|
|
||||||
|
JLabel lblNewLabel_1 = new JLabel("Title: ");
|
||||||
|
lblNewLabel_1.setFont(new Font("Tahoma", Font.BOLD, 12));
|
||||||
|
lblNewLabel_1.setForeground(new Color(255, 255, 255));
|
||||||
|
lblNewLabel_1.setBounds(65, 69, 77, 17);
|
||||||
|
panel.add(lblNewLabel_1);
|
||||||
|
|
||||||
|
removeTaskEingabe = new JTextField();
|
||||||
|
removeTaskEingabe.setBounds(128, 67, 114, 21);
|
||||||
|
panel.add(removeTaskEingabe);
|
||||||
|
removeTaskEingabe.setColumns(10);
|
||||||
|
|
||||||
|
removeTaskButton = new JButton("Submit");
|
||||||
|
removeTaskButton.setBounds(65, 121, 105, 27);
|
||||||
|
panel.add(removeTaskButton);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void zeigeFenster() {
|
||||||
|
this.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public JTextField getRemoveTaskEingabe() {
|
||||||
|
return removeTaskEingabe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoveTaskEingabe(JTextField removeTaskEingabe) {
|
||||||
|
this.removeTaskEingabe = removeTaskEingabe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JButton getRemoveTaskButton() {
|
||||||
|
return removeTaskButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showInfo(String message) {
|
||||||
|
JOptionPane.showMessageDialog(null, message, "Task gelöscht", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
public void showError(String message) {
|
||||||
|
JOptionPane.showMessageDialog(null, message, "Task gelöscht", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,17 +8,21 @@ public class Userverwalter {
|
||||||
private ProgrammSystem system;
|
private ProgrammSystem system;
|
||||||
private GUI_UserInterface user;
|
private GUI_UserInterface user;
|
||||||
private GUI_addTask taskHinziFuegenFenster;
|
private GUI_addTask taskHinziFuegenFenster;
|
||||||
|
private RemoveTask taskLöschenFenster;
|
||||||
|
private MarkTask markTaskFenster;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public Userverwalter() {
|
public Userverwalter() {
|
||||||
this.system = new ProgrammSystem();
|
this.system = new ProgrammSystem();
|
||||||
this.user = new GUI_UserInterface();
|
this.user = new GUI_UserInterface();
|
||||||
this.taskHinziFuegenFenster = new GUI_addTask();
|
this.taskHinziFuegenFenster = new GUI_addTask();
|
||||||
|
this.taskLöschenFenster = new RemoveTask();
|
||||||
|
this.markTaskFenster = new MarkTask();
|
||||||
|
|
||||||
// Buttons User:
|
// Buttons User:
|
||||||
user.getAddTask().addActionListener(e -> {
|
user.getAddTask().addActionListener(e -> {
|
||||||
try {
|
try {
|
||||||
zeigeFenster();
|
taskAddFenster();
|
||||||
} catch (FalscheEinagebException e1) {
|
} catch (FalscheEinagebException e1) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
|
@ -34,13 +38,18 @@ public class Userverwalter {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
markTaskFenster.getMarkTaskButton().addActionListener(e -> markTaskAsDone());
|
||||||
|
taskLöschenFenster.getRemoveTaskButton().addActionListener(e-> removeTask());
|
||||||
|
user.getTaskDone().addActionListener(e ->zeigeMarkTaskFenster());
|
||||||
|
|
||||||
user.getZeigeAlleTasks().addActionListener(e -> showAllTasks());
|
user.getZeigeAlleTasks().addActionListener(e -> showAllTasks());
|
||||||
user.getClear().addActionListener(e -> clearTextArea());
|
user.getClear().addActionListener(e -> clearTextArea());
|
||||||
|
user.getRemoveTask().addActionListener(e -> removeTaskFenster());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void zeigeFenster() throws FalscheEinagebException {
|
public void taskAddFenster() throws FalscheEinagebException {
|
||||||
taskHinziFuegenFenster.zeigeFensterAddTask();
|
taskHinziFuegenFenster.zeigeFensterAddTask();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,8 +89,43 @@ public class Userverwalter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeTaskFenster() {
|
||||||
|
taskLöschenFenster.zeigeFenster();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTask() {
|
||||||
|
String title = taskLöschenFenster.getRemoveTaskEingabe().getText();
|
||||||
|
if (system.removeTask(title)) {
|
||||||
|
taskLöschenFenster.showInfo("Task erfolgreich gelöscht");
|
||||||
|
clearTextArea();
|
||||||
|
showAllTasks();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
taskLöschenFenster.showError("Task ist nicht auf der Liste");
|
||||||
|
}
|
||||||
|
|
||||||
public void clearTextArea() {
|
public void clearTextArea() {
|
||||||
|
if (user.getAllTasksArea().getText().isEmpty())
|
||||||
|
user.showInfo("Ist bereits leer!");
|
||||||
|
|
||||||
user.getAllTasksArea().setText("");
|
user.getAllTasksArea().setText("");
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void zeigeMarkTaskFenster() {
|
||||||
|
markTaskFenster.zeigeFenster();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void markTaskAsDone() {
|
||||||
|
String title = markTaskFenster.getMarkTaskEingabe().getText();
|
||||||
|
|
||||||
|
if (title.isEmpty())
|
||||||
|
markTaskFenster.showError("Sie müssen Title eingeben");
|
||||||
|
else if (system.markTaskAsDone(title)) {
|
||||||
|
markTaskFenster.showInfo("Task ist als Gemacht makiert");
|
||||||
|
clearTextArea();
|
||||||
|
showAllTasks();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue