moved confirmation dialog to AmidstMessageBox
parent
b446cdd729
commit
b92205eef3
|
@ -222,7 +222,7 @@ public class Actions {
|
|||
+ file.getAbsolutePath();
|
||||
AmidstLogger.warn(message);
|
||||
mainWindow.displayError(message);
|
||||
} else if (!file.exists() || mainWindow.askToConfirm(
|
||||
} else if (!file.exists() || mainWindow.askToConfirmYesNo(
|
||||
"Replace file?",
|
||||
"File already exists. Do you want to replace it?\n" + file.getAbsolutePath() + "")) {
|
||||
saveImageToFile(image, file);
|
||||
|
@ -305,7 +305,7 @@ public class Actions {
|
|||
if (input != null) {
|
||||
player.moveTo(targetCoordinates, tryParseLong(input, currentHeight), currentCoordinates.getDimension());
|
||||
viewerFacade.reloadPlayerLayer();
|
||||
if (mainWindow.askToConfirm("Save Player Locations", "Do you want to save the player locations?")) {
|
||||
if (mainWindow.askToConfirmYesNo("Save Player Locations", "Do you want to save the player locations?")) {
|
||||
if (mainWindow.askToConfirmSaveGameManipulation()) {
|
||||
viewerFacade.savePlayerLocations();
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ public class MainWindow {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public boolean askToConfirmSaveGameManipulation() {
|
||||
return askToConfirm(
|
||||
return askToConfirmYesNo(
|
||||
"Save Game Manipulation",
|
||||
"WARNING: You are about to change the contents of the save game directory. There is a chance that it gets corrupted.\n"
|
||||
+ "We try to minimize the risk by creating a backup of the changed file, before it is changed.\n"
|
||||
|
@ -309,9 +309,8 @@ public class MainWindow {
|
|||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public boolean askToConfirm(String title, String message) {
|
||||
return JOptionPane
|
||||
.showConfirmDialog(frame, message, title, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
|
||||
public boolean askToConfirmYesNo(String title, String message) {
|
||||
return AmidstMessageBox.askToConfirmYesNo(frame, title, message);
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
|
|
|
@ -7,8 +7,6 @@ import java.net.URISyntaxException;
|
|||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import amidst.AmidstVersion;
|
||||
import amidst.documentation.AmidstThread;
|
||||
import amidst.documentation.CalledOnlyBy;
|
||||
|
@ -34,14 +32,14 @@ public class UpdatePrompt {
|
|||
workerExecutor,
|
||||
NOOP_CONSUMER,
|
||||
NOOP,
|
||||
message -> mainWindow.askToConfirm(TITLE, message));
|
||||
message -> mainWindow.askToConfirmYesNo(TITLE, message));
|
||||
} else {
|
||||
return new UpdatePrompt(
|
||||
currentVersion,
|
||||
workerExecutor,
|
||||
e -> mainWindow.displayException(e),
|
||||
() -> mainWindow.displayMessage(TITLE, NO_UPDATES_AVAILABLE),
|
||||
message -> mainWindow.askToConfirm(TITLE, message));
|
||||
message -> mainWindow.askToConfirmYesNo(TITLE, message));
|
||||
}
|
||||
} else {
|
||||
if (silent) {
|
||||
|
@ -50,23 +48,18 @@ public class UpdatePrompt {
|
|||
workerExecutor,
|
||||
NOOP_CONSUMER,
|
||||
NOOP,
|
||||
message -> askToConfirmDirectly(message));
|
||||
message -> AmidstMessageBox.askToConfirmYesNo(TITLE, message));
|
||||
} else {
|
||||
return new UpdatePrompt(
|
||||
currentVersion,
|
||||
workerExecutor,
|
||||
e -> AmidstMessageBox.displayError(TITLE, e),
|
||||
() -> AmidstMessageBox.displayInfo(TITLE, NO_UPDATES_AVAILABLE),
|
||||
message -> askToConfirmDirectly(message));
|
||||
message -> AmidstMessageBox.askToConfirmYesNo(TITLE, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private static boolean askToConfirmDirectly(String message) {
|
||||
return JOptionPane.showConfirmDialog(null, message, TITLE, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
|
||||
}
|
||||
|
||||
private static final String TITLE = "Amidst Updater";
|
||||
private static final String NO_UPDATES_AVAILABLE = "There are no updates available.";
|
||||
|
||||
|
|
|
@ -94,11 +94,22 @@ public enum AmidstMessageBox {
|
|||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private static void displayMessageBox(String title, String message, int type) {
|
||||
JOptionPane.showMessageDialog(null, message, title, type);
|
||||
displayMessageBox(null, title, message, type);
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
private static void displayMessageBox(Component parent, String title, String message, int type) {
|
||||
JOptionPane.showMessageDialog(parent, message, title, type);
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public static boolean askToConfirmYesNo(String title, String message) {
|
||||
return askToConfirmYesNo(null, title, message);
|
||||
}
|
||||
|
||||
@CalledOnlyBy(AmidstThread.EDT)
|
||||
public static boolean askToConfirmYesNo(Component parent, String title, String message) {
|
||||
return JOptionPane
|
||||
.showConfirmDialog(parent, message, title, JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue