4,10 → 4,10 |
* Coded by: Group 5, software practice summer 2003 |
* University of Bielefeld, Germany |
* |
* @version $Revision: 1.11 $ |
* @version $Revision: 1.12 $ |
* |
* Last modification: $Date: 2003/07/15 18:21:54 $ |
* $Id: OtherGUIActions.java,v 1.11 2003/07/15 18:21:54 smcsporr Exp $ |
* Last modification: $Date: 2003/07/16 15:54:46 $ |
* $Id: OtherGUIActions.java,v 1.12 2003/07/16 15:54:46 hjokusch Exp $ |
*/ |
|
package src.control; |
24,12 → 24,19 |
private DocumentManagerInterface docMaster; |
|
/** |
* Empty constructor |
* Empty constructor. |
*/ |
public OtherGUIActions() { |
} |
|
// TODO JavaDoc-comments |
/** |
* Sets a reference to an implementation of a document manager. This |
* manager must implement the <code> DocumentManagerInterface</code>. |
* |
* @param doc: A document manager conforming to src.control.DocumentManagerInterface. |
* |
* author Group 5 |
*/ |
public void setDocManagerInterface(DocumentManagerInterface doc) |
{ |
docMaster = doc; |
36,12 → 43,24 |
} |
|
/** |
* Method needed by <code>ActionListener</code>. |
* <code>actionPerformed</code> takes <code>ActionEvent</code>s and |
* performs the appropiate actions. This method catches and handles |
* <code>ActionEvent</code>s that have an action command 'Exit'. |
* |
* @param ae: An <code>ActionEvent</code> that needs to be processed. |
* |
* author Group 5 |
* |
* Last revision: 16-Jul-2003 by S. McSporran |
*/ |
public void actionPerformed(ActionEvent e) { |
public void actionPerformed(ActionEvent ae) { |
|
if (e.getActionCommand() == "Exit") { |
if (ae.getActionCommand() == "Exit") { |
|
/* Ask the user if he really wishes to leave the program. */ |
if (quitConfirmed() == true) { |
|
/* Close all open documents. */ |
docMaster.closeAll(); |
System.exit(0); |
} |
49,23 → 68,27 |
} |
|
/** |
* <code>quitConfirmed</code> asks the user if he/she wants to leave to program. |
* <code>quitConfirmed</code> asks the user if he/she wants to leave the program. |
* |
* @return A <code>boolean</code> value indicating if the exit procedure has been confirmed. |
* <code>true<code> if user confirms, <code>false<code> otherwise. |
* |
* author Group 5 |
* |
* Last revision: 16-Jul-2003 by S. McSporran |
*/ |
// TODO comments |
private boolean quitConfirmed() |
{ |
|
JFrame frame = new JFrame(); |
// if (documents.unsaved() == true) |
{ |
|
} |
//if (documents.unsaved() == true) |
|
/* Create the button labels for the dialog. */ |
String s1 = "Quit"; |
String s2 = "Cancel"; |
Object[] options = {s1, s2}; |
|
/* Show the dialog with 'Quit' and 'Cancel' text instead of 'yes' and 'no'. */ |
int n = JOptionPane.showOptionDialog(frame, |
"Do you really want to quit?", |
"Quit Confirmation", |
74,12 → 97,16 |
null, |
options, |
s1); |
if (n == JOptionPane.YES_OPTION) |
{ |
|
/* Return 'true' if the user clicked 'Quit'. */ |
if (n == JOptionPane.YES_OPTION) { |
|
return true; |
} |
else |
{ |
|
/* Return 'false' if the user clicked 'Cancel' or closed the dialog. */ |
else { |
|
return false; |
} |
} |