Java 类org.eclipse.ui.texteditor.AbstractDecoratedTextEditor 实例源码

项目:SPLevo    文件:OpenUnifiedDiffSourceHandler.java   
/**
 * 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());
        }
    }
}
项目:idecore    文件:MetadataFormPage.java   
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);
    }
}
项目:dLabPro-Plugin    文件:WorkbenchUtil.java   
/**
 * 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;
}
项目:external-filter    文件:EclipseEditorGetSet.java   
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;
}
项目:idecore    文件:BracketInserter.java   
public BracketInserter(AbstractDecoratedTextEditor editor, ISourceViewer viewer) {
    this.editor = editor;
    this.viewer = viewer;
}
项目:external-filter    文件:EclipseEditorGetSet.java   
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);
//            }
        }
    }