}
}
else {
IDirectory directoryModel = ((DirectoryTreeNode) treeNode).getDirectory();
choice = view.confirmDeleteDirectory(directoryModel);
if (choice == view.DELETE_DIRECTORY) {
// If the current configuration is in the deleted directory, then it is deleted
// as
// well.
if (currentConfig != null) {
IDirectory directorySearch = currentConfig.getDirectory();
boolean isConfigurationInside = false;
while (!isConfigurationInside && directorySearch != null) {
isConfigurationInside = directorySearch.equals(directoryModel);
directorySearch = directorySearch.getDirectory();
}
if (isConfigurationInside) {
currentConfig = null;
applicationController.setConfig(null);
}
}
// Case if the root directory is the deleted directory.
if (directoryModel.equals(rootDirectory)) {
rootDirectory = null;
currentDirectory = null;
}
// Cas if the current directory is the deleted directory or is inside the
// deleted
// directory.
if (currentDirectory != null) {
IDirectory directorySearch = currentDirectory.getDirectory();
boolean isDirectoryInside = currentDirectory.equals(directoryModel);
while (!isDirectoryInside && directorySearch != null) {
isDirectoryInside = directorySearch.equals(directoryModel);
directorySearch = directorySearch.getDirectory();
}
if (isDirectoryInside) {
currentDirectory = null;
}
}
// IDirectory directory = DirectoryModelWrapperFactory.getInstance().unWrap(
// directoryModel);
IDirectory directory = AutoCopier.copyDirectoryToImpl(directoryModel);
// directoryModel);
try {
ConfigApi.deleteDirectory(directory);
IDirectory parentDirectory = directoryModel.getDirectory();
if (parentDirectory != null) {
parentDirectory.getSubDirectoriesList().remove(directoryModel);
}
}
catch (PersistenceException e) {
e.printStackTrace();
errorMessage("Error deleting directory " + directory.getName()