Example #1
0
 private EditorCell findTarget(EditorCell cell) {
   EditorCell toLeft = cell.getLeafToLeft(CellConditions.SELECTABLE);
   if (toLeft != null) {
     return toLeft;
   }
   return cell.getPrevLeaf(CellConditions.SELECTABLE);
 }
Example #2
0
 private EditorCell getNextLeaf(EditorCell current) {
   if (mySide == CellSide.LEFT) {
     return current.getPrevLeaf(CellConditions.SELECTABLE);
   } else {
     return current.getNextLeaf(CellConditions.SELECTABLE);
   }
 }
 public void execute_internal(EditorContext editorContext, SNode node) {
   jetbrains.mps.nodeEditor.cells.EditorCell current =
       (jetbrains.mps.nodeEditor.cells.EditorCell) editorContext.getSelectedCell();
   jetbrains.mps.nodeEditor.cells.EditorCell toSelect =
       current.getPrevLeaf(CellConditions.SELECTABLE);
   SPropertyOperations.set(node, "caseInsensitive", "" + (false));
   editorContext.getEditorComponent().changeSelection(toSelect);
 }
Example #4
0
  private boolean processSideDeletes(CellActionType type) {
    // TODO: review this logic - it was originally copied from EditorComponentKeyboardHandler
    final EditorCell selectedCell = getEditorCell();
    if (type == CellActionType.DELETE
        && selectedCell.isLastPositionInBigCell()
        && !selectedCell.isFirstPositionInBigCell()) {
      final EditorCell target;
      if (selectedCell.isLastPositionInBigCell()
          && selectedCell.getContainingBigCell().getNextSibling() != null) {
        target = selectedCell.getContainingBigCell().getNextSibling();
      } else if (selectedCell.getNextSibling() != null) {
        target = selectedCell.getNextSibling();
      } else {
        target = selectedCell.getNextLeaf(CellConditions.SELECTABLE);
      }

      if (target == null
          || ModelAccess.instance()
              .runReadAction(
                  new Computable<Boolean>() {
                    public Boolean compute() {
                      return target.getSNode().isAncestorOf(selectedCell.getSNode());
                    }
                  })) return false;

      return target.executeAction(CellActionType.DELETE);
    }

    if (type == CellActionType.BACKSPACE
        && selectedCell.isFirstPositionInBigCell()
        && !selectedCell.isLastPositionInBigCell()) {
      final EditorCell target;
      if (selectedCell.isFirstPositionInBigCell()
          && selectedCell.getContainingBigCell().getPrevSibling() != null) {
        target = selectedCell.getContainingBigCell().getPrevSibling();
      } else if (selectedCell.getPrevSibling() != null) {
        target = selectedCell.getPrevSibling();
      } else {
        target = selectedCell.getPrevLeaf(CellConditions.SELECTABLE);
      }

      if (target == null) return false;
      /*
      if (ModelAccess.instance().runReadAction(new Computable<Boolean>() {
        public Boolean compute() {
          return target.getSNode().isAncestorOf(selectedCell.getSNode());
        }
      })) return false;
      */
      return target.executeAction(CellActionType.DELETE);
    }
    return false;
  }
Example #5
0
 private EditorCell findTarget(SelectionManager selectionManager) {
   Selection selection = selectionManager.getSelection();
   if (selection == null) {
     return null;
   }
   List<EditorCell> selectedCells = selection.getSelectedCells();
   EditorCell cell = myHome ? selectedCells.get(0) : selectedCells.get(selectedCells.size() - 1);
   EditorCell leaf =
       myHome
           ? cell.getLeafToLeft(CellConditions.SELECTABLE)
           : cell.getLeafToRight(CellConditions.SELECTABLE);
   if (leaf != null) {
     return leaf;
   }
   return myHome
       ? cell.getPrevLeaf(CellConditions.SELECTABLE)
       : cell.getNextLeaf(CellConditions.SELECTABLE);
 }
Example #6
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));
 }
Example #7
0
 public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) {
   EditorCell selection = ((EditorComponent) context.getEditorComponent()).getSelectedCell();
   return selection != null && selection.getPrevLeaf(CellConditions.EDITABLE) != null;
 }
 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);
 }