Skip to content

Commit aa3e93e

Browse files
committed
Code quality improvements
1 parent 42bdd66 commit aa3e93e

File tree

13 files changed

+144
-137
lines changed

13 files changed

+144
-137
lines changed

src/main/java/net/sourceforge/dionysus/gui/Constants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ public final class Constants {
2828
/** Version nickname */
2929
public static final String SOFTWARE_VERSION_NICK = "\"Riesling\"";
3030

31+
/**
32+
* Private constructor
33+
*/
34+
private Constants() {
35+
super();
36+
}
37+
3138
}

src/main/java/net/sourceforge/dionysus/gui/NewCategoryDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public NewCategoryDialog() {
136136
JButton okButton = new JButton(Messages.getString("NewCategoryDialog.5"), okIcon); //$NON-NLS-1$
137137
okButton.setActionCommand(Messages.getString("NewCategoryDialog.6")); //$NON-NLS-1$
138138

139-
okButton.addActionListener((arg0) -> {
139+
okButton.addActionListener(arg0 -> {
140140
try {
141141
if (nameField.getText().isEmpty()) {
142142
throw new IllegalArgumentException(Messages.getString("NewCategoryDialog.7")); //$NON-NLS-1$
@@ -159,7 +159,7 @@ public NewCategoryDialog() {
159159
JButton cancelButton = new JButton(Messages.getString("NewCategoryDialog.11"), cancelIcon); //$NON-NLS-1$
160160
cancelButton.setActionCommand(Messages.getString("NewCategoryDialog.12")); //$NON-NLS-1$
161161

162-
cancelButton.addActionListener((arg0) -> setVisible(false));
162+
cancelButton.addActionListener(arg0 -> setVisible(false));
163163

164164
buttonPane.add(cancelButton);
165165
}

src/main/java/net/sourceforge/dionysus/gui/NewUserDialog.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public NewUserDialog() {
193193
JButton okButton = new JButton(Messages.getString("NewUserDialog2.9"), okIcon); //$NON-NLS-1$
194194
okButton.setActionCommand(Messages.getString("NewUserDialog2.10")); //$NON-NLS-1$
195195

196-
okButton.addActionListener((arg0) -> {
196+
okButton.addActionListener(arg0 -> {
197197
if (!nomField.getText().isEmpty() && !prenomField.getText().isEmpty()) {
198198
// TODO : Check
199199
Integer i = (int) promoChooser.getValue();
@@ -226,7 +226,7 @@ public NewUserDialog() {
226226
JButton cancelButton = new JButton(Messages.getString("NewUserDialog2.16"), cancelIcon); //$NON-NLS-1$
227227
cancelButton.setActionCommand(Messages.getString("NewUserDialog2.17")); //$NON-NLS-1$
228228

229-
cancelButton.addActionListener((arg0) -> {
229+
cancelButton.addActionListener(arg0 -> {
230230
user = null;
231231
setVisible(false);
232232
});
@@ -252,7 +252,6 @@ public NewUserDialog(User u) {
252252
* @return the user being edited/created
253253
*/
254254
public User getUser() {
255-
// this.setVisible(true);
256255
return this.user;
257256
}
258257

src/main/java/net/sourceforge/dionysus/gui/PasswordDialog.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public PasswordDialog() {
7878
setModal(true);
7979
setSize(450, 123);
8080
setLocationRelativeTo(null);
81-
// setBounds(100, 100, 450, 123);
8281
getContentPane().setLayout(new BorderLayout());
8382
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
8483
getContentPane().add(contentPanel, BorderLayout.CENTER);
@@ -100,8 +99,6 @@ public PasswordDialog() {
10099
}
101100
{
102101
loginField = new JTextField();
103-
// loginField.setText("default");
104-
// loginField.setEnabled(false);
105102
GridBagConstraints gbc_loginField = new GridBagConstraints();
106103
gbc_loginField.anchor = GridBagConstraints.NORTH;
107104
gbc_loginField.fill = GridBagConstraints.HORIZONTAL;
@@ -255,7 +252,6 @@ private void loadDatabase() {
255252
line = s.nextLine();
256253
}
257254

258-
s.close();
259255
} catch (IOException e) {
260256
JOptionPane.showMessageDialog(null, Messages.getString("PasswordDialog.23"), //$NON-NLS-1$
261257
Messages.getString("PasswordDialog.24"), //$NON-NLS-1$

src/main/java/net/sourceforge/dionysus/gui/UserChoiceDialog.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.awt.GridBagConstraints;
2323
import java.awt.GridBagLayout;
2424
import java.awt.Insets;
25-
import java.awt.event.ActionEvent;
2625
import java.util.regex.PatternSyntaxException;
2726

2827
import javax.swing.ImageIcon;
@@ -129,7 +128,6 @@ public void removeUpdate(DocumentEvent e) {
129128
table.setRowSorter(sorter);
130129
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
131130
table.setFillsViewportHeight(true);
132-
// table.setAutoCreateRowSorter(true);
133131

134132
JScrollPane tableSP = new JScrollPane(table);
135133

@@ -149,7 +147,7 @@ public void removeUpdate(DocumentEvent e) {
149147
ImageIcon okIcon = new ImageIcon(getClass().getResource(Messages.getString("UserChoiceDialog2.2"))); //$NON-NLS-1$
150148
JButton okButton = new JButton(Messages.getString("UserChoiceDialog2.3"), okIcon); //$NON-NLS-1$
151149
okButton.setActionCommand(Messages.getString("UserChoiceDialog2.4")); //$NON-NLS-1$
152-
okButton.addActionListener((ActionEvent arg0) -> {
150+
okButton.addActionListener(arg0 -> {
153151
// Choice of the user from the user which was selected in the table
154152
int row = table.getSelectedRow();
155153
if (row >= 0) {
@@ -165,7 +163,7 @@ public void removeUpdate(DocumentEvent e) {
165163
ImageIcon cancelIcon = new ImageIcon(getClass().getResource(Messages.getString("UserChoiceDialog2.5"))); //$NON-NLS-1$
166164
JButton cancelButton = new JButton(Messages.getString("UserChoiceDialog2.6"), cancelIcon); //$NON-NLS-1$
167165
cancelButton.setActionCommand(Messages.getString("UserChoiceDialog2.7")); //$NON-NLS-1$
168-
cancelButton.addActionListener((arg0) -> setVisible(false));
166+
cancelButton.addActionListener(arg0 -> setVisible(false));
169167

170168
buttonPane.add(cancelButton);
171169
}
@@ -181,11 +179,10 @@ private void newFilter() {
181179
// If current expression doesn't parse, don't update.
182180
try {
183181
rf = RowFilter.regexFilter(Messages.getString("UserChoiceDialog2.8") + textField.getText()); //$NON-NLS-1$
184-
} catch (PatternSyntaxException e) {
185-
return;
186-
} catch (NullPointerException e) {
182+
} catch (PatternSyntaxException | NullPointerException e) {
187183
return;
188184
}
185+
189186
sorter.setRowFilter(rf);
190187
}
191188
}

src/main/java/net/sourceforge/dionysus/gui/models/ArticleTableModel.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,41 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
1918
package net.sourceforge.dionysus.gui.models;
2019

2120
import javax.swing.table.DefaultTableModel;
2221

2322
public class ArticleTableModel extends DefaultTableModel {
2423

2524
private static final long serialVersionUID = -2641198391560050967L;
26-
private static String [] colNames = new String[] {
27-
"Name", "Code", "Active", "Price 0", "Price 1", "Price 2", "Current stock", "Alert from"
28-
};
29-
30-
public ArticleTableModel(Object[][] data){
25+
private static String[] colNames = new String[] { "Name", "Code", "Active", "Price 0", "Price 1", "Price 2",
26+
"Current stock", "Alert from" };
27+
28+
Class[] columnTypes = new Class[] { String.class, Long.class, Boolean.class, String.class, String.class,
29+
String.class, String.class, String.class };
30+
31+
boolean[] columnEditables = new boolean[] { false, false, false, false, false, false, false, false };
32+
33+
public ArticleTableModel(Object[][] data) {
3134
super(data, colNames);
3235
}
33-
34-
Class[] columnTypes = new Class[] {
35-
String.class, Long.class, Boolean.class, String.class, String.class, String.class, String.class, String.class
36-
};
36+
37+
/** {@inheritDoc} */
38+
@Override
3739
public Class getColumnClass(int columnIndex) {
3840
return columnTypes[columnIndex];
3941
}
40-
boolean[] columnEditables = new boolean[] {
41-
false, false, false, false, false, false, false, false
42-
};
42+
43+
/** {@inheritDoc} */
44+
@Override
4345
public boolean isCellEditable(int row, int column) {
4446
return columnEditables[column];
4547
}
4648

47-
public void refreshData(Object[][] newData){
49+
public void refreshData(Object[][] newData) {
4850
setDataVector(newData, colNames);
4951
}
5052
}

src/main/java/net/sourceforge/dionysus/gui/models/TicketItemTableModel.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

1818
package net.sourceforge.dionysus.gui.models;
@@ -25,21 +25,24 @@
2525
*/
2626
public class TicketItemTableModel extends DefaultTableModel {
2727
private static final long serialVersionUID = -2023864553780594289L;
28-
private static String [] colNames = new String[] {"Name", "Quantity", "Price"};
29-
30-
public TicketItemTableModel(Object[][] data){
28+
private static String[] colNames = new String[] { "Name", "Quantity", "Price" };
29+
30+
Class[] columnTypes = new Class[] { String.class, String.class, String.class };
31+
32+
boolean[] columnEditables = new boolean[] { false, true, false };
33+
34+
public TicketItemTableModel(Object[][] data) {
3135
super(data, colNames);
3236
}
33-
34-
Class[] columnTypes = new Class[] {
35-
String.class, String.class, String.class
36-
};
37+
38+
/** {@inheritDoc} */
39+
@Override
3740
public Class getColumnClass(int columnIndex) {
3841
return columnTypes[columnIndex];
3942
}
40-
boolean[] columnEditables = new boolean[] {
41-
false, true, false
42-
};
43+
44+
/** {@inheritDoc} */
45+
@Override
4346
public boolean isCellEditable(int row, int column) {
4447
return columnEditables[column];
4548
}

src/main/java/net/sourceforge/dionysus/gui/models/TransactionTableModel.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
1918
package net.sourceforge.dionysus.gui.models;
2019

2120
import java.util.Date;
@@ -25,30 +24,31 @@
2524
public class TransactionTableModel extends DefaultTableModel {
2625

2726
private static final long serialVersionUID = 7595571828972009182L;
28-
private static String [] colNames = new String[] {
29-
"Date", "Article", "Quantity", "Amount", "Source account", "Dest. account", "Paid by", "Vendor"
30-
};
27+
private static String[] colNames = new String[] { "Date", "Article", "Quantity", "Amount", "Source account",
28+
"Dest. account", "Paid by", "Vendor" };
29+
30+
Class[] columnTypes = new Class[] { Date.class, String.class, Integer.class, String.class, String.class,
31+
String.class, String.class, String.class };
32+
33+
boolean[] columnEditables = new boolean[] { false, false, false, false, false, false, false, false };
3134

32-
33-
public TransactionTableModel(Object[][] data){
34-
super(data,colNames);
35+
public TransactionTableModel(Object[][] data) {
36+
super(data, colNames);
3537
}
36-
37-
38-
Class[] columnTypes = new Class[] {
39-
Date.class, String.class, Integer.class, String.class, String.class, String.class, String.class, String.class
40-
};
38+
39+
/** {@inheritDoc} */
40+
@Override
4141
public Class getColumnClass(int columnIndex) {
4242
return columnTypes[columnIndex];
4343
}
44-
boolean[] columnEditables = new boolean[] {
45-
false, false, false, false, false, false, false, false
46-
};
44+
45+
/** {@inheritDoc} */
46+
@Override
4747
public boolean isCellEditable(int row, int column) {
4848
return columnEditables[column];
4949
}
50-
51-
public void refreshData(Object[][] newData){
50+
51+
public void refreshData(Object[][] newData) {
5252
setDataVector(newData, colNames);
5353
}
5454
}

src/main/java/net/sourceforge/dionysus/gui/models/UserTableModel.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
GNU General Public License for more details.
1313
1414
You should have received a copy of the GNU General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

1818
package net.sourceforge.dionysus.gui.models;
@@ -22,37 +22,38 @@
2222
public class UserTableModel extends DefaultTableModel {
2323

2424
private static final long serialVersionUID = -2841704746545744058L;
25-
private static String [] colNames = new String[] {"Last name", "First name", "ID", "Year", "Balance", "Deposit"};
26-
27-
public UserTableModel(Object[][] data){
25+
private static String[] colNames = new String[] { "Last name", "First name", "ID", "Year", "Balance", "Deposit" };
26+
27+
Class[] columnTypes = new Class[] { String.class, String.class, String.class, Integer.class, String.class,
28+
Boolean.class };
29+
30+
boolean[] columnEditables = new boolean[] { false, false, false, false, false, false };
31+
32+
public UserTableModel(Object[][] data) {
2833
super(data, colNames);
2934
}
30-
31-
32-
Class[] columnTypes = new Class[] {
33-
String.class, String.class, String.class, Integer.class, String.class, Boolean.class
34-
};
35-
35+
36+
/** {@inheritDoc} */
37+
@Override
3638
public Class getColumnClass(int columnIndex) {
3739
return columnTypes[columnIndex];
3840
}
39-
40-
boolean[] columnEditables = new boolean[] {
41-
false, false, false, false, false, false
42-
};
43-
41+
42+
/** {@inheritDoc} */
43+
@Override
4444
public boolean isCellEditable(int row, int column) {
4545
return columnEditables[column];
4646
}
47-
48-
public void setValueAt(Object value, int row, int col) {
49-
//data[row][col] = value;
50-
fireTableCellUpdated(row, col);
5147

52-
}
53-
54-
public void refreshData(Object[][] newData){
48+
public void refreshData(Object[][] newData) {
5549
setDataVector(newData, colNames);
5650
}
57-
51+
52+
/** {@inheritDoc} */
53+
@Override
54+
public void setValueAt(Object value, int row, int col) {
55+
fireTableCellUpdated(row, col);
56+
57+
}
58+
5859
}

0 commit comments

Comments
 (0)