Strict Resource Icons

Known resource type icons are now only shown for non-directories, or the root directory for each resource
This commit is contained in:
Konloch 2021-07-15 01:47:04 -07:00
parent 7b01aa607c
commit 9f50385717

View file

@ -29,7 +29,8 @@ public class ResourceListIconRenderer extends DefaultTreeCellRenderer
if (value instanceof ResourceTreeNode) if (value instanceof ResourceTreeNode)
{ {
ResourceTreeNode node = (ResourceTreeNode) value; ResourceTreeNode node = (ResourceTreeNode) value;
String name = node.toString().toLowerCase(); String nameOG = node.toString();
String name = nameOG.toLowerCase();
String onlyName = FilenameUtils.getName(name); String onlyName = FilenameUtils.getName(name);
boolean iconSet = false; boolean iconSet = false;
@ -38,17 +39,28 @@ public class ResourceListIconRenderer extends DefaultTreeCellRenderer
: ResourceType.extensionMap.get(FilenameUtils.getExtension(onlyName).toLowerCase()); : ResourceType.extensionMap.get(FilenameUtils.getExtension(onlyName).toLowerCase());
//set the icon to a known file type //set the icon to a known file type
if (knownResourceType != null) if (knownResourceType != null
//check if is parent/root node, or not a directory
&& (node.getParent() == node.getRoot()
|| node.getChildCount() == 0))
{ {
setIcon(knownResourceType.getIcon()); setIcon(knownResourceType.getIcon());
iconSet = true; iconSet = true;
} }
//hardcoded resource icons go here //hardcoded resource icons go here
else if (name.equals("decoded resources")) else if (nameOG.equals("Decoded Resources") && node.getChildCount() > 0)
{ {
setIcon(IconResources.decodedIcon); setIcon(IconResources.decodedIcon);
iconSet = true; iconSet = true;
} }
else if (node.getChildCount() == 0
&& (nameOG.equals("README")
|| nameOG.equals("LICENSE")
|| nameOG.equals("NOTICE")))
{
setIcon(IconResources.configIcon);
iconSet = true;
}
//folders //folders
if (node.getChildCount() > 0) if (node.getChildCount() > 0)