unified styling
This commit is contained in:
parent
851e1a4b41
commit
f9325824cb
@ -1,14 +1,14 @@
|
|||||||
package de.dhsn.oop.data;
|
package de.dhsn.oop.data;
|
||||||
|
|
||||||
public abstract class TodoItem{
|
public abstract class TodoItem{
|
||||||
public boolean done = false;
|
private boolean done = false;
|
||||||
public String title;
|
public String title;
|
||||||
public TodoItem(String t){
|
public TodoItem(String t){
|
||||||
title = t;
|
title = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TodoItem(boolean done, String title) {
|
public TodoItem(boolean done, String title) {
|
||||||
this.done = done;
|
this.setDone(done);
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ package de.dhsn.oop.data;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TodoList {
|
public class TodoList {
|
||||||
@ -27,11 +29,17 @@ public class TodoList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<TextTodoItem> getList(){
|
public List<TextTodoItem> getList(){
|
||||||
|
Collections.sort(list, new Comparator<TextTodoItem>() {
|
||||||
|
@Override
|
||||||
|
public int compare(TextTodoItem o1, TextTodoItem o2) {
|
||||||
|
return Boolean.compare(o1.isDone(), o2.isDone());
|
||||||
|
}
|
||||||
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int length(){
|
public int length(){
|
||||||
return list.toArray().length;
|
return list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package de.dhsn.oop.ui;
|
package de.dhsn.oop.ui;
|
||||||
|
|
||||||
import de.dhsn.oop.data.TodoList;
|
import de.dhsn.oop.data.TodoList;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatLabel;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatPanel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -8,11 +10,11 @@ import java.awt.*;
|
|||||||
/**
|
/**
|
||||||
* Overview List Item to show Todo Lists on the home screen
|
* Overview List Item to show Todo Lists on the home screen
|
||||||
*/
|
*/
|
||||||
public class ListOverviewItem extends JPanel {
|
public class ListOverviewItem extends FlatPanel {
|
||||||
private JLabel titleText = new JLabel();
|
private FlatLabel titleText = new FlatLabel();
|
||||||
private JLabel title = new JLabel();
|
private FlatLabel title = new FlatLabel();
|
||||||
private JLabel length = new JLabel();
|
private FlatLabel length = new FlatLabel();
|
||||||
private JLabel lenghtText = new JLabel();
|
private FlatLabel lenghtText = new FlatLabel();
|
||||||
|
|
||||||
public ListOverviewItem(TodoList list) {
|
public ListOverviewItem(TodoList list) {
|
||||||
this.setLayout(new GridBagLayout());
|
this.setLayout(new GridBagLayout());
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package de.dhsn.oop.ui;
|
package de.dhsn.oop.ui;
|
||||||
|
|
||||||
import de.dhsn.oop.data.TodoList;
|
import de.dhsn.oop.data.TodoList;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatButton;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatPanel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ListsOverview extends JPanel {
|
public class ListsOverview extends FlatPanel {
|
||||||
|
|
||||||
public ListsOverview(List<TodoList> lists){
|
public ListsOverview(List<TodoList> lists){
|
||||||
super();
|
super();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.dhsn.oop.ui;
|
package de.dhsn.oop.ui;
|
||||||
|
|
||||||
import de.dhsn.oop.data.TodoList;
|
import de.dhsn.oop.data.TodoList;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatButton;
|
||||||
import de.dhsn.oop.ui.helpers.TodoListListModel;
|
import de.dhsn.oop.ui.helpers.TodoListListModel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@ -18,7 +19,7 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MainWindow extends JFrame implements ActionListener, ListSelectionListener {
|
public class MainWindow extends JFrame implements ActionListener, ListSelectionListener {
|
||||||
private JButton addNewList;
|
private FlatButton addNewList;
|
||||||
private List<TodoList> lists;
|
private List<TodoList> lists;
|
||||||
private JList<String> list;
|
private JList<String> list;
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ public class MainWindow extends JFrame implements ActionListener, ListSelectionL
|
|||||||
public MainWindow(List<TodoList> lists) throws HeadlessException {
|
public MainWindow(List<TodoList> lists) throws HeadlessException {
|
||||||
super();
|
super();
|
||||||
this.lists = lists;
|
this.lists = lists;
|
||||||
|
setBackground(Color.WHITE);
|
||||||
Container cp = getContentPane();
|
Container cp = getContentPane();
|
||||||
cp.removeAll();
|
cp.removeAll();
|
||||||
setTitle("Todo List");
|
setTitle("Todo List");
|
||||||
@ -44,9 +46,10 @@ public class MainWindow extends JFrame implements ActionListener, ListSelectionL
|
|||||||
list.addListSelectionListener(this);
|
list.addListSelectionListener(this);
|
||||||
cp.add(list, BorderLayout.NORTH);
|
cp.add(list, BorderLayout.NORTH);
|
||||||
|
|
||||||
addNewList = new JButton("Neue Liste Anlegen");
|
addNewList = new FlatButton("Neue Liste Anlegen");
|
||||||
addNewList.addActionListener(this);
|
addNewList.addActionListener(this);
|
||||||
cp.add(addNewList, BorderLayout.SOUTH);
|
cp.add(addNewList, BorderLayout.SOUTH);
|
||||||
|
cp.setBackground(Color.WHITE);
|
||||||
|
|
||||||
pack();
|
pack();
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package de.dhsn.oop.ui;
|
package de.dhsn.oop.ui;
|
||||||
|
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatButton;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatLabel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -7,14 +10,14 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
public class NewListDialog extends JFrame implements ActionListener {
|
public class NewListDialog extends JFrame implements ActionListener {
|
||||||
private JTextField input = new JTextField("TODO");
|
private JTextField input = new JTextField("TODO");
|
||||||
private JButton confirm = new JButton("Anlegen");
|
private FlatButton confirm = new FlatButton("Anlegen");
|
||||||
private MainWindow mw;
|
private MainWindow mw;
|
||||||
|
|
||||||
public NewListDialog(MainWindow mw){
|
public NewListDialog(MainWindow mw){
|
||||||
this.mw = mw;
|
this.mw = mw;
|
||||||
Container cp = getContentPane();
|
Container cp = getContentPane();
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
JLabel l = new JLabel("Name der Liste: ");
|
FlatLabel l = new FlatLabel("Name der Liste: ");
|
||||||
cp.add(l, BorderLayout.LINE_START);
|
cp.add(l, BorderLayout.LINE_START);
|
||||||
|
|
||||||
input.setColumns(15);
|
input.setColumns(15);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.dhsn.oop.ui;
|
package de.dhsn.oop.ui;
|
||||||
|
|
||||||
import de.dhsn.oop.data.TextTodoItem;
|
import de.dhsn.oop.data.TextTodoItem;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatButton;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -9,7 +10,7 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
public class NewTodoItemView extends JFrame implements ActionListener {
|
public class NewTodoItemView extends JFrame implements ActionListener {
|
||||||
JTextField input = new JTextField();
|
JTextField input = new JTextField();
|
||||||
JButton submit = new JButton("OK");
|
FlatButton submit = new FlatButton("OK");
|
||||||
TodoListView view;
|
TodoListView view;
|
||||||
|
|
||||||
public NewTodoItemView(TodoListView view){
|
public NewTodoItemView(TodoListView view){
|
||||||
|
@ -2,13 +2,17 @@ package de.dhsn.oop.ui;
|
|||||||
|
|
||||||
import de.dhsn.oop.data.TodoItem;
|
import de.dhsn.oop.data.TodoItem;
|
||||||
import de.dhsn.oop.data.TodoList;
|
import de.dhsn.oop.data.TodoList;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatButton;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatCheckBox;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatLabel;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatPanel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
public class TodoItemPanel extends JPanel implements ActionListener {
|
public class TodoItemPanel extends FlatPanel implements ActionListener {
|
||||||
private TodoItem item;
|
private TodoItem item;
|
||||||
private TodoList list;
|
private TodoList list;
|
||||||
private TodoListView view;
|
private TodoListView view;
|
||||||
@ -19,15 +23,15 @@ public class TodoItemPanel extends JPanel implements ActionListener {
|
|||||||
view = v;
|
view = v;
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
JCheckBox cb = new JCheckBox();
|
FlatCheckBox cb = new FlatCheckBox();
|
||||||
cb.setSelected(item.isDone());
|
cb.setSelected(item.isDone());
|
||||||
cb.addActionListener(this);
|
cb.addActionListener(this);
|
||||||
add(cb, BorderLayout.LINE_START);
|
add(cb, BorderLayout.LINE_START);
|
||||||
|
|
||||||
JLabel title = new JLabel(item.title);
|
FlatLabel title = new FlatLabel(item.title);
|
||||||
add(title, BorderLayout.CENTER);
|
add(title, BorderLayout.CENTER);
|
||||||
|
|
||||||
JButton delete = new JButton("X");
|
FlatButton delete = new FlatButton("X");
|
||||||
delete.addActionListener(this::deletePressed);
|
delete.addActionListener(this::deletePressed);
|
||||||
add(delete, BorderLayout.LINE_END);
|
add(delete, BorderLayout.LINE_END);
|
||||||
|
|
||||||
@ -40,7 +44,7 @@ public class TodoItemPanel extends JPanel implements ActionListener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
item.setDone(((JCheckBox)(e.getSource())).isSelected());
|
item.setDone(((FlatCheckBox)(e.getSource())).isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,17 +3,20 @@ package de.dhsn.oop.ui;
|
|||||||
import de.dhsn.oop.data.TextTodoItem;
|
import de.dhsn.oop.data.TextTodoItem;
|
||||||
import de.dhsn.oop.data.TodoItem;
|
import de.dhsn.oop.data.TodoItem;
|
||||||
import de.dhsn.oop.data.TodoList;
|
import de.dhsn.oop.data.TodoList;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatButton;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatLabel;
|
||||||
|
import de.dhsn.oop.ui.UIOverrides.FlatPanel;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
||||||
public class TodoListView extends JFrame {
|
public class TodoListView extends JFrame {
|
||||||
private JLabel title;
|
private FlatLabel title;
|
||||||
private JButton addButton;
|
private FlatButton addButton;
|
||||||
private JButton deleteButton;
|
private FlatButton deleteButton;
|
||||||
private TodoList list;
|
private TodoList list;
|
||||||
private JPanel scrollContent;
|
private FlatPanel scrollContent;
|
||||||
private JScrollPane scrolPane;
|
private JScrollPane scrolPane;
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
|
|
||||||
@ -29,16 +32,16 @@ public class TodoListView extends JFrame {
|
|||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
c.gridy = 0;
|
c.gridy = 0;
|
||||||
title = new JLabel(list.getListTitle());
|
title = new FlatLabel(list.getListTitle());
|
||||||
cp.add(title, c);
|
cp.add(title, c);
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
|
|
||||||
addButton = new JButton("+");
|
addButton = new FlatButton("+");
|
||||||
addButton.addActionListener(this::addTodoClicked);
|
addButton.addActionListener(this::addTodoClicked);
|
||||||
cp.add(addButton, c);
|
cp.add(addButton, c);
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
|
|
||||||
deleteButton = new JButton("\uD83D\uDEAE");
|
deleteButton = new FlatButton("\uD83D\uDEAE");
|
||||||
deleteButton.addActionListener(this::deleteButtonClicked);
|
deleteButton.addActionListener(this::deleteButtonClicked);
|
||||||
cp.add(deleteButton, c);
|
cp.add(deleteButton, c);
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
@ -51,7 +54,7 @@ public class TodoListView extends JFrame {
|
|||||||
|
|
||||||
// scrolling content panel
|
// scrolling content panel
|
||||||
//not setting a size results in immediate collapsing of the lsit upon resizing the window
|
//not setting a size results in immediate collapsing of the lsit upon resizing the window
|
||||||
scrollContent = new JPanel();
|
scrollContent = new FlatPanel();
|
||||||
|
|
||||||
buildScrollPanel();
|
buildScrollPanel();
|
||||||
|
|
||||||
@ -61,7 +64,7 @@ public class TodoListView extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void buildScrollPanel(){
|
public void buildScrollPanel(){
|
||||||
scrollContent = new JPanel();
|
scrollContent = new FlatPanel();
|
||||||
scrollContent.removeAll();
|
scrollContent.removeAll();
|
||||||
scrollContent.setMinimumSize(new Dimension(50,50));
|
scrollContent.setMinimumSize(new Dimension(50,50));
|
||||||
scrollContent.setLayout(new BoxLayout(scrollContent, BoxLayout.Y_AXIS));
|
scrollContent.setLayout(new BoxLayout(scrollContent, BoxLayout.Y_AXIS));
|
||||||
|
15
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatButton.java
Normal file
15
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatButton.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package de.dhsn.oop.ui.UIOverrides;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class FlatButton extends JButton {
|
||||||
|
public FlatButton(){
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlatButton(String title){
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
this.setText(title);
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatCheckBox.java
Normal file
10
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatCheckBox.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package de.dhsn.oop.ui.UIOverrides;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class FlatCheckBox extends JCheckBox {
|
||||||
|
public FlatCheckBox(){
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
}
|
14
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatLabel.java
Normal file
14
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatLabel.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package de.dhsn.oop.ui.UIOverrides;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class FlatLabel extends JLabel {
|
||||||
|
public FlatLabel(){
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
public FlatLabel(String t){
|
||||||
|
this();
|
||||||
|
setText(t);
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatPanel.java
Normal file
10
src/main/java/de/dhsn/oop/ui/UIOverrides/FlatPanel.java
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package de.dhsn.oop.ui.UIOverrides;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class FlatPanel extends JPanel {
|
||||||
|
public FlatPanel(){
|
||||||
|
this.setBackground(Color.WHITE);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user