Feed to panel partially works
This commit is contained in:
parent
d30944ebec
commit
d5df5d7042
@ -1028,6 +1028,14 @@ public class FilePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public void showFeedToPanel(List<FileItem> items) {
|
||||
FilePanelTab tab = getCurrentTab();
|
||||
if (tab != null) {
|
||||
tab.showFeedToPanel(items);
|
||||
updatePathField();
|
||||
}
|
||||
}
|
||||
|
||||
public void navigateUp() {
|
||||
FilePanelTab tab = getCurrentTab();
|
||||
if (tab != null) {
|
||||
|
||||
@ -351,6 +351,42 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a custom list of items (e.g. search results).
|
||||
* This puts the tab in "search mode".
|
||||
*/
|
||||
public void showFeedToPanel(List<FileItem> items) {
|
||||
searchModeActive = true;
|
||||
this.currentDirectory = new File("Search results"); // Or something indicative
|
||||
|
||||
allItems.clear();
|
||||
allItems.addAll(items);
|
||||
|
||||
tableModel.setItems(new ArrayList<>(items));
|
||||
|
||||
if (sortColumn >= 0) {
|
||||
sortItemsByColumn(sortColumn, sortAscending);
|
||||
}
|
||||
|
||||
if (viewMode == ViewMode.BRIEF) {
|
||||
tableModel.calculateBriefLayout();
|
||||
tableModel.fireTableStructureChanged();
|
||||
} else {
|
||||
tableModel.fireTableDataChanged();
|
||||
}
|
||||
|
||||
updateColumnRenderers();
|
||||
updateColumnWidths();
|
||||
fileTable.revalidate();
|
||||
fileTable.repaint();
|
||||
|
||||
if (tableModel.getRowCount() > 0) {
|
||||
fileTable.setRowSelectionInterval(0, 0);
|
||||
}
|
||||
fileTable.requestFocusInWindow();
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
private void updateContentBorder() {
|
||||
if (tableScrollPane == null) {
|
||||
return;
|
||||
@ -1174,7 +1210,7 @@ public class FilePanelTab extends JPanel {
|
||||
filterTextField.requestFocusInWindow();
|
||||
}
|
||||
|
||||
private void enterSearchMode() {
|
||||
public void enterSearchMode() {
|
||||
searchModeActive = true;
|
||||
filterTextField.setText("");
|
||||
filterPanel.setVisible(true);
|
||||
@ -1182,7 +1218,7 @@ public class FilePanelTab extends JPanel {
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void exitSearchMode() {
|
||||
public void exitSearchMode() {
|
||||
searchModeActive = false;
|
||||
filterPanel.setVisible(false);
|
||||
filterTextField.setText("");
|
||||
@ -1638,6 +1674,8 @@ public class FilePanelTab extends JPanel {
|
||||
* Refresh the current directory while attempting to preserve selection and focus.
|
||||
*/
|
||||
public void refresh(boolean requestFocus) {
|
||||
if (searchModeActive) return;
|
||||
|
||||
if (isFtpTab) {
|
||||
loadFtpDirectory(ftpCurrentPath, false, requestFocus);
|
||||
return;
|
||||
@ -4133,6 +4171,9 @@ public class FilePanelTab extends JPanel {
|
||||
java.util.List<FileItem> items = tableModel.items;
|
||||
if (items.isEmpty()) return;
|
||||
|
||||
// In search mode (no real directory), ".." might not be present or shouldn't be special
|
||||
boolean hasParentDir = !items.isEmpty() && items.get(0).getName().equals("..");
|
||||
|
||||
// Remember currently selected item name to restore selection after sort
|
||||
final String selectedItemName;
|
||||
FileItem focused = getFocusedItem();
|
||||
@ -4140,7 +4181,7 @@ public class FilePanelTab extends JPanel {
|
||||
|
||||
// Extract and remember the ".." (parent directory) entry if present
|
||||
FileItem parentDir = null;
|
||||
if (!items.isEmpty() && items.get(0).getName().equals("..")) {
|
||||
if (hasParentDir) {
|
||||
parentDir = items.remove(0);
|
||||
}
|
||||
|
||||
|
||||
@ -1500,6 +1500,10 @@ public class MainWindow extends JFrame {
|
||||
switchPanels();
|
||||
}
|
||||
|
||||
public FilePanel getActivePanel() {
|
||||
return activePanel;
|
||||
}
|
||||
|
||||
private void updateCommandLinePrompt() {
|
||||
if (cmdLabel == null) return;
|
||||
|
||||
|
||||
@ -373,9 +373,13 @@ public class SearchDialog extends JDialog {
|
||||
JButton openButton = new JButton("Open location");
|
||||
openButton.addActionListener(e -> openSelectedFile());
|
||||
|
||||
JButton feedToPanelButton = new JButton("Feed to panel");
|
||||
feedToPanelButton.addActionListener(e -> feedToActivePanel());
|
||||
|
||||
bottomButtonPanel.add(viewButton);
|
||||
bottomButtonPanel.add(editButton);
|
||||
bottomButtonPanel.add(openButton);
|
||||
bottomButtonPanel.add(feedToPanelButton);
|
||||
bottomButtonPanel.add(cancelButton);
|
||||
|
||||
JPanel bottomPanel = new JPanel(new BorderLayout());
|
||||
@ -802,6 +806,25 @@ public class SearchDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Feed all search results to the active panel in MainWindow.
|
||||
*/
|
||||
private void feedToActivePanel() {
|
||||
if (tableModel.getRowCount() == 0) {
|
||||
JOptionPane.showMessageDialog(this, "No search results to feed to panel.", "Information", JOptionPane.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
java.awt.Window w = SwingUtilities.getWindowAncestor(this);
|
||||
if (w instanceof MainWindow mw) {
|
||||
FilePanel active = mw.getActivePanel();
|
||||
if (active != null) {
|
||||
active.showFeedToPanel(tableModel.getResults());
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the selected file in the internal viewer (read-only)
|
||||
*/
|
||||
@ -917,6 +940,10 @@ public class SearchDialog extends JDialog {
|
||||
return results.get(row);
|
||||
}
|
||||
|
||||
public List<FileItem> getResults() {
|
||||
return new ArrayList<>(results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return results.size();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user