本文整理汇总了Java中org.eclipse.ui.texteditor.AbstractDecoratedTextEditor类的典型用法代码示例。如果您正苦于以下问题:Java AbstractDecoratedTextEditor类的具体用法?Java AbstractDecoratedTextEditor怎么用?Java AbstractDecoratedTextEditor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AbstractDecoratedTextEditor类属于org.eclipse.ui.texteditor包,在下文中一共展示了AbstractDecoratedTextEditor类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: selectAndReveal
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; //导入依赖的package包/类
/**
* Selects and reveals a given line number within the given editor provided by the file information.
*
* @param editor
* the editor to select and reveal in.
* @param fileInformation
* the information containing the line number.
*/
private void selectAndReveal(IEditorPart editor, FileLineNumberPair fileInformation) {
AbstractDecoratedTextEditor specificEditor = (AbstractDecoratedTextEditor) editor;
IEditorInput input = specificEditor.getEditorInput();
IDocument document = specificEditor.getDocumentProvider().getDocument(input);
if (document != null) {
// create line information
IRegion lineInfo = null;
try {
lineInfo = document.getLineInformation(fileInformation.getLineNumber() - 1);
} catch (BadLocationException e) {
LOGGER.error("The selected line " + (fileInformation.getLineNumber() - 1)
+ " could not be found within source file \"" + fileInformation.getFile().getAbsolutePath() + "\"!", e);
}
// highlight the selected line number
if (lineInfo != null) {
specificEditor.selectAndReveal(lineInfo.getOffset(), lineInfo.getLength());
}
}
}
示例2: setTextOfMetadataEditor
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; //导入依赖的package包/类
protected void setTextOfMetadataEditor(String value) {
AbstractDecoratedTextEditor metadataEditor = multiPageEditor.getMetadataEditor();
IDocument document = metadataEditor.getDocumentProvider().getDocument(getEditorInput());
if (!value.contentEquals(document.get().trim())) { // If the content is the same, don't bother setting
document.set(value);
}
}
示例3: getEditorIDocument
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; //导入依赖的package包/类
/**
* this method gets the IDocument shown in the actually opened/shown editor
*
* @return
*/
public static IDocument getEditorIDocument()
{
IEditorPart ed = getActiveEditor();
IDocument doc = null;
if (ed instanceof AbstractDecoratedTextEditor) doc = ((AbstractDecoratedTextEditor)ed)
.getDocumentProvider().getDocument(ed.getEditorInput());
return doc;
}
示例4: getFullDocumentText
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; //导入依赖的package包/类
static TextSelection getFullDocumentText(IWorkbenchWindow window) {
IEditorPart page = window.getActivePage().getActiveEditor();
if (null == page)
return null;
if (!(page instanceof AbstractDecoratedTextEditor))
return null;
IDocumentProvider docProvider = ((AbstractDecoratedTextEditor) page).getDocumentProvider();
IDocument document = docProvider.getDocument(page.getEditorInput());
TextSelection selection = new TextSelection(document, 0, document.getLength());
return selection;
}
示例5: BracketInserter
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; //导入依赖的package包/类
public BracketInserter(AbstractDecoratedTextEditor editor, ISourceViewer viewer) {
this.editor = editor;
this.viewer = viewer;
}
示例6: setText
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor; //导入依赖的package包/类
public static void setText(IWorkbenchWindow window, String newText, ITextSelection originalSelection, TextTarget to) {
if (to == TextTarget.toNothing)
return;
if (to == TextTarget.toConsole) {
outputToConsole(window, newText);
return;
}
if (to == TextTarget.toMessageBox) {
MessageDialog.openInformation(window.getShell(), "External Filter", newText);
return;
}
if (to == TextTarget.toClipboard) {
ClipboardSelection.toClipboard(newText);
return;
}
IEditorPart page = window.getActivePage().getActiveEditor();
if (null == page)
return;
if (!(page instanceof AbstractDecoratedTextEditor))
return;
IDocumentProvider docProvider = ((AbstractDecoratedTextEditor) page).getDocumentProvider();
// System.out.println(docProvider); // org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitDocumentProvider
IDocument document = docProvider.getDocument(page.getEditorInput()); // org.eclipse.core.internal.filebuffers.SynchronizableDocument
if (document instanceof Document) {
if (to == TextTarget.replaceCrtDoc)
((Document) document).set(newText);
else if (to == TextTarget.replaceCrtSel)
replaceCurrentSelection((Document) document, originalSelection, newText);
else if (to == TextTarget.appendToCrtDoc)
appendToCurrentDocument((Document) document, originalSelection, newText);
// else if (to == TextTarget.insertAtCursorPos) {
// currentPos = ((AbstractTextEditor)page).getEditorInput().get
// // This is really the end of selection, not current cursor position
// // And what happens if the original selection was clipboard?
// insertInDocumentAtPosition((Document) document,
// originalSelection.getOffset() + originalSelection.getLength(),
// originalSelection, newText);
// }
}
}