Github user FSchumacher commented on a diff in the pull request:

    https://github.com/apache/jmeter/pull/432#discussion_r235117129
  
    --- Diff: src/core/org/apache/jmeter/gui/action/SelectTemplatesDialog.java 
---
    @@ -137,67 +160,127 @@ private void checkDirtyAndLoad(final ActionEvent 
actionEvent)
             if (template == null) {
                 return;
             }
    +        
templateList.setValues(TemplateManager.getInstance().reset().getTemplateNames());
 // reload the templates before loading
    +        
             final boolean isTestPlan = template.isTestPlan();
             // Check if the user wants to drop any changes
    -        if (isTestPlan) {
    -            ActionRouter.getInstance().doActionNow(new 
ActionEvent(actionEvent.getSource(), actionEvent.getID(), 
ActionNames.CHECK_DIRTY));
    -            GuiPackage guiPackage = GuiPackage.getInstance();
    -            if (guiPackage.isDirty()) {
    -                // Check if the user wants to create from template
    -                int response = 
JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(),
    -                        
JMeterUtils.getResString("cancel_new_from_template"), // $NON-NLS-1$
    -                        JMeterUtils.getResString("template_load?"),  // 
$NON-NLS-1$
    -                        JOptionPane.YES_NO_CANCEL_OPTION,
    -                        JOptionPane.QUESTION_MESSAGE);
    -                if(response == JOptionPane.YES_OPTION) {
    -                    ActionRouter.getInstance().doActionNow(new 
ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.SAVE));
    -                }
    -                if (response == JOptionPane.CLOSED_OPTION || response == 
JOptionPane.CANCEL_OPTION) {
    -                    return; // Don't clear the plan
    -                }
    -            }
    +        if (isTestPlan && !checkDirty(actionEvent)) {
    +            return;
             }
             ActionRouter.getInstance().doActionNow(new 
ActionEvent(actionEvent.getSource(), actionEvent.getID(), 
ActionNames.STOP_THREAD));
             final File parent = template.getParent();
    -        final File fileToCopy = parent != null 
    +        File fileToCopy = parent != null 
                   ? new File(parent, template.getFileName())
    -              : new File(JMeterUtils.getJMeterHome(), 
template.getFileName());       
    -        Load.loadProjectFile(actionEvent, fileToCopy, !isTestPlan, false);
    -        this.setVisible(false);
    +              : new File(JMeterUtils.getJMeterHome(), 
template.getFileName());
    +        File temporaryGeneratedFile = null;
    --- End diff --
    
    Could this and the following try block be extracted into a method? That 
would enable us to show the intent of the code block by using the method name.


---

Reply via email to