Skip to content

Commit

Permalink
Fixed noPermissionsMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
benchdoos committed Dec 1, 2016
1 parent b9f4837 commit 7f741ef
Showing 1 changed file with 59 additions and 50 deletions.
109 changes: 59 additions & 50 deletions UpdateModule/src/com/doos/update_module/gui/UpdateDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public void initTranslations() {
successUpdatedMessage = messages.getString("successUpdatedMessage");
installationCancelledTitle = messages.getString("installationCancelledTitle");
installationCancelledMessage = messages.getString("installationCancelledMessage");
noPermissionsMessage = messages.getString("noPermissionsMessage");
installationCancelledByErrorMessage1 = messages.getString("installationCancelledByErrorMessage1");
installationCancelledByErrorMessage2 = messages.getString("installationCancelledByErrorMessage2");
installationCancelledByErrorMessage3 = messages.getString("installationCancelledByErrorMessage3");
Expand Down Expand Up @@ -191,56 +192,7 @@ private void onOK() {

if (!Thread.currentThread().isInterrupted()) {
successUpdate = 1;
switch (successUpdate) {
case 0: //NORMAL state, app updated
try {
SettingsManager.loadInfo();
} catch (RegistryCanNotReadInfoException | RegistryCanNotWriteInfoException ignore) {
/*NOP*/
}


JOptionPane.showMessageDialog(this, successUpdatedMessage
+ serverAppVersion.getVersion(), successTitle, JOptionPane.INFORMATION_MESSAGE);

if (Main.mode != Main.Mode.AFTER_UPDATE) {
try {
dispose();
String value = RegistryManager.getInstallLocationValue();
final String command
= "java -jar \"" + value + "Updater.jar\" " + ApplicationConstants.UPDATE_DELETE_TEMP_FILE_ARGUMENT;
System.out.println(
"running " + ApplicationConstants.UPDATE_DELETE_TEMP_FILE_ARGUMENT + " " +
"argument: " + command);
Runtime.getRuntime().exec(command);
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}

break;
case 1: //Installation was cancelled or Incorrect function or corrupt file
showErrorMessageToUser(this, installationCancelledTitle,
installationCancelledMessage);
Updater.installerFile.delete();
break;
case 2: //The system cannot find the file specified. OR! User gave no permissions.
showErrorMessageToUser(this, installationCancelledTitle, noPermissionsMessage);
break;

case 193: //Installation file is corrupt
showErrorMessageToUser(this, installationCancelledTitle, noPermissionsMessage);
break;
default:
String message = installationCancelledByErrorMessage1
+ "\n" + installationCancelledByErrorMessage2 +
successUpdate
+ "\n" + installationCancelledByErrorMessage3;
showErrorMessageToUser(this, installationCancelledTitle, message);

break;
}
processUpdateResult(successUpdate);
}
} else {
buttonOK.setEnabled(false);
Expand All @@ -249,6 +201,63 @@ private void onOK() {
//dispose();
}

private void processUpdateResult(int successUpdate) {
switch (successUpdate) {
case 0: //NORMAL state, app updated
updateSuccessfullyInstalled();

break;
case 1: //Installation was cancelled or Incorrect function or corrupt file
showErrorMessageToUser(this, installationCancelledTitle,
installationCancelledMessage);
Updater.installerFile.delete();
break;
case 2: //The system cannot find the file specified. OR! User gave no permissions.
showErrorMessageToUser(this, installationCancelledTitle, noPermissionsMessage);
break;

case 193: //Installation file is corrupt
showErrorMessageToUser(this, installationCancelledTitle, noPermissionsMessage);
break;
default:
String message = installationCancelledByErrorMessage1
+ "\n" + installationCancelledByErrorMessage2 +
successUpdate
+ "\n" + installationCancelledByErrorMessage3;
showErrorMessageToUser(this, installationCancelledTitle, message);

break;
}
}

private void updateSuccessfullyInstalled() {
try {
SettingsManager.loadInfo();
} catch (RegistryCanNotReadInfoException | RegistryCanNotWriteInfoException ignore) {
/*NOP*/
}


JOptionPane.showMessageDialog(this, successUpdatedMessage
+ serverAppVersion.getVersion(), successTitle, JOptionPane.INFORMATION_MESSAGE);

if (Main.mode != Main.Mode.AFTER_UPDATE) {
try {
dispose();
String value = RegistryManager.getInstallLocationValue();
final String command
= "java -jar \"" + value + "Updater.jar\" " + ApplicationConstants.UPDATE_DELETE_TEMP_FILE_ARGUMENT;
System.out.println(
"running " + ApplicationConstants.UPDATE_DELETE_TEMP_FILE_ARGUMENT + " " +
"argument: " + command);
Runtime.getRuntime().exec(command);
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}

}

private void onCancel() {
// add your code here if necessary
Expand Down

0 comments on commit 7f741ef

Please sign in to comment.