Compare commits
2 Commits
bc42c8986f
...
6ee3bc8201
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ee3bc8201 | ||
|
|
4d9774471c |
@ -18,6 +18,7 @@ public class FileItem {
|
||||
private final boolean isDirectory;
|
||||
private final Icon icon;
|
||||
private boolean marked;
|
||||
private boolean recentlyChanged;
|
||||
private String displayPath;
|
||||
|
||||
public FileItem(File file) {
|
||||
@ -102,6 +103,14 @@ public class FileItem {
|
||||
this.marked = !this.marked;
|
||||
}
|
||||
|
||||
public boolean isRecentlyChanged() {
|
||||
return recentlyChanged;
|
||||
}
|
||||
|
||||
public void setRecentlyChanged(boolean recentlyChanged) {
|
||||
this.recentlyChanged = recentlyChanged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format file size into a human-readable string
|
||||
*/
|
||||
|
||||
@ -19,7 +19,9 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
import java.io.InputStream;
|
||||
@ -524,6 +526,7 @@ public class FilePanelTab extends JPanel {
|
||||
lastValidRow = row;
|
||||
lastValidBriefColumn = briefCurrentColumn;
|
||||
}
|
||||
updateStatus();
|
||||
} else {
|
||||
// Selection became empty. Attempt to restore it.
|
||||
// We do this even if e.getValueIsAdjusting() is true to prevent temporary selection loss.
|
||||
@ -543,6 +546,7 @@ public class FilePanelTab extends JPanel {
|
||||
try {
|
||||
fileTable.scrollRectToVisible(fileTable.getCellRect(finalRow, finalCol, true));
|
||||
} catch (Exception ignore) {}
|
||||
updateStatus();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -923,6 +927,7 @@ public class FilePanelTab extends JPanel {
|
||||
if (requestFocus) {
|
||||
fileTable.requestFocusInWindow();
|
||||
}
|
||||
updateStatus();
|
||||
});
|
||||
} else {
|
||||
if (autoSelectFirst && fileTable.getRowCount() > 0) {
|
||||
@ -946,9 +951,8 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updateStatus();
|
||||
}
|
||||
|
||||
// Notify directory change
|
||||
if (onDirectoryChanged != null) {
|
||||
@ -965,6 +969,20 @@ public class FilePanelTab extends JPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
// Identify which items are new or have changed metadata (size/date)
|
||||
final List<String> changedNames = new ArrayList<>();
|
||||
Map<String, FileItem> oldItemsMap = new HashMap<>();
|
||||
for (FileItem item : tableModel.items) {
|
||||
oldItemsMap.put(item.getName(), item);
|
||||
}
|
||||
|
||||
for (FileItem newItem : newItems) {
|
||||
FileItem oldItem = oldItemsMap.get(newItem.getName());
|
||||
if (oldItem == null || !newItem.isSameAs(oldItem)) {
|
||||
changedNames.add(newItem.getName());
|
||||
}
|
||||
}
|
||||
|
||||
FileItem focused = getFocusedItem();
|
||||
final String focusedName = (focused != null) ? focused.getName() : null;
|
||||
|
||||
@ -976,11 +994,14 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
|
||||
loadDirectory(currentDirectory, false, requestFocus, () -> {
|
||||
// Restore marks
|
||||
// Restore marks and set recentlyChanged flag
|
||||
for (FileItem item : tableModel.items) {
|
||||
if (markedNames.contains(item.getName())) {
|
||||
item.setMarked(true);
|
||||
}
|
||||
if (changedNames.contains(item.getName())) {
|
||||
item.setRecentlyChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore focus
|
||||
@ -1004,7 +1025,24 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
}
|
||||
fileTable.repaint();
|
||||
updateStatus();
|
||||
|
||||
if (!changedNames.isEmpty()) {
|
||||
// Clear the recentlyChanged flag after 2 seconds
|
||||
javax.swing.Timer timer = new javax.swing.Timer(2000, e -> {
|
||||
boolean found = false;
|
||||
for (FileItem item : tableModel.items) {
|
||||
if (item.isRecentlyChanged()) {
|
||||
item.setRecentlyChanged(false);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
fileTable.repaint();
|
||||
}
|
||||
});
|
||||
timer.setRepeats(false);
|
||||
timer.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -2176,6 +2214,10 @@ public class FilePanelTab extends JPanel {
|
||||
int newStyle = baseStyle | Font.BOLD;
|
||||
setFont(baseFont.deriveFont(newStyle));
|
||||
setForeground(markedColor);
|
||||
} else if (item.isRecentlyChanged()) {
|
||||
// Highlight recently changed items with bold and a different color
|
||||
setFont(baseFont.deriveFont(baseStyle | Font.BOLD));
|
||||
setForeground(new Color(0, 128, 255)); // Bright blue
|
||||
} else {
|
||||
// Preserve whatever style the base font has (do not force plain)
|
||||
setFont(baseFont.deriveFont(baseStyle));
|
||||
@ -2318,9 +2360,10 @@ public class FilePanelTab extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
String newStatus;
|
||||
if (markedCount > 0) {
|
||||
statusLabel.setText(String.format(" Selected: %d files, %d directories (%s)",
|
||||
fileCount, dirCount, FileItem.formatSize(totalSize)));
|
||||
newStatus = String.format(" Selected: %d files, %d directories (%s)",
|
||||
fileCount, dirCount, FileItem.formatSize(totalSize));
|
||||
} else {
|
||||
int selectedRow = fileTable.getSelectedRow();
|
||||
if (selectedRow >= 0) {
|
||||
@ -2334,22 +2377,26 @@ public class FilePanelTab extends JPanel {
|
||||
if (item != null && !item.getName().equals("..")) {
|
||||
if (item.isDirectory()) {
|
||||
// Always display directory names in square brackets
|
||||
statusLabel.setText(String.format(" [%s] | %s",
|
||||
newStatus = String.format(" [%s] | %s",
|
||||
item.getName(),
|
||||
item.getFormattedDate()));
|
||||
item.getFormattedDate());
|
||||
} else {
|
||||
statusLabel.setText(String.format(" %s | %s | %s",
|
||||
newStatus = String.format(" %s | %s | %s",
|
||||
item.getName(),
|
||||
FileItem.formatSize(item.getSize()),
|
||||
item.getFormattedDate()));
|
||||
item.getFormattedDate());
|
||||
}
|
||||
} else {
|
||||
statusLabel.setText(String.format(" Items: %d", tableModel.items.size()));
|
||||
newStatus = String.format(" Items: %d", tableModel.items.size());
|
||||
}
|
||||
} else {
|
||||
statusLabel.setText(String.format(" Items: %d", tableModel.items.size()));
|
||||
newStatus = String.format(" Items: %d", tableModel.items.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (statusLabel != null && !newStatus.equals(statusLabel.getText())) {
|
||||
statusLabel.setText(newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user