IDEA-165089 Hide the icon if scheme does not provide any actions

This commit is contained in:
Sergey Malenkov
2017-04-26 16:38:37 +03:00
parent 9e65356788
commit 82a4bd2dba
@@ -226,6 +226,17 @@ public abstract class AbstractSchemesPanel<T extends Scheme, InfoComponent exten
public void update(AnActionEvent e) {
Presentation p = e.getPresentation();
p.setIcon(AllIcons.General.Gear);
p.setEnabledAndVisible(isEnabledAndVisible(e));
}
private boolean isEnabledAndVisible(AnActionEvent e) {
// copy existing event because an action update changes its presentation
e = AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, e.getDataContext());
for (AnAction action : myActionGroup.getChildren(e)) {
action.update(e); // ensure that at least action is enabled and visible
if (e.getPresentation().isEnabledAndVisible()) return true;
}
return false;
}
@Override