package jetbrains.mps.ide.hierarchy.toggle;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import com.intellij.openapi.actionSystem.ToggleAction;
import javax.swing.Icon;
import com.intellij.openapi.actionSystem.AnActionEvent;

@GeneratedClass(node = "r:b522c221-948b-4fac-886a-2badf29b5fb4(jetbrains.mps.ide.hierarchy.toggle)/5797068448049410625", model = "r:b522c221-948b-4fac-886a-2badf29b5fb4(jetbrains.mps.ide.hierarchy.toggle)")
public abstract class GroupedToggleAction extends ToggleAction {
  private boolean mySelected = false;
  private ToggleActionGroup myGroup = null;
  public GroupedToggleAction(String text, String description, Icon icon, boolean initiallySelected) {
    super(text, description, icon);
    mySelected = initiallySelected;
  }
  public void setGroup(ToggleActionGroup group) {
    myGroup = group;
  }
  @Override
  public boolean isSelected(AnActionEvent e) {
    return mySelected;
  }
  @Override
  public void setSelected(AnActionEvent e, boolean state) {
    if (!(state)) {
      return;
    }
    mySelected = true;
    if (myGroup != null) {
      myGroup.changeSelection(this);
    }
    select();
  }
  public void deselect() {
    mySelected = false;
    unselect();
  }
  public abstract void select();
  public void unselect() {
  }
}
