00001
00002
00003
00004
00005
00006 package i2bpro.layer;
00007
00008 import i2bpro.Exceptions.ErrorMsg;
00009 import i2bpro.Exceptions.PlayListException;
00010 import i2bpro.playlist.PlayList;
00011 import java.awt.event.WindowAdapter;
00012 import java.awt.event.WindowEvent;
00013 import java.io.IOException;
00014 import javax.swing.JOptionPane;
00015
00016
00024 public final class WindowClosingAdapter extends WindowAdapter
00025 {
00026 private boolean exitSystem;
00027
00028 public WindowClosingAdapter(boolean exitSystem)
00029 {
00030 this.exitSystem = exitSystem;
00031 }
00032
00033 public WindowClosingAdapter()
00034 {
00035 this(false);
00036 }
00037
00038
00039 @Override
00040 public void windowClosing(WindowEvent event)
00041 {
00042 if (Layer.getInstance().isSave())
00043 {
00044 JOptionPane pane = new JOptionPane();
00045 if (pane.showConfirmDialog(null,
00046 "Möchten Sie die an der Playlist vorgenommenen Änderungen "
00047 + "speichern?", null, JOptionPane.YES_NO_OPTION,
00048 JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
00049 {
00050 try {
00051 PlayList.getInstance().PlayListSave(PlayList.getInstance().getFileName());
00052 exitSystem = true;
00053 }
00054 catch (PlayListException ex) { ErrorMsg.show(ex.getMessage()); }
00055 catch (IOException ex) { ErrorMsg.show(ex.getMessage()); }
00056 }
00057 }
00058 event.getWindow().setVisible(false);
00059 event.getWindow().dispose();
00060 if (exitSystem)
00061 System.exit(0);
00062 }
00063 }