use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.
the class BasicActiveFileHandler method scrollToLine.
protected void scrollToLine(EditorPartPresenter editor, int lineNumber) {
if (editor instanceof TextEditor) {
TextEditor textEditor = (TextEditor) editor;
Document document = textEditor.getDocument();
if (document != null) {
TextPosition newPosition = new TextPosition(lineNumber, 0);
document.setCursorPosition(newPosition);
}
}
}
use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.
the class TestResultViewImpl method gotoClass.
@Override
public void gotoClass(String packagePath, int line) {
lastWentLine = line;
final Project project = appContext.getRootProject();
String testSrcPath = project.getPath() + "/" + DEFAULT_TEST_SOURCE_FOLDER;
appContext.getWorkspaceRoot().getFile(testSrcPath + packagePath).then(new Operation<Optional<File>>() {
@Override
public void apply(Optional<File> file) throws OperationException {
if (file.isPresent()) {
eventBus.fireEvent(FileEvent.createOpenFileEvent(file.get()));
Timer t = new Timer() {
@Override
public void run() {
EditorPartPresenter editorPart = editorAgent.getActiveEditor();
Document doc = ((TextEditor) editorPart).getDocument();
doc.setCursorPosition(new TextPosition(lastWentLine - 1, 0));
}
};
t.schedule(500);
}
}
}).catchError(new Operation<PromiseError>() {
@Override
public void apply(PromiseError error) throws OperationException {
Log.info(TestResultViewImpl.class, error);
}
});
}
use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.
the class CloseCStyleCommentChangeInterceptorTest method testStartNotEmptyLine.
@Test
public void testStartNotEmptyLine() {
doReturn("whatever").when(document).getLineContent(0);
doReturn("s/*").when(document).getLineContent(1);
doReturn(" *").when(document).getLineContent(2);
final TextChange input = new TextChange.Builder().from(new TextPosition(1, 3)).to(new TextPosition(2, 2)).insert("\n *").build();
final TextChange output = interceptor.processChange(input, document);
assertNull(output);
}
use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.
the class CloseCStyleCommentChangeInterceptorTest method testPasteWholeCommentStart.
@Test
public void testPasteWholeCommentStart() {
doReturn("/**").when(document).getLineContent(0);
doReturn(" *").when(document).getLineContent(1);
final TextChange input = new TextChange.Builder().from(new TextPosition(0, 0)).to(new TextPosition(1, 2)).insert("/**\n *").build();
final TextChange output = interceptor.processChange(input, document);
assertNull(output);
}
use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.
the class CloseCStyleCommentChangeInterceptorTest method testWithLeading.
private void testWithLeading(final String lead) {
doReturn(lead + "/*").when(document).getLineContent(1);
doReturn(lead + " *").when(document).getLineContent(2);
final TextChange input = new TextChange.Builder().from(new TextPosition(1, 2 + lead.length())).to(new TextPosition(2, 2 + lead.length())).insert("\n" + lead + " *").build();
final TextChange output = interceptor.processChange(input, document);
assertNotNull(output);
final TextChange expected = new TextChange.Builder().from(new TextPosition(1, 2 + lead.length())).to(new TextPosition(3, 3 + lead.length())).insert("\n" + lead + " * " + "\n" + lead + " */").build();
Assert.assertEquals(expected, output);
}
Aggregations