diff --git a/README.md b/README.md index 0034d2a..ed68b3f 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,8 @@ kBorrow is going to be a simple application to manage items that have been borro This software uses the Xerial SQLite JDBC (https://bitbucket.org/xerial/sqlite-jdbc). The SQLite JDBC follows the Apache License Version 2.0 (http://www.apache.org/licenses/) ### MySQL Connector -This software uses the Oracle MySQL Java Connector (http://dev.mysql.com/downloads/connector/j/). The MySQL Java Connector is provided under the GPL License Version 2.0 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html). \ No newline at end of file +This software uses the Oracle MySQL Java Connector (http://dev.mysql.com/downloads/connector/j/). The MySQL Java Connector is provided under the GPL License Version 2.0 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html). + +### Tango Desktop Project +This software also uses icons provided by the Tango Desktop Project (http://tango.freedesktop.org/). +License will follow! \ No newline at end of file diff --git a/assets/icons/accessories-text-editor.png b/assets/icons/accessories-text-editor.png new file mode 100644 index 0000000..c3d245d Binary files /dev/null and b/assets/icons/accessories-text-editor.png differ diff --git a/assets/icons/edit-delete.png b/assets/icons/edit-delete.png new file mode 100644 index 0000000..3811b64 Binary files /dev/null and b/assets/icons/edit-delete.png differ diff --git a/src/de/katho/kBorrow/Main.java b/src/de/katho/kBorrow/Main.java index 1a96762..3e3c9c8 100644 --- a/src/de/katho/kBorrow/Main.java +++ b/src/de/katho/kBorrow/Main.java @@ -39,7 +39,7 @@ public class Main { } try { new MainWindow(this.dbCon); - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); System.exit(1); diff --git a/src/de/katho/kBorrow/gui/ArticleTab.java b/src/de/katho/kBorrow/gui/ArticleTab.java index 11d5aa4..798fd83 100644 --- a/src/de/katho/kBorrow/gui/ArticleTab.java +++ b/src/de/katho/kBorrow/gui/ArticleTab.java @@ -5,6 +5,7 @@ import java.awt.Color; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; import javax.swing.BorderFactory; import javax.swing.JButton; @@ -35,8 +36,9 @@ public class ArticleTab extends JPanel implements ActionListener { /** * Create the panel. + * @throws IOException */ - public ArticleTab(final DbConnector dbCon) { + public ArticleTab(final DbConnector dbCon) throws IOException { super(); this.setLayout(null); @@ -45,14 +47,18 @@ public class ArticleTab extends JPanel implements ActionListener { */ this.articleTableModel = new ArticleTableModel(dbCon); JTable articleTable = new JTable(articleTableModel); + articleTable.setRowHeight(30); ArticleDeleteTableButton articleDeleteTableButton = new ArticleDeleteTableButton("Löschen", articleTable); ArticleEditTableButton articleEditTableButton = new ArticleEditTableButton("Bearbeiten", articleTable, this); - articleTable.getColumnModel().getColumn(4).setCellEditor(articleDeleteTableButton); - articleTable.getColumnModel().getColumn(4).setCellRenderer(articleDeleteTableButton); - - articleTable.getColumnModel().getColumn(3).setCellEditor(articleEditTableButton); - articleTable.getColumnModel().getColumn(3).setCellRenderer(articleEditTableButton); + for (int i = 3; i <= 4; i++){ + articleTable.getColumnModel().getColumn(i).setCellEditor(i == 3 ? articleEditTableButton : articleDeleteTableButton); + articleTable.getColumnModel().getColumn(i).setCellRenderer(i == 3 ? articleEditTableButton : articleDeleteTableButton); + + articleTable.getColumnModel().getColumn(i).setMinWidth(30); + articleTable.getColumnModel().getColumn(i).setMaxWidth(30); + articleTable.getColumnModel().getColumn(i).setPreferredWidth(30); + } articleTable.setFillsViewportHeight(true); diff --git a/src/de/katho/kBorrow/gui/MainWindow.java b/src/de/katho/kBorrow/gui/MainWindow.java index 55dccfa..e4804a1 100644 --- a/src/de/katho/kBorrow/gui/MainWindow.java +++ b/src/de/katho/kBorrow/gui/MainWindow.java @@ -6,6 +6,7 @@ import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import java.awt.BorderLayout; +import java.io.IOException; import de.katho.kBorrow.db.DbConnector; @@ -26,8 +27,9 @@ public class MainWindow { * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException + * @throws IOException */ - public MainWindow(DbConnector pDbCon) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { + public MainWindow(DbConnector pDbCon) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException { this.dbCon = pDbCon; initialize(); this.frame.setVisible(true); @@ -39,8 +41,9 @@ public class MainWindow { * @throws IllegalAccessException * @throws InstantiationException * @throws ClassNotFoundException + * @throws IOException */ - private void initialize() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { + private void initialize() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException, IOException { this.frame = new JFrame(); this.frame.setResizable(false); this.frame.setBounds(100, 100, 600, 500); diff --git a/src/de/katho/kBorrow/gui/UserTab.java b/src/de/katho/kBorrow/gui/UserTab.java index f9f544a..77777a1 100644 --- a/src/de/katho/kBorrow/gui/UserTab.java +++ b/src/de/katho/kBorrow/gui/UserTab.java @@ -3,6 +3,7 @@ package de.katho.kBorrow.gui; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; import javax.swing.JButton; import javax.swing.JLabel; @@ -29,20 +30,25 @@ public class UserTab extends JPanel implements ActionListener { private int userEditId; private UserTableModel userTableModel; - public UserTab(final DbConnector dbCon){ + public UserTab(final DbConnector dbCon) throws IOException{ super(); this.setLayout(null); //Tabelle und drumherum this.userTableModel = new UserTableModel(dbCon); JTable userTable = new JTable(userTableModel); + userTable.setRowHeight(30); UserDeleteTableButton userDeleteTableButton = new UserDeleteTableButton("Löschen", userTable); - userTable.getColumnModel().getColumn(4).setCellEditor(userDeleteTableButton); - userTable.getColumnModel().getColumn(4).setCellRenderer(userDeleteTableButton); - UserEditTableButton userEditTableButton = new UserEditTableButton("Bearbeiten", userTable, this); - userTable.getColumnModel().getColumn(3).setCellEditor(userEditTableButton); - userTable.getColumnModel().getColumn(3).setCellRenderer(userEditTableButton); + + for (int i = 3; i <= 4; i++){ + userTable.getColumnModel().getColumn(i).setCellEditor(i == 3 ? userEditTableButton : userDeleteTableButton); + userTable.getColumnModel().getColumn(i).setCellRenderer(i == 3 ? userEditTableButton : userDeleteTableButton); + + userTable.getColumnModel().getColumn(i).setMinWidth(30); + userTable.getColumnModel().getColumn(i).setMaxWidth(30); + userTable.getColumnModel().getColumn(i).setPreferredWidth(30); + } userTable.setFillsViewportHeight(true); @@ -115,7 +121,7 @@ public class UserTab extends JPanel implements ActionListener { break; case 2: - this.lblUserStatus.setText("Entweder Vor- oder Nachname m�ssen ausgef�llt sein."); + this.lblUserStatus.setText("Entweder Vor- oder Nachname müssen ausgefüllt sein."); break; } @@ -128,7 +134,7 @@ public class UserTab extends JPanel implements ActionListener { switch (re){ case 0: - this.lblUserStatus.setText("Benutzer \""+this.textFieldUserName.getText()+" "+this.textFieldUserSurname.getText()+"\" erfolgreich hinzugef�gt."); + this.lblUserStatus.setText("Benutzer \""+this.textFieldUserName.getText()+" "+this.textFieldUserSurname.getText()+"\" erfolgreich hinzugefügt."); this.textFieldUserName.setText(""); this.textFieldUserSurname.setText(""); break; @@ -140,7 +146,7 @@ public class UserTab extends JPanel implements ActionListener { break; case 2: - this.lblUserStatus.setText("Entweder Vor- oder Nachname m�ssen ausgef�llt sein."); + this.lblUserStatus.setText("Entweder Vor- oder Nachname müssen ausgefüllt sein."); break; } } diff --git a/src/de/katho/kBorrow/listener/ArticleDeleteTableButton.java b/src/de/katho/kBorrow/listener/ArticleDeleteTableButton.java index d8eb39d..4965224 100644 --- a/src/de/katho/kBorrow/listener/ArticleDeleteTableButton.java +++ b/src/de/katho/kBorrow/listener/ArticleDeleteTableButton.java @@ -2,7 +2,12 @@ package de.katho.kBorrow.listener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; import javax.swing.JTable; import de.katho.kBorrow.gui.ArticleTableModel; @@ -14,8 +19,8 @@ public class ArticleDeleteTableButton extends TableButton { */ private static final long serialVersionUID = 7701712368979056068L; - public ArticleDeleteTableButton(String pLabel, JTable pTable) { - super(pLabel, pTable); + public ArticleDeleteTableButton(String pLabel, JTable pTable) throws IOException { + super(new ImageIcon(ImageIO.read(new File("assets/icons/edit-delete.png"))), pTable); this.buttonE.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ diff --git a/src/de/katho/kBorrow/listener/ArticleEditTableButton.java b/src/de/katho/kBorrow/listener/ArticleEditTableButton.java index a540eb1..055485d 100644 --- a/src/de/katho/kBorrow/listener/ArticleEditTableButton.java +++ b/src/de/katho/kBorrow/listener/ArticleEditTableButton.java @@ -2,7 +2,11 @@ package de.katho.kBorrow.listener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; import javax.swing.JTable; import de.katho.kBorrow.gui.ArticleTab; @@ -15,8 +19,8 @@ public class ArticleEditTableButton extends TableButton { */ private static final long serialVersionUID = -5902626427691636902L; - public ArticleEditTableButton(String pLabel, JTable pTable, final ArticleTab articleTab) { - super(pLabel, pTable); + public ArticleEditTableButton(String pLabel, JTable pTable, final ArticleTab articleTab) throws IOException { + super(new ImageIcon(ImageIO.read(new File("assets/icons/accessories-text-editor.png"))), pTable); this.buttonE.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ diff --git a/src/de/katho/kBorrow/listener/TableButton.java b/src/de/katho/kBorrow/listener/TableButton.java index f422a99..fad8e0e 100644 --- a/src/de/katho/kBorrow/listener/TableButton.java +++ b/src/de/katho/kBorrow/listener/TableButton.java @@ -3,6 +3,7 @@ package de.katho.kBorrow.listener; import java.awt.Component; import javax.swing.AbstractCellEditor; +import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JTable; import javax.swing.table.TableCellEditor; @@ -15,11 +16,11 @@ public abstract class TableButton extends AbstractCellEditor implements TableCel protected JButton buttonR; protected JButton buttonE; - public TableButton (String pLabel, JTable pTable) { - this.label = pLabel; + public TableButton (ImageIcon pIcon, JTable pTable) { + //this.label = pLabel; this.table = pTable; - this.buttonR = new JButton(pLabel); - this.buttonE = new JButton(pLabel); + this.buttonR = new JButton(pIcon); + this.buttonE = new JButton(pIcon); } public Object getCellEditorValue() { diff --git a/src/de/katho/kBorrow/listener/UserDeleteTableButton.java b/src/de/katho/kBorrow/listener/UserDeleteTableButton.java index 5e7e4b5..2717c54 100644 --- a/src/de/katho/kBorrow/listener/UserDeleteTableButton.java +++ b/src/de/katho/kBorrow/listener/UserDeleteTableButton.java @@ -2,7 +2,11 @@ package de.katho.kBorrow.listener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; import javax.swing.JTable; import de.katho.kBorrow.gui.UserTableModel; @@ -11,8 +15,8 @@ public class UserDeleteTableButton extends TableButton { private static final long serialVersionUID = -886584066497429394L; - public UserDeleteTableButton(String pLabel, JTable pTable){ - super(pLabel, pTable); + public UserDeleteTableButton(String pLabel, JTable pTable) throws IOException{ + super(new ImageIcon(ImageIO.read(new File("assets/icons/edit-delete.png"))), pTable); this.buttonE.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ diff --git a/src/de/katho/kBorrow/listener/UserEditTableButton.java b/src/de/katho/kBorrow/listener/UserEditTableButton.java index 456adc0..5bf79b7 100644 --- a/src/de/katho/kBorrow/listener/UserEditTableButton.java +++ b/src/de/katho/kBorrow/listener/UserEditTableButton.java @@ -2,7 +2,11 @@ package de.katho.kBorrow.listener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; import javax.swing.JTable; import de.katho.kBorrow.gui.UserTab; @@ -15,8 +19,8 @@ public class UserEditTableButton extends TableButton { */ private static final long serialVersionUID = -886584066497429394L; - public UserEditTableButton(String pLabel, JTable pTable, final UserTab pPanel){ - super(pLabel, pTable); + public UserEditTableButton(String pLabel, JTable pTable, final UserTab pPanel) throws IOException{ + super(new ImageIcon(ImageIO.read(new File("assets/icons/accessories-text-editor.png"))), pTable); this.buttonE.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){