package jetbrains.mps.samples.multipleProjections.requestTracking.intentions; /*Generated by MPS */ import jetbrains.mps.intentions.AbstractIntentionDescriptor; import jetbrains.mps.openapi.intentions.IntentionFactory; import java.util.Collection; import jetbrains.mps.openapi.intentions.IntentionExecutable; import jetbrains.mps.openapi.intentions.Kind; import jetbrains.mps.smodel.SNodePointer; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.openapi.editor.EditorContext; import java.util.Collections; import jetbrains.mps.intentions.AbstractIntentionExecutable; import jetbrains.mps.openapi.intentions.IntentionDescriptor; public final class ViewAsTabular_Intention extends AbstractIntentionDescriptor implements IntentionFactory { private Collection<IntentionExecutable> myCachedExecutable; public ViewAsTabular_Intention() { super(Kind.NORMAL, true, new SNodePointer("r:609c99e8-3a24-425d-8723-60cb603f5c76(jetbrains.mps.samples.multipleProjections.requestTracking.intentions)", "1007054899182276663")); } @Override public String getPresentation() { return "ViewAsTabular"; } @Override public boolean isApplicable(final SNode node, final EditorContext editorContext) { return true; } @Override public boolean isSurroundWith() { return false; } public Collection<IntentionExecutable> instances(final SNode node, final EditorContext context) { if (myCachedExecutable == null) { myCachedExecutable = Collections.<IntentionExecutable>singletonList(new ViewAsTabular_Intention.IntentionImplementation()); } return myCachedExecutable; } /*package*/ final class IntentionImplementation extends AbstractIntentionExecutable { public IntentionImplementation() { } @Override public String getDescription(final SNode node, final EditorContext editorContext) { String[] explicitEditorHintsForNode = editorContext.getEditorComponent().getUpdater().getExplicitEditorHintsForNode(node.getReference()); if (explicitEditorHintsForNode == null || explicitEditorHintsForNode.length == 0) { return "View As Tabular"; } else { return "View As Structural"; } } @Override public void execute(final SNode node, final EditorContext editorContext) { String[] explicitEditorHintsForNode = editorContext.getEditorComponent().getUpdater().getExplicitEditorHintsForNode(node.getReference()); editorContext.getEditorComponent().getUpdater().clearExplicitHints(); if (explicitEditorHintsForNode == null || explicitEditorHintsForNode.length == 0) { editorContext.getEditorComponent().getUpdater().addExplicitEditorHintsForNode(node.getReference(), new String[]{"jetbrains.mps.samples.multipleProjections.requestTracking.editor.WorkflowPresentations.tabular"}); } else { editorContext.getEditorComponent().getUpdater().addExplicitEditorHintsForNode(node.getReference(), new String[]{}); } editorContext.getEditorComponent().getUpdater().update(); } @Override public IntentionDescriptor getDescriptor() { return ViewAsTabular_Intention.this; } } }