Examples of SelectionModel


Examples of com.google.collide.client.editor.selection.SelectionModel

        "color: black;\n",
        "fake: ;\n",
        "}\n"
    });
    helper.setup(new PathUtil("test.css"), text, 1, 3, false);
    SelectionModel selection = helper.editor.getSelection();

    AutocompleteProposals completions = cssAutocompleter.findAutocompletions(selection, CTRL_SPACE);
    assertEquals(1, completions.size());
    AutocompleteResult commonResult = cssAutocompleter.computeAutocompletionResult(
        completions.select(0));
    assertTrue("result type", commonResult instanceof DefaultAutocompleteResult);
    DefaultAutocompleteResult result = (DefaultAutocompleteResult) commonResult;
    assertEquals(8, result.getJumpLength());
    assertEquals("cursor: ;", result.getAutocompletionText());

    CssCompletionQuery query = cssAutocompleter.updateOrCreateQuery(
        null, selection.getCursorPosition());
    JsoArray<String> completedProperties = query.getCompletedProperties();
    assertEquals(2, completedProperties.size());
    assertEquals("color", completedProperties.get(0));
    assertEquals("fake", completedProperties.get(1));
  }
View Full Code Here

Examples of com.google.collide.client.editor.selection.SelectionModel

      }
    });
  }

  private void startNewLine(Editor editor) {
    SelectionModel selection = editor.getSelection();
    selection.deselect();
    Line line = selection.getCursorLine();
    int lineNumber = selection.getCursorLineNumber();
    int lastCursorColumn = LineUtils.getLastCursorColumn(line);
    selection.setCursorPosition(new LineInfo(line, lineNumber), lastCursorColumn);
    editor.getEditorDocumentMutator().insertText(line, lineNumber, lastCursorColumn, "\n");
  }
View Full Code Here

Examples of com.google.collide.client.editor.selection.SelectionModel

    editor.getEditorDocumentMutator().insertText(line, lineNumber, lastCursorColumn, "\n");
  }

  private void splitLine(Editor editor) {
    // TODO: Add language specific logic (i.e. string splitting).
    SelectionModel selection = editor.getSelection();
    Position[] selectionRange = selection.getSelectionRange(false);
    Position cursor = selectionRange[0];

    editor.getEditorDocumentMutator().insertText(cursor.getLine(), cursor.getLineNumber(),
        cursor.getColumn(), "\n", true);
    selection.setCursorPosition(cursor.getLineInfo(), cursor.getColumn());
  }
View Full Code Here

Examples of com.google.collide.client.editor.selection.SelectionModel

  private void saveSelection() {
    if (fileEditSessionKey == null) {
      return;
    }

    SelectionModel selectionModel = editor.getSelection();
    Buffer buffer = editor.getBuffer();

    int cursorLineNumber = selectionModel.getCursorLineNumber();
    int cursorScrollTopOffset = buffer.calculateLineTop(cursorLineNumber) - buffer.getScrollTop();

    selections.put(fileEditSessionKey, new Selection(selectionModel.getBaseLineNumber(),
        selectionModel.getBaseColumn(), cursorLineNumber, selectionModel.getCursorColumn(),
        cursorScrollTopOffset));
  }
View Full Code Here

Examples of com.google.collide.client.editor.selection.SelectionModel

    return popupAction;
  }

  @Override
  public void apply(Editor editor) {
    SelectionModel selection = editor.getSelection();
    Position[] selectionRange = selection.getSelectionRange(false);
    boolean selectionChanged = false;

    // 1) New beginning of selection based on suffix-matching and
    //    backspaceCount
    Position selectionStart = selectionRange[0];
    int selectionStartColumn = selectionStart.getColumn();
    String textBefore = selectionStart.getLine().getText().substring(0, selectionStartColumn);
    if (!textBefore.endsWith(preContentSuffix)) {
      Log.warn(getClass(),
          "expected suffix [" + preContentSuffix + "] do not match [" + textBefore + "]");
      return;
    }
    int matchCount = preContentSuffix.length();

    int leftOffset = backspaceCount + matchCount;
    if (leftOffset > 0) {
      selectionStart = getPosition(selectionStart, -leftOffset);
      selectionChanged = true;
    }

    // 2) Calculate end of selection
    Position selectionEnd = selectionRange[1];
    if (deleteCount > 0) {
      selectionEnd = getPosition(selectionEnd, deleteCount);
      selectionChanged = true;
    }

    // 3) Set selection it was changed.
    if (selectionChanged) {
      selection.setSelection(selectionStart.getLineInfo(), selectionStart.getColumn(),
          selectionEnd.getLineInfo(), selectionEnd.getColumn());
    }

    // 4) Replace selection
    EditorDocumentMutator mutator = editor.getEditorDocumentMutator();
    if (selection.hasSelection() || autocompletionText.length() > 0) {
      mutator.insertText(selectionStart.getLine(), selectionStart.getLineNumber(),
          selectionStart.getColumn(), autocompletionText);
    }

    // 5) Move cursor / set final selection
    selectionEnd = getPosition(selectionStart, jumpLength);
    if (selectionCount == 0) {
      selection.setCursorPosition(selectionEnd.getLineInfo(), selectionEnd.getColumn());
    } else {
      selectionStart = getPosition(selectionStart, jumpLength - selectionCount);
      selection.setSelection(selectionStart.getLineInfo(), selectionStart.getColumn(),
          selectionEnd.getLineInfo(), selectionEnd.getColumn());
    }
  }
View Full Code Here

Examples of com.google.collide.client.editor.selection.SelectionModel

  }

  private void goToDefinitionAtCurrentCaretPosition() {
    // TODO: Check here that our code model is fresh enough.
    // int caretOffset = getCaretOffset(editor.getWidget().getElement());
    SelectionModel selection = editor.getSelection();
    LineInfo lineInfo = new LineInfo(selection.getCursorLine(), selection.getCursorLineNumber());
    NavigableReference reference =
        referenceStore.findReference(lineInfo, selection.getCursorColumn(), true);
    navigateReference(reference);
  }
View Full Code Here

Examples of com.google.gwt.view.client.SelectionModel

        dataSource.markRetrieveStart();
        assertTrue(dataSource.isRetrieveActive());

        List<String> visibleItems = new ArrayList<String>();
        SelectionModel selectionModel = mock(SelectionModel.class);
        when(renderer.getDisplay().getSelectionModel()).thenReturn(selectionModel);
        when(renderer.getDisplay().getVisibleItems()).thenReturn(visibleItems);
        dataSource.applyResults(43, results);
        assertFalse(dataSource.isRetrieveActive());
        InOrder order = inOrder(dataSource.getDisplay());
View Full Code Here

Examples of com.google.gwt.view.client.SelectionModel

        assertTrue(dataSource.isRetrieveActive());

        List<String> visibleItems = new ArrayList<String>();
        visibleItems.add("whatever");

        SelectionModel selectionModel = mock(SelectionModel.class);
        when(renderer.getDisplay().getSelectionModel()).thenReturn(selectionModel);
        when(renderer.getDisplay().getVisibleItems()).thenReturn(visibleItems);
        dataSource.applyResults(43, results);
        assertFalse(dataSource.isRetrieveActive());
        InOrder order = inOrder(dataSource.getDisplay(), selectionModel);
View Full Code Here

Examples of com.intellij.openapi.editor.SelectionModel

    }

    public String preprocessOnPaste(Project project, PsiFile file, Editor editor, String text, RawText rawText) {
        Document document = editor.getDocument();
        PsiDocumentManager.getInstance(project).commitDocument(document);
        SelectionModel selectionModel = editor.getSelectionModel();

        // pastes in block selection mode (column mode) are not handled by a CopyPasteProcessor
        int selectionStart = selectionModel.getSelectionStart();
        int selectionEnd = selectionModel.getSelectionEnd();
        IElementType tokenType = findLiteralTokenType(file, selectionStart, selectionEnd);

        if (tokenType == HaskellTokenTypes.STRING) {
            if (rawText != null && rawText.rawText != null)
                return rawText.rawText; // Copied from the string literal. Copy as is.
View Full Code Here

Examples of com.intellij.openapi.editor.SelectionModel

    }

    public void loadFromEditor(@NotNull FileEditorStateLevel level, @NotNull TextEditor textEditor) {
        Editor editor = textEditor.getEditor();
        Project project = editor.getProject();
        SelectionModel selectionModel = editor.getSelectionModel();
        LogicalPosition logicalPosition = editor.getCaretModel().getLogicalPosition();

        line = logicalPosition.line;
        column = logicalPosition.column;

        if(FileEditorStateLevel.FULL == level) {
            selectionStart = selectionModel.getSelectionStart();
            selectionEnd = selectionModel.getSelectionEnd();

/*            if(project != null){
                PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
                CodeFoldingState foldingState = CodeFoldingManager.getInstance(project).saveFoldingState(editor);
                setFoldingState(foldingState);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.