Skip to content

Commit

Permalink
show confirmation dialog before reset settings, use warning icon for …
Browse files Browse the repository at this point in the history
…joptionpane
  • Loading branch information
creme332 committed Jul 11, 2024
1 parent 79f06f5 commit 822e192
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void initializeButtonListeners(AppState app) {
int confirmation = JOptionPane.showConfirmDialog(null,
"Do you want to clear the current canvas? This action is irreversible.",
"Clear canvas",
JOptionPane.OK_CANCEL_OPTION);
JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);

if (confirmation == JOptionPane.YES_OPTION) {
canvasModel.getShapeManager().reset();
Expand Down Expand Up @@ -119,16 +119,23 @@ public void mousePressed(MouseEvent e) {

// Reset button
sidebar.getResetButton().addActionListener(e -> {
// Reset guidelines checkbox and model
if (sidebar.getGridLinesCheckBox().isSelected()) {
sidebar.getGridLinesCheckBox().setSelected(false);
canvasModel.setGuidelinesEnabled(true);
}
int confirmation = JOptionPane.showConfirmDialog(null,
"Do you want to reset the canvas settings to its default values? This action is irreversible.",
"Reset canvas settings",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE);

// Reset axes checkbox and model
if (sidebar.getAxesCheckBox().isSelected()) {
sidebar.getAxesCheckBox().setSelected(false);
canvasModel.setAxesVisible(true);
if (confirmation == JOptionPane.YES_OPTION) {
// Reset guidelines checkbox and model
if (sidebar.getGridLinesCheckBox().isSelected()) {
sidebar.getGridLinesCheckBox().setSelected(false);
canvasModel.setGuidelinesEnabled(true);
}

// Reset axes checkbox and model
if (sidebar.getAxesCheckBox().isSelected()) {
sidebar.getAxesCheckBox().setSelected(false);
canvasModel.setAxesVisible(true);
}
}
});
}
Expand Down

0 comments on commit 822e192

Please sign in to comment.