in idea-plugin/src/main/java/com/jetbrains/ide/streamdeck/customization/CustomizableActionsPanel.java [378:416]
private static boolean doSetIcon(@NotNull CustomActionsSchema schema,
@NotNull DefaultMutableTreeNode node,
@Nullable String path) {
Object userObj = node.getUserObject();
Object value = userObj instanceof Pair<?, ?> pair ? pair.first : userObj;
String actionId = value instanceof Group group ? group.getId()
: value instanceof String ? (String)value : null;
if (actionId == null) return false;
if (StringUtil.isEmpty(path)) {
node.setUserObject(Pair.create(value, null));
schema.removeIconCustomization(actionId);
return true;
}
ActionManager actionManager = ActionManager.getInstance();
AnAction action = actionManager.getAction(actionId);
if (action == null) return false;
AnAction reuseFrom = actionManager.getAction(path);
if (reuseFrom != null) {
Icon toSet = CustomActionsSchemaKt.getOriginalIconFrom(reuseFrom);
Icon defaultIcon = CustomActionsSchemaKt.getOriginalIconFrom(action);
node.setUserObject(Pair.create(value, toSet));
schema.addIconCustomization(actionId, toSet != defaultIcon ? path : null);
}
else {
Icon icon;
try {
icon = loadCustomIcon(path);
}
catch (Throwable t) {
Logger.getInstance(CustomizableActionsPanel.class)
.warn(String.format("Failed to load icon with path '%s' and set it to action '%s'", path, actionId), t);
return false;
}
node.setUserObject(Pair.create(value, icon));
schema.addIconCustomization(actionId, path);
}
return true;
}