Interface IOpenEditorParticipant

  • All Known Subinterfaces:
    IOpenEditorsParticipant
    All Known Implementing Classes:
    DefaultOpenEditorParticipant

    public interface IOpenEditorParticipant
    A participant in "open file" action, which is capable to guess the file/line and/or open appropriated editor based on provided information.

    The method of participants would be called in the followed order: guessFile->openEditor->guessLine

    Because there might be multiple participants with same priority, the order of operation might be undefined. If one of participants was successful in guessing the file/opening the editor, other participants would be ignored.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int PRIO_DEFAULT
      default prio with value 5
      static int PRIO_HIGH
      high prio with value 10
      static int PRIO_LOW
      low prio with value 0
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int getPriority()
      Priority defines the order of participation, the range is PRIO_LOW to PRIO_HIGH, participant with prio PRIO_HIGH is the first participant.
      org.eclipse.core.resources.IFile guessFile​(org.eclipse.jface.text.IDocument doc, org.eclipse.jface.viewers.ISelectionProvider selectionProvider, org.eclipse.ui.IEditorInput currentInput, org.eclipse.ui.IWorkbenchPart currentPart)
      Try to guess file under cursor
      int guessLine​(org.eclipse.jface.text.IDocument doc, org.eclipse.jface.viewers.ISelectionProvider selectionProvider, org.eclipse.ui.IWorkbenchPart currentPart)
      Try to guess the line under cursor.
      org.eclipse.ui.IEditorPart openEditor​(org.eclipse.jface.text.IDocument doc, org.eclipse.jface.viewers.ISelectionProvider selectionProvider, org.eclipse.ui.IEditorInput currentInput, org.eclipse.core.resources.IFile file)
      Opens editor
    • Method Detail

      • guessFile

        org.eclipse.core.resources.IFile guessFile​(org.eclipse.jface.text.IDocument doc,
                                                   org.eclipse.jface.viewers.ISelectionProvider selectionProvider,
                                                   org.eclipse.ui.IEditorInput currentInput,
                                                   org.eclipse.ui.IWorkbenchPart currentPart)
                                            throws org.eclipse.core.runtime.OperationCanceledException
        Try to guess file under cursor
        Parameters:
        doc - document with possible editor/file reference, might be null
        selectionProvider - selection in the document, might be null or empty
        currentInput - document input, might be null
        currentPart - current part, if any (might be null)
        Returns:
        null if no file information was found, otherwise the file object
        Throws:
        org.eclipse.core.runtime.OperationCanceledException - if user decided to cancel operation
      • openEditor

        org.eclipse.ui.IEditorPart openEditor​(org.eclipse.jface.text.IDocument doc,
                                              org.eclipse.jface.viewers.ISelectionProvider selectionProvider,
                                              org.eclipse.ui.IEditorInput currentInput,
                                              org.eclipse.core.resources.IFile file)
                                       throws org.eclipse.core.runtime.OperationCanceledException
        Opens editor

        There is always at least one default participant which is capable to open file if it is not null, therefore it is ok to return null in this case and don't reimplement the standart file opening strategy.

        Parameters:
        doc - document with possible editor/file reference, might be null
        selectionProvider - selection in the document, might be null or empty
        currentInput - document input, might be null
        file - document file, might be null
        Returns:
        null if editor part was not opened, otherwise opened editor reference.
        Throws:
        org.eclipse.core.runtime.OperationCanceledException - if user decided to cancel operation
      • guessLine

        int guessLine​(org.eclipse.jface.text.IDocument doc,
                      org.eclipse.jface.viewers.ISelectionProvider selectionProvider,
                      org.eclipse.ui.IWorkbenchPart currentPart)
               throws org.eclipse.core.runtime.OperationCanceledException
        Try to guess the line under cursor. Would be called only if the editor part was opened.
        Parameters:
        doc - document with possible line reference, might be null
        selectionProvider - selection in the document, might be null or empty
        currentPart - might be null, the sourse part from where we trying to guess the line information, NOT the target part which is opened before
        Returns:
        -1 if operation was not successful, otherwise the line number
        Throws:
        org.eclipse.core.runtime.OperationCanceledException - if user decided to cancel operation
      • getPriority

        int getPriority()
        Priority defines the order of participation, the range is PRIO_LOW to PRIO_HIGH, participant with prio PRIO_HIGH is the first participant. If there are more then one participant, then order is not guaranteed. It is recommended to use PRIO_DEFAULT as default :)
        Returns:
        one of PRIO_* constants