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