Exemplo n.º 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);
 }
Exemplo n.º 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();
     }
   }
 }
Exemplo n.º 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();
   }
 }
Exemplo n.º 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();
   }
 }
Exemplo n.º 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);
 }
Exemplo n.º 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();
   }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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();
   }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 14
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   return ((EditorComponent) context.getEditorComponent())
           .getSelectionManager()
           .getSelectionStackSize()
       > 1;
 }
Exemplo n.º 15
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = (EditorCell) context.getSelectedCell();
   return selection != null && selection.getSubstituteInfo() != null;
 }
Exemplo n.º 16
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   ((EditorComponent) context.getEditorComponent()).getSelectionManager().popSelection();
 }
Exemplo n.º 17
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   ((EditorComponent) context.getEditorComponent()).showMessageTooltip();
 }
Exemplo n.º 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));
 }
Exemplo n.º 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;
 }
Exemplo n.º 20
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   return findTarget(((EditorComponent) context.getEditorComponent()).getSelectionManager())
       != null;
 }
Exemplo n.º 21
0
 public void execute(jetbrains.mps.openapi.editor.EditorContext context) {
   SelectionManager selectionManager =
       ((EditorComponent) context.getEditorComponent()).getSelectionManager();
   selectionManager.setSelection(findTarget(selectionManager));
   selectionManager.getSelection().ensureVisible();
 }