/** * Inserts the tree into the GUI. * Does not check if the previous tree has been saved. * Clears the existing GUI test plan if we are inserting a complete plan. * @param id the id for the ActionEvent that is created * @param tree the tree to load * @return true if the loaded tree was a full test plan * @throws IllegalUserActionException if the tree cannot be merged at the selected position or the tree is empty */ // Called by JMeter#startGui() public static boolean insertLoadedTree(final int id, final HashTree tree) throws IllegalUserActionException { return insertLoadedTree(id, tree, false); }
/** * Loads or merges a file into the current GUI, reporting any errors to the user. * If the file is a complete test plan, sets the GUI test plan file name * * @param e the event that triggered the action * @param f the file to load * @param merging if true, then try to merge the file into the current GUI. */ static void loadProjectFile(final ActionEvent e, final File f, final boolean merging) { loadProjectFile(e, f, merging, true); }
final boolean isTestPlan = insertLoadedTree(e.getID(), tree, merging); reportError("Missing jar file. {}", ex, true); } catch (ConversionException ex) { if (log.isWarnEnabled()) { reportError("Error reading file. {}", ex, false); } catch (StreamException ex) { Throwable exceptionToDisplay = ex; exceptionToDisplay = ex.getCause(); reportError("Error in XML format. {}", exceptionToDisplay, false); } catch (Exception ex) { reportError("Unexpected error. {}", ex, true);
/** * Loads dragged file asking before for save if current open file is dirty. * @param e {@link ActionEvent} * @param file File to Load */ public static void loadProject(ActionEvent e, File file) { if(!Close.performAction(e)) { return; } Load.loadProjectFile(e, file, false); } }
Load.insertLoadedTree(1, tree); } catch (ConversionException e) { log.error("Failure loading test file", e);
@Override public void doActionAfterCheck(final ActionEvent e) { final JFileChooser chooser = FileDialoger.promptToOpenFile(new String[] { ".jmx" }); //$NON-NLS-1$ if (chooser == null) { return; } final File selectedFile = chooser.getSelectedFile(); if (selectedFile != null) { final boolean merging = e.getActionCommand().equals(ActionNames.MERGE); // We must ask the user if it is ok to close current project if (!merging) { // i.e. it is OPEN if (!Close.performAction(e)) { return; } } loadProjectFile(e, selectedFile, merging); } }
@Override public void doActionAfterCheck(ActionEvent e) { // Get the file name of the current project String projectFile = GuiPackage.getInstance().getTestPlanFile(); // Check if the user has loaded any file if (projectFile == null) { return; } // Check if the user wants to drop any changes ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.CHECK_DIRTY)); GuiPackage guiPackage = GuiPackage.getInstance(); if (guiPackage.isDirty()) { // Check if the user wants to revert int response = JOptionPane.showConfirmDialog(GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("cancel_revert_project"), // $NON-NLS-1$ JMeterUtils.getResString("revert_project?"), // $NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { // Close the current project Close.closeProject(e); // Reload the project Load.loadProjectFile(e, new File(projectFile), false); } } } }
? new File(parent, template.getFileName()) : new File(JMeterUtils.getJMeterHome(), template.getFileName()); Load.loadProjectFile(actionEvent, fileToCopy, !isTestPlan, false); this.setVisible(false);