org.eclipse.xtext.xbase.ui.editor
Class XbaseEditor

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.ui.part.WorkbenchPart
          extended by org.eclipse.ui.part.EditorPart
              extended by org.eclipse.ui.texteditor.AbstractTextEditor
                  extended by org.eclipse.ui.texteditor.StatusTextEditor
                      extended by org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
                          extended by org.eclipse.ui.editors.text.TextEditor
                              extended by org.eclipse.xtext.ui.editor.XtextEditor
                                  extended by org.eclipse.xtext.xbase.ui.editor.XbaseEditor
All Implemented Interfaces:
org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.ui.IEditorPart, org.eclipse.ui.INavigationLocationProvider, org.eclipse.ui.IPersistable, org.eclipse.ui.IPersistableEditor, org.eclipse.ui.IReusableEditor, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISaveablesSource, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation, org.eclipse.ui.texteditor.ITextEditor, org.eclipse.ui.texteditor.ITextEditorExtension, org.eclipse.ui.texteditor.ITextEditorExtension2, org.eclipse.ui.texteditor.ITextEditorExtension3, org.eclipse.ui.texteditor.ITextEditorExtension4, org.eclipse.ui.texteditor.ITextEditorExtension5

public class XbaseEditor
extends XtextEditor

This enhances the Xtext editor with functionality that allows to reveal the originating offsets for selected java elements. Thus the XbaseEditor is capable to work with input that points to java resources.

Author:
Sebastian Zarnekow - Initial contribution and API

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.xtext.ui.editor.XtextEditor
XtextEditor.DeleteNextSubWordAction, XtextEditor.DeletePreviousSubWordAction, XtextEditor.NavigateNextSubWordAction, XtextEditor.NavigatePreviousSubWordAction, XtextEditor.NextSubWordAction, XtextEditor.PreviousSubWordAction, XtextEditor.SelectNextSubWordAction, XtextEditor.SelectPreviousSubWordAction, XtextEditor.SmartLineStartAction
 
Nested classes/interfaces inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
org.eclipse.ui.texteditor.AbstractTextEditor.AbstractSelectionChangedListener, org.eclipse.ui.texteditor.AbstractTextEditor.ColumnSupport, org.eclipse.ui.texteditor.AbstractTextEditor.IdMapEntry, org.eclipse.ui.texteditor.AbstractTextEditor.LineEndAction, org.eclipse.ui.texteditor.AbstractTextEditor.LineStartAction, org.eclipse.ui.texteditor.AbstractTextEditor.SelectionProvider, org.eclipse.ui.texteditor.AbstractTextEditor.TextEditorSavable
 
Nested classes/interfaces inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
org.eclipse.ui.texteditor.ITextEditorExtension3.InsertMode
 
Field Summary
protected static java.lang.String TAG_ASSOCIATED_JAVA_RESOURCE
           
 
Fields inherited from class org.eclipse.xtext.ui.editor.XtextEditor
DEFAULT_KEY_BINDING_SCOPE, ERROR_ANNOTATION_TYPE, ID, INFO_ANNOTATION_TYPE, KEY_BINDING_SCOPE, WARNING_ANNOTATION_TYPE
 
Fields inherited from class org.eclipse.ui.editors.text.TextEditor
fEncodingSupport
 
Fields inherited from class org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
DEFAULT_OVERVIEW_RULER_CONTEXT_MENU_ID, fAnnotationAccess, fIsUpdatingMarkerViews, fLineNumberRulerColumn, fOverviewRuler, fSourceViewerDecorationSupport
 
Fields inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
ACTION_MAP, COMMON_EDITOR_CONTEXT_MENU_ID, COMMON_RULER_CONTEXT_MENU_ID, DEFAULT_EDITOR_CONTEXT_MENU_ID, DEFAULT_RULER_CONTEXT_MENU_ID, fErrorLabel, PREFERENCE_COLOR_BACKGROUND, PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_FIND_SCOPE, PREFERENCE_COLOR_FOREGROUND, PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_BACKGROUND, PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_FOREGROUND, PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_FONT, PREFERENCE_HOVER_ENRICH_MODE, PREFERENCE_HYPERLINK_KEY_MODIFIER, PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK, PREFERENCE_HYPERLINKS_ENABLED, PREFERENCE_NAVIGATION_SMART_HOME_END, PREFERENCE_RULER_CONTRIBUTIONS, PREFERENCE_SHOW_WHITESPACE_CHARACTERS, PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED, PREFERENCE_USE_CUSTOM_CARETS, PREFERENCE_WIDE_CARET, TAG_SELECTION_LENGTH, TAG_SELECTION_OFFSET, VERTICAL_RULER_WIDTH
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Fields inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
INSERT, SMART_INSERT
 
Constructor Summary
XbaseEditor()
           
 
Method Summary
protected  boolean containsSavedState(org.eclipse.ui.IMemento memento)
           
protected  void doRestoreState(org.eclipse.ui.IMemento memento)
           
protected  void doSetInput(org.eclipse.ui.IEditorInput input)
           
 org.eclipse.ui.texteditor.IDocumentProvider getDocumentProvider()
           
protected  int getLineInJavaDocument(org.eclipse.jface.text.Document document, int selectionStart, int selectionLength)
          Returns the line of the given selection.
protected  int getStartOffsetOfContentsInJava(org.eclipse.jface.text.Document document, int line)
           
 boolean isDirty()
           
 void markNextSelectionAsJavaOffset(org.eclipse.core.resources.IResource javaResource)
           
 void reveal(int offset, int length)
          Copied from AbstractTextEditor.selectAndReveal(int, int)  and removed selection functionality.
protected  void safelySanityCheckState(org.eclipse.ui.IEditorInput input)
           
 void saveState(org.eclipse.ui.IMemento memento)
           
protected  void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength)
           
 
Methods inherited from class org.eclipse.xtext.ui.editor.XtextEditor
collectContextMenuPreferencePages, configureSourceViewerDecorationSupport, configureToggleCommentAction, createActions, createAnnotationAccess, createDeleteNextSubWordAction, createDeletePreviousSubWordAction, createNavigateNextSubWordAction, createNavigatePreviousSubWordAction, createNavigationActions, createPartControl, createSelectNextSubWordAction, createSelectPreviousSubWordAction, createSmartLineStartAction, createSourceViewer, createWordIterator, dispose, doRevertToSaved, doSave, doSaveAs, getAdapter, getDefaultImage, getDocument, getInternalSourceViewer, getLanguageName, getResource, getUndoRedoOperationApprover, getXtextSourceViewerConfiguration, handlePreferenceStoreChanged, init, initializeKeyBindingScopes, installFoldingSupport, installProjectionSupport, isContentAssistAvailable, outlinePageClosed, resetProjection, rulerContextMenuAboutToShow, setKeyBindingScope, setLanguageName, setPreferenceStore, setXtextEditorCallback, uninstallFoldingSupport, updatedTitleImage, updateStatusLine, validateEditorInputState
 
Methods inherited from class org.eclipse.ui.editors.text.TextEditor
editorContextMenuAboutToShow, getStatusBanner, getStatusHeader, getStatusMessage, initializeEditor, installEncodingSupport, isSaveAsAllowed, updatePropertyDependentActions
 
Methods inherited from class org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
collectOverviewRulerMenuPreferencePages, collectRulerMenuPreferencePages, createAnnotationRulerColumn, createChangeHover, createChangeRulerColumn, createColumnSupport, createCompositeRuler, createContextMenuListener, createLineNumberRulerColumn, createOverviewRuler, createOverviewRulerContextMenu, createStatusControl, createVerticalRuler, disposeDocumentProvider, getAnnotationAccess, getAnnotationPreferenceLookup, getAnnotationPreferences, getOverviewRuler, getOverviewRulerContextMenuId, getSharedColors, getSourceViewerDecorationSupport, gotoAnnotation, gotoMarker, hideOverviewRuler, initializeLineNumberRulerColumn, isChangeInformationShowing, isEditable, isErrorStatus, isLineNumberRulerVisible, isNavigationTarget, isOverviewRulerVisible, isOverwriteModeEnabled, isPrefQuickDiffAlwaysOn, isTabsToSpacesConversionEnabled, overviewRulerContextMenuAboutToShow, performSaveAs, setDocumentProvider, setOverviewRulerContextMenuId, showChangeInformation, showOverviewRuler, showRevisionInformation, updateMarkerViews
 
Methods inherited from class org.eclipse.ui.texteditor.StatusTextEditor
handleEditorInputChanged, handleElementContentReplaced, sanityCheckState, updatePartControl, updateStatusField
 
Methods inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
addAction, addAction, addGroup, addRulerContextMenuListener, adjustHighlightRange, affectsTextPresentation, canHandleMove, close, configureInsertMode, createEmptyNavigationLocation, createNavigationLocation, createUndoRedoActions, doGetSelection, doSetSelection, editorSaved, enableOverwriteMode, enableSanityChecking, enableStateValidation, findAnnotation, firePropertyChange, getAction, getActiveSaveables, getContextMenuListener, getCoverage, getCursorListener, getCursorPosition, getEditorContextMenuId, getFontPropertyPreferenceKey, getHelpContextId, getHighlightRange, getInsertMode, getLegalInsertModes, getPreferenceStore, getProgressMonitor, getRangeIndicator, getRulerContextMenuId, getRulerMouseListener, getSaveables, getSelectionChangedListener, getSelectionProvider, getSourceViewer, getSourceViewerConfiguration, getStatusField, getStatusLineManager, getVerticalRuler, handleCursorPositionChanged, handleExceptionOnSave, handleInsertModeChanged, initializeDragAndDrop, initializeViewerColors, installTabsToSpacesConverter, installTextDragAndDrop, internalInit, isBlockSelectionModeEnabled, isBlockSelectionModeSupported, isEditorInputIncludedInContextMenu, isEditorInputModifiable, isEditorInputReadOnly, isInInsertMode, isVisible, markAsContentDependentAction, markAsPropertyDependentAction, markAsSelectionDependentAction, markAsStateDependentAction, markInNavigationHistory, modelOffset2WidgetOffset, openSaveErrorDialog, performRevert, performSave, rememberSelection, removeActionActivationCode, removeRulerContextMenuListener, resetHighlightRange, restoreSelection, restoreState, selectAndReveal, setAction, setActionActivationCode, setBlockSelectionMode, setCompatibilityMode, setDocumentProvider, setEditorContextMenuId, setFocus, setHelpContextId, setHighlightRange, setInput, setInputWithNotify, setInsertMode, setKeyBindingScopes, setRangeIndicator, setRulerContextMenuId, setSourceViewerConfiguration, setStatusField, setStatusLineErrorMessage, setStatusLineMessage, showHighlightRangeOnly, showsHighlightRangeOnly, uninstallTabsToSpacesConverter, uninstallTextDragAndDrop, updateContentDependentActions, updateContributedRulerColumns, updateIndentPrefixes, updateSelectionDependentActions, updateState, updateStateDependentActions, updateStatusFields, validateState, widgetOffset2ModelOffset
 
Methods inherited from class org.eclipse.ui.part.EditorPart
checkSite, getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setContentDescription, setInitializationData, setPartName
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, getConfigurationElement, getContentDescription, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
 
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
 

Field Detail

TAG_ASSOCIATED_JAVA_RESOURCE

protected static final java.lang.String TAG_ASSOCIATED_JAVA_RESOURCE
See Also:
Constant Field Values
Constructor Detail

XbaseEditor

public XbaseEditor()
Method Detail

saveState

public void saveState(org.eclipse.ui.IMemento memento)
Specified by:
saveState in interface org.eclipse.ui.IPersistable
Overrides:
saveState in class org.eclipse.ui.texteditor.AbstractTextEditor

doRestoreState

protected void doRestoreState(org.eclipse.ui.IMemento memento)
Overrides:
doRestoreState in class org.eclipse.ui.texteditor.AbstractTextEditor

containsSavedState

protected boolean containsSavedState(org.eclipse.ui.IMemento memento)
Overrides:
containsSavedState in class org.eclipse.ui.texteditor.AbstractTextEditor

doSetInput

protected void doSetInput(org.eclipse.ui.IEditorInput input)
                   throws org.eclipse.core.runtime.CoreException
Overrides:
doSetInput in class XtextEditor
Throws:
org.eclipse.core.runtime.CoreException

markNextSelectionAsJavaOffset

public void markNextSelectionAsJavaOffset(org.eclipse.core.resources.IResource javaResource)

safelySanityCheckState

protected void safelySanityCheckState(org.eclipse.ui.IEditorInput input)
Overrides:
safelySanityCheckState in class org.eclipse.ui.texteditor.AbstractTextEditor

isDirty

public boolean isDirty()
Specified by:
isDirty in interface org.eclipse.ui.ISaveablePart
Overrides:
isDirty in class org.eclipse.ui.texteditor.AbstractTextEditor

getDocumentProvider

public org.eclipse.ui.texteditor.IDocumentProvider getDocumentProvider()
Specified by:
getDocumentProvider in interface org.eclipse.ui.texteditor.ITextEditor
Overrides:
getDocumentProvider in class org.eclipse.ui.texteditor.AbstractDecoratedTextEditor

selectAndReveal

protected void selectAndReveal(int selectionStart,
                               int selectionLength,
                               int revealStart,
                               int revealLength)
Overrides:
selectAndReveal in class org.eclipse.ui.texteditor.AbstractTextEditor

getLineInJavaDocument

protected int getLineInJavaDocument(org.eclipse.jface.text.Document document,
                                    int selectionStart,
                                    int selectionLength)
                             throws org.eclipse.jface.text.BadLocationException
Returns the line of the given selection. It is assumed that it covers an entire line in the Java file.

Returns:
the line in the Java file (zero based) or -1 if the selection does not cover a complete line.
Throws:
org.eclipse.jface.text.BadLocationException

getStartOffsetOfContentsInJava

protected int getStartOffsetOfContentsInJava(org.eclipse.jface.text.Document document,
                                             int line)
                                      throws org.eclipse.jface.text.BadLocationException
Throws:
org.eclipse.jface.text.BadLocationException

reveal

public void reveal(int offset,
                   int length)
Description copied from class: XtextEditor
Copied from AbstractTextEditor.selectAndReveal(int, int)  and removed selection functionality.

Overrides:
reveal in class XtextEditor