Skip to content

Commit

Permalink
Version 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DennisTurco authored Nov 17, 2024
2 parents ce74773 + 222ff6a commit ade86e3
Show file tree
Hide file tree
Showing 48 changed files with 2,090 additions and 211 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
Binary file not shown.
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
<maven.compiler.target>19</maven.compiler.target>
</properties>
<dependencies>
<!-- Dependency for org.json -->
<!-- Dependency for json -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>

<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.9</version>
</dependency>

<!-- Dependency for JUnit 4 -->
<dependency>
<groupId>junit</groupId>
Expand All @@ -42,6 +48,11 @@
</dependency>

<!-- Dependency for flatlaf -->
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf-intellij-themes</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>com.formdev</groupId>
<artifactId>flatlaf</artifactId>
Expand Down
38 changes: 23 additions & 15 deletions src/main/java/com/mycompany/autobackupprogram/BackupOperations.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.mycompany.autobackupprogram;

import static com.mycompany.autobackupprogram.BackupManagerGUI.OpenExceptionMessage;
import static com.mycompany.autobackupprogram.BackupManagerGUI.dateForfolderNameFormatter;
import static com.mycompany.autobackupprogram.BackupManagerGUI.formatter;
import static com.mycompany.autobackupprogram.GUI.BackupManagerGUI.OpenExceptionMessage;
import static com.mycompany.autobackupprogram.GUI.BackupManagerGUI.dateForfolderNameFormatter;
import static com.mycompany.autobackupprogram.GUI.BackupManagerGUI.formatter;

import java.awt.TrayIcon;
import java.io.File;
import java.io.FileOutputStream;
Expand All @@ -26,6 +27,13 @@
import javax.swing.JToggleButton;
import javax.swing.SwingUtilities;

import com.mycompany.autobackupprogram.Entities.Backup;
import com.mycompany.autobackupprogram.Enums.ConfigKey;
import com.mycompany.autobackupprogram.Enums.TranslationLoaderEnum.TranslationCategory;
import com.mycompany.autobackupprogram.Enums.TranslationLoaderEnum.TranslationKey;
import com.mycompany.autobackupprogram.GUI.BackupManagerGUI;
import com.mycompany.autobackupprogram.GUI.BackupProgressGUI;
import com.mycompany.autobackupprogram.Entities.TimeInterval;
import com.mycompany.autobackupprogram.Logger.LogLevel;

public class BackupOperations{
Expand Down Expand Up @@ -62,7 +70,7 @@ public static void SingleBackup(Backup backup, TrayIcon trayIcon, BackupProgress
zipDirectory(path1, path2+".zip", backup, trayIcon, progressBar, singleBackupBtn, autoBackupBtn);
} catch (IOException e) {
Logger.logMessage("Error during the backup operation: the initial path is incorrect!", Logger.LogLevel.WARN);
JOptionPane.showMessageDialog(null, "Error during the backup operation: the initial path is incorrect!", "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_FOR_INCORRECT_INITIAL_PATH), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
if (singleBackupBtn != null) singleBackupBtn.setEnabled(true);
if (autoBackupBtn != null) autoBackupBtn.setEnabled(true);
} catch (Exception ex) {
Expand Down Expand Up @@ -109,27 +117,27 @@ private static void updateAfterBackup(String path1, String path2, Backup backup,

updateBackup(backups, backup);

if (trayIcon != null) {
trayIcon.displayMessage("Backup Manager", "Backup: "+ backup.getBackupName() +"\nThe backup was successfully completed:\nFrom: " + path1 + "\nTo: " + path2, TrayIcon.MessageType.INFO);
if (trayIcon != null) {
trayIcon.displayMessage(TranslationCategory.GENERAL.getTranslation(TranslationKey.APP_NAME), TranslationCategory.GENERAL.getTranslation(TranslationKey.BACKUP) + ": " + backup.getBackupName() + TranslationCategory.TRAY_ICON.getTranslation(TranslationKey.SUCCESS_MESSAGE) + "\n" + TranslationCategory.GENERAL.getTranslation(TranslationKey.FROM) + ": " + path1 + "\n" + TranslationCategory.GENERAL.getTranslation(TranslationKey.TO) + ": " + path2, TrayIcon.MessageType.INFO);
}
} catch (IllegalArgumentException ex) {
Logger.logMessage("An error occurred: " + ex.getMessage(), Logger.LogLevel.ERROR, ex);
OpenExceptionMessage(ex.getMessage(), Arrays.toString(ex.getStackTrace()));
} catch (Exception e) {
Logger.logMessage("Error saving file", Logger.LogLevel.WARN);
JOptionPane.showMessageDialog(null, "Error saving file", "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_SAVING_FILE), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
}
}

public static boolean CheckInputCorrect(String backupName, String path1, String path2, TrayIcon trayIcon) {
//check if inputs are null
if(path1.length() == 0 || path2.length() == 0) {
Logger.logMessage("Input Missing!", Logger.LogLevel.WARN);
if (trayIcon != null){
trayIcon.displayMessage("Backup Manager", "Backup: "+ backupName +"\nError during automatic backup.\nInput Missing!", TrayIcon.MessageType.ERROR);

if (trayIcon != null) {
trayIcon.displayMessage(TranslationCategory.GENERAL.getTranslation(TranslationKey.APP_NAME), TranslationCategory.GENERAL.getTranslation(TranslationKey.BACKUP) + ": " + backupName + TranslationCategory.TRAY_ICON.getTranslation(TranslationKey.ERROR_MESSAGE_INPUT_MISSING), TrayIcon.MessageType.ERROR);
} else {
JOptionPane.showMessageDialog(null, "Input Missing!", "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_INPUT_MISSING_GENERIC), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
}
return false;
}
Expand All @@ -138,9 +146,9 @@ public static boolean CheckInputCorrect(String backupName, String path1, String
Logger.logMessage("Input Error! One or both paths do not exist.", Logger.LogLevel.WARN);

if (trayIcon != null) {
trayIcon.displayMessage("Backup Manager", "Backup: "+ backupName +"\nError during automatic backup.\nOne or both paths do not exist!", TrayIcon.MessageType.ERROR);
trayIcon.displayMessage(TranslationCategory.GENERAL.getTranslation(TranslationKey.APP_NAME), TranslationCategory.GENERAL.getTranslation(TranslationKey.BACKUP) + ": " + backupName + TranslationCategory.TRAY_ICON.getTranslation(TranslationKey.ERROR_MESSAGE_FILES_NOT_EXISTING), TrayIcon.MessageType.ERROR);
} else {
JOptionPane.showMessageDialog(null, "One or both paths do not exist!", "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_PATH_NOT_EXISTING), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
}
return false;
}
Expand All @@ -149,9 +157,9 @@ public static boolean CheckInputCorrect(String backupName, String path1, String
Logger.logMessage("The initial path and destination path cannot be the same. Please choose different paths", Logger.LogLevel.WARN);

if (trayIcon != null) {
trayIcon.displayMessage("Backup Manager", "Backup: "+ backupName +"\nError during automatic backup.\nThe initial path and destination path cannot be the same. Please choose different paths!", TrayIcon.MessageType.ERROR);
trayIcon.displayMessage(TranslationCategory.GENERAL.getTranslation(TranslationKey.APP_NAME), TranslationCategory.GENERAL.getTranslation(TranslationKey.BACKUP) + ": " + backupName + TranslationCategory.TRAY_ICON.getTranslation(TranslationKey.ERROR_MESSAGE_SAME_PATHS), TrayIcon.MessageType.ERROR);
} else {
JOptionPane.showMessageDialog(null, "The initial path and destination path cannot be the same. Please choose different paths!", "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_SAME_PATHS_GENERIC), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
import java.util.concurrent.TimeUnit;
import javax.swing.JFrame;

import com.mycompany.autobackupprogram.Entities.Backup;
import com.mycompany.autobackupprogram.Enums.ConfigKey;
import com.mycompany.autobackupprogram.GUI.BackupManagerGUI;

public class BackupService {
private ScheduledExecutorService scheduler;
private final JSONAutoBackup json = new JSONAutoBackup();
private final JSONConfigReader jsonConfig = new JSONConfigReader(ConfigKey.CONFIG_FILE_STRING.getValue(), ConfigKey.RES_DIRECTORY_STRING.getValue());
private final JSONConfigReader jsonConfig = new JSONConfigReader(ConfigKey.CONFIG_FILE_STRING.getValue(), ConfigKey.CONFIG_DIRECTORY_STRING.getValue());
private TrayIcon trayIcon = null;
private BackupManagerGUI guiInstance = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
<Property name="title" type="java.lang.String" value="Preferences"/>
<Property name="alwaysOnTop" type="boolean" value="true"/>
<Property name="resizable" type="boolean" value="false"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="223" max="32767" attributes="0"/>
<Component id="applyBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="closeBtn" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jLabel1" max="32767" attributes="0"/>
<Component id="jLabel2" alignment="0" pref="345" max="32767" attributes="0"/>
<Component id="themesComboBox" alignment="0" max="32767" attributes="0"/>
<Component id="languagesComboBox" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="13" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="languagesComboBox" min="-2" pref="34" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="themesComboBox" min="-2" pref="34" max="-2" attributes="0"/>
<EmptySpace pref="109" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="applyBtn" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="closeBtn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="languagesComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value=""/>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Language"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Theme"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="themesComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="themesComboBoxActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="applyBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Apply"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyBtnActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="closeBtn">
<Properties>
<Property name="text" type="java.lang.String" value="Close"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeBtnActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
Loading

0 comments on commit ade86e3

Please sign in to comment.