Class DefaultOpenEditorParticipant

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static org.eclipse.core.runtime.content.IContentType getContentType​(java.io.File file)  
      private static java.lang.String getEditorId​(java.io.File file)  
      private static java.util.List<org.eclipse.core.resources.IFile> getFromPath​(org.eclipse.ui.IEditorInput currentInput, java.util.List<java.lang.String> pathStrings, java.lang.String selection, org.eclipse.ui.IWorkbenchPart currentPart)  
      private static java.util.List<org.eclipse.core.resources.IFile> getFromSelection​(java.lang.String selection)  
      private static java.lang.String getLinePart​(org.eclipse.jface.text.IDocument doc, int caretPosition)  
      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
      java.util.List<org.eclipse.core.resources.IFile> guessFiles​(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 multiple files in given context
      int guessLine​(org.eclipse.jface.text.IDocument doc, org.eclipse.jface.viewers.ISelectionProvider selectionProvider, org.eclipse.ui.IWorkbenchPart editorPart)
      Try to guess the line under cursor.
      private static java.util.List<java.lang.String> guessPaths​(org.eclipse.jface.text.IDocument doc, org.eclipse.jface.viewers.ISelectionProvider selectionProvider, java.lang.String selection)  
      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
      private static org.eclipse.ui.IEditorPart openExternalEditor​(org.eclipse.core.resources.IFile file)  
      private static org.eclipse.ui.IEditorPart openInternalEditor​(org.eclipse.core.resources.IFile file)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultOpenEditorParticipant

        public DefaultOpenEditorParticipant()
    • Method Detail

      • getPriority

        public int getPriority()
        Description copied from interface: IOpenEditorParticipant
        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 :)
        Specified by:
        getPriority in interface IOpenEditorParticipant
        Returns:
        one of PRIO_* constants
      • guessLine

        public int guessLine​(org.eclipse.jface.text.IDocument doc,
                             org.eclipse.jface.viewers.ISelectionProvider selectionProvider,
                             org.eclipse.ui.IWorkbenchPart editorPart)
        Description copied from interface: IOpenEditorParticipant
        Try to guess the line under cursor. Would be called only if the editor part was opened.
        Specified by:
        guessLine in interface IOpenEditorParticipant
        Parameters:
        doc - document with possible line reference, might be null
        selectionProvider - selection in the document, might be null or empty
        editorPart - 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
      • getLinePart

        private static java.lang.String getLinePart​(org.eclipse.jface.text.IDocument doc,
                                                    int caretPosition)
      • openEditor

        public 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
        Description copied from interface: IOpenEditorParticipant
        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.

        Specified by:
        openEditor in interface IOpenEditorParticipant
        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
      • openInternalEditor

        private static org.eclipse.ui.IEditorPart openInternalEditor​(org.eclipse.core.resources.IFile file)
                                                              throws org.eclipse.ui.PartInitException
        Throws:
        org.eclipse.ui.PartInitException
      • openExternalEditor

        private static org.eclipse.ui.IEditorPart openExternalEditor​(org.eclipse.core.resources.IFile file)
                                                              throws org.eclipse.core.runtime.CoreException
        Throws:
        org.eclipse.core.runtime.CoreException
      • getEditorId

        private static java.lang.String getEditorId​(java.io.File file)
      • getContentType

        private static org.eclipse.core.runtime.content.IContentType getContentType​(java.io.File file)
      • guessFile

        public 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
        Description copied from interface: IOpenEditorParticipant
        Try to guess file under cursor
        Specified by:
        guessFile in interface IOpenEditorParticipant
        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
      • guessFiles

        public java.util.List<org.eclipse.core.resources.IFile> guessFiles​(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
        Description copied from interface: IOpenEditorsParticipant
        Try to guess multiple files in given context
        Specified by:
        guessFiles in interface IOpenEditorsParticipant
        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:
        empty list if no file information was found, otherwise the list of guessed files, never null
        Throws:
        org.eclipse.core.runtime.OperationCanceledException - if user decided to cancel operation
      • guessPaths

        private static java.util.List<java.lang.String> guessPaths​(org.eclipse.jface.text.IDocument doc,
                                                                   org.eclipse.jface.viewers.ISelectionProvider selectionProvider,
                                                                   java.lang.String selection)
      • getFromPath

        private static java.util.List<org.eclipse.core.resources.IFile> getFromPath​(org.eclipse.ui.IEditorInput currentInput,
                                                                                    java.util.List<java.lang.String> pathStrings,
                                                                                    java.lang.String selection,
                                                                                    org.eclipse.ui.IWorkbenchPart currentPart)
                                                                             throws org.eclipse.core.runtime.OperationCanceledException
        Throws:
        org.eclipse.core.runtime.OperationCanceledException
      • getFromSelection

        private static java.util.List<org.eclipse.core.resources.IFile> getFromSelection​(java.lang.String selection)
                                                                                  throws org.eclipse.core.runtime.OperationCanceledException
        Throws:
        org.eclipse.core.runtime.OperationCanceledException