diff --git a/src/me/teridax/jcash/Logging.java b/src/me/teridax/jcash/Logging.java index ee1bfec..d5ab62d 100644 --- a/src/me/teridax/jcash/Logging.java +++ b/src/me/teridax/jcash/Logging.java @@ -21,6 +21,10 @@ public final class Logging { * Folder the log files are stored in, relative to the file containing the class */ private static final String LOG_FOLDER_NAME = "logs/"; + /** + * Format for the date time used for log files + */ + private static final String DATE_TIME_FORMAT = "yyyy-MM-dd_HH-mm-ss"; /** * Initialize the global system logger. @@ -35,17 +39,30 @@ public final class Logging { LOGGER.setLevel(level); } + /** + * Add a console log handler writing to the applications stderr + * @param level the level to set the handler to + */ private static void createConsoleLogger(Level level) { var ch = new ConsoleHandler(); ch.setLevel(level); LOGGER.addHandler(ch); } + /** + * Create a log handler writing to a file. + * The file will be located in a folder directly besides the application + * with the name LOG_FOLDER_NAME. The name will follow the format DATE_TIME_FORMAT plus "log" as + * file extension. + * @param level the log level to set the handler to + */ private static void createFileLogger(Level level) { + // setup log file name var now = LocalDateTime.now(); - var dateTime = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss").format(now); + var dateTime = DateTimeFormatter.ofPattern(DATE_TIME_FORMAT).format(now); var logFileName = LOG_FOLDER_NAME + dateTime + ".log"; + // setup the folder for the logs initializeLogFolder(); try { @@ -57,6 +74,10 @@ public final class Logging { } } + /** + * Checks if the folder containing log files is present. + * If the folder does not exist, the function will create a new folder. + */ private static void initializeLogFolder() { var folderPath = Path.of(LOG_FOLDER_NAME); diff --git a/src/me/teridax/jcash/Main.java b/src/me/teridax/jcash/Main.java index 937f592..5403e1a 100644 --- a/src/me/teridax/jcash/Main.java +++ b/src/me/teridax/jcash/Main.java @@ -47,6 +47,13 @@ public final class Main { getInstance().showLoginScreen(); } + /** + * Set the look and feel via the ui manager. + * This function will select a look and feel so that the application will + * look most like a native application. + * It will select the systems look and feel for Windows and MacOS + * and GTK for unix based systems. + */ private static void setPlatformDependingTheme() { // default look and feel var laf = UIManager.getCrossPlatformLookAndFeelClassName(); diff --git a/src/me/teridax/jcash/gui/Loader.java b/src/me/teridax/jcash/gui/Loader.java index 7d446b9..79321da 100644 --- a/src/me/teridax/jcash/gui/Loader.java +++ b/src/me/teridax/jcash/gui/Loader.java @@ -2,7 +2,6 @@ package me.teridax.jcash.gui; import me.teridax.jcash.Logging; import me.teridax.jcash.banking.management.BankingManagementSystem; -import me.teridax.jcash.lang.Translator; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; diff --git a/src/me/teridax/jcash/gui/login/AccountSelectionListener.java b/src/me/teridax/jcash/gui/login/AccountSelectionListener.java index 080efe3..ffe8782 100644 --- a/src/me/teridax/jcash/gui/login/AccountSelectionListener.java +++ b/src/me/teridax/jcash/gui/login/AccountSelectionListener.java @@ -5,6 +5,7 @@ import me.teridax.jcash.banking.management.Profile; /** * Listens for changes in a selected account. */ +@FunctionalInterface public interface AccountSelectionListener { /** diff --git a/src/me/teridax/jcash/gui/login/LoginView.java b/src/me/teridax/jcash/gui/login/LoginView.java index a5e0c4e..5b790e3 100644 --- a/src/me/teridax/jcash/gui/login/LoginView.java +++ b/src/me/teridax/jcash/gui/login/LoginView.java @@ -1,14 +1,22 @@ package me.teridax.jcash.gui.login; import javax.swing.*; -import javax.swing.text.NumberFormatter; +import javax.swing.text.*; import java.awt.*; import java.text.NumberFormat; +import static java.awt.BorderLayout.NORTH; +import static javax.swing.SwingConstants.CENTER; import static me.teridax.jcash.lang.Translator.translate; public class LoginView extends JPanel { + /** + * Maximum number of decimal digits that can be stored lossless by a 32-bit signed integer. + * N = log10(2^32-1) = 9,632959861146281 + */ + private static final int MAX_PIN_DECIMAL_DIGITS = 9; + private JFormattedTextField blz; private JFormattedTextField iban; private JPasswordField pin; @@ -22,15 +30,15 @@ public class LoginView extends JPanel { private void layoutComponents() { var content = new JPanel(new GridBagLayout()); - this.setBorder(BorderFactory.createEmptyBorder(8,8,8,8)); + this.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); this.setLayout(new BorderLayout(16, 16)); this.add(new JScrollPane(content), BorderLayout.CENTER); - this.add(new JLabel(translate("Cashmachine")), BorderLayout.NORTH); + this.add(new JLabel("