focus while copying
This commit is contained in:
parent
b05a6fa3b7
commit
bf735d99f7
@ -136,6 +136,10 @@ public class AppConfig {
|
||||
return properties.getProperty("leftPanel.tab." + index + ".path", null);
|
||||
}
|
||||
|
||||
public String getLeftPanelTabFocusedItem(int index) {
|
||||
return properties.getProperty("leftPanel.tab." + index + ".focusedItem", null);
|
||||
}
|
||||
|
||||
public String getLeftPanelTabViewMode(int index) {
|
||||
return properties.getProperty("leftPanel.tab." + index + ".viewMode", "FULL");
|
||||
}
|
||||
@ -144,11 +148,16 @@ public class AppConfig {
|
||||
return Integer.parseInt(properties.getProperty("leftPanel.selectedIndex", "0"));
|
||||
}
|
||||
|
||||
public void saveLeftPanelTabs(java.util.List<String> paths, java.util.List<String> viewModes, int selectedIndex) {
|
||||
public void saveLeftPanelTabs(java.util.List<String> paths, java.util.List<String> viewModes, java.util.List<String> focusedItems, int selectedIndex) {
|
||||
properties.setProperty("leftPanel.tabs.count", String.valueOf(paths.size()));
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
properties.setProperty("leftPanel.tab." + i + ".path", paths.get(i));
|
||||
properties.setProperty("leftPanel.tab." + i + ".viewMode", viewModes.get(i));
|
||||
if (focusedItems != null && i < focusedItems.size() && focusedItems.get(i) != null) {
|
||||
properties.setProperty("leftPanel.tab." + i + ".focusedItem", focusedItems.get(i));
|
||||
} else {
|
||||
properties.remove("leftPanel.tab." + i + ".focusedItem");
|
||||
}
|
||||
}
|
||||
properties.setProperty("leftPanel.selectedIndex", String.valueOf(selectedIndex));
|
||||
}
|
||||
@ -157,6 +166,10 @@ public class AppConfig {
|
||||
return Integer.parseInt(properties.getProperty("rightPanel.tabs.count", "0"));
|
||||
}
|
||||
|
||||
public String getRightPanelTabFocusedItem(int index) {
|
||||
return properties.getProperty("rightPanel.tab." + index + ".focusedItem", null);
|
||||
}
|
||||
|
||||
public String getRightPanelTabPath(int index) {
|
||||
return properties.getProperty("rightPanel.tab." + index + ".path", null);
|
||||
}
|
||||
@ -169,11 +182,16 @@ public class AppConfig {
|
||||
return Integer.parseInt(properties.getProperty("rightPanel.selectedIndex", "0"));
|
||||
}
|
||||
|
||||
public void saveRightPanelTabs(java.util.List<String> paths, java.util.List<String> viewModes, int selectedIndex) {
|
||||
public void saveRightPanelTabs(java.util.List<String> paths, java.util.List<String> viewModes, java.util.List<String> focusedItems, int selectedIndex) {
|
||||
properties.setProperty("rightPanel.tabs.count", String.valueOf(paths.size()));
|
||||
for (int i = 0; i < paths.size(); i++) {
|
||||
properties.setProperty("rightPanel.tab." + i + ".path", paths.get(i));
|
||||
properties.setProperty("rightPanel.tab." + i + ".viewMode", viewModes.get(i));
|
||||
if (focusedItems != null && i < focusedItems.size() && focusedItems.get(i) != null) {
|
||||
properties.setProperty("rightPanel.tab." + i + ".focusedItem", focusedItems.get(i));
|
||||
} else {
|
||||
properties.remove("rightPanel.tab." + i + ".focusedItem");
|
||||
}
|
||||
}
|
||||
properties.setProperty("rightPanel.selectedIndex", String.valueOf(selectedIndex));
|
||||
}
|
||||
|
||||
@ -326,6 +326,18 @@ public class FilePanel extends JPanel {
|
||||
return modes;
|
||||
}
|
||||
|
||||
public java.util.List<String> getTabFocusedItems() {
|
||||
java.util.List<String> items = new java.util.ArrayList<>();
|
||||
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
||||
Component c = tabbedPane.getComponentAt(i);
|
||||
if (c instanceof FilePanelTab) {
|
||||
cz.kamma.kfmanager.model.FileItem focused = ((FilePanelTab) c).getFocusedItem();
|
||||
items.add(focused != null ? focused.getName() : null);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public int getSelectedTabIndex() {
|
||||
return tabbedPane.getSelectedIndex();
|
||||
}
|
||||
@ -333,7 +345,7 @@ public class FilePanel extends JPanel {
|
||||
/**
|
||||
* Restore the set of tabs according to specified paths and view modes. If the list is empty, nothing happens.
|
||||
*/
|
||||
public void restoreTabs(java.util.List<String> paths, java.util.List<String> viewModes, int selectedIndex) {
|
||||
public void restoreTabs(java.util.List<String> paths, java.util.List<String> viewModes, java.util.List<String> focusedItems, int selectedIndex) {
|
||||
if (paths == null || paths.isEmpty()) return;
|
||||
|
||||
tabbedPane.removeAll();
|
||||
@ -349,6 +361,13 @@ public class FilePanel extends JPanel {
|
||||
}
|
||||
}
|
||||
addNewTabWithMode(p, mode);
|
||||
|
||||
// Restore focus to the specific item if provided
|
||||
if (focusedItems != null && i < focusedItems.size() && focusedItems.get(i) != null) {
|
||||
final String focusName = focusedItems.get(i);
|
||||
final FilePanelTab currentTab = (FilePanelTab) tabbedPane.getComponentAt(i);
|
||||
SwingUtilities.invokeLater(() -> currentTab.selectItem(focusName));
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedIndex >= 0 && selectedIndex < tabbedPane.getTabCount()) {
|
||||
@ -632,9 +651,13 @@ public class FilePanel extends JPanel {
|
||||
}
|
||||
|
||||
public void loadDirectory(File directory) {
|
||||
loadDirectory(directory, true);
|
||||
}
|
||||
|
||||
public void loadDirectory(File directory, boolean requestFocus) {
|
||||
FilePanelTab tab = getCurrentTab();
|
||||
if (tab != null) {
|
||||
tab.loadDirectory(directory);
|
||||
tab.loadDirectory(directory, true, requestFocus);
|
||||
updatePathField();
|
||||
}
|
||||
}
|
||||
|
||||
@ -790,10 +790,14 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
|
||||
public void loadDirectory(File directory) {
|
||||
loadDirectory(directory, true);
|
||||
loadDirectory(directory, true, true);
|
||||
}
|
||||
|
||||
private void loadDirectory(File directory, boolean autoSelectFirst) {
|
||||
public void loadDirectory(File directory, boolean autoSelectFirst) {
|
||||
loadDirectory(directory, autoSelectFirst, true);
|
||||
}
|
||||
|
||||
public void loadDirectory(File directory, boolean autoSelectFirst, boolean requestFocus) {
|
||||
// If we are switching directories, cleanup any previously extracted archive temp dirs
|
||||
cleanupArchiveTempDirIfNeeded(directory);
|
||||
if (directory == null || !directory.isDirectory()) {
|
||||
@ -848,15 +852,19 @@ public class FilePanelTab extends JPanel {
|
||||
fileTable.setRowSelectionInterval(selRow, selRow);
|
||||
fileTable.scrollRectToVisible(fileTable.getCellRect(selRow, selCol, true));
|
||||
}
|
||||
fileTable.requestFocusInWindow();
|
||||
if (requestFocus) {
|
||||
fileTable.requestFocusInWindow();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (autoSelectFirst && fileTable.getRowCount() > 0) {
|
||||
int startIndex = 0;
|
||||
fileTable.setRowSelectionInterval(startIndex, startIndex);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try { fileTable.requestFocusInWindow(); } catch (Exception ignore) {}
|
||||
});
|
||||
if (requestFocus) {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
try { fileTable.requestFocusInWindow(); } catch (Exception ignore) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -132,14 +132,16 @@ public class MainWindow extends JFrame {
|
||||
if (leftCount > 0) {
|
||||
java.util.List<String> paths = new java.util.ArrayList<>();
|
||||
java.util.List<String> modes = new java.util.ArrayList<>();
|
||||
java.util.List<String> focusedItems = new java.util.ArrayList<>();
|
||||
for (int i = 0; i < leftCount; i++) {
|
||||
String p = config.getLeftPanelTabPath(i);
|
||||
if (p == null) p = System.getProperty("user.home");
|
||||
paths.add(p);
|
||||
modes.add(config.getLeftPanelTabViewMode(i));
|
||||
focusedItems.add(config.getLeftPanelTabFocusedItem(i));
|
||||
}
|
||||
int sel = config.getLeftPanelSelectedIndex();
|
||||
leftPanel.restoreTabs(paths, modes, sel);
|
||||
leftPanel.restoreTabs(paths, modes, focusedItems, sel);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore and keep default
|
||||
@ -150,14 +152,16 @@ public class MainWindow extends JFrame {
|
||||
if (rightCount > 0) {
|
||||
java.util.List<String> paths = new java.util.ArrayList<>();
|
||||
java.util.List<String> modes = new java.util.ArrayList<>();
|
||||
java.util.List<String> focusedItems = new java.util.ArrayList<>();
|
||||
for (int i = 0; i < rightCount; i++) {
|
||||
String p = config.getRightPanelTabPath(i);
|
||||
if (p == null) p = System.getProperty("user.home");
|
||||
paths.add(p);
|
||||
modes.add(config.getRightPanelTabViewMode(i));
|
||||
focusedItems.add(config.getRightPanelTabFocusedItem(i));
|
||||
}
|
||||
int sel = config.getRightPanelSelectedIndex();
|
||||
rightPanel.restoreTabs(paths, modes, sel);
|
||||
rightPanel.restoreTabs(paths, modes, focusedItems, sel);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// ignore and keep default
|
||||
@ -1115,10 +1119,10 @@ public class MainWindow extends JFrame {
|
||||
private void copyFiles() {
|
||||
List<FileItem> selectedItems = activePanel.getSelectedItems();
|
||||
if (selectedItems.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"No files selected",
|
||||
"Copy",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"No files selected",
|
||||
"Copy",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1147,10 +1151,10 @@ public class MainWindow extends JFrame {
|
||||
private void moveFiles() {
|
||||
List<FileItem> selectedItems = activePanel.getSelectedItems();
|
||||
if (selectedItems.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"No files selected",
|
||||
"Move",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(this,
|
||||
"No files selected",
|
||||
"Move",
|
||||
JOptionPane.INFORMATION_MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1288,7 +1292,7 @@ public class MainWindow extends JFrame {
|
||||
final File finalTargetZip = targetZip;
|
||||
performFileOperation((callback) -> {
|
||||
FileOperations.zip(selectedItems, finalTargetZip, callback);
|
||||
}, "Zipped into " + zipName, false, targetPanel);
|
||||
}, "Zipped into " + zipName, false, targetPanel, targetPanel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1824,12 +1828,14 @@ public class MainWindow extends JFrame {
|
||||
progressDialog.dispose();
|
||||
for (FilePanel panel : panelsToRefresh) {
|
||||
if (panel.getCurrentDirectory() != null) {
|
||||
panel.loadDirectory(panel.getCurrentDirectory());
|
||||
panel.loadDirectory(panel.getCurrentDirectory(), false);
|
||||
}
|
||||
}
|
||||
|
||||
if (activePanel != null && activePanel.getFileTable() != null) {
|
||||
activePanel.getFileTable().requestFocusInWindow();
|
||||
}
|
||||
|
||||
if (callback.isCancelled()) {
|
||||
JOptionPane.showMessageDialog(MainWindow.this, "Operation was cancelled by user.");
|
||||
if (activePanel != null && activePanel.getFileTable() != null) {
|
||||
@ -1889,8 +1895,9 @@ public class MainWindow extends JFrame {
|
||||
try {
|
||||
java.util.List<String> leftPaths = leftPanel.getTabPaths();
|
||||
java.util.List<String> leftModes = leftPanel.getTabViewModes();
|
||||
java.util.List<String> leftFocused = leftPanel.getTabFocusedItems();
|
||||
int leftSelected = leftPanel.getSelectedTabIndex();
|
||||
config.saveLeftPanelTabs(leftPaths, leftModes, leftSelected);
|
||||
config.saveLeftPanelTabs(leftPaths, leftModes, leftFocused, leftSelected);
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
@ -1898,8 +1905,9 @@ public class MainWindow extends JFrame {
|
||||
try {
|
||||
java.util.List<String> rightPaths = rightPanel.getTabPaths();
|
||||
java.util.List<String> rightModes = rightPanel.getTabViewModes();
|
||||
java.util.List<String> rightFocused = rightPanel.getTabFocusedItems();
|
||||
int rightSelected = rightPanel.getSelectedTabIndex();
|
||||
config.saveRightPanelTabs(rightPaths, rightModes, rightSelected);
|
||||
config.saveRightPanelTabs(rightPaths, rightModes, rightFocused, rightSelected);
|
||||
} catch (Exception ex) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 MiB |
Loading…
x
Reference in New Issue
Block a user