AnAction (@NlsActions.ActionText String text, Icon icon, Icon hoveredIcon, Icon selectedIcon, boolean isLike) { return new DumbAwareAction(text, null, icon) { @Override public void actionPerformed(@NotNull AnActionEvent e) { myCurrentLikenessState = isSelected() ? null : isLike; } @Override public void update(@NotNull AnActionEvent e) { boolean selected = isSelected(); Presentation presentation = e.getPresentation(); presentation.setIcon(selected ? selectedIcon : icon); presentation.setHoveredIcon(selected ? selectedIcon : hoveredIcon); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } private boolean isSelected() { return myCurrentLikenessState != null && myCurrentLikenessState == isLike; } }; }