Class EmbeddedXtextSourceEditor
- java.lang.Object
-
- net.ssehub.easy.dslCore.ui.editors.EmbeddedXtextSourceEditor
-
- All Implemented Interfaces:
IEmbeddedEditor,IUpdatableEditor
class EmbeddedXtextSourceEditor extends java.lang.Object implements IEmbeddedEditor, IUpdatableEditor
Represents an embedded Xtext editor.- Author:
- Holger Eichelberger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classEmbeddedXtextSourceEditor.DocumentContextObserverImplements a delegating document context observer.private classEmbeddedXtextSourceEditor.ValidationStateListenerImplements a delegating validation state listener.-
Nested classes/interfaces inherited from interface net.ssehub.easy.dslCore.ui.editors.IEmbeddedEditor
IEmbeddedEditor.IDocumentStateListener, IEmbeddedEditor.IValidationStateListener
-
-
Field Summary
Fields Modifier and Type Field Description private booleandirtyprivate java.util.Map<IEmbeddedEditor.IDocumentStateListener,org.eclipse.xtext.ui.editor.model.IXtextDocumentContentObserver>documentStateListenersprivate org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorembeddedEditorprivate AbstractModelChangeListenermodelListenerprivate org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccesspartialEditorModelAccessprivate org.eclipse.core.resources.IResourceresourceprivate booleanskipNextUpdateEventprivate java.util.Map<IEmbeddedEditor.IValidationStateListener,org.eclipse.jface.text.source.IAnnotationModelListener>validationStateListenersprivate org.eclipse.xtext.ui.editor.XtextSourceViewerviewer
-
Constructor Summary
Constructors Constructor Description EmbeddedXtextSourceEditor(org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor embeddedEditor, org.eclipse.xtext.ui.editor.XtextSourceViewer viewer, org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccess partialEditorModelAccess, boolean requireWorkspaceResource)Creates an editor representation instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocumentStateListener(IEmbeddedEditor.IDocumentStateListener listener)Adds a document state listener.voidaddValidationStateListener(IEmbeddedEditor.IValidationStateListener listener)Adds a validation state listener.voidbuildModel(org.eclipse.xtext.ui.editor.model.IXtextDocument doc)Creates the model in the given xText documentdoc.booleandoSave()Save the editor content to the original resource if content changed.java.lang.StringgetContent()Returns the full content of the editor, including potential context such as prefix and postfix.java.lang.StringgetEditableContent()Returns the editable content in this editor.private EASyLoggerFactory.EASyLoggergetLogger()Returns the logger of this class.org.eclipse.core.resources.IResourcegetResource()Returns the resource of this editor.org.eclipse.jface.viewers.ViewergetViewer()Returns the actual viewer implementing the editor.voidrefresh()Refreshes the editor.voidremoveDocumentStateListener(IEmbeddedEditor.IDocumentStateListener listener)Removes the given document state listener.voidremoveValidationStateListener(IEmbeddedEditor.IValidationStateListener listener)Removes the given validation state listener.booleansetContent(java.lang.String[] content)Changes the content of the embedded editor.voidsetEditable(boolean editable)Changes whether the editor is enabled for editing.voidsetModelListener(AbstractModelChangeListener modelListener)Defines the model listener being called inIEmbeddedEditor.doSave().voidupdateEditor()Updates this editor.
-
-
-
Field Detail
-
embeddedEditor
private org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor embeddedEditor
-
viewer
private org.eclipse.xtext.ui.editor.XtextSourceViewer viewer
-
partialEditorModelAccess
private org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccess partialEditorModelAccess
-
validationStateListeners
private java.util.Map<IEmbeddedEditor.IValidationStateListener,org.eclipse.jface.text.source.IAnnotationModelListener> validationStateListeners
-
documentStateListeners
private java.util.Map<IEmbeddedEditor.IDocumentStateListener,org.eclipse.xtext.ui.editor.model.IXtextDocumentContentObserver> documentStateListeners
-
modelListener
private AbstractModelChangeListener modelListener
-
dirty
private boolean dirty
-
skipNextUpdateEvent
private boolean skipNextUpdateEvent
-
resource
private org.eclipse.core.resources.IResource resource
-
-
Constructor Detail
-
EmbeddedXtextSourceEditor
public EmbeddedXtextSourceEditor(org.eclipse.xtext.ui.editor.embedded.EmbeddedEditor embeddedEditor, org.eclipse.xtext.ui.editor.XtextSourceViewer viewer, org.eclipse.xtext.ui.editor.embedded.EmbeddedEditorModelAccess partialEditorModelAccess, boolean requireWorkspaceResource)Creates an editor representation instance.- Parameters:
embeddedEditor- the embedded editorviewer- the underlying source viewerpartialEditorModelAccess- the model accessrequireWorkspaceResource- whether the editor requires a workspace resource and shall complain at least in the logs or whether it shall be silent
-
-
Method Detail
-
getLogger
private EASyLoggerFactory.EASyLogger getLogger()
Returns the logger of this class.- Returns:
- the logger
-
getViewer
public org.eclipse.jface.viewers.Viewer getViewer()
Description copied from interface:IEmbeddedEditorReturns the actual viewer implementing the editor.- Specified by:
getViewerin interfaceIEmbeddedEditor- Returns:
- the actiall viewer
-
setContent
public boolean setContent(java.lang.String[] content)
Description copied from interface:IEmbeddedEditorChanges the content of the embedded editor.- Specified by:
setContentin interfaceIEmbeddedEditor- Parameters:
content- the actual editable content in terms of prefix not to be shown [0], content to be displayed [1] and postfix not to be shown[2]- Returns:
- whether the operation was successful (
true) or not (false)
-
refresh
public void refresh()
Description copied from interface:IEmbeddedEditorRefreshes the editor.- Specified by:
refreshin interfaceIEmbeddedEditor
-
addValidationStateListener
public void addValidationStateListener(IEmbeddedEditor.IValidationStateListener listener)
Description copied from interface:IEmbeddedEditorAdds a validation state listener.- Specified by:
addValidationStateListenerin interfaceIEmbeddedEditor- Parameters:
listener- the listener to be added
-
removeValidationStateListener
public void removeValidationStateListener(IEmbeddedEditor.IValidationStateListener listener)
Description copied from interface:IEmbeddedEditorRemoves the given validation state listener.- Specified by:
removeValidationStateListenerin interfaceIEmbeddedEditor- Parameters:
listener- the listener to be removed
-
addDocumentStateListener
public void addDocumentStateListener(IEmbeddedEditor.IDocumentStateListener listener)
Description copied from interface:IEmbeddedEditorAdds a document state listener.- Specified by:
addDocumentStateListenerin interfaceIEmbeddedEditor- Parameters:
listener- the listener to be added
-
removeDocumentStateListener
public void removeDocumentStateListener(IEmbeddedEditor.IDocumentStateListener listener)
Description copied from interface:IEmbeddedEditorRemoves the given document state listener.- Specified by:
removeDocumentStateListenerin interfaceIEmbeddedEditor- Parameters:
listener- the listener to be removed
-
setModelListener
public void setModelListener(AbstractModelChangeListener modelListener)
Description copied from interface:IEmbeddedEditorDefines the model listener being called inIEmbeddedEditor.doSave().- Specified by:
setModelListenerin interfaceIEmbeddedEditor- Parameters:
modelListener- the model listener (null for ignore it)
-
getEditableContent
public java.lang.String getEditableContent()
Description copied from interface:IEmbeddedEditorReturns the editable content in this editor.- Specified by:
getEditableContentin interfaceIEmbeddedEditor- Returns:
- the editable content
-
getContent
public java.lang.String getContent()
Description copied from interface:IEmbeddedEditorReturns the full content of the editor, including potential context such as prefix and postfix.- Specified by:
getContentin interfaceIEmbeddedEditor- Returns:
- the full content
-
doSave
public boolean doSave()
Description copied from interface:IEmbeddedEditorSave the editor content to the original resource if content changed.- Specified by:
doSavein interfaceIEmbeddedEditor- Returns:
trueif the content was saved,falseelse
-
updateEditor
public void updateEditor()
Description copied from interface:IUpdatableEditorUpdates this editor.- Specified by:
updateEditorin interfaceIUpdatableEditor
-
getResource
public org.eclipse.core.resources.IResource getResource()
Description copied from interface:IUpdatableEditorReturns the resource of this editor.- Specified by:
getResourcein interfaceIUpdatableEditor- Returns:
- the resource
-
buildModel
public void buildModel(org.eclipse.xtext.ui.editor.model.IXtextDocument doc)
Description copied from interface:IUpdatableEditorCreates the model in the given xText documentdoc. This method synchronizes overdocin order to avoid reentrant model validation.- Specified by:
buildModelin interfaceIUpdatableEditor- Parameters:
doc- the document to create the model for
-
setEditable
public void setEditable(boolean editable)
Description copied from interface:IEmbeddedEditorChanges whether the editor is enabled for editing.- Specified by:
setEditablein interfaceIEmbeddedEditor- Parameters:
editable-trueif editing is enabled,falseif only viewing is supported
-
-