View Javadoc

1   package gov.nasa.pds.ltdt.gui;
2   
3   import gov.nasa.pds.ltdt.gui.configuration.LTDTKeys;
4   
5   import java.util.Enumeration;
6   import java.util.HashMap;
7   import java.util.Iterator;
8   import java.util.Properties;
9   
10  import javax.swing.JOptionPane;
11  
12  public class ToolExit {
13  	Properties props;
14  	
15  	// take care of these when user choose Exit or close a window 
16  	public static void exitHandling (Properties props, MainWindow window){
17  
18  		if ("true".equals(props.getProperty("debug"))) {
19  			System.err.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<");
20  			System.err.println ("All configuration parameter values at closing time");			
21  			for (Enumeration e= props.propertyNames(); e.hasMoreElements();) {
22  				String key = e.nextElement().toString();
23  				System.err.println (key+"="+props.getProperty(key));
24  			}
25  			//System.err.println ("Project Altered is ->"+	props.getProperty(LTDTKeys.PROJECTALTERED));
26  			//System.err.println ("Tempalate exist is ->"+ props.getProperty(LTDTKeys.TEMPLATEEXISTS));
27  		}
28  
29  		if ("true".equals(props.getProperty(LTDTKeys.PROJECTALTERED)))  {
30  			int response=JOptionPane.showConfirmDialog (
31  					window,					
32  					"Do you want to save changes made to this project\nbefore exiting?",
33  					LTDTKeys.PROJECTMODIFIEDTITLE,
34  					JOptionPane.YES_NO_CANCEL_OPTION );
35  			
36  			switch (response) {
37  				case JOptionPane.YES_OPTION:
38  					/*
39  					//if ("Untitled".equals(props.getProperty(LTDTKeys.PROJECTNAME)))
40  						////new ProjectCreateDialog(props, window, LTDTKeys.NEWPROJECTTITLE, LTDTKeys.NEWPROJECT);
41  						//ProjectSave.save(props, window);
42  					//else {
43  						//ProjectSave.save(props, window);
44  					//}
45  					*/
46  					int status = ProjectSave.save(props, window);
47  					//if (status==LTDTKeys.SUCCESS) {
48  					//	JOptionPane.showMessageDialog(
49  					//			window, 
50  					//			"Project "+props.getProperty(LTDTKeys.PROJECTNAME)+" saved successfully");	
51  					//}
52  					window.dictionaryMap.clear();
53  					System.exit(0);
54  					break;
55  				case JOptionPane.NO_OPTION:
56  					window.dictionaryMap.clear();
57  					System.exit(0);
58  					break;	
59  				case JOptionPane.CANCEL_OPTION:
60  					break;
61  				default:;
62  			}
63  		}
64  		else {
65  			window.dictionaryMap.clear();
66  			System.exit(0);
67  		}
68  	}
69  
70  }