package jetbrains.mps.ide.editor.actions;
/*Generated by MPS */
import jetbrains.mps.workbench.action.BaseAction;
import javax.swing.Icon;
import com.intellij.openapi.actionSystem.AnActionEvent;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import jetbrains.mps.openapi.editor.EditorContext;
import jetbrains.mps.ide.editor.MPSEditorDataKeys;
import jetbrains.mps.nodeEditor.EditorComponent;
import jetbrains.mps.openapi.editor.cells.CellAction;
import jetbrains.mps.openapi.editor.cells.CellActionType;
public class CollapseRecursively_Action extends BaseAction {
private static final Icon ICON = null;
public CollapseRecursively_Action() {
super("Collapse Recursively", "", ICON);
this.setIsAlwaysVisible(false);
this.setExecuteOutsideCommand(false);
}
@Override
public boolean isDumbAware() {
return true;
}
@Override
public boolean isApplicable(AnActionEvent event, final Map<String, Object> _params) {
return CollapseRecursively_Action.this.getAction(event) != null;
}
@Override
public void doUpdate(@NotNull AnActionEvent event, final Map<String, Object> _params) {
this.setEnabledState(event.getPresentation(), this.isApplicable(event, _params));
}
@Override
protected boolean collectActionData(AnActionEvent event, final Map<String, Object> _params) {
if (!(super.collectActionData(event, _params))) {
return false;
}
{
EditorContext p = event.getData(MPSEditorDataKeys.EDITOR_CONTEXT);
if (p == null) {
return false;
}
}
{
EditorComponent editorComponent = event.getData(MPSEditorDataKeys.EDITOR_COMPONENT);
if (editorComponent != null && editorComponent.isInvalid()) {
editorComponent = null;
}
if (editorComponent == null) {
return false;
}
}
return true;
}
@Override
public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) {
CollapseRecursively_Action.this.getAction(event).execute(event.getData(MPSEditorDataKeys.EDITOR_CONTEXT));
}
private CellAction getAction(final AnActionEvent event) {
return event.getData(MPSEditorDataKeys.EDITOR_COMPONENT).getComponentAction(CellActionType.FOLD_RECURSIVELY);
}
}