/** * Updates the current case to the given case and fires off the appropriate property-change * * @param newCase the new current case */ private static void changeCase(Case newCase) { Case oldCase = Case.currentCase; Case.currentCase = null; String oldCaseName = oldCase != null ? oldCase.name : ""; doCaseChange(null); // closes windows, etc pcs.firePropertyChange(CASE_CURRENT_CASE, oldCase, null); doCaseNameChange(""); pcs.firePropertyChange(CASE_NAME, oldCaseName, ""); if (newCase != null) { currentCase = newCase; pcs.firePropertyChange(CASE_CURRENT_CASE, null, currentCase); doCaseChange(currentCase); pcs.firePropertyChange(CASE_NAME, "", currentCase.name); doCaseNameChange(currentCase.name); RecentCases.getInstance() .addRecentCase(currentCase.name, currentCase.configFilePath); // update the recent cases } }
/** * Updates the case name. * * @param oldCaseName the old case name that wants to be updated * @param oldPath the old path that wants to be updated * @param newCaseName the new case name * @param newPath the new path */ void updateCaseName(String oldCaseName, String oldPath, String newCaseName, String newPath) throws CaseActionException { try { xmlcm.setCaseName(newCaseName); // set the case name = newCaseName; // change the local value RecentCases.getInstance() .updateRecentCase(oldCaseName, oldPath, newCaseName, newPath); // update the recent case pcs.firePropertyChange(CASE_NAME, oldCaseName, newCaseName); doCaseNameChange(newCaseName); } catch (Exception e) { throw new CaseActionException("Error while trying to update the case name.", e); } }
/** * Delete this case. This methods delete all folders and files of this case. * * @param caseDir case dir to delete * @throws CaseActionException exception throw if case could not be deleted */ void deleteCase(File caseDir) throws CaseActionException { logger.log(Level.INFO, "Deleting case.\ncaseDir: {0}", caseDir); try { xmlcm.close(); // close the xmlcm boolean result = deleteCaseDirectory(caseDir); // delete the directory RecentCases.getInstance() .removeRecentCase(this.name, this.configFilePath); // remove it from the recent case Case.changeCase(null); if (result == false) { throw new CaseActionException("Error deleting the case dir: " + caseDir); } } catch (Exception ex) { logger.log(Level.SEVERE, "Error deleting the current case dir: " + caseDir, ex); throw new CaseActionException("Error deleting the case dir: " + caseDir, ex); } }