added shortcut to home
This commit is contained in:
parent
6f626b7607
commit
30502d6136
@ -120,7 +120,17 @@ public class FilePanel extends JPanel {
|
|||||||
|
|
||||||
// Path field removed; path is shown in tab titles instead
|
// Path field removed; path is shown in tab titles instead
|
||||||
|
|
||||||
// Button for parent directory
|
// Buttons for navigation
|
||||||
|
JPanel navBtnPaths = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 0));
|
||||||
|
JButton homeButton = new JButton("~");
|
||||||
|
homeButton.setToolTipText("Home Directory");
|
||||||
|
homeButton.addActionListener(e -> {
|
||||||
|
FilePanelTab currentTab = getCurrentTab();
|
||||||
|
if (currentTab != null) {
|
||||||
|
currentTab.loadDirectory(new File(System.getProperty("user.home")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
JButton upButton = new JButton("↑");
|
JButton upButton = new JButton("↑");
|
||||||
upButton.setToolTipText("Parent directory (Backspace)");
|
upButton.setToolTipText("Parent directory (Backspace)");
|
||||||
upButton.addActionListener(e -> {
|
upButton.addActionListener(e -> {
|
||||||
@ -129,7 +139,9 @@ public class FilePanel extends JPanel {
|
|||||||
currentTab.navigateUp();
|
currentTab.navigateUp();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
topPanel.add(upButton, BorderLayout.EAST);
|
navBtnPaths.add(homeButton);
|
||||||
|
navBtnPaths.add(upButton);
|
||||||
|
topPanel.add(navBtnPaths, BorderLayout.EAST);
|
||||||
|
|
||||||
add(topPanel, BorderLayout.NORTH);
|
add(topPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
@ -520,9 +532,10 @@ public class FilePanel extends JPanel {
|
|||||||
container.setBackground(bg);
|
container.setBackground(bg);
|
||||||
boolean dark = isDark(bg);
|
boolean dark = isDark(bg);
|
||||||
for (Component c : container.getComponents()) {
|
for (Component c : container.getComponents()) {
|
||||||
if (c instanceof JPanel || c instanceof JToolBar || c instanceof JScrollPane || c instanceof JViewport || c instanceof JTabbedPane) {
|
if (c instanceof JPanel || c instanceof JToolBar || c instanceof JScrollPane || c instanceof JViewport || c instanceof JTabbedPane || c instanceof JButton) {
|
||||||
c.setBackground(bg);
|
c.setBackground(bg);
|
||||||
} else if (c instanceof JLabel || c instanceof JCheckBox || c instanceof JRadioButton) {
|
}
|
||||||
|
if (c instanceof JLabel || c instanceof JCheckBox || c instanceof JRadioButton || c instanceof JButton) {
|
||||||
c.setForeground(dark ? Color.WHITE : Color.BLACK);
|
c.setForeground(dark ? Color.WHITE : Color.BLACK);
|
||||||
}
|
}
|
||||||
if (c instanceof Container) {
|
if (c instanceof Container) {
|
||||||
|
|||||||
@ -706,10 +706,14 @@ public class FilePanelTab extends JPanel {
|
|||||||
fileTable.setRowSelectionInterval(0, 0);
|
fileTable.setRowSelectionInterval(0, 0);
|
||||||
fileTable.scrollRectToVisible(fileTable.getCellRect(0, 0, true));
|
fileTable.scrollRectToVisible(fileTable.getCellRect(0, 0, true));
|
||||||
}
|
}
|
||||||
|
fileTable.requestFocusInWindow();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (autoSelectFirst && fileTable.getRowCount() > 0) {
|
if (autoSelectFirst && fileTable.getRowCount() > 0) {
|
||||||
fileTable.setRowSelectionInterval(0, 0);
|
fileTable.setRowSelectionInterval(0, 0);
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
try { fileTable.requestFocusInWindow(); } catch (Exception ignore) {}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1002,24 +1006,11 @@ public class FilePanelTab extends JPanel {
|
|||||||
if (cur.equals(currentArchiveTempDir)) {
|
if (cur.equals(currentArchiveTempDir)) {
|
||||||
File parent = currentArchiveSourceFile.getParentFile();
|
File parent = currentArchiveSourceFile.getParentFile();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
String archiveName = currentArchiveSourceFile.getName();
|
|
||||||
// cleanup temp dir before switching back
|
// cleanup temp dir before switching back
|
||||||
deleteTempDirRecursively(currentArchiveTempDir);
|
deleteTempDirRecursively(currentArchiveTempDir);
|
||||||
currentArchiveTempDir = null;
|
currentArchiveTempDir = null;
|
||||||
currentArchiveSourceFile = null;
|
currentArchiveSourceFile = null;
|
||||||
loadDirectory(parent, false);
|
loadDirectory(parent, true);
|
||||||
|
|
||||||
if (viewMode == ViewMode.BRIEF) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
tableModel.calculateBriefLayout();
|
|
||||||
tableModel.fireTableStructureChanged();
|
|
||||||
updateColumnRenderers();
|
|
||||||
updateColumnWidths();
|
|
||||||
selectItemByName(archiveName);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
selectItemByName(archiveName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1028,20 +1019,7 @@ public class FilePanelTab extends JPanel {
|
|||||||
|
|
||||||
File parent = currentDirectory.getParentFile();
|
File parent = currentDirectory.getParentFile();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
String previousDirName = currentDirectory.getName();
|
loadDirectory(parent, true);
|
||||||
loadDirectory(parent, false);
|
|
||||||
|
|
||||||
if (viewMode == ViewMode.BRIEF) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
tableModel.calculateBriefLayout();
|
|
||||||
tableModel.fireTableStructureChanged();
|
|
||||||
updateColumnRenderers();
|
|
||||||
updateColumnWidths();
|
|
||||||
selectItemByName(previousDirName);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
selectItemByName(previousDirName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user