@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(); } } }
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); }
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(); } }
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(); } }
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); }
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(); } }
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; }
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); }
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(); } }
@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; }
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; }
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); }
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); } }
public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) { return ((EditorComponent) context.getEditorComponent()) .getSelectionManager() .getSelectionStackSize() > 1; }
public void execute(jetbrains.mps.openapi.editor.EditorContext context) { ((EditorComponent) context.getEditorComponent()).getSelectionManager().popSelection(); }
public void execute(jetbrains.mps.openapi.editor.EditorContext context) { ((EditorComponent) context.getEditorComponent()).showMessageTooltip(); }
public void execute(jetbrains.mps.openapi.editor.EditorContext context) { EditorComponent editorComponent = (EditorComponent) context.getEditorComponent(); EditorCell selection = editorComponent.getSelectedCell(); editorComponent.changeSelection(selection.getPrevLeaf(CellConditions.EDITABLE)); }
public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) { EditorCell selection = ((EditorComponent) context.getEditorComponent()).getSelectedCell(); return selection != null && selection.getPrevLeaf(CellConditions.EDITABLE) != null; }
public boolean canExecute(jetbrains.mps.openapi.editor.EditorContext context) { return findTarget(((EditorComponent) context.getEditorComponent()).getSelectionManager()) != null; }
public void execute(jetbrains.mps.openapi.editor.EditorContext context) { SelectionManager selectionManager = ((EditorComponent) context.getEditorComponent()).getSelectionManager(); selectionManager.setSelection(findTarget(selectionManager)); selectionManager.getSelection().ensureVisible(); }