showing names in brief mode improved
This commit is contained in:
parent
61d6d7ed3c
commit
b9b87692f2
@ -512,6 +512,40 @@ public class AppConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBriefModeMaxNameLength() {
|
||||||
|
return Integer.parseInt(properties.getProperty("appearance.brief.max.len", "30"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBriefModeMaxNameLength(int len) {
|
||||||
|
properties.setProperty("appearance.brief.max.len", String.valueOf(len));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBriefModeStartLength() {
|
||||||
|
return Integer.parseInt(properties.getProperty("appearance.brief.start.len", "20"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBriefModeStartLength(int len) {
|
||||||
|
properties.setProperty("appearance.brief.start.len", String.valueOf(len));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBriefModeEndLength() {
|
||||||
|
return Integer.parseInt(properties.getProperty("appearance.brief.end.len", "10"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBriefModeEndLength(int len) {
|
||||||
|
properties.setProperty("appearance.brief.end.len", String.valueOf(len));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBriefModeSeparator() {
|
||||||
|
return properties.getProperty("appearance.brief.separator", "...");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBriefModeSeparator(String sep) {
|
||||||
|
if (sep != null) {
|
||||||
|
properties.setProperty("appearance.brief.separator", sep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -- Sorting persistence (global default)
|
// -- Sorting persistence (global default)
|
||||||
public int getDefaultSortColumn() {
|
public int getDefaultSortColumn() {
|
||||||
return Integer.parseInt(properties.getProperty("global.sort.column", "-1"));
|
return Integer.parseInt(properties.getProperty("global.sort.column", "-1"));
|
||||||
|
|||||||
@ -115,6 +115,15 @@ public class FilePanelTab extends JPanel {
|
|||||||
} else {
|
} else {
|
||||||
tf.selectAll();
|
tf.selectAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure Escape key cancels editing
|
||||||
|
tf.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelEditing");
|
||||||
|
tf.getActionMap().put("cancelEditing", new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
fileTable.getCellEditor().cancelCellEditing();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -157,6 +166,15 @@ public class FilePanelTab extends JPanel {
|
|||||||
|
|
||||||
tf.requestFocusInWindow();
|
tf.requestFocusInWindow();
|
||||||
tf.selectAll();
|
tf.selectAll();
|
||||||
|
|
||||||
|
// Ensure Escape key cancels editing
|
||||||
|
tf.getInputMap(JComponent.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancelEditing");
|
||||||
|
tf.getActionMap().put("cancelEditing", new AbstractAction() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
fileTable.getCellEditor().cancelCellEditing();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inlineRenameActive = false;
|
inlineRenameActive = false;
|
||||||
@ -2564,7 +2582,19 @@ public class FilePanelTab extends JPanel {
|
|||||||
// Prepare displayed text: wrap directory names in square brackets
|
// Prepare displayed text: wrap directory names in square brackets
|
||||||
String displayText = "";
|
String displayText = "";
|
||||||
if (viewMode == ViewMode.BRIEF) {
|
if (viewMode == ViewMode.BRIEF) {
|
||||||
displayText = item.getName();
|
String name = item.getName();
|
||||||
|
int maxLen = persistedConfig != null ? persistedConfig.getBriefModeMaxNameLength() : 30;
|
||||||
|
if (name.length() > maxLen) {
|
||||||
|
int startLen = persistedConfig != null ? persistedConfig.getBriefModeStartLength() : 20;
|
||||||
|
int endLen = persistedConfig != null ? persistedConfig.getBriefModeEndLength() : 10;
|
||||||
|
String sep = persistedConfig != null ? persistedConfig.getBriefModeSeparator() : "...";
|
||||||
|
|
||||||
|
// Safety check to ensure indices are valid even if config has weird values
|
||||||
|
if (startLen + endLen < name.length()) {
|
||||||
|
name = name.substring(0, startLen) + sep + name.substring(name.length() - endLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
displayText = name;
|
||||||
if (item.isDirectory()) {
|
if (item.isDirectory()) {
|
||||||
displayText = "[" + displayText + "]";
|
displayText = "[" + displayText + "]";
|
||||||
}
|
}
|
||||||
@ -2699,7 +2729,18 @@ public class FilePanelTab extends JPanel {
|
|||||||
|
|
||||||
for (FileItem item : tableModel.items) {
|
for (FileItem item : tableModel.items) {
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
String display = item.getName();
|
String name = item.getName();
|
||||||
|
// Match truncation from renderer for BRIEF mode
|
||||||
|
int maxLen = persistedConfig != null ? persistedConfig.getBriefModeMaxNameLength() : 30;
|
||||||
|
if (name.length() > maxLen) {
|
||||||
|
int startLen = persistedConfig != null ? persistedConfig.getBriefModeStartLength() : 20;
|
||||||
|
int endLen = persistedConfig != null ? persistedConfig.getBriefModeEndLength() : 10;
|
||||||
|
String sep = persistedConfig != null ? persistedConfig.getBriefModeSeparator() : "...";
|
||||||
|
if (startLen + endLen < name.length()) {
|
||||||
|
name = name.substring(0, startLen) + sep + name.substring(name.length() - endLen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String display = name;
|
||||||
if (item.isDirectory()) {
|
if (item.isDirectory()) {
|
||||||
display = "[" + display + "]";
|
display = "[" + display + "]";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -975,21 +975,21 @@ public class MainWindow extends JFrame {
|
|||||||
private void applyAppearanceSettings() {
|
private void applyAppearanceSettings() {
|
||||||
updateAutoRefreshTimer();
|
updateAutoRefreshTimer();
|
||||||
Font gfont = config.getGlobalFont();
|
Font gfont = config.getGlobalFont();
|
||||||
if (gfont != null) {
|
|
||||||
// Apply to toolbars, buttons and tables
|
// Apply to toolbars, buttons and tables
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
if (gfont != null) {
|
||||||
for (Component c : getContentPane().getComponents()) {
|
for (Component c : getContentPane().getComponents()) {
|
||||||
c.setFont(gfont);
|
c.setFont(gfont);
|
||||||
}
|
}
|
||||||
// Apply to panels' tables
|
|
||||||
if (leftPanel != null && leftPanel.getFileTable() != null) {
|
|
||||||
leftPanel.applyGlobalFont(gfont);
|
|
||||||
}
|
}
|
||||||
if (rightPanel != null && rightPanel.getFileTable() != null) {
|
// Apply to panels (font, colors, and layout refresh)
|
||||||
rightPanel.applyGlobalFont(gfont);
|
if (leftPanel != null) {
|
||||||
|
if (gfont != null) leftPanel.applyGlobalFont(gfont);
|
||||||
|
}
|
||||||
|
if (rightPanel != null) {
|
||||||
|
if (gfont != null) rightPanel.applyGlobalFont(gfont);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
Color bg = config.getBackgroundColor();
|
Color bg = config.getBackgroundColor();
|
||||||
if (bg != null) {
|
if (bg != null) {
|
||||||
|
|||||||
@ -27,6 +27,10 @@ public class SettingsDialog extends JDialog {
|
|||||||
private final Color originalSel;
|
private final Color originalSel;
|
||||||
private final Color originalMark;
|
private final Color originalMark;
|
||||||
private final Color originalFolder;
|
private final Color originalFolder;
|
||||||
|
private final int originalBriefMaxLen;
|
||||||
|
private final int originalBriefStartLen;
|
||||||
|
private final int originalBriefEndLen;
|
||||||
|
private final String originalBriefSeparator;
|
||||||
private final Font originalGlobalFont;
|
private final Font originalGlobalFont;
|
||||||
private final Font originalEditorFont;
|
private final Font originalEditorFont;
|
||||||
private final String originalExternalEditorPath;
|
private final String originalExternalEditorPath;
|
||||||
@ -57,6 +61,10 @@ public class SettingsDialog extends JDialog {
|
|||||||
this.originalSel = config.getSelectionColor();
|
this.originalSel = config.getSelectionColor();
|
||||||
this.originalMark = config.getMarkedColor();
|
this.originalMark = config.getMarkedColor();
|
||||||
this.originalFolder = config.getFolderColor();
|
this.originalFolder = config.getFolderColor();
|
||||||
|
this.originalBriefMaxLen = config.getBriefModeMaxNameLength();
|
||||||
|
this.originalBriefStartLen = config.getBriefModeStartLength();
|
||||||
|
this.originalBriefEndLen = config.getBriefModeEndLength();
|
||||||
|
this.originalBriefSeparator = config.getBriefModeSeparator();
|
||||||
this.originalGlobalFont = config.getGlobalFont();
|
this.originalGlobalFont = config.getGlobalFont();
|
||||||
this.originalEditorFont = config.getEditorFont();
|
this.originalEditorFont = config.getEditorFont();
|
||||||
this.originalExternalEditorPath = config.getExternalEditorPath();
|
this.originalExternalEditorPath = config.getExternalEditorPath();
|
||||||
@ -231,6 +239,10 @@ public class SettingsDialog extends JDialog {
|
|||||||
config.setSelectionColor(originalSel);
|
config.setSelectionColor(originalSel);
|
||||||
config.setMarkedColor(originalMark);
|
config.setMarkedColor(originalMark);
|
||||||
config.setFolderColor(originalFolder);
|
config.setFolderColor(originalFolder);
|
||||||
|
config.setBriefModeMaxNameLength(originalBriefMaxLen);
|
||||||
|
config.setBriefModeStartLength(originalBriefStartLen);
|
||||||
|
config.setBriefModeEndLength(originalBriefEndLen);
|
||||||
|
config.setBriefModeSeparator(originalBriefSeparator);
|
||||||
config.setGlobalFont(originalGlobalFont);
|
config.setGlobalFont(originalGlobalFont);
|
||||||
config.setEditorFont(originalEditorFont);
|
config.setEditorFont(originalEditorFont);
|
||||||
config.setExternalEditorPath(originalExternalEditorPath);
|
config.setExternalEditorPath(originalExternalEditorPath);
|
||||||
@ -401,6 +413,55 @@ public class SettingsDialog extends JDialog {
|
|||||||
gbc.gridx = 1; gbc.gridy = row++; gbc.weightx = 1.0;
|
gbc.gridx = 1; gbc.gridy = row++; gbc.weightx = 1.0;
|
||||||
grid.add(appearanceFolderBtn, gbc);
|
grid.add(appearanceFolderBtn, gbc);
|
||||||
|
|
||||||
|
// Brief mode max name length
|
||||||
|
gbc.gridx = 0; gbc.gridy = row; gbc.weightx = 0.0;
|
||||||
|
grid.add(new JLabel("Brief mode max name length:"), gbc);
|
||||||
|
|
||||||
|
JSpinner briefMaxLenSpinner = new JSpinner(new SpinnerNumberModel(config.getBriefModeMaxNameLength(), 10, 255, 1));
|
||||||
|
briefMaxLenSpinner.addChangeListener(e -> {
|
||||||
|
config.setBriefModeMaxNameLength((Integer) briefMaxLenSpinner.getValue());
|
||||||
|
if (onChange != null) onChange.run();
|
||||||
|
});
|
||||||
|
p.putClientProperty("briefMaxLen", briefMaxLenSpinner);
|
||||||
|
gbc.gridx = 1; gbc.gridy = row++; gbc.weightx = 1.0;
|
||||||
|
grid.add(briefMaxLenSpinner, gbc);
|
||||||
|
|
||||||
|
// Brief mode start/end length
|
||||||
|
gbc.gridx = 0; gbc.gridy = row; gbc.weightx = 0.0;
|
||||||
|
grid.add(new JLabel("Brief mode truncation (start/end):"), gbc);
|
||||||
|
|
||||||
|
JPanel truncationPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
|
||||||
|
JSpinner briefStartLenSpinner = new JSpinner(new SpinnerNumberModel(config.getBriefModeStartLength(), 1, 100, 1));
|
||||||
|
briefStartLenSpinner.addChangeListener(e -> {
|
||||||
|
config.setBriefModeStartLength((Integer) briefStartLenSpinner.getValue());
|
||||||
|
if (onChange != null) onChange.run();
|
||||||
|
});
|
||||||
|
truncationPanel.add(briefStartLenSpinner);
|
||||||
|
truncationPanel.add(new JLabel(" / "));
|
||||||
|
JSpinner briefEndLenSpinner = new JSpinner(new SpinnerNumberModel(config.getBriefModeEndLength(), 1, 100, 1));
|
||||||
|
briefEndLenSpinner.addChangeListener(e -> {
|
||||||
|
config.setBriefModeEndLength((Integer) briefEndLenSpinner.getValue());
|
||||||
|
if (onChange != null) onChange.run();
|
||||||
|
});
|
||||||
|
truncationPanel.add(briefEndLenSpinner);
|
||||||
|
gbc.gridx = 1; gbc.gridy = row++; gbc.weightx = 1.0;
|
||||||
|
grid.add(truncationPanel, gbc);
|
||||||
|
|
||||||
|
// Brief mode separator
|
||||||
|
gbc.gridx = 0; gbc.gridy = row; gbc.weightx = 0.0;
|
||||||
|
grid.add(new JLabel("Brief mode separator:"), gbc);
|
||||||
|
|
||||||
|
JTextField briefSeparatorField = new JTextField(config.getBriefModeSeparator());
|
||||||
|
briefSeparatorField.addFocusListener(new java.awt.event.FocusAdapter() {
|
||||||
|
@Override
|
||||||
|
public void focusLost(java.awt.event.FocusEvent e) {
|
||||||
|
config.setBriefModeSeparator(briefSeparatorField.getText());
|
||||||
|
if (onChange != null) onChange.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gbc.gridx = 1; gbc.gridy = row++; gbc.weightx = 1.0;
|
||||||
|
grid.add(briefSeparatorField, gbc);
|
||||||
|
|
||||||
p.add(grid, BorderLayout.NORTH);
|
p.add(grid, BorderLayout.NORTH);
|
||||||
panels.put("Appearance", p);
|
panels.put("Appearance", p);
|
||||||
return p;
|
return p;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user