package jetbrains.mps.baseLanguage.regexp.editor;
/*Generated by MPS */
import jetbrains.mps.openapi.editor.cells.EditorCell;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.openapi.editor.EditorContext;
import jetbrains.mps.openapi.editor.cells.CellActionType;
import jetbrains.mps.editor.runtime.cells.AbstractCellAction;
import jetbrains.mps.smodel.action.SNodeFactoryOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import jetbrains.mps.editor.runtime.selection.SelectionUtil;
import jetbrains.mps.openapi.editor.selection.SelectionManager;
public class RegexpSequenceByEnter {
public static void setCellActions(EditorCell editorCell, SNode node, EditorContext context) {
editorCell.setAction(CellActionType.INSERT_BEFORE, new RegexpSequenceByEnter.RegexpSequenceByEnter_INSERT_BEFORE(node));
editorCell.setAction(CellActionType.INSERT, new RegexpSequenceByEnter.RegexpSequenceByEnter_INSERT(node));
}
public static class RegexpSequenceByEnter_INSERT_BEFORE extends AbstractCellAction {
/*package*/ SNode myNode;
public RegexpSequenceByEnter_INSERT_BEFORE(SNode node) {
this.myNode = node;
}
public String getDescriptionText() {
return "insert an item before";
}
public void execute(EditorContext editorContext) {
this.execute_internal(editorContext, this.myNode);
}
public void execute_internal(EditorContext editorContext, SNode node) {
SNode nt = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174bc30e7L, "jetbrains.mps.baseLanguage.regexp.structure.SeqRegexp")), null);
SNodeOperations.replaceWithAnother(node, nt);
SLinkOperations.setTarget(nt, MetaAdapterFactory.getContainmentLink(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174c56bf9L, 0x11174c5a26fL, "right"), node);
SelectionUtil.selectCell(editorContext, SLinkOperations.getTarget(nt, MetaAdapterFactory.getContainmentLink(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174c56bf9L, 0x11174c59241L, "left")), SelectionManager.FIRST_CELL);
}
}
public static class RegexpSequenceByEnter_INSERT extends AbstractCellAction {
/*package*/ SNode myNode;
public RegexpSequenceByEnter_INSERT(SNode node) {
this.myNode = node;
}
public String getDescriptionText() {
return "insert an item after";
}
public void execute(EditorContext editorContext) {
this.execute_internal(editorContext, this.myNode);
}
public void execute_internal(EditorContext editorContext, SNode node) {
SNode nt = SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174bc30e7L, "jetbrains.mps.baseLanguage.regexp.structure.SeqRegexp")), null);
SNodeOperations.replaceWithAnother(node, nt);
SLinkOperations.setTarget(nt, MetaAdapterFactory.getContainmentLink(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174c56bf9L, 0x11174c59241L, "left"), node);
SelectionUtil.selectCell(editorContext, SLinkOperations.getTarget(nt, MetaAdapterFactory.getContainmentLink(0xdaafa647f1f74b0bL, 0xb09669cd7c8408c0L, 0x11174c56bf9L, 0x11174c5a26fL, "right")), SelectionManager.FIRST_CELL);
}
}
}