@Override public void elementDeleted(Object element) { IEditorInput input = getDocumentKey(); if (input != null && input.equals(element)) { // This method will only get called if the buffer is not dirty resetDocument(); } } private void resetDocument() {
public void elementDeleted(Object element) { IEditorInput input = getDocumentKey(); if (input != null && input.equals(element)) { // This method will only get called if the buffer is not dirty resetDocument(); } } private void resetDocument() {
@Override public void elementMoved(Object originalElement, Object movedElement) { IEditorInput input = getDocumentKey(); if (input != null && input.equals(originalElement)) { // This method will only get called if the buffer is not dirty resetDocument(); } }
IEditorInput key = getDocumentKey(); if (key != null) { if (fDocumentProvider != null) {
/** * Connect to a shared document if possible. Return <code>null</code> * if the connection was not possible. * @return the shared document or <code>null</code> if connection to a * shared document was not possible */ private IDocument connectToSharedDocument() { IEditorInput key = getDocumentKey(); if (key != null) { if (fDocumentProvider != null) { // We've already connected and setup the document return fDocumentProvider.getDocument(key); } IDocumentProvider documentProvider = getDocumentProvider(); if (documentProvider != null) { try { connect(documentProvider, key); setCachedDocumentProvider(key, documentProvider); IDocument newDoc = documentProvider.getDocument(key); this.fViewer.updateDirtyState(key, documentProvider, fLeg); return newDoc; } catch (CoreException e) { // Connection failed. Log the error and continue without a shared document CompareUIPlugin.log(e); } } } return null; }
public void disconnect() { IDocumentProvider provider = null; IEditorInput input = getDocumentKey(); synchronized(this) { if (fDocumentProvider != null) { provider = fDocumentProvider; fDocumentProvider = null; fDocumentKey = null; } } if (provider != null) { disconnect(provider, input); provider.removeElementStateListener(this); } // If we have a listener registered with the widget, remove it if (fSourceViewer != null) { StyledText textWidget = fSourceViewer.getSourceViewer().getTextWidget(); if (textWidget != null && !textWidget.isDisposed()) { if (fNeedsValidation) { textWidget.removeVerifyListener(this); fNeedsValidation = false; } IDocument oldDoc= internalGetDocument(fSourceViewer); if (oldDoc != null) { oldDoc.removeDocumentListener(this); } } } clearCachedDocument(); }
public void disconnect() { IDocumentProvider provider = null; IEditorInput input = getDocumentKey(); synchronized(this) { if (fDocumentProvider != null) { provider = fDocumentProvider; fDocumentProvider = null; fDocumentKey = null; } } if (provider != null) { disconnect(provider, input); provider.removeElementStateListener(this); } // If we have a listener registered with the widget, remove it if (fSourceViewer != null && !fSourceViewer.getTextWidget().isDisposed()) { if (fNeedsValidation) { fSourceViewer.getTextWidget().removeVerifyListener(this); fNeedsValidation = false; } IDocument oldDoc= internalGetDocument(fSourceViewer); if (oldDoc != null) { oldDoc.removeDocumentListener(this); } } clearCachedDocument(); }
public boolean flush() throws CoreException { if (fDocumentProvider != null) { IEditorInput input = getDocumentKey(); IDocument document = fDocumentProvider.getDocument(input); if (document != null) { final ISharedDocumentAdapter sda = (ISharedDocumentAdapter) Utilities.getAdapter(fElement, ISharedDocumentAdapter.class); if (sda != null) { sda.flushDocument(fDocumentProvider, input, document, false); return true; } try { fDocumentProvider.aboutToChange(input); fDocumentProvider.saveDocument(new NullProgressMonitor(), input, document, false); return true; } finally { fDocumentProvider.changed(input); } } } return false; }
public boolean flush() throws CoreException { if (fDocumentProvider != null) { IEditorInput input = getDocumentKey(); IDocument document = fDocumentProvider.getDocument(input); if (document != null) { final ISharedDocumentAdapter sda = Adapters.adapt(fElement, ISharedDocumentAdapter.class); if (sda != null) { sda.flushDocument(fDocumentProvider, input, document, false); return true; } try { fDocumentProvider.aboutToChange(input); fDocumentProvider.saveDocument(new NullProgressMonitor(), input, document, false); return true; } finally { fDocumentProvider.changed(input); } } } return false; }
@Override public void elementContentReplaced(Object element) { if (!checkState()) return; IEditorInput input = getDocumentKey(); if (input != null && input.equals(element)) { this.fViewer.updateDirtyState(input, getDocumentProvider(), fLeg); // recalculate diffs and update controls new UIJob(CompareMessages.DocumentMerger_0) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { update(true); updateStructure(fLeg); return Status.OK_STATUS; } }.schedule(); } } @Override
public IDocument getDocument() { if (fDocumentProvider != null) { IDocument document = fDocumentProvider.getDocument(getDocumentKey()); if (document != null) return document; } if (fElement instanceof IDocument) return (IDocument) fElement; if (fElement instanceof IDocumentRange) return ((IDocumentRange) fElement).getDocument(); if (fElement instanceof IStreamContentAccessor) return DocumentManager.get(fElement); return null; }
public IDocument getDocument() { if (fDocumentProvider != null) { IDocument document = fDocumentProvider.getDocument(getDocumentKey()); if (document != null) return document; } if (fElement instanceof IDocument) return (IDocument) fElement; if (fElement instanceof IDocumentRange) return ((IDocumentRange) fElement).getDocument(); if (fElement instanceof IStreamContentAccessor) return DocumentManager.get(fElement); return null; }
public void elementMoved(Object originalElement, Object movedElement) { IEditorInput input = getDocumentKey(); if (input != null && input.equals(originalElement)) { // This method will only get called if the buffer is not dirty resetDocument(); } } public void elementDirtyStateChanged(Object element, boolean isDirty) {
private IDocumentProvider getDocumentProvider() { if (fDocumentProvider != null) return fDocumentProvider; // We will only use document providers if the content provider is the // default content provider if (isUsingDefaultContentProvider()) { IEditorInput input = getDocumentKey(); if (input != null) return SharedDocumentAdapter.getDocumentProvider(input); } return null; }
private IDocumentProvider getDocumentProvider() { if (fDocumentProvider != null) return fDocumentProvider; // We will only use document providers if the content provider is the // default content provider if (isUsingDefaultContentProvider()) { IEditorInput input = getDocumentKey(); if (input != null) return SharedDocumentAdapter.getDocumentProvider(input); } return null; }
@Override public void elementDirtyStateChanged(Object element, boolean isDirty) { if (!checkState()) return; IEditorInput input = getDocumentKey(); if (input != null && input.equals(element)) { this.fViewer.updateDirtyState(input, getDocumentProvider(), fLeg); } }
public void elementDirtyStateChanged(Object element, boolean isDirty) { if (!checkState()) return; IEditorInput input = getDocumentKey(); if (input != null && input.equals(element)) { this.fViewer.updateDirtyState(input, getDocumentProvider(), fLeg); } }
boolean hasSharedDocument(Object object) { return (fElement == object && fDocumentProvider != null && fDocumentProvider.getDocument(getDocumentKey()) != null); }
boolean hasSharedDocument(Object object) { return (fElement == object && fDocumentProvider != null && fDocumentProvider.getDocument(getDocumentKey()) != null); }
public void elementContentReplaced(Object element) { if (!checkState()) return; IEditorInput input = getDocumentKey(); if (input != null && input.equals(element)) { this.fViewer.updateDirtyState(input, getDocumentProvider(), fLeg); } } public void elementContentAboutToBeReplaced(Object element) {