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.IContentTypegetContentType(java.io.File file)private static java.lang.StringgetEditorId(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.StringgetLinePart(org.eclipse.jface.text.IDocument doc, int caretPosition)intgetPriority()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.IFileguessFile(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 contextintguessLine(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.IEditorPartopenEditor(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.IEditorPartopenExternalEditor(org.eclipse.core.resources.IFile file)private static org.eclipse.ui.IEditorPartopenInternalEditor(org.eclipse.core.resources.IFile file)
-
-
-
Method Detail
-
getPriority
public int getPriority()
Description copied from interface:IOpenEditorParticipantPriority 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:
getPriorityin 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:IOpenEditorParticipantTry to guess the line under cursor. Would be called only if the editor part was opened.- Specified by:
guessLinein 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.OperationCanceledExceptionDescription copied from interface:IOpenEditorParticipantOpens 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:
openEditorin 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.OperationCanceledExceptionDescription copied from interface:IOpenEditorParticipantTry to guess file under cursor- Specified by:
guessFilein 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.OperationCanceledExceptionDescription copied from interface:IOpenEditorsParticipantTry to guess multiple files in given context- Specified by:
guessFilesin 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
-
-