use of org.eclipse.ui.texteditor.ITextEditor in project dbeaver by serge-rider.
the class SQLAnnotationHover method findAnnotations.
/**
* Finds annotations either by offset or by lineNumber
*/
private void findAnnotations(int offset, IAnnotationModel model, IDocument document, int lineNumber) {
annotations.clear();
if (model == null) {
if (editor != null) {
ITextEditor editor = this.editor;
model = editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
}
}
if (model == null) {
return;
}
for (Iterator<?> it = model.getAnnotationIterator(); it.hasNext(); ) {
Annotation annotation = (Annotation) it.next();
Position position = model.getPosition(annotation);
// if position is null, just return.
if (position == null) {
return;
}
try {
if (position.overlapsWith(offset, 1) || document != null && document.getLineOfOffset(position.offset) == lineNumber) {
annotations.add(annotation);
}
} catch (BadLocationException e) {
log.error(e);
}
}
}
use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.
the class OpenEditorAction method run.
@Override
public void run() {
if (inputFile == null) {
return;
}
IWorkbenchPartSite workbenchPartSite = derivedSourceView.getSite();
IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
try {
IEditorPart editorPart = workbenchPage.openEditor(new FileEditorInput(inputFile), COMPILATION_UNIT_EDITOR_ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
if (selectedRegion != null) {
((ITextEditor) editorPart).selectAndReveal(selectedRegion.getOffset(), selectedRegion.getLength());
}
} catch (PartInitException partInitException) {
throw new WrappedRuntimeException(partInitException);
}
}
use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.
the class SeveralEditorsQueuedBuildTest method undoEditorChangesAndClose.
@Test
public void undoEditorChangesAndClose() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package mypackage;");
_builder.newLine();
_builder.newLine();
_builder.append("public class Foo {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("public void foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.testHelper.createFile("/mypackage/Foo.java", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package mypackage;");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("public class Bar {");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("public void bar() {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.testHelper.createFile("/mypackage/Bar.java", _builder_1.toString());
this.reset();
final ITextEditor fooEditor = this._javaEditorExtension.reconcile("/mypackage/Foo.java", "foo", "foo2");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
final ITextEditor barEditor = this._javaEditorExtension.reconcile("/mypackage/Bar.java", "bar", "bar2");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.reconcile(fooEditor, "foo2", "foo");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.close(fooEditor);
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.save(barEditor);
this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Bar");
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this.confirmDeltas();
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Bar");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.
the class SeveralEditorsQueuedBuildTest method saveSeveralEditorsOneByOne.
@Test
public void saveSeveralEditorsOneByOne() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package mypackage;");
_builder.newLine();
_builder.newLine();
_builder.append("public class Foo {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("public void foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.testHelper.createFile("/mypackage/Foo.java", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package mypackage;");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("public class Bar {");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("public void bar() {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.testHelper.createFile("/mypackage/Bar.java", _builder_1.toString());
this.reset();
final ITextEditor fooEditor = this._javaEditorExtension.reconcile("/mypackage/Foo.java", "foo", "foo2");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
final ITextEditor barEditor = this._javaEditorExtension.reconcile("/mypackage/Bar.java", "bar", "bar2");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.save(barEditor);
this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Bar");
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this.confirmDeltas();
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Bar");
this._javaEditorExtension.save(fooEditor);
this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Foo");
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this.confirmDeltas();
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Foo");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.ui.texteditor.ITextEditor in project xtext-xtend by eclipse.
the class SeveralEditorsQueuedBuildTest method undoEditorChangesAndSave.
@Test
public void undoEditorChangesAndSave() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package mypackage;");
_builder.newLine();
_builder.newLine();
_builder.append("public class Foo {");
_builder.newLine();
_builder.newLine();
_builder.append("\t");
_builder.append("public void foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.testHelper.createFile("/mypackage/Foo.java", _builder.toString());
StringConcatenation _builder_1 = new StringConcatenation();
_builder_1.append("package mypackage;");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("public class Bar {");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("public void bar() {");
_builder_1.newLine();
_builder_1.append("\t");
_builder_1.append("}");
_builder_1.newLine();
_builder_1.newLine();
_builder_1.append("}");
_builder_1.newLine();
this.testHelper.createFile("/mypackage/Bar.java", _builder_1.toString());
this.reset();
final ITextEditor fooEditor = this._javaEditorExtension.reconcile("/mypackage/Foo.java", "foo", "foo2");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
final ITextEditor barEditor = this._javaEditorExtension.reconcile("/mypackage/Bar.java", "bar", "bar2");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.reconcile(fooEditor, "foo2", "foo");
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.save(fooEditor);
this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Foo");
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this.confirmDeltas();
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this._javaEditorExtension.save(barEditor);
this.assertThereAreDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas(), "mypackage.Bar");
this.assertThereAreNotDeltas(this.queuedBuildData.getAndRemovePendingDeltas());
this.confirmDeltas();
this.assertThereAreNotDeltas(this.queuedBuildDataContribution.getUnconfirmedDeltas());
this.assertThereAreDeltas(this.queuedBuildData.getAndRemovePendingDeltas(), "mypackage.Bar");
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations