Skip to content

Commit

Permalink
Fix delete folder through File Explorer apache#3620
Browse files Browse the repository at this point in the history
  • Loading branch information
nadment committed Feb 13, 2024
1 parent 18ccdf6 commit cd2a333
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,6 @@ public void determineRootFolderName(HopGui hopGui) {
}

protected void createTree(Composite parent) {
PropsUi props = PropsUi.getInstance();

// Create composite
//
Composite composite = new Composite(parent, SWT.BORDER);
Expand Down Expand Up @@ -507,20 +505,23 @@ private void deleteFile(TreeItem item) {
try {
TreeItemFolder tif = (TreeItemFolder) item.getData();
if (tif != null && tif.fileType != null) {

FileObject fileObject = HopVfs.getFileObject(tif.path);

String header = BaseMessages.getString(PKG, "ExplorerPerspective.DeleteFile.Confirmation.Header");
String message = BaseMessages.getString(PKG, "ExplorerPerspective.DeleteFile.Confirmation.Message");
if ( fileObject.isFolder() ) {
header = BaseMessages.getString(PKG, "ExplorerPerspective.DeleteFolder.Confirmation.Header");
message = BaseMessages.getString(PKG, "ExplorerPerspective.DeleteFolder.Confirmation.Message");
}

MessageBox box = new MessageBox(hopGui.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(
BaseMessages.getString(PKG, "ExplorerPerspective.DeleteFile.Confirmation.Header"));
box.setMessage(
BaseMessages.getString(PKG, "ExplorerPerspective.DeleteFile.Confirmation.Message")
+ Const.CR
+ Const.CR
+ tif.path);
box.setText(header);
box.setMessage(message + Const.CR + Const.CR + tif.path);

int answer = box.open();
if ((answer & SWT.YES) != 0) {
FileObject fileObject = HopVfs.getFileObject(tif.path);
boolean deleted = fileObject.delete();
if (deleted) {
int deleted = fileObject.deleteAll();
if (deleted>0) {
refresh();
}
}
Expand Down Expand Up @@ -582,8 +583,6 @@ private void renameFile(TreeItem item) {
}

protected void createTabFolder(Composite parent) {
PropsUi props = PropsUi.getInstance();

tabFolder = new CTabFolder(parent, SWT.MULTI | SWT.BORDER);
tabFolder.addCTabFolder2Listener(
new CTabFolder2Adapter() {
Expand Down Expand Up @@ -708,7 +707,6 @@ public void contentSafe(Object parentObject) {
}
});

PropsUi props = PropsUi.getInstance();
// Create composite for editor and buttons
//
Composite composite = new Composite(tabFolder, SWT.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ ExplorerPerspective.Error.TreeRefresh.Header=Error
ExplorerPerspective.Error.TreeRefresh.Message=Error refreshing file explorer tree
ExplorerPerspective.DeleteFile.Confirmation.Header=Delete file?
ExplorerPerspective.DeleteFile.Confirmation.Message=Are you sure you want to delete the following file?
ExplorerPerspective.DeleteFolder.Confirmation.Header=Delete folder?
ExplorerPerspective.DeleteFolder.Confirmation.Message=Are you sure you want to delete the following folder and all it's files?
ExplorerPerspective.ToolbarElement.Open.Tooltip=Open selected file
ExplorerPerspective.ToolbarElement.Delete.Tooltip=Delete selected file
ExplorerPerspective.ToolbarElement.Rename.Tooltip=Rename the selected file
Expand Down

0 comments on commit cd2a333

Please sign in to comment.