UI fixes for deleting

This commit is contained in:
Radek Davidek 2026-01-20 17:10:14 +01:00
parent 16f7ad3840
commit 17cdea5857
2 changed files with 28 additions and 5 deletions

View File

@ -1485,20 +1485,36 @@ public class FilePanelTab extends JPanel {
});
SwingUtilities.invokeLater(() -> {
progressDialog.dispose();
// Return focus to the application
Window win = SwingUtilities.getWindowAncestor(FilePanelTab.this);
if (win != null) {
win.toFront();
}
loadDirectory(getCurrentDirectory(), false);
// Use another invokeLater to ensure BRIEF mode layout is updated
SwingUtilities.invokeLater(() -> {
selectItemByIndex(rememberedIndex - 1);
selectItemByIndex(rememberedIndex);
fileTable.requestFocusInWindow();
});
});
} catch (Exception ex) {
SwingUtilities.invokeLater(() -> {
progressDialog.dispose();
// Return focus even on error
Window win = SwingUtilities.getWindowAncestor(FilePanelTab.this);
if (win != null) {
win.toFront();
}
JOptionPane.showMessageDialog(FilePanelTab.this, "Delete failed: " + ex.getMessage());
fileTable.requestFocusInWindow();
});
}
}).start();
progressDialog.setVisible(true);
} else {
fileTable.requestFocusInWindow();
}
});
menu.add(deleteItem);

View File

@ -1432,6 +1432,11 @@ public class MainWindow extends JFrame {
});
dialog.setVisible(true);
// Ensure focus returns to main window after dialog
this.toFront();
requestFocusInActivePanel();
Object selectedValue = pane.getValue();
if (selectedValue == null) return 2; // Cancel
if (selectedValue.equals(options[0])) return 0; // OK
@ -1483,7 +1488,7 @@ public class MainWindow extends JFrame {
if (activePanel != null && activePanel.getCurrentTab() != null) {
// Use another invokeLater to ensure BRIEF mode layout is updated
SwingUtilities.invokeLater(() -> {
activePanel.getCurrentTab().selectItemByIndex(rememberedIndex - 1);
activePanel.getCurrentTab().selectItemByIndex(rememberedIndex);
});
}
} catch (Exception ignore) {}
@ -2202,6 +2207,10 @@ public class MainWindow extends JFrame {
SwingUtilities.invokeLater(() -> {
progressDialog.dispose();
// Force the window to front and request focus after modal dialog
MainWindow.this.toFront();
for (FilePanel panel : panelsToRefresh) {
if (panel.getCurrentDirectory() != null) {
panel.loadDirectory(panel.getCurrentDirectory(), false, false);
@ -2212,9 +2221,7 @@ public class MainWindow extends JFrame {
SwingUtilities.invokeLater(postTask);
}
if (activePanel != null && activePanel.getFileTable() != null) {
activePanel.getFileTable().requestFocusInWindow();
}
requestFocusInActivePanel();
if (callback.isCancelled()) {
JOptionPane.showMessageDialog(MainWindow.this, "Operation was cancelled by user.");