Skip to content

Commit ade86e3

Browse files
authored
Version 2.0.3
2 parents ce74773 + 222ff6a commit ade86e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2090
-211
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "interactive"
3+
}
1.36 MB
Binary file not shown.

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@
1010
<maven.compiler.target>19</maven.compiler.target>
1111
</properties>
1212
<dependencies>
13-
<!-- Dependency for org.json -->
13+
<!-- Dependency for json -->
1414
<dependency>
1515
<groupId>com.googlecode.json-simple</groupId>
1616
<artifactId>json-simple</artifactId>
1717
<version>1.1.1</version>
1818
</dependency>
1919

20+
<dependency>
21+
<groupId>com.google.code.gson</groupId>
22+
<artifactId>gson</artifactId>
23+
<version>2.8.9</version>
24+
</dependency>
25+
2026
<!-- Dependency for JUnit 4 -->
2127
<dependency>
2228
<groupId>junit</groupId>
@@ -42,6 +48,11 @@
4248
</dependency>
4349

4450
<!-- Dependency for flatlaf -->
51+
<dependency>
52+
<groupId>com.formdev</groupId>
53+
<artifactId>flatlaf-intellij-themes</artifactId>
54+
<version>3.5.2</version>
55+
</dependency>
4556
<dependency>
4657
<groupId>com.formdev</groupId>
4758
<artifactId>flatlaf</artifactId>

src/main/java/com/mycompany/autobackupprogram/BackupOperations.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.mycompany.autobackupprogram;
22

3-
import static com.mycompany.autobackupprogram.BackupManagerGUI.OpenExceptionMessage;
4-
import static com.mycompany.autobackupprogram.BackupManagerGUI.dateForfolderNameFormatter;
5-
import static com.mycompany.autobackupprogram.BackupManagerGUI.formatter;
3+
import static com.mycompany.autobackupprogram.GUI.BackupManagerGUI.OpenExceptionMessage;
4+
import static com.mycompany.autobackupprogram.GUI.BackupManagerGUI.dateForfolderNameFormatter;
5+
import static com.mycompany.autobackupprogram.GUI.BackupManagerGUI.formatter;
6+
67
import java.awt.TrayIcon;
78
import java.io.File;
89
import java.io.FileOutputStream;
@@ -26,6 +27,13 @@
2627
import javax.swing.JToggleButton;
2728
import javax.swing.SwingUtilities;
2829

30+
import com.mycompany.autobackupprogram.Entities.Backup;
31+
import com.mycompany.autobackupprogram.Enums.ConfigKey;
32+
import com.mycompany.autobackupprogram.Enums.TranslationLoaderEnum.TranslationCategory;
33+
import com.mycompany.autobackupprogram.Enums.TranslationLoaderEnum.TranslationKey;
34+
import com.mycompany.autobackupprogram.GUI.BackupManagerGUI;
35+
import com.mycompany.autobackupprogram.GUI.BackupProgressGUI;
36+
import com.mycompany.autobackupprogram.Entities.TimeInterval;
2937
import com.mycompany.autobackupprogram.Logger.LogLevel;
3038

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

110118
updateBackup(backups, backup);
111119

112-
if (trayIcon != null) {
113-
trayIcon.displayMessage("Backup Manager", "Backup: "+ backup.getBackupName() +"\nThe backup was successfully completed:\nFrom: " + path1 + "\nTo: " + path2, TrayIcon.MessageType.INFO);
120+
if (trayIcon != null) {
121+
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);
114122
}
115123
} catch (IllegalArgumentException ex) {
116124
Logger.logMessage("An error occurred: " + ex.getMessage(), Logger.LogLevel.ERROR, ex);
117125
OpenExceptionMessage(ex.getMessage(), Arrays.toString(ex.getStackTrace()));
118126
} catch (Exception e) {
119127
Logger.logMessage("Error saving file", Logger.LogLevel.WARN);
120-
JOptionPane.showMessageDialog(null, "Error saving file", "Error", JOptionPane.ERROR_MESSAGE);
128+
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_SAVING_FILE), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
121129
}
122130
}
123131

124132
public static boolean CheckInputCorrect(String backupName, String path1, String path2, TrayIcon trayIcon) {
125133
//check if inputs are null
126134
if(path1.length() == 0 || path2.length() == 0) {
127135
Logger.logMessage("Input Missing!", Logger.LogLevel.WARN);
128-
129-
if (trayIcon != null){
130-
trayIcon.displayMessage("Backup Manager", "Backup: "+ backupName +"\nError during automatic backup.\nInput Missing!", TrayIcon.MessageType.ERROR);
136+
137+
if (trayIcon != null) {
138+
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);
131139
} else {
132-
JOptionPane.showMessageDialog(null, "Input Missing!", "Error", JOptionPane.ERROR_MESSAGE);
140+
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_INPUT_MISSING_GENERIC), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
133141
}
134142
return false;
135143
}
@@ -138,9 +146,9 @@ public static boolean CheckInputCorrect(String backupName, String path1, String
138146
Logger.logMessage("Input Error! One or both paths do not exist.", Logger.LogLevel.WARN);
139147

140148
if (trayIcon != null) {
141-
trayIcon.displayMessage("Backup Manager", "Backup: "+ backupName +"\nError during automatic backup.\nOne or both paths do not exist!", TrayIcon.MessageType.ERROR);
149+
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);
142150
} else {
143-
JOptionPane.showMessageDialog(null, "One or both paths do not exist!", "Error", JOptionPane.ERROR_MESSAGE);
151+
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_PATH_NOT_EXISTING), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
144152
}
145153
return false;
146154
}
@@ -149,9 +157,9 @@ public static boolean CheckInputCorrect(String backupName, String path1, String
149157
Logger.logMessage("The initial path and destination path cannot be the same. Please choose different paths", Logger.LogLevel.WARN);
150158

151159
if (trayIcon != null) {
152-
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);
160+
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);
153161
} else {
154-
JOptionPane.showMessageDialog(null, "The initial path and destination path cannot be the same. Please choose different paths!", "Error", JOptionPane.ERROR_MESSAGE);
162+
JOptionPane.showMessageDialog(null, TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_MESSAGE_SAME_PATHS_GENERIC), TranslationCategory.DIALOGS.getTranslation(TranslationKey.ERROR_GENERIC_TITLE), JOptionPane.ERROR_MESSAGE);
155163
}
156164
return false;
157165
}

src/main/java/com/mycompany/autobackupprogram/BackupService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
import java.util.concurrent.TimeUnit;
1414
import javax.swing.JFrame;
1515

16+
import com.mycompany.autobackupprogram.Entities.Backup;
17+
import com.mycompany.autobackupprogram.Enums.ConfigKey;
18+
import com.mycompany.autobackupprogram.GUI.BackupManagerGUI;
19+
1620
public class BackupService {
1721
private ScheduledExecutorService scheduler;
1822
private final JSONAutoBackup json = new JSONAutoBackup();
19-
private final JSONConfigReader jsonConfig = new JSONConfigReader(ConfigKey.CONFIG_FILE_STRING.getValue(), ConfigKey.RES_DIRECTORY_STRING.getValue());
23+
private final JSONConfigReader jsonConfig = new JSONConfigReader(ConfigKey.CONFIG_FILE_STRING.getValue(), ConfigKey.CONFIG_DIRECTORY_STRING.getValue());
2024
private TrayIcon trayIcon = null;
2125
private BackupManagerGUI guiInstance = null;
2226

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
3+
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
4+
<Properties>
5+
<Property name="defaultCloseOperation" type="int" value="2"/>
6+
<Property name="title" type="java.lang.String" value="Preferences"/>
7+
<Property name="alwaysOnTop" type="boolean" value="true"/>
8+
<Property name="resizable" type="boolean" value="false"/>
9+
</Properties>
10+
<SyntheticProperties>
11+
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
12+
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
13+
</SyntheticProperties>
14+
<AuxValues>
15+
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
16+
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
17+
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
18+
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
19+
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
20+
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
21+
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
22+
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
23+
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
24+
</AuxValues>
25+
26+
<Layout>
27+
<DimensionLayout dim="0">
28+
<Group type="103" groupAlignment="0" attributes="0">
29+
<Group type="102" alignment="0" attributes="0">
30+
<Group type="103" groupAlignment="1" attributes="0">
31+
<Group type="102" alignment="1" attributes="0">
32+
<EmptySpace pref="223" max="32767" attributes="0"/>
33+
<Component id="applyBtn" min="-2" max="-2" attributes="0"/>
34+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
35+
<Component id="closeBtn" min="-2" max="-2" attributes="0"/>
36+
</Group>
37+
<Group type="102" alignment="0" attributes="0">
38+
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
39+
<Group type="103" groupAlignment="0" max="-2" attributes="0">
40+
<Component id="jLabel1" max="32767" attributes="0"/>
41+
<Component id="jLabel2" alignment="0" pref="345" max="32767" attributes="0"/>
42+
<Component id="themesComboBox" alignment="0" max="32767" attributes="0"/>
43+
<Component id="languagesComboBox" alignment="0" max="32767" attributes="0"/>
44+
</Group>
45+
</Group>
46+
</Group>
47+
<EmptySpace pref="13" max="32767" attributes="0"/>
48+
</Group>
49+
</Group>
50+
</DimensionLayout>
51+
<DimensionLayout dim="1">
52+
<Group type="103" groupAlignment="0" attributes="0">
53+
<Group type="102" alignment="0" attributes="0">
54+
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
55+
<Component id="jLabel1" min="-2" pref="16" max="-2" attributes="0"/>
56+
<EmptySpace max="-2" attributes="0"/>
57+
<Component id="languagesComboBox" min="-2" pref="34" max="-2" attributes="0"/>
58+
<EmptySpace type="separate" max="-2" attributes="0"/>
59+
<Component id="jLabel2" min="-2" pref="16" max="-2" attributes="0"/>
60+
<EmptySpace max="-2" attributes="0"/>
61+
<Component id="themesComboBox" min="-2" pref="34" max="-2" attributes="0"/>
62+
<EmptySpace pref="109" max="32767" attributes="0"/>
63+
<Group type="103" groupAlignment="3" attributes="0">
64+
<Component id="applyBtn" alignment="3" min="-2" max="-2" attributes="0"/>
65+
<Component id="closeBtn" alignment="3" min="-2" max="-2" attributes="0"/>
66+
</Group>
67+
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
68+
</Group>
69+
</Group>
70+
</DimensionLayout>
71+
</Layout>
72+
<SubComponents>
73+
<Component class="javax.swing.JComboBox" name="languagesComboBox">
74+
<Properties>
75+
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
76+
<StringArray count="0"/>
77+
</Property>
78+
<Property name="toolTipText" type="java.lang.String" value=""/>
79+
</Properties>
80+
<AuxValues>
81+
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
82+
</AuxValues>
83+
</Component>
84+
<Component class="javax.swing.JLabel" name="jLabel1">
85+
<Properties>
86+
<Property name="text" type="java.lang.String" value="Language"/>
87+
</Properties>
88+
</Component>
89+
<Component class="javax.swing.JLabel" name="jLabel2">
90+
<Properties>
91+
<Property name="text" type="java.lang.String" value="Theme"/>
92+
</Properties>
93+
</Component>
94+
<Component class="javax.swing.JComboBox" name="themesComboBox">
95+
<Properties>
96+
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
97+
<StringArray count="0"/>
98+
</Property>
99+
</Properties>
100+
<Events>
101+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="themesComboBoxActionPerformed"/>
102+
</Events>
103+
<AuxValues>
104+
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
105+
</AuxValues>
106+
</Component>
107+
<Component class="javax.swing.JButton" name="applyBtn">
108+
<Properties>
109+
<Property name="text" type="java.lang.String" value="Apply"/>
110+
</Properties>
111+
<Events>
112+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="applyBtnActionPerformed"/>
113+
</Events>
114+
</Component>
115+
<Component class="javax.swing.JButton" name="closeBtn">
116+
<Properties>
117+
<Property name="text" type="java.lang.String" value="Close"/>
118+
</Properties>
119+
<Events>
120+
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeBtnActionPerformed"/>
121+
</Events>
122+
</Component>
123+
</SubComponents>
124+
</Form>

0 commit comments

Comments
 (0)