1
1
package com .mycompany .autobackupprogram ;
2
2
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
+
6
7
import java .awt .TrayIcon ;
7
8
import java .io .File ;
8
9
import java .io .FileOutputStream ;
26
27
import javax .swing .JToggleButton ;
27
28
import javax .swing .SwingUtilities ;
28
29
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 ;
29
37
import com .mycompany .autobackupprogram .Logger .LogLevel ;
30
38
31
39
public class BackupOperations {
@@ -62,7 +70,7 @@ public static void SingleBackup(Backup backup, TrayIcon trayIcon, BackupProgress
62
70
zipDirectory (path1 , path2 +".zip" , backup , trayIcon , progressBar , singleBackupBtn , autoBackupBtn );
63
71
} catch (IOException e ) {
64
72
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 );
66
74
if (singleBackupBtn != null ) singleBackupBtn .setEnabled (true );
67
75
if (autoBackupBtn != null ) autoBackupBtn .setEnabled (true );
68
76
} catch (Exception ex ) {
@@ -109,27 +117,27 @@ private static void updateAfterBackup(String path1, String path2, Backup backup,
109
117
110
118
updateBackup (backups , backup );
111
119
112
- if (trayIcon != null ) {
113
- trayIcon .displayMessage ("Backup Manager" , "Backup : " + backup .getBackupName () +" \n The backup was successfully completed: \n From: " + path1 + "\n To : " + 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 );
114
122
}
115
123
} catch (IllegalArgumentException ex ) {
116
124
Logger .logMessage ("An error occurred: " + ex .getMessage (), Logger .LogLevel .ERROR , ex );
117
125
OpenExceptionMessage (ex .getMessage (), Arrays .toString (ex .getStackTrace ()));
118
126
} catch (Exception e ) {
119
127
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 );
121
129
}
122
130
}
123
131
124
132
public static boolean CheckInputCorrect (String backupName , String path1 , String path2 , TrayIcon trayIcon ) {
125
133
//check if inputs are null
126
134
if (path1 .length () == 0 || path2 .length () == 0 ) {
127
135
Logger .logMessage ("Input Missing!" , Logger .LogLevel .WARN );
128
-
129
- if (trayIcon != null ){
130
- trayIcon .displayMessage ("Backup Manager" , "Backup : " + backupName +" \n Error during automatic backup. \n Input 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 );
131
139
} 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 );
133
141
}
134
142
return false ;
135
143
}
@@ -138,9 +146,9 @@ public static boolean CheckInputCorrect(String backupName, String path1, String
138
146
Logger .logMessage ("Input Error! One or both paths do not exist." , Logger .LogLevel .WARN );
139
147
140
148
if (trayIcon != null ) {
141
- trayIcon .displayMessage ("Backup Manager" , "Backup : " + backupName +" \n Error during automatic backup. \n One 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 );
142
150
} 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 );
144
152
}
145
153
return false ;
146
154
}
@@ -149,9 +157,9 @@ public static boolean CheckInputCorrect(String backupName, String path1, String
149
157
Logger .logMessage ("The initial path and destination path cannot be the same. Please choose different paths" , Logger .LogLevel .WARN );
150
158
151
159
if (trayIcon != null ) {
152
- trayIcon .displayMessage ("Backup Manager" , "Backup : " + backupName +" \n Error during automatic backup. \n The 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 );
153
161
} 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 );
155
163
}
156
164
return false ;
157
165
}
0 commit comments