1 18 19 package org.apache.jmeter.gui.action; 20 21 import java.awt.event.ActionEvent ; 22 import java.util.HashSet ; 23 import java.util.Set ; 24 25 import javax.swing.JOptionPane ; 26 27 import org.apache.jmeter.gui.GuiPackage; 28 import org.apache.jmeter.util.JMeterUtils; 29 30 35 public class ExitCommand implements Command 36 { 37 38 public static final String EXIT = "exit"; 39 private static Set commands = new HashSet (); 40 static { 41 commands.add(EXIT); 42 } 43 44 47 public ExitCommand() 48 {} 49 50 55 public Set getActionNames() 56 { 57 return commands; 58 } 59 60 65 public void doAction(ActionEvent e) 66 { 67 ActionRouter.getInstance().doActionNow( 68 new ActionEvent (e.getSource(), e.getID(), CheckDirty.CHECK_DIRTY)); 69 if (GuiPackage.getInstance().isDirty()) 70 { 71 int chosenOption = 72 JOptionPane.showConfirmDialog( 73 GuiPackage.getInstance().getMainFrame(), 74 JMeterUtils.getResString("cancel_exit_to_save"), 75 JMeterUtils.getResString("Save?"), 76 JOptionPane.YES_NO_CANCEL_OPTION, 77 JOptionPane.QUESTION_MESSAGE); 78 if (chosenOption == JOptionPane.NO_OPTION) 79 { 80 System.exit(0); 81 } 82 else if (chosenOption == JOptionPane.YES_OPTION) 83 { 84 ActionRouter.getInstance().doActionNow( 85 new ActionEvent (e.getSource(), e.getID(), Save.SAVE_ALL_AS)); 86 if (!GuiPackage.getInstance().isDirty()) 87 { 88 System.exit(0); 89 } 90 } 91 } 92 else 93 { 94 System.exit(0); 95 } 96 } 97 } 98 | Popular Tags |