This commit is contained in:
Radek Davidek 2026-01-20 19:21:05 +01:00
parent c1e2bce59c
commit 2f0e1df9c9
2 changed files with 14 additions and 6 deletions

View File

@ -2827,17 +2827,17 @@ public class FilePanelTab extends JPanel {
private void showAssociationDialog(File file) { private void showAssociationDialog(File file) {
String name = file.getName(); String name = file.getName();
String ext = ""; String initialPattern = "";
int lastDot = name.lastIndexOf('.'); int lastDot = name.lastIndexOf('.');
if (lastDot > 0 && lastDot < name.length() - 1) { if (lastDot > 0 && lastDot < name.length() - 1) {
ext = name.substring(lastDot + 1); initialPattern = "*." + name.substring(lastDot + 1).toLowerCase();
} else { } else {
ext = name; // fallback to full name if no extension initialPattern = name; // fallback to full name if no extension
} }
String pattern = JOptionPane.showInputDialog(this, String pattern = JOptionPane.showInputDialog(this,
"File pattern (e.g. *.txt or txt):", "File pattern (e.g. *.txt or txt):",
ext); initialPattern);
if (pattern == null || pattern.trim().isEmpty()) return; if (pattern == null || pattern.trim().isEmpty()) return;

View File

@ -7,7 +7,7 @@ import java.awt.*;
* Custom icon for files with type-specific indicators. * Custom icon for files with type-specific indicators.
*/ */
public class FileSpecificIcon implements Icon { public class FileSpecificIcon implements Icon {
public enum Type { IMAGE, VIDEO, AUDIO, ARCHIVE, CODE, TEXT, DOC, EXEC, OTHER } public enum Type { IMAGE, VIDEO, AUDIO, ARCHIVE, CODE, TEXT, DOC, EXEC, SHELL, OTHER }
private final Type type; private final Type type;
private final Color color; private final Color color;
@ -22,6 +22,7 @@ public class FileSpecificIcon implements Icon {
case TEXT: this.color = Color.GRAY; break; case TEXT: this.color = Color.GRAY; break;
case DOC: this.color = new Color(70, 90, 180); break; // Darker blue case DOC: this.color = new Color(70, 90, 180); break; // Darker blue
case EXEC: this.color = new Color(0, 128, 128); break; // Teal case EXEC: this.color = new Color(0, 128, 128); break; // Teal
case SHELL: this.color = new Color(40, 44, 52); break; // Dark grey
default: this.color = Color.LIGHT_GRAY; break; default: this.color = Color.LIGHT_GRAY; break;
} }
} }
@ -48,9 +49,11 @@ public class FileSpecificIcon implements Icon {
if (name.endsWith(".java") || name.endsWith(".c") || name.endsWith(".cpp") || if (name.endsWith(".java") || name.endsWith(".c") || name.endsWith(".cpp") ||
name.endsWith(".cs") || name.endsWith(".py") || name.endsWith(".js") || name.endsWith(".cs") || name.endsWith(".py") || name.endsWith(".js") ||
name.endsWith(".ts") || name.endsWith(".html") || name.endsWith(".css") || name.endsWith(".ts") || name.endsWith(".html") || name.endsWith(".css") ||
name.endsWith(".xml") || name.endsWith(".json") || name.endsWith(".sh") || name.endsWith(".xml") || name.endsWith(".json") ||
name.endsWith(".bat") || name.endsWith(".pl") || name.endsWith(".php")) return Type.CODE; name.endsWith(".bat") || name.endsWith(".pl") || name.endsWith(".php")) return Type.CODE;
if (name.endsWith(".sh")) return Type.SHELL;
if (name.endsWith(".pdf") || name.endsWith(".doc") || name.endsWith(".docx") || if (name.endsWith(".pdf") || name.endsWith(".doc") || name.endsWith(".docx") ||
name.endsWith(".xls") || name.endsWith(".xlsx") || name.endsWith(".ppt") || name.endsWith(".xls") || name.endsWith(".xlsx") || name.endsWith(".ppt") ||
name.endsWith(".pptx") || name.endsWith(".odt") || name.endsWith(".ods")) return Type.DOC; name.endsWith(".pptx") || name.endsWith(".odt") || name.endsWith(".ods")) return Type.DOC;
@ -107,6 +110,11 @@ public class FileSpecificIcon implements Icon {
g2.drawLine(x + 9, y + 7, x + 11, y + 9); // > g2.drawLine(x + 9, y + 7, x + 11, y + 9); // >
g2.drawLine(x + 9, y + 11, x + 11, y + 9); g2.drawLine(x + 9, y + 11, x + 11, y + 9);
break; break;
case SHELL:
g2.drawLine(x + 5, y + 6, x + 7, y + 8); // >
g2.drawLine(x + 5, y + 10, x + 7, y + 8);
g2.drawLine(x + 8, y + 11, x + 11, y + 11); // _
break;
case TEXT: case TEXT:
case DOC: case DOC:
g2.drawLine(x + 5, y + 6, x + 11, y + 6); g2.drawLine(x + 5, y + 6, x + 11, y + 6);