Esempio n. 1
0
 public static void extractComponent(final SNode node, EditorContext editorContext) {
   final SNode container =
       SNodeOperations.getAncestor(
           node, "jetbrains.mps.lang.editor.structure.BaseEditorComponent", false, false);
   final String componentName =
       JOptionPane.showInputDialog(
           editorContext.getNodeEditorComponent(), "Enter a component name:", "");
   if (componentName == null) {
     return;
   }
   ModelAccess.instance()
       .runWriteActionInCommand(
           new Runnable() {
             public void run() {
               SModel model = SNodeOperations.getModel(node);
               SNode component =
                   SModelOperations.createNewRootNode(
                       model,
                       "jetbrains.mps.lang.editor.structure.EditorComponentDeclaration",
                       null);
               SPropertyOperations.set(component, "name", componentName);
               SLinkOperations.setTarget(
                   component,
                   "conceptDeclaration",
                   ((SNode)
                       BehaviorManager.getInstance()
                           .invoke(
                               Object.class,
                               SNodeOperations.cast(
                                   container,
                                   "jetbrains.mps.lang.editor.structure.AbstractComponent"),
                               "virtual_getConceptDeclaration_7055725856388417603",
                               new Class[] {SNode.class})),
                   false);
               SLinkOperations.setTarget(
                   component, "cellModel", SNodeOperations.copyNode(node), true);
               SNode toReplace =
                   SConceptOperations.createNewNode(
                       "jetbrains.mps.lang.editor.structure.CellModel_Component", null);
               SLinkOperations.setTarget(toReplace, "editorComponent", component, false);
               SNodeOperations.replaceWithAnother(node, toReplace);
             }
           });
 }
 public void execute_internal(EditorContext editorContext, SNode node) {
   EditorCell current = editorContext.getSelectedCell();
   EditorCell toSelect = current.getPrevLeaf(CellConditions.SELECTABLE);
   SPropertyOperations.set(node, "caseInsensitive", "" + false);
   editorContext.getNodeEditorComponent().changeSelection(toSelect);
 }