Task
parent
bcbaa03c9b
commit
81d4e75abd
|
@ -18,6 +18,12 @@ public class ProgrammSystem {
|
|||
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
|
||||
public String toString() {
|
||||
return "title=" + title + ", beschreibung=" + beschreibung + ((istGemacht == false) ? ", istGemacht = Nein" : ", istGemacht = Ja")
|
||||
+ ", taskprioritaet=" + taskprioritaet;
|
||||
return "Title= " + title + ", Beschreibung= " + beschreibung + ((istGemacht == false) ? ", istGemacht = Nein" : ", istGemacht = Ja")
|
||||
+ ", Priorität= " + taskprioritaet;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,39 +7,39 @@ import TodoListApp.Domain.KlassenException.*;
|
|||
public class TaskList {
|
||||
|
||||
private ArrayList<Task> alleTasks;
|
||||
|
||||
public TaskList() {
|
||||
|
||||
this.alleTasks = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean addTaskZuList(String title, String beschreibung, String eingabeTaskprioritaet) {
|
||||
Prioritaet taskPrioritaet = null;
|
||||
switch (eingabeTaskprioritaet) {
|
||||
case "niedrig":
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
break;
|
||||
Prioritaet taskPrioritaet = null;
|
||||
switch (eingabeTaskprioritaet) {
|
||||
case "niedrig":
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
break;
|
||||
|
||||
case "mittel":
|
||||
taskPrioritaet = taskPrioritaet.Mittel;
|
||||
break;
|
||||
case "mittel":
|
||||
taskPrioritaet = taskPrioritaet.Mittel;
|
||||
break;
|
||||
|
||||
case "hoch":
|
||||
taskPrioritaet = taskPrioritaet.Hoch;
|
||||
break;
|
||||
default:
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
}
|
||||
|
||||
alleTasks.add(new Task(title,beschreibung,taskPrioritaet));
|
||||
return true;
|
||||
case "hoch":
|
||||
taskPrioritaet = taskPrioritaet.Hoch;
|
||||
break;
|
||||
default:
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
}
|
||||
|
||||
alleTasks.add(new Task(title, beschreibung, taskPrioritaet));
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeTask(Task task) {
|
||||
public boolean removeTask(String title) {
|
||||
|
||||
for (Task t : alleTasks) {
|
||||
if (t.getTitle().equalsIgnoreCase(task.getTitle())) {
|
||||
alleTasks.remove(task);
|
||||
if (t.getTitle().equalsIgnoreCase(title)) {
|
||||
alleTasks.remove(t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class TaskList {
|
|||
if (t.getTitle() == title)
|
||||
return t.toString();
|
||||
}
|
||||
throw new TaskNichtGefundenException("Task wurde nicht gefunden" );
|
||||
throw new TaskNichtGefundenException("Task wurde nicht gefunden");
|
||||
}
|
||||
|
||||
public ArrayList<String> printAlleGemachteTasks() {
|
||||
|
@ -73,4 +73,13 @@ public class TaskList {
|
|||
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 JTextArea AllTasksArea;
|
||||
private JButton clear;
|
||||
private JButton removeTask;
|
||||
private JButton taskDone;
|
||||
|
||||
public GUI_UserInterface() {
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
|
||||
|
@ -43,7 +45,6 @@ public class GUI_UserInterface extends JFrame {
|
|||
panel_1.setLayout(null);
|
||||
|
||||
AllTasksArea = new JTextArea();
|
||||
AllTasksArea.setEnabled(false);
|
||||
AllTasksArea.setEditable(false);
|
||||
AllTasksArea.setForeground(new Color(0, 0, 0));
|
||||
AllTasksArea.setFont(new Font("Arial", Font.BOLD, 14));
|
||||
|
@ -61,6 +62,14 @@ public class GUI_UserInterface extends JFrame {
|
|||
clear = new JButton("Clear TextArea");
|
||||
clear.setBounds(384, 506, 159, 29);
|
||||
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);
|
||||
this.setVisible(true);
|
||||
|
||||
|
@ -89,6 +98,13 @@ public class GUI_UserInterface extends JFrame {
|
|||
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 GUI_UserInterface user;
|
||||
private GUI_addTask taskHinziFuegenFenster;
|
||||
private RemoveTask taskLöschenFenster;
|
||||
private MarkTask markTaskFenster;
|
||||
private int index = 0;
|
||||
|
||||
public Userverwalter() {
|
||||
this.system = new ProgrammSystem();
|
||||
this.user = new GUI_UserInterface();
|
||||
this.taskHinziFuegenFenster = new GUI_addTask();
|
||||
this.taskLöschenFenster = new RemoveTask();
|
||||
this.markTaskFenster = new MarkTask();
|
||||
|
||||
// Buttons User:
|
||||
user.getAddTask().addActionListener(e -> {
|
||||
try {
|
||||
zeigeFenster();
|
||||
taskAddFenster();
|
||||
} catch (FalscheEinagebException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
|
@ -35,12 +39,17 @@ public class Userverwalter {
|
|||
}
|
||||
});
|
||||
|
||||
markTaskFenster.getMarkTaskButton().addActionListener(e -> markTaskAsDone());
|
||||
taskLöschenFenster.getRemoveTaskButton().addActionListener(e-> removeTask());
|
||||
user.getTaskDone().addActionListener(e ->zeigeMarkTaskFenster());
|
||||
|
||||
user.getZeigeAlleTasks().addActionListener(e -> showAllTasks());
|
||||
user.getClear().addActionListener(e -> clearTextArea());
|
||||
user.getRemoveTask().addActionListener(e -> removeTaskFenster());
|
||||
|
||||
}
|
||||
|
||||
public void zeigeFenster() throws FalscheEinagebException {
|
||||
public void taskAddFenster() throws FalscheEinagebException {
|
||||
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() {
|
||||
if (user.getAllTasksArea().getText().isEmpty())
|
||||
user.showInfo("Ist bereits leer!");
|
||||
|
||||
user.getAllTasksArea().setText("");
|
||||
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