Ejemplo n.º 1
0
 private jetbrains.mps.openapi.editor.cells.EditorCell getAnchorCell(
     EditorMessageIconRenderer renderer) {
   SNode rendererNode = renderer.getNode();
   EditorCell nodeCell = myEditorComponent.findNodeCell(rendererNode);
   if (nodeCell == null) {
     // no cell for node?..
     return null;
   }
   return renderer.getAnchorCell(nodeCell);
 }
Ejemplo n.º 2
0
  @Override
  public void execute(EditorContext context) {
    LOG.assertInCommand();
    EditorComponent editorComponent = (EditorComponent) context.getEditorComponent();
    EditorCell selectedCell = editorComponent.getSelectedCell();
    SNode anchorNode = selectedCell.getSNode();

    PasteNodeData pasteNodeData =
        CopyPasteUtil.getPasteNodeDataFromClipboard(anchorNode.getModel());
    if (pasteNodeData == null || pasteNodeData.getNodes().isEmpty()) {
      pasteNodeData =
          CopyPasteUtil.getConvertedFromClipboard(
              anchorNode.getModel(), context.getOperationContext().getProject());
      if (pasteNodeData == null) return;
    }
    List<SNode> pasteNodes = pasteNodeData.getNodes();
    Set<SReference> requireResolveReferences = pasteNodeData.getRequireResolveReferences();

    new NodePaster(pasteNodes).pasteRelative(anchorNode, myPastePlaceHint);
    ResolverComponent.getInstance()
        .resolveScopesOnly(requireResolveReferences, context.getOperationContext());

    // set selection
    editorComponent.flushEvents();
    EditorCell nodeCell = editorComponent.findNodeCell(pasteNodes.get(0));
    if (nodeCell == null) return; // after 'set reference'?
    EditorCell_Label labelCell =
        CellFinderUtil.findChildByClass(nodeCell, EditorCell_Label.class, true);

    if (labelCell != null) {
      editorComponent.changeSelection(labelCell);
    }

    if (pasteNodes.size() == 1) {
      editorComponent.pushSelection(nodeCell);
    } else {
      SelectionManager selectionManager = editorComponent.getSelectionManager();
      selectionManager.pushSelection(
          selectionManager.createRangeSelection(
              pasteNodes.get(0), pasteNodes.get(pasteNodes.size() - 1)));
    }
  }
Ejemplo n.º 3
0
 public LeftEditorHighlighterDataContext(
     @NotNull EditorComponent editorComponent, SNode selectedNode) {
   myEditorDataContext = DataManager.getInstance().getDataContext(editorComponent);
   mySelectedNode = selectedNode;
   myNodeCell = editorComponent.findNodeCell(mySelectedNode);
 }