Пример #1
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = (EditorCell) context.getSelectedCell();
   ((EditorComponent) context.getEditorComponent())
       .activateNodeSubstituteChooser(
           selection,
           ((selection instanceof EditorCell_Label)
               && ((EditorCell_Label) selection).isEverythingSelected()),
           true);
 }
Пример #2
0
 @Override
 public void execute(final jetbrains.mps.openapi.editor.EditorContext context) {
   EditorComponent editorComponent = ((EditorComponent) context.getEditorComponent());
   SelectionManager selectionManager = editorComponent.getSelectionManager();
   Selection selection = selectionManager.getSelection();
   if (selection instanceof SingularSelection) {
     EditorCell selectedCell = ((SingularSelection) selection).getEditorCell();
     SNode selectedNode = selectedCell.getSNode();
     SNode topMostNodeInSingularContainment =
         findTopMostNodeWithSingularContainment(selectedNode);
     if (topMostNodeInSingularContainment != selectedNode) {
       EditorCell nodeCell = editorComponent.findNodeCell(topMostNodeInSingularContainment);
       if (nodeCell != null) {
         editorComponent.pushSelection(nodeCell);
         editorComponent.scrollToCell(nodeCell);
       }
     } else {
       Selection newSelection =
           selectionManager.createRangeSelection(selectedNode, selectedNode);
       if (newSelection instanceof NodeRangeSelection && selectedCell.isBigCell()) {
         newSelection = ((NodeRangeSelection) newSelection).enlargeSelection(myUp);
       }
       if (newSelection != null) {
         selectionManager.pushSelection(newSelection);
         newSelection.ensureVisible();
       }
     }
   } else if (selection instanceof NodeRangeSelection) {
     Selection newSelection = ((NodeRangeSelection) selection).enlargeSelection(myUp);
     if (newSelection != null) {
       selectionManager.pushSelection(newSelection);
       newSelection.ensureVisible();
     }
   }
 }
Пример #3
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = getDeepestSelectedCell(context);
   EditorCell target = findTarget(selection);
   ((EditorComponent) context.getEditorComponent()).changeSelection(target);
   if (target instanceof EditorCell_Label) {
     EditorCell_Label label = (EditorCell_Label) target;
     label.end();
   }
 }
Пример #4
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   EditorCell cell = findTarget(selectionManager);
   selectionManager.pushSelection(selectionManager.createSelection(cell));
   if (cell instanceof EditorCell_Label) {
     ((EditorCell_Label) cell).selectWordOrAll();
   }
 }
Пример #5
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorComponent editorComponent = ((EditorComponent) context.getEditorComponent());
   EditorCell target = findTarget(editorComponent);
   if (target instanceof EditorCell_Label) {
     EditorCell_Label label = (EditorCell_Label) target;
     label.end();
     editorComponent.resetLastCaretX();
   }
   editorComponent.changeSelection(target);
 }
Пример #6
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = getDeepestSelectedCell(context);
   EditorCell target = findTarget(selection);
   ((EditorComponent) context.getEditorComponent()).changeSelection(target);
   if (target.isPunctuationLayout() && ((EditorCell_Label) target).isCaretPositionAllowed(1)) {
     ((EditorCell_Label) target).setCaretPosition(1);
   } else if (target instanceof EditorCell_Label) {
     EditorCell_Label label = (EditorCell_Label) target;
     label.home();
   }
 }
Пример #7
0
 private EditorCell getDeepestSelectedCell(jetbrains.mps.openapi.editor.EditorContext context) {
   Selection deepestSelection =
       ((EditorComponent) context.getEditorComponent())
           .getSelectionManager()
           .getDeepestSelection();
   if (deepestSelection instanceof SingularSelection) {
     return ((SingularSelection) deepestSelection).getEditorCell();
   } else if (deepestSelection instanceof NodeRangeSelection) {
     return ((NodeRangeSelection) deepestSelection).getLastCell();
   }
   return null;
 }
Пример #8
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selectedCell = getDeepestSelectedCell(context);
   int caretX = selectedCell.getCaretX();
   EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
   if (editorComponent.hasLastCaretX()) {
     caretX = editorComponent.getLastCaretX();
   }
   editorComponent.saveLastCaretX(caretX);
   EditorCell target = findTarget(selectedCell, caretX);
   target.setCaretX(caretX);
   editorComponent.changeSelection(target, false);
 }
Пример #9
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   EditorCell cell = findTarget(selectionManager);
   selectionManager.setSelection(cell);
   if (cell.isPunctuationLayout()
       && (cell instanceof EditorCell_Label)
       && ((EditorCell_Label) cell).isCaretPositionAllowed(1)) {
     ((EditorCell_Label) cell).setCaretPosition(1);
   } else {
     cell.home();
   }
 }
Пример #10
0
 @Override
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   // TODO: this check should be reallocated into Selection.canExecuteAction() method once it
   // created
   Selection selection =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager().getSelection();
   if (selection instanceof NodeRangeSelection) {
     return true;
   }
   if (selection instanceof SingularSelection) {
     EditorCell editorCell = ((SingularSelection) selection).getEditorCell();
     return editorCell.getSNode().getParent() != null;
   }
   return false;
 }
Пример #11
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   Selection selection = selectionManager.getSelection();
   if (selection instanceof SingularSelection) {
     SingularSelection singularSelection = (SingularSelection) selection;
     if (!expandSelection(singularSelection) && selectionManager.getSelectionStackSize() > 1) {
       return true;
     }
     EditorCell selected = singularSelection.getEditorCell();
     EditorCell nextLeaf = getNextLeaf(selected);
     return nextLeaf != null && getCommonSelectableAncestor(selected, nextLeaf) != null;
   }
   return false;
 }
Пример #12
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   SingularSelection selection = (SingularSelection) selectionManager.getSelection();
   if (!expandSelection(selection) && selectionManager.getSelectionStackSize() > 1) {
     selectionManager.popSelection();
     return;
   }
   EditorCell selected = selection.getEditorCell();
   EditorCell nextLeaf = getNextLeaf(selected);
   EditorCell cellToSelect = getCommonSelectableAncestor(selected, nextLeaf);
   Selection newSelection = selectionManager.createSelection(cellToSelect);
   if (newSelection instanceof SingularSelection) {
     ((SingularSelection) newSelection)
         .setSideSelectDirection(
             mySide == CellSide.LEFT ? SideSelectDirection.LEFT : SideSelectDirection.RIGHT);
   }
   selectionManager.pushSelection(newSelection);
 }
Пример #13
0
 private static void navigatePage(
     jetbrains.mps.openapi.editor.EditorContext context, boolean isDown) {
   EditorComponent editor = (EditorComponent) context.getEditorComponent();
   jetbrains.mps.openapi.editor.cells.EditorCell selection = editor.getSelectedCell();
   Rectangle rect = editor.getVisibleRect();
   int height = (int) rect.getHeight();
   height = isDown ? height : -height;
   int caretX = selection.getCaretX();
   int y = selection.getY() + (selection.getHeight() / 2);
   int newY = y + height;
   jetbrains.mps.openapi.editor.cells.EditorCell target = editor.findCellWeak(caretX, newY);
   if (target == null) {
     target =
         isDown
             ? editor.myRootCell.findChild(CellFinders.LAST_SELECTABLE_LEAF)
             : editor.myRootCell.findChild(CellFinders.FIRST_SELECTABLE_LEAF);
     editor.changeSelection(target);
   } else {
     target.setCaretX(caretX);
     editor.changeSelection(target);
   }
 }
Пример #14
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   return ((EditorComponent) context.getEditorComponent())
           .getSelectionManager()
           .getSelectionStackSize()
       > 1;
 }
Пример #15
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = (EditorCell) context.getSelectedCell();
   return selection != null && selection.getSubstituteInfo() != null;
 }
Пример #16
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   ((EditorComponent) context.getEditorComponent()).getSelectionManager().popSelection();
 }
Пример #17
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   ((EditorComponent) context.getEditorComponent()).showMessageTooltip();
 }
Пример #18
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
   EditorCell selection = editorComponent.getSelectedCell();
   editorComponent.changeSelection(selection.getPrevLeaf(CellConditions.EDITABLE));
 }
Пример #19
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = ((EditorComponent) context.getEditorComponent()).getSelectedCell();
   return selection != null && selection.getPrevLeaf(CellConditions.EDITABLE) != null;
 }
Пример #20
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   return findTarget(((EditorComponent) context.getEditorComponent()).getSelectionManager())
       != null;
 }
Пример #21
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   selectionManager.setSelection(findTarget(selectionManager));
   selectionManager.getSelection().ensureVisible();
 }