use of org.eclipse.ui.texteditor.AbstractTextEditor in project webtools.sourceediting by eclipse.
the class TestProjectSetup method editFile.
/**
* <p>
* Edits the file given by the fileName. The number of characters indicated by length are
* replaced by the given text beginning at the character located at the given line number and
* the line character offset.
* </p>
*
* @param fileName
* @param lineNum
* @param lineRelativeCharOffset
* @param length
* @param text
* @throws Exception
*/
public void editFile(String fileName, int lineNum, int lineRelativeCharOffset, int length, String text) throws Exception {
IFile file = this.getFile(fileName);
AbstractTextEditor editor = this.getEditor(file);
IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
int offset = doc.getLineOffset(lineNum) + lineRelativeCharOffset;
doc.replace(offset, length, text);
waitForIndexManager();
}
use of org.eclipse.ui.texteditor.AbstractTextEditor in project liferay-ide by liferay.
the class MessageKeyHyperlink method open.
public void open() {
try {
IEditorPart editorPart = IDE.openEditor(UIUtil.getActivePage(), _file, true);
if (editorPart instanceof AbstractTextEditor) {
AbstractTextEditor editor = (AbstractTextEditor) editorPart;
editor.selectAndReveal(_offset, _length);
}
} catch (PartInitException pie) {
PortletUIPlugin.logError("Could not open properties file " + this._file.getName(), pie);
}
}
use of org.eclipse.ui.texteditor.AbstractTextEditor in project soot by Sable.
the class SootPartManager method updatePart.
public void updatePart(IEditorPart part) {
if (part == null)
return;
if (part instanceof JimpleEditor) {
AbstractAttributesComputer aac = new JimpleAttributesComputer();
SootAttributesJimpleColorer sajc = new SootAttributesJimpleColorer();
SootAttrJimpleIconGenerator saji = new SootAttrJimpleIconGenerator();
SourceViewer viewer = (SourceViewer) ((AbstractTextEditor) part).getAdapter(ITextOperationTarget.class);
SootAttributesHandler handler = aac.getAttributesHandler((AbstractTextEditor) part);
if (handler != null) {
if (isUpdateForOpen() || handler.isUpdate()) {
sajc.setEditorPart(part);
sajc.setViewer(viewer);
sajc.setHandler(handler);
Thread cThread = new Thread(sajc);
cThread.start();
saji.setHandler(handler);
saji.setRec((IFile) aac.getRec());
Thread iThread = new Thread(saji);
iThread.start();
handler.setUpdate(false);
}
}
handleKeys(handler);
handleTypes(handler, (IFile) aac.getRec());
} else if (part instanceof AbstractTextEditor) {
IEditorInput input = ((AbstractTextEditor) part).getEditorInput();
IJavaElement jElem = (IJavaElement) ((IAdaptable) input).getAdapter(IJavaElement.class);
if (!(jElem instanceof ICompilationUnit))
return;
AbstractAttributesComputer aac = new JavaAttributesComputer();
SootAttributesJavaColorer sajc = new SootAttributesJavaColorer();
SootAttrJavaIconGenerator saji = new SootAttrJavaIconGenerator();
SourceViewer viewer = (SourceViewer) ((AbstractTextEditor) part).getAdapter(ITextOperationTarget.class);
SootAttributesHandler handler = aac.getAttributesHandler((AbstractTextEditor) part);
if (handler != null) {
if (isUpdateForOpen() || handler.isUpdate()) {
sajc.setEditorPart(part);
sajc.setViewer(viewer);
sajc.setHandler(handler);
Thread cThread = new Thread(sajc);
cThread.start();
saji.setHandler(handler);
saji.setRec((IFile) aac.getRec());
Thread iThread = new Thread(saji);
iThread.start();
handler.setUpdate(false);
}
}
handleKeys(handler);
handleTypes(handler, (IFile) aac.getRec());
}
setUpdateForOpen(false);
}
use of org.eclipse.ui.texteditor.AbstractTextEditor in project dbeaver by serge-rider.
the class TextEditorUtils method enableHostEditorKeyBindingsSupport.
public static void enableHostEditorKeyBindingsSupport(final IWorkbenchPartSite partSite, Control control) {
if (!(partSite.getPart() instanceof AbstractTextEditor)) {
return;
}
final boolean[] activated = new boolean[] { false };
control.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (!activated[0]) {
enableHostEditorKeyBindings(partSite, false);
activated[0] = true;
}
}
@Override
public void focusLost(FocusEvent e) {
if (activated[0]) {
enableHostEditorKeyBindings(partSite, true);
activated[0] = false;
}
}
});
control.addDisposeListener(e -> {
if (activated[0]) {
if (!DBWorkbench.getPlatform().isShuttingDown()) {
enableHostEditorKeyBindings(partSite, true);
}
activated[0] = false;
}
});
}
use of org.eclipse.ui.texteditor.AbstractTextEditor in project titan.EclipsePlug-ins by eclipse.
the class FindDefinitionAction method showInEditor.
private void showInEditor(final ILocateableNode node) {
final Location location = node.getLocation();
final IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(location.getFile().getName());
if (desc == null) {
TITANDebugConsole.println("Cannot find the editor");
return;
}
final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
final IEditorPart editorPart = activePage.openEditor(new FileEditorInput((IFile) location.getFile()), desc.getId());
if (editorPart != null && (editorPart instanceof AbstractTextEditor)) {
((AbstractTextEditor) editorPart).selectAndReveal(location.getOffset(), location.getEndOffset() - location.getOffset());
}
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace("Error while opening the editor", e);
}
}
Aggregations