refresh search results tab

This commit is contained in:
Radek Davidek 2026-04-22 17:48:33 +02:00
parent d5df5d7042
commit f8f138d98d
3 changed files with 82 additions and 13 deletions

View File

@ -15,7 +15,7 @@ import java.io.InputStreamReader;
*/ */
public class MainApp { public class MainApp {
public static final String APP_VERSION = "1.4.1"; public static final String APP_VERSION = "1.4.2";
public enum OS { public enum OS {
WINDOWS, LINUX, MACOS, UNKNOWN WINDOWS, LINUX, MACOS, UNKNOWN

View File

@ -380,6 +380,45 @@ public class FilePanel extends JPanel {
}); });
} }
public void showFeedToPanel(List<FileItem> items) {
addNewSearchTab(items);
}
public FilePanelTab addNewSearchTab(List<FileItem> items) {
ViewMode currentMode = getViewMode();
FilePanelTab tab = new FilePanelTab(null, true);
if (appConfig != null) tab.setAppConfig(appConfig);
tab.setActive(this.active);
tab.setOnDirectoryChanged(() -> {
updateTabTitle(tab);
if (onDirectoryChangedAll != null) onDirectoryChangedAll.run();
});
tab.setOnSwitchPanelRequested(switchPanelCallback);
if (onTableCreated != null) {
onTableCreated.accept(tab.getFileTable());
}
if (currentMode != null) {
tab.setViewMode(currentMode);
}
applyConfiguredAppearance(tab);
tabbedPane.addTab("Search Results", tab);
tab.showFeedToPanel(items);
tabbedPane.setSelectedComponent(tab);
addMouseListenerToComponents(tab);
updateTabStyles();
SwingUtilities.invokeLater(() -> {
tab.getFileTable().requestFocusInWindow();
tab.ensureRenderers();
});
return tab;
}
/** /**
* Add a new tab and explicitly set the ViewMode for this tab. * Add a new tab and explicitly set the ViewMode for this tab.
*/ */
@ -754,8 +793,13 @@ public class FilePanel extends JPanel {
for (int i = 0; i < tabbedPane.getTabCount(); i++) { for (int i = 0; i < tabbedPane.getTabCount(); i++) {
Component c = tabbedPane.getComponentAt(i); Component c = tabbedPane.getComponentAt(i);
if (c instanceof FilePanelTab tab) { if (c instanceof FilePanelTab tab) {
String title;
if (tab.isSearchModeActive()) {
title = "Search Results";
} else {
File dir = tab.getCurrentDirectory(); File dir = tab.getCurrentDirectory();
String title = getTabTitle(dir != null ? dir.getAbsolutePath() : ""); title = getTabTitle(dir != null ? dir.getAbsolutePath() : "");
}
if (i == selectedIndex) { if (i == selectedIndex) {
// Active tab: bold font // Active tab: bold font
@ -1028,14 +1072,6 @@ public class FilePanel extends JPanel {
} }
} }
public void showFeedToPanel(List<FileItem> items) {
FilePanelTab tab = getCurrentTab();
if (tab != null) {
tab.showFeedToPanel(items);
updatePathField();
}
}
public void navigateUp() { public void navigateUp() {
FilePanelTab tab = getCurrentTab(); FilePanelTab tab = getCurrentTab();
if (tab != null) { if (tab != null) {

View File

@ -357,7 +357,6 @@ public class FilePanelTab extends JPanel {
*/ */
public void showFeedToPanel(List<FileItem> items) { public void showFeedToPanel(List<FileItem> items) {
searchModeActive = true; searchModeActive = true;
this.currentDirectory = new File("Search results"); // Or something indicative
allItems.clear(); allItems.clear();
allItems.addAll(items); allItems.addAll(items);
@ -1674,7 +1673,37 @@ public class FilePanelTab extends JPanel {
* Refresh the current directory while attempting to preserve selection and focus. * Refresh the current directory while attempting to preserve selection and focus.
*/ */
public void refresh(boolean requestFocus) { public void refresh(boolean requestFocus) {
if (searchModeActive) return; if (searchModeActive) {
// In search results mode, refresh means checking if items still exist
List<FileItem> itemsToRemove = new ArrayList<>();
for (FileItem item : allItems) {
if (item.getFile() != null && !item.getFile().exists()) {
itemsToRemove.add(item);
}
}
if (!itemsToRemove.isEmpty()) {
allItems.removeAll(itemsToRemove);
tableModel.setItems(new ArrayList<>(allItems));
if (sortColumn >= 0) {
sortItemsByColumn(sortColumn, sortAscending);
}
if (viewMode == ViewMode.BRIEF) {
tableModel.calculateBriefLayout();
tableModel.fireTableStructureChanged();
} else {
tableModel.fireTableDataChanged();
}
updateColumnRenderers();
updateColumnWidths();
fileTable.revalidate();
fileTable.repaint();
updateStatus();
}
return;
}
if (isFtpTab) { if (isFtpTab) {
loadFtpDirectory(ftpCurrentPath, false, requestFocus); loadFtpDirectory(ftpCurrentPath, false, requestFocus);
@ -4384,6 +4413,10 @@ public class FilePanelTab extends JPanel {
return fileTable; return fileTable;
} }
public boolean isSearchModeActive() {
return searchModeActive;
}
public File getCurrentDirectory() { public File getCurrentDirectory() {
return currentDirectory; return currentDirectory;
} }