* @param setDetails if true, then set the file details (if not merging)
*/
static void loadProjectFile(final ActionEvent e, final File f, final boolean merging, final boolean setDetails) {
ActionRouter.getInstance().doActionNow(new ActionEvent(e.getSource(), e.getID(), ActionNames.STOP_THREAD));
final GuiPackage guiPackage = GuiPackage.getInstance();
if (f != null) {
InputStream reader = null;
try {
if (merging) {
log.info("Merging file: " + f);
} else {
log.info("Loading file: " + f);
// TODO should this be done even if not a full test plan?
// and what if load fails?
if(setDetails) {
FileServer.getFileServer().setBaseForScript(f);
}
}
reader = new FileInputStream(f);
final HashTree tree = SaveService.loadTree(reader);
final boolean isTestPlan = insertLoadedTree(e.getID(), tree, merging);
// don't change name if merging
if (!merging && isTestPlan && setDetails) {
// TODO should setBaseForScript be called here rather than above?
guiPackage.setTestPlanFile(f.getAbsolutePath());
}
} catch (NoClassDefFoundError ex) {// Allow for missing optional jars
reportError("Missing jar file", ex, true);
} catch (ConversionException ex) {
log.warn("Could not convert file "+ex);
JMeterUtils.reportErrorToUser(SaveService.CEtoString(ex));
} catch (IOException ex) {
reportError("Error reading file: ", ex, false);
} catch (Exception ex) {
reportError("Unexpected error", ex, true);
} finally {
JOrphanUtils.closeQuietly(reader);
}
guiPackage.updateCurrentGui();
guiPackage.getMainFrame().repaint();
}
}