cancel & save confirm dialogs
This commit is contained in:
parent
b7161a9295
commit
851223fa9f
|
@ -102,7 +102,7 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
frame.setLocationRelativeTo(parent);
|
frame.setLocationRelativeTo(parent);
|
||||||
frame.setAlwaysOnTop(true);
|
frame.setAlwaysOnTop(true);
|
||||||
|
|
||||||
cancelBtn.addActionListener(this); // TODO: put warning dialog "Are you sure? All unsaved changes will be lost."
|
cancelBtn.addActionListener(this);
|
||||||
saveBtn.addActionListener(this);
|
saveBtn.addActionListener(this);
|
||||||
addSongBtn.addActionListener(this); // file picker
|
addSongBtn.addActionListener(this); // file picker
|
||||||
deleteSongBtn.addActionListener(this); // delete from list
|
deleteSongBtn.addActionListener(this); // delete from list
|
||||||
|
@ -117,9 +117,12 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
frame.addWindowListener(new WindowAdapter() {
|
frame.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosing(WindowEvent e)
|
public void windowClosing(WindowEvent e)
|
||||||
{// TODO: put warning dialog "Are you sure? All unsaved changes will be lost."
|
{
|
||||||
parent.setEnabled(true);
|
int result = JOptionPane.showConfirmDialog(frame, "Are you sure?\nAll unsaved changes will be lost.", "Soundtrack Mod Generator", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||||
e.getWindow().dispose();
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
|
parent.setEnabled(true);
|
||||||
|
e.getWindow().dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -133,8 +136,11 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent actionEvent) {
|
public void actionPerformed(ActionEvent actionEvent) {
|
||||||
if (actionEvent.getSource() == cancelBtn) {
|
if (actionEvent.getSource() == cancelBtn) {
|
||||||
parent.setEnabled(true);
|
int result = JOptionPane.showConfirmDialog(frame, "Are you sure?\nAll unsaved changes will be lost.", "Soundtrack Mod Generator", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||||
frame.dispose();
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
|
parent.setEnabled(true);
|
||||||
|
frame.dispose();
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if (actionEvent.getSource() == fTitle || actionEvent.getSource() == fArtist) {
|
if (actionEvent.getSource() == fTitle || actionEvent.getSource() == fArtist) {
|
||||||
tracklist.get(curIndex).title = fTitle.getText();
|
tracklist.get(curIndex).title = fTitle.getText();
|
||||||
|
@ -148,7 +154,30 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
if (actionEvent.getSource() == moveDownBtn) {moveDown(curIndex);} else
|
if (actionEvent.getSource() == moveDownBtn) {moveDown(curIndex);} else
|
||||||
if (actionEvent.getSource() == frontendMainChooseBtn) {setSPMusic();} else
|
if (actionEvent.getSource() == frontendMainChooseBtn) {setSPMusic();} else
|
||||||
if (actionEvent.getSource() == frontendDemoChooseBtn) {setMPMusic();} else
|
if (actionEvent.getSource() == frontendDemoChooseBtn) {setMPMusic();} else
|
||||||
if (actionEvent.getSource() == saveBtn) {save();}
|
if (actionEvent.getSource() == saveBtn) {
|
||||||
|
if (tracklist.isEmpty() && sptrack == null && mptrack == null) {
|
||||||
|
JOptionPane.showMessageDialog(frame, "Please add at least one song to the playlist.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
String deets;
|
||||||
|
if (tracklist.isEmpty()) {
|
||||||
|
deets = "no songs";
|
||||||
|
} else {
|
||||||
|
deets = tracklist.size() + " songs";
|
||||||
|
}
|
||||||
|
if (sptrack != null && mptrack == null) {
|
||||||
|
deets = deets + " and a custom campaign menu track";
|
||||||
|
} else if (mptrack != null && sptrack == null) {
|
||||||
|
deets = deets + " and a custom lobby menu track";
|
||||||
|
} else if (mptrack != null && sptrack != null) {
|
||||||
|
deets = deets + ", a custom campaign menu track, and a custom lobby menu track";
|
||||||
|
}
|
||||||
|
int result = JOptionPane.showConfirmDialog(frame, "Your custom playlist with " + deets + " will be generated.\nPress YES to continue, or NO to continue editing.", "Soundtrack Mod Generator", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
|
||||||
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -270,11 +299,6 @@ public class Suggs implements ActionListener, ListSelectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
if (tracklist.isEmpty() && sptrack == null && mptrack == null) {
|
|
||||||
JOptionPane.showMessageDialog(frame, "Please add at least one song to the playlist.", "Error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
frame.setEnabled(false);
|
frame.setEnabled(false);
|
||||||
frame.setAlwaysOnTop(false);
|
frame.setAlwaysOnTop(false);
|
||||||
Main.deleteDir(new File(System.getProperty("user.home") + "/.firestar/temp/")); // starts with clean temp
|
Main.deleteDir(new File(System.getProperty("user.home") + "/.firestar/temp/")); // starts with clean temp
|
||||||
|
|
Loading…
Reference in New Issue
Block a user