Package com.google.collide.shared.document.anchor

Examples of com.google.collide.shared.document.anchor.Anchor


    LineInfo lineInfo = lineFinder.findLine(1);

    Editor editor = Editor.create(new MockAppContext());
    editor.setDocument(doc);

    Anchor topAnchor = anchorManager.createAnchor(topType, lineInfo.line(), lineInfo.number(),
        AnchorManager.IGNORE_COLUMN);
    topAnchor.setRemovalStrategy(Anchor.RemovalStrategy.SHIFT);
    topAnchor.setInsertionPlacementStrategy(InsertionPlacementStrategy.EARLIER);

    Anchor bottomAnchor = anchorManager.createAnchor(bottomType, lineInfo.line(), lineInfo.number(),
        AnchorManager.IGNORE_COLUMN);
    bottomAnchor.setRemovalStrategy(Anchor.RemovalStrategy.SHIFT);
    bottomAnchor.setInsertionPlacementStrategy(InsertionPlacementStrategy.LATER);

    SelectionModel selection = editor.getSelection();

    selection.setSelection(lineInfo, 1, lineInfo, 4);
View Full Code Here


       * participant model listener will set the color)
       */
      cursorView.setColor(participant.getColor());
    }

    Anchor anchor =
        document.getAnchorManager().createAnchor(COLLABORATOR_CURSOR_ANCHOR_TYPE, line, lineNumber,
            column);
    anchor.setRemovalStrategy(RemovalStrategy.SHIFT);
    buffer.addAnchoredElement(anchor, cursorView.getElement());

    collaboratorStates.put(userId, new CollaboratorState(anchor, cursorView));
  }
View Full Code Here

  private static final AnchorType PARSER_ANCHOR_TYPE = AnchorType.create(DocumentParser.class,
      "parser");

  private Anchor createParserPosition(Document document) {
    Anchor position =
        document.getAnchorManager().createAnchor(PARSER_ANCHOR_TYPE, document.getFirstLine(), 0,
            AnchorManager.IGNORE_COLUMN);
    position.setRemovalStrategy(RemovalStrategy.SHIFT);
    return position;
  }
View Full Code Here

  public List<DocumentSelection> getDocumentSelections(String resourceId) {

    List<DocumentSelection> selections = Lists.newArrayList();
    for (UserSelection userSelection : userSelections.values()) {
      if (userSelection.resourceId.equals(resourceId)) {
        Anchor cursorAnchor = userSelection.cursorAnchor;
        Anchor baseAnchor = userSelection.baseAnchor;
        if (cursorAnchor != null && baseAnchor != null) {
          FilePositionImpl basePosition = FilePositionImpl.make()
              .setColumn(baseAnchor.getColumn()).setLineNumber(baseAnchor.getLineNumber());
          FilePositionImpl cursorPosition = FilePositionImpl.make().setColumn(
              cursorAnchor.getColumn()).setLineNumber(cursorAnchor.getLineNumber());
          DocumentSelectionImpl selection = DocumentSelectionImpl.make()
              .setUserId(userSelection.clientId).setBasePosition(basePosition)
              .setCursorPosition(cursorPosition);
View Full Code Here

    int distanceFromFirstLine = targetLineNumber;
    int distanceFromLastLine = document.getLineCount() - targetLineNumber - 1;

    int distanceFromClosestLineAnchor;
    Anchor closestLineAnchor =
        document.getAnchorManager().findClosestAnchorWithLineNumber(targetLineNumber);
    if (closestLineAnchor != null) {
      distanceFromClosestLineAnchor =
          Math.abs(closestLineAnchor.getLineInfo().number() - targetLineNumber);
    } else {
      distanceFromClosestLineAnchor = Integer.MAX_VALUE;
    }

    LineInfo lineInfo;
    if (distanceFromClosestLineAnchor < distanceFromFirstLine
        && distanceFromClosestLineAnchor < distanceFromLastLine) {
      lineInfo = closestLineAnchor.getLineInfo();
    } else if (distanceFromFirstLine < distanceFromLastLine) {
      lineInfo = new LineInfo(document.getFirstLine(), 0);
    } else {
      lineInfo = new LineInfo(document.getLastLine(), document.getLineCount() - 1);
    }
View Full Code Here

    if (!chunkText.isEmpty()) {
      Line lastLine = document.getLastLine();
      int lastColumn = lastLine.getText().length();

      document.insertText(lastLine, document.getLastLineNumber(), lastColumn, chunkText);
      Anchor anchor = document.getAnchorManager().createAnchor(
          DIFF_CHUNK_ANCHOR_TYPE, lastLine, AnchorManager.IGNORE_LINE_NUMBER, lastColumn);
      anchor.setValue(chunkStyles.get(chunkType.toString()));
      // TODO Below is temp fix to ensure
      // "Left should never have Green. Right should never have Red"
      if (isBeforeFile) {
        if (chunkType == DiffChunkResponse.DiffType.ADDED_LINE
            || chunkType == DiffChunkResponse.DiffType.ADDED) {
          anchor.setValue(diffBlockStyle);
        } else if (chunkType == DiffChunkResponse.DiffType.CHANGED) {
          anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.REMOVED.toString()));
        } else if (chunkType == DiffChunkResponse.DiffType.CHANGED_LINE) {
          anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.REMOVED_LINE.toString()));
        }
      } else {
        if (chunkType == DiffChunkResponse.DiffType.REMOVED
            || chunkType == DiffChunkResponse.DiffType.REMOVED_LINE) {
          anchor.setValue(diffBlockStyle);
        } else if (chunkType == DiffChunkResponse.DiffType.CHANGED) {
          anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.ADDED.toString()));
        } else if (chunkType == DiffChunkResponse.DiffType.CHANGED_LINE) {
          anchor.setValue(chunkStyles.get(DiffChunkResponse.DiffType.ADDED_LINE.toString()));
        }
      }
    }
  }
View Full Code Here

  }

  public Anchor anchorBreakpoint(Breakpoint breakpoint) {
    LineInfo lineInfo = document.getLineFinder().findLine(breakpoint.getLineNumber());

    Anchor anchor = document.getAnchorManager().createAnchor(BREAKPOINT_ANCHOR_TYPE,
        lineInfo.line(), lineInfo.number(), AnchorManager.IGNORE_COLUMN);
    anchor.setRemovalStrategy(Anchor.RemovalStrategy.SHIFT);
    anchor.setValue(breakpoint);
    anchor.getShiftListenerRegistrar().add(anchorShiftListener);

    if (anchors.isEmpty()) {
      document.getTextListenerRegistrar().add(documentTextListener);
    }
View Full Code Here

    // collaborative editing), we consider this tolerable.
    anchors.sort(anchorComparator);

    int deltaSum = 0;
    for (int i = 0, n = anchors.size(); i < n; ++i) {
      Anchor anchor = anchors.get(i);
      Breakpoint breakpoint = anchor.getValue();
      deltaSum += anchor.getLineNumber() - breakpoint.getLineNumber();
    }

    for (int i = 0, n = anchors.size(); i < n; ++i) {
      Anchor anchor = anchors.get(deltaSum < 0 ? i : n - 1 - i);
      Breakpoint oldBreakpoint = anchor.getValue();
      Breakpoint newBreakpoint = new Breakpoint.Builder(oldBreakpoint)
          .setLineNumber(anchor.getLineNumber())
          .build();
      debuggingModel.updateBreakpoint(oldBreakpoint, newBreakpoint);
    }
  }
View Full Code Here

    if (breakpointDescriptionListener == null) {
      return;
    }

    for (int i = 0, n = anchors.size(); i < n; ++i) {
      Anchor anchor = anchors.get(i);
      Breakpoint breakpoint = anchor.getValue();
      String newText = anchor.getLine().getText();
      breakpointDescriptionListener.onBreakpointDescriptionChange(breakpoint, newText);
    }
  }
View Full Code Here

    root = null;
    document = null;
  }

  private static void collectAttachedAnchors(JsonArray<Anchor> anchors, OutlineNode node) {
    Anchor anchor = node.getAnchor();
    if (anchor != null && anchor.isAttached()) {
      anchors.add(anchor);
    }
    JsonArray<OutlineNode> children = node.getChildren();
    if (children == null) {
      return;
View Full Code Here

TOP

Related Classes of com.google.collide.shared.document.anchor.Anchor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.