Package de.loskutov.anyedit.compare
Class TextStreamContent
- java.lang.Object
-
- de.loskutov.anyedit.compare.TextStreamContent
-
- All Implemented Interfaces:
StreamContent
,org.eclipse.compare.IEditableContent
,org.eclipse.compare.IEditableContentExtension
,org.eclipse.compare.IStreamContentAccessor
,org.eclipse.compare.ITypedElement
,org.eclipse.compare.structuremergeviewer.IStructureComparator
,org.eclipse.core.runtime.IAdaptable
public class TextStreamContent extends java.lang.Object implements StreamContent, org.eclipse.compare.IStreamContentAccessor, org.eclipse.compare.IEditableContent, org.eclipse.compare.IEditableContentExtension
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
TextStreamContent.PartListener2Impl
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ANY_EDIT_COMPARE
private byte[]
bytes
private AnyeditCompareInput
compareInput
private ContentWrapper
content
private boolean
dirty
private boolean
disposed
private org.eclipse.jface.text.IDocumentListener
docListener
private AbstractEditor
editor
private org.eclipse.jface.text.source.Annotation
lineAnnotation
private org.eclipse.ui.IPartListener2
partListener
private org.eclipse.jface.text.Position
position
private org.eclipse.jface.text.DefaultPositionUpdater
positionUpdater
private java.lang.String
selectedText
private EditableSharedDocumentAdapter
sharedDocumentAdapter
-
Constructor Summary
Constructors Modifier Constructor Description TextStreamContent(ContentWrapper content, AbstractEditor editor)
private
TextStreamContent(ContentWrapper content, AbstractEditor editor, java.lang.String selectedText, org.eclipse.jface.text.Position position)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addSelectionAnnotation()
boolean
commitChanges(org.eclipse.core.runtime.IProgressMonitor pm)
private static org.eclipse.jface.text.Position
createPosition(org.eclipse.jface.text.ITextSelection selection)
void
dispose()
java.lang.Object
getAdapter(java.lang.Class adapter)
private java.lang.String
getChangedCompareText()
java.lang.Object[]
getChildren()
java.io.InputStream
getContents()
java.lang.String
getFullName()
org.eclipse.swt.graphics.Image
getImage()
java.lang.String
getName()
private org.eclipse.compare.ISharedDocumentAdapter
getSharedDocumentAdapter()
The code below is copy from org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement and is required to add full Java editor capabilities (content assist, navigation etc) to the compare editorprivate java.lang.String
getText(org.eclipse.jface.text.Position pos)
java.lang.String
getType()
private void
hookOnSelection()
void
init(AnyeditCompareInput input)
boolean
isDirty()
boolean
isDisposed()
boolean
isEditable()
boolean
isReadOnly()
StreamContent
recreate()
create new one with the selection re-created from annotation, if anyprivate void
removeSelectionAnnotation()
org.eclipse.compare.ITypedElement
replace(org.eclipse.compare.ITypedElement dest, org.eclipse.compare.ITypedElement src)
void
setContent(byte[] newContent)
void
setDirty(boolean dirty)
(package private) void
updateCompareEditor(org.eclipse.jface.text.DocumentEvent event)
org.eclipse.core.runtime.IStatus
validateEdit(org.eclipse.swt.widgets.Shell shell)
-
-
-
Field Detail
-
ANY_EDIT_COMPARE
private static final java.lang.String ANY_EDIT_COMPARE
- See Also:
- Constant Field Values
-
selectedText
private final java.lang.String selectedText
-
position
private final org.eclipse.jface.text.Position position
-
content
private final ContentWrapper content
-
editor
private final AbstractEditor editor
-
bytes
private byte[] bytes
-
dirty
private boolean dirty
-
partListener
private final org.eclipse.ui.IPartListener2 partListener
-
positionUpdater
private org.eclipse.jface.text.DefaultPositionUpdater positionUpdater
-
docListener
private org.eclipse.jface.text.IDocumentListener docListener
-
lineAnnotation
private org.eclipse.jface.text.source.Annotation lineAnnotation
-
compareInput
private AnyeditCompareInput compareInput
-
disposed
private boolean disposed
-
sharedDocumentAdapter
private EditableSharedDocumentAdapter sharedDocumentAdapter
-
-
Constructor Detail
-
TextStreamContent
public TextStreamContent(ContentWrapper content, AbstractEditor editor)
- Parameters:
content
- NOT nulleditor
- might be null
-
TextStreamContent
private TextStreamContent(ContentWrapper content, AbstractEditor editor, java.lang.String selectedText, org.eclipse.jface.text.Position position)
-
-
Method Detail
-
updateCompareEditor
void updateCompareEditor(org.eclipse.jface.text.DocumentEvent event)
-
createPosition
private static org.eclipse.jface.text.Position createPosition(org.eclipse.jface.text.ITextSelection selection)
-
hookOnSelection
private void hookOnSelection()
-
getChangedCompareText
private java.lang.String getChangedCompareText()
-
getImage
public org.eclipse.swt.graphics.Image getImage()
- Specified by:
getImage
in interfaceorg.eclipse.compare.ITypedElement
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceorg.eclipse.compare.ITypedElement
-
getFullName
public java.lang.String getFullName()
- Specified by:
getFullName
in interfaceStreamContent
-
getType
public java.lang.String getType()
- Specified by:
getType
in interfaceorg.eclipse.compare.ITypedElement
-
getChildren
public java.lang.Object[] getChildren()
- Specified by:
getChildren
in interfaceorg.eclipse.compare.structuremergeviewer.IStructureComparator
-
commitChanges
public boolean commitChanges(org.eclipse.core.runtime.IProgressMonitor pm) throws org.eclipse.core.runtime.CoreException
- Specified by:
commitChanges
in interfaceStreamContent
- Throws:
org.eclipse.core.runtime.CoreException
-
isDirty
public boolean isDirty()
- Specified by:
isDirty
in interfaceStreamContent
-
getContents
public java.io.InputStream getContents() throws org.eclipse.core.runtime.CoreException
- Specified by:
getContents
in interfaceorg.eclipse.compare.IStreamContentAccessor
- Throws:
org.eclipse.core.runtime.CoreException
-
isEditable
public final boolean isEditable()
- Specified by:
isEditable
in interfaceorg.eclipse.compare.IEditableContent
-
replace
public org.eclipse.compare.ITypedElement replace(org.eclipse.compare.ITypedElement dest, org.eclipse.compare.ITypedElement src)
- Specified by:
replace
in interfaceorg.eclipse.compare.IEditableContent
-
setContent
public void setContent(byte[] newContent)
- Specified by:
setContent
in interfaceorg.eclipse.compare.IEditableContent
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceStreamContent
-
isDisposed
public boolean isDisposed()
- Specified by:
isDisposed
in interfaceStreamContent
-
addSelectionAnnotation
private void addSelectionAnnotation()
-
removeSelectionAnnotation
private void removeSelectionAnnotation()
-
init
public void init(AnyeditCompareInput input)
- Specified by:
init
in interfaceStreamContent
-
recreate
public StreamContent recreate()
create new one with the selection re-created from annotation, if any- Specified by:
recreate
in interfaceStreamContent
-
getText
private java.lang.String getText(org.eclipse.jface.text.Position pos)
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnly
in interfaceorg.eclipse.compare.IEditableContentExtension
-
validateEdit
public org.eclipse.core.runtime.IStatus validateEdit(org.eclipse.swt.widgets.Shell shell)
- Specified by:
validateEdit
in interfaceorg.eclipse.compare.IEditableContentExtension
-
getAdapter
public java.lang.Object getAdapter(java.lang.Class adapter)
- Specified by:
getAdapter
in interfaceorg.eclipse.core.runtime.IAdaptable
-
getSharedDocumentAdapter
private org.eclipse.compare.ISharedDocumentAdapter getSharedDocumentAdapter()
The code below is copy from org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement and is required to add full Java editor capabilities (content assist, navigation etc) to the compare editor- Returns:
-
setDirty
public void setDirty(boolean dirty)
- Specified by:
setDirty
in interfaceStreamContent
-
-