Package de.loskutov.anyedit.actions
Class DefaultOpenEditorParticipant
- java.lang.Object
-
- de.loskutov.anyedit.actions.DefaultOpenEditorParticipant
-
- All Implemented Interfaces:
IOpenEditorParticipant
,IOpenEditorsParticipant
public class DefaultOpenEditorParticipant extends java.lang.Object implements IOpenEditorsParticipant
-
-
Field Summary
-
Fields inherited from interface de.loskutov.anyedit.IOpenEditorParticipant
PRIO_DEFAULT, PRIO_HIGH, PRIO_LOW
-
-
Constructor Summary
Constructors Constructor Description 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 cursorjava.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 contextint
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 editorprivate 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)
-
-
-
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 interfaceIOpenEditorParticipant
- 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 interfaceIOpenEditorParticipant
- Parameters:
doc
- document with possible line reference, might be nullselectionProvider
- selection in the document, might be null or emptyeditorPart
- 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 editorThere 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 interfaceIOpenEditorParticipant
- Parameters:
doc
- document with possible editor/file reference, might be nullselectionProvider
- selection in the document, might be null or emptycurrentInput
- document input, might be nullfile
- 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 interfaceIOpenEditorParticipant
- Parameters:
doc
- document with possible editor/file reference, might be nullselectionProvider
- selection in the document, might be null or emptycurrentInput
- document input, might be nullcurrentPart
- 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 interfaceIOpenEditorsParticipant
- Parameters:
doc
- document with possible editor/file reference, might be nullselectionProvider
- selection in the document, might be null or emptycurrentInput
- document input, might be nullcurrentPart
- 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
-
-