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 38 public class Close implements Command 39 { 40 41 private static Set commands = new HashSet (); 42 static { 43 commands.add("close"); 44 } 45 46 49 public Close() 50 { 51 } 52 53 58 public Set getActionNames() 59 { 60 return commands; 61 } 62 63 68 public void doAction(ActionEvent e) 69 { 70 ActionRouter.getInstance().doActionNow( 71 new ActionEvent (e.getSource(), e.getID(), CheckDirty.CHECK_DIRTY)); 72 GuiPackage guiPackage = GuiPackage.getInstance(); 73 if (guiPackage.isDirty()) 74 { 75 if (JOptionPane 76 .showConfirmDialog( 77 GuiPackage.getInstance().getMainFrame(), 78 JMeterUtils.getResString("cancel_new_to_save"), 79 JMeterUtils.getResString("Save?"), 80 JOptionPane.YES_NO_OPTION, 81 JOptionPane.QUESTION_MESSAGE) 82 == JOptionPane.YES_OPTION) 83 { 84 ActionRouter.getInstance().doActionNow( 85 new ActionEvent ( 86 e.getSource(), 87 e.getID(), 88 Save.SAVE)); 89 } 90 } 91 guiPackage.getTreeModel().clearTestPlan(); 92 guiPackage.getTreeListener().getJTree().setSelectionRow(1); 93 94 Save save = 96 (Save) ActionRouter.getInstance().getAction( 97 "save", 98 "org.apache.jmeter.gui.action.Save"); 99 save.setTestPlanFile(null); 100 101 ActionRouter.getInstance().actionPerformed( 102 new ActionEvent (e.getSource(), e.getID(), CheckDirty.ADD_ALL)); 103 } 104 } 105 | Popular Tags |