Fix Extension: Override preview issues

This commit is contained in:
Reinhard Pointner 2017-01-08 01:10:35 +08:00
parent 512051bf27
commit 44d76aba9f
3 changed files with 9 additions and 11 deletions

View File

@ -98,7 +98,7 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
if (renameModel.preserveExtension()) {
setText(FileUtilities.getName(file));
} else {
setText(isSelected || !renameModel.hasComplement(index) ? formatPath(file) : colorizePath(file.getAbsoluteFile(), true));
setText(isSelected || !renameModel.hasComplement(index) ? formatPath(file) : colorizePath(file, true));
}
} else if (value instanceof FormattedFuture) {
// display progress icon
@ -215,7 +215,7 @@ class RenameListCellRenderer extends DefaultFancyListCellRenderer {
return "Folder";
}
String extension = FileUtilities.getExtension(file);
String extension = getExtension(file);
if (extension != null) {
return extension.toLowerCase();
}

View File

@ -7,8 +7,6 @@ import java.awt.Color;
import java.io.File;
import java.util.List;
import net.filebot.util.FileUtilities;
public class TextColorizer {
private Color pathRainbowBeginColor;
@ -40,13 +38,13 @@ public class TextColorizer {
for (int i = 0; i < path.size() - 1; i++) {
float f = (path.size() <= 2) ? 1 : (float) i / (path.size() - 2);
Color c = interpolateHSB(pathRainbowBeginColor, pathRainbowEndColor, f);
html.append(String.format("<span style='color:rgb(%1$d, %2$d, %3$d)'>%4$s</span><span style='color:rgb(%1$d, %2$d, %3$d)'>/</span>", c.getRed(), c.getGreen(), c.getBlue(), escapeHTML(FileUtilities.getFolderName(path.get(i)))));
html.append(String.format("<span style='color:rgb(%1$d, %2$d, %3$d)'>%4$s</span><span style='color:rgb(%1$d, %2$d, %3$d)'>/</span>", c.getRed(), c.getGreen(), c.getBlue(), escapeHTML(getFolderName(path.get(i)))));
}
// only colorize extension
if (hasExtension) {
html.append(escapeHTML(FileUtilities.getName(file)));
String extension = FileUtilities.getExtension(file);
html.append(escapeHTML(getNameWithoutExtension(file.getName())));
String extension = getExtension(file);
if (extension != null) {
html.append(String.format("<span style='color:#607080'>.%s</span>", escapeHTML(extension))); // highlight extension
}

View File

@ -322,12 +322,12 @@ public final class FileUtilities {
return null;
}
if (file.isFile()) {
return getNameWithoutExtension(file.getName());
// directory || root drive || network share
if (file.isDirectory()) {
return getFolderName(file);
}
// directory || root drive || network share
return getFolderName(file);
return getNameWithoutExtension(file.getName());
}
public static String getFolderName(File file) {