package jetbrains.mps.ide.actions; /*Generated by MPS */ import jetbrains.mps.workbench.action.BaseAction; import javax.swing.Icon; import jetbrains.mps.icons.MPSIcons; import com.intellij.openapi.actionSystem.AnActionEvent; import java.util.Map; import org.jetbrains.mps.openapi.module.SModule; import jetbrains.mps.FilteredGlobalScope; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.internal.collections.runtime.MapSequence; import jetbrains.mps.internal.collections.runtime.Sequence; import org.jetbrains.annotations.NotNull; import jetbrains.mps.project.MPSProject; import jetbrains.mps.ide.projectPane.ProjectPane; import org.jetbrains.mps.openapi.model.SModel; public class ShowInLogicalView_Action extends BaseAction { private static final Icon ICON = MPSIcons.ProjectPane.LogicalView; public ShowInLogicalView_Action() { super("Show Node in Logical View", "", ICON); this.setIsAlwaysVisible(false); this.setExecuteOutsideCommand(false); } @Override public boolean isDumbAware() { return true; } @Override public boolean isApplicable(AnActionEvent event, final Map<String, Object> _params) { Iterable<SModule> modules = (Iterable<SModule>) new FilteredGlobalScope().getModules(); SModule currentModule = check_fx2sd0_a0b0e(check_fx2sd0_a0a1a4(((SNode) MapSequence.fromMap(_params).get("node")))); return Sequence.fromIterable(modules).contains(currentModule); } @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; } { MPSProject p = event.getData(MPSCommonDataKeys.MPS_PROJECT); MapSequence.fromMap(_params).put("mpsProject", p); if (p == null) { return false; } } { SNode p = event.getData(MPSCommonDataKeys.NODE); MapSequence.fromMap(_params).put("node", p); if (p == null) { return false; } } return true; } @Override public void doExecute(@NotNull final AnActionEvent event, final Map<String, Object> _params) { ProjectPane pane = ProjectPane.getInstance(((MPSProject) MapSequence.fromMap(_params).get("mpsProject"))); SNode nodeToSelect = (pane.showNodeStructure() ? ((SNode) MapSequence.fromMap(_params).get("node")) : ((SNode) MapSequence.fromMap(_params).get("node")).getContainingRoot()); pane.selectNode(nodeToSelect, true); } private static SModule check_fx2sd0_a0b0e(SModel checkedDotOperand) { if (null != checkedDotOperand) { return checkedDotOperand.getModule(); } return null; } private static SModel check_fx2sd0_a0a1a4(SNode checkedDotOperand) { if (null != checkedDotOperand) { return checkedDotOperand.getModel(); } return null; } }