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 classTextStreamContent.PartListener2Impl
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringANY_EDIT_COMPAREprivate byte[]bytesprivate AnyeditCompareInputcompareInputprivate ContentWrappercontentprivate booleandirtyprivate booleandisposedprivate org.eclipse.jface.text.IDocumentListenerdocListenerprivate AbstractEditoreditorprivate org.eclipse.jface.text.source.AnnotationlineAnnotationprivate org.eclipse.ui.IPartListener2partListenerprivate org.eclipse.jface.text.Positionpositionprivate org.eclipse.jface.text.DefaultPositionUpdaterpositionUpdaterprivate java.lang.StringselectedTextprivate EditableSharedDocumentAdaptersharedDocumentAdapter
-
Constructor Summary
Constructors Modifier Constructor Description TextStreamContent(ContentWrapper content, AbstractEditor editor)privateTextStreamContent(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 voidaddSelectionAnnotation()booleancommitChanges(org.eclipse.core.runtime.IProgressMonitor pm)private static org.eclipse.jface.text.PositioncreatePosition(org.eclipse.jface.text.ITextSelection selection)voiddispose()java.lang.ObjectgetAdapter(java.lang.Class adapter)private java.lang.StringgetChangedCompareText()java.lang.Object[]getChildren()java.io.InputStreamgetContents()java.lang.StringgetFullName()org.eclipse.swt.graphics.ImagegetImage()java.lang.StringgetName()private org.eclipse.compare.ISharedDocumentAdaptergetSharedDocumentAdapter()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.StringgetText(org.eclipse.jface.text.Position pos)java.lang.StringgetType()private voidhookOnSelection()voidinit(AnyeditCompareInput input)booleanisDirty()booleanisDisposed()booleanisEditable()booleanisReadOnly()StreamContentrecreate()create new one with the selection re-created from annotation, if anyprivate voidremoveSelectionAnnotation()org.eclipse.compare.ITypedElementreplace(org.eclipse.compare.ITypedElement dest, org.eclipse.compare.ITypedElement src)voidsetContent(byte[] newContent)voidsetDirty(boolean dirty)(package private) voidupdateCompareEditor(org.eclipse.jface.text.DocumentEvent event)org.eclipse.core.runtime.IStatusvalidateEdit(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:
getImagein interfaceorg.eclipse.compare.ITypedElement
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceorg.eclipse.compare.ITypedElement
-
getFullName
public java.lang.String getFullName()
- Specified by:
getFullNamein interfaceStreamContent
-
getType
public java.lang.String getType()
- Specified by:
getTypein interfaceorg.eclipse.compare.ITypedElement
-
getChildren
public java.lang.Object[] getChildren()
- Specified by:
getChildrenin interfaceorg.eclipse.compare.structuremergeviewer.IStructureComparator
-
commitChanges
public boolean commitChanges(org.eclipse.core.runtime.IProgressMonitor pm) throws org.eclipse.core.runtime.CoreException- Specified by:
commitChangesin interfaceStreamContent- Throws:
org.eclipse.core.runtime.CoreException
-
isDirty
public boolean isDirty()
- Specified by:
isDirtyin interfaceStreamContent
-
getContents
public java.io.InputStream getContents() throws org.eclipse.core.runtime.CoreException- Specified by:
getContentsin interfaceorg.eclipse.compare.IStreamContentAccessor- Throws:
org.eclipse.core.runtime.CoreException
-
isEditable
public final boolean isEditable()
- Specified by:
isEditablein interfaceorg.eclipse.compare.IEditableContent
-
replace
public org.eclipse.compare.ITypedElement replace(org.eclipse.compare.ITypedElement dest, org.eclipse.compare.ITypedElement src)- Specified by:
replacein interfaceorg.eclipse.compare.IEditableContent
-
setContent
public void setContent(byte[] newContent)
- Specified by:
setContentin interfaceorg.eclipse.compare.IEditableContent
-
dispose
public void dispose()
- Specified by:
disposein interfaceStreamContent
-
isDisposed
public boolean isDisposed()
- Specified by:
isDisposedin interfaceStreamContent
-
addSelectionAnnotation
private void addSelectionAnnotation()
-
removeSelectionAnnotation
private void removeSelectionAnnotation()
-
init
public void init(AnyeditCompareInput input)
- Specified by:
initin interfaceStreamContent
-
recreate
public StreamContent recreate()
create new one with the selection re-created from annotation, if any- Specified by:
recreatein interfaceStreamContent
-
getText
private java.lang.String getText(org.eclipse.jface.text.Position pos)
-
isReadOnly
public boolean isReadOnly()
- Specified by:
isReadOnlyin interfaceorg.eclipse.compare.IEditableContentExtension
-
validateEdit
public org.eclipse.core.runtime.IStatus validateEdit(org.eclipse.swt.widgets.Shell shell)
- Specified by:
validateEditin interfaceorg.eclipse.compare.IEditableContentExtension
-
getAdapter
public java.lang.Object getAdapter(java.lang.Class adapter)
- Specified by:
getAdapterin 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:
setDirtyin interfaceStreamContent
-
-