Update of /cvsroot/javanetsim/javaNetSim/guiUI
In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv17633/guiUI
Modified Files:
MainScreen.java MenuBar.java
Log Message:
quit() was extended
Index: MainScreen.java
===================================================================
RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v
retrieving revision 1.104
retrieving revision 1.105
diff -C2 -d -r1.104 -r1.105
*** MainScreen.java 27 Oct 2008 16:09:02 -0000 1.104
--- MainScreen.java 27 Oct 2008 21:22:11 -0000 1.105
***************
*** 69,73 ****
import java.awt.event.ComponentListener;
import java.awt.image.BufferedImage;
- import java.awt.image.RenderedImage;
import java.io.BufferedReader;
import java.io.BufferedWriter;
--- 69,72 ----
***************
*** 120,124 ****
import core.Node;
import core.Simulation;
- import core.protocolsuite.tcp_ip.DHCPC;
import core.protocolsuite.tcp_ip.DHCPD;
import core.protocolsuite.tcp_ip.Echo;
--- 119,122 ----
***************
*** 609,613 ****
this.setLocationRelativeTo(null);
! this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
--- 607,617 ----
this.setLocationRelativeTo(null);
! this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
!
! this.addWindowListener(new java.awt.event.WindowAdapter() {
! public void windowClosing(java.awt.event.WindowEvent e) {
! quit();
! }
! });
this.setVisible(true);
***************
*** 1570,1574 ****
public void quit() {
! System.exit(0);
}
--- 1574,1594 ----
public void quit() {
! if(isDirty){
! int result = JOptionPane.showConfirmDialog(this,
! "Save changes"+(simSaveFile!=null?" as "+simSaveFile.getName():"")+"?");
! switch(result){
! case JOptionPane.YES_OPTION:{
! if(Save()){
! System.exit(0);
! }
! break;
! }
! case JOptionPane.NO_OPTION: System.exit(0); break;
! case JOptionPane.CANCEL_OPTION: break;
! }
! }
! else{
! System.exit(0);
! }
}
***************
*** 1708,1720 ****
}
! public void Save() {
if (simSaveFile != null)
! SaveAs(simSaveFile.getPath());
else
! SaveAs(null);
}
! public void SaveAs(String saveas) {
!
JFileChooser chooser = new JFileChooser();
--- 1728,1740 ----
}
! public boolean Save() {
if (simSaveFile != null)
! return SaveAs(simSaveFile.getPath());
else
! return SaveAs(null);
}
! public boolean SaveAs(String saveas) {
!
JFileChooser chooser = new JFileChooser();
***************
*** 1747,1752 ****
if(JOptionPane.showConfirmDialog(this, "File exists! Overwrite?",
"Confirm overwriting!", JOptionPane.YES_NO_OPTION,
! JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION)
! return;
}
--- 1767,1772 ----
if(JOptionPane.showConfirmDialog(this, "File exists! Overwrite?",
"Confirm overwriting!", JOptionPane.YES_NO_OPTION,
! JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION)
! return false;
}
***************
*** 1923,1926 ****
--- 1943,1948 ----
setStatus("Simulation was saved succesfully.");
+
+ return true;
} catch (IOException e) {
***************
*** 1933,1936 ****
--- 1955,1960 ----
}
+
+ return false;
}
Index: MenuBar.java
===================================================================
RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MenuBar.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** MenuBar.java 24 Oct 2008 18:13:48 -0000 1.22
--- MenuBar.java 27 Oct 2008 21:22:11 -0000 1.23
***************
*** 247,260 ****
mnuExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
! int result = JOptionPane
! .showConfirmDialog(null,
! "Are you sure you wish to quit?",
! "Really Quit?", JOptionPane.YES_NO_OPTION,
! JOptionPane.QUESTION_MESSAGE);
!
! if (result == JOptionPane.YES_OPTION) {
! // Quit the program if Yes is selected.
controller.quit();
! }
}
});
--- 247,260 ----
mnuExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
! // int result = JOptionPane
! // .showConfirmDialog(null,
! // "Are you sure you wish to quit?",
! // "Really Quit?", JOptionPane.YES_NO_OPTION,
! // JOptionPane.QUESTION_MESSAGE);
! //
! // if (result == JOptionPane.YES_OPTION) {
! // // Quit the program if Yes is selected.
controller.quit();
! // }
}
});
|