1 11 package org.eclipse.compare.structuremergeviewer; 12 13 import org.eclipse.compare.ISharedDocumentAdapter; 14 import org.eclipse.compare.SharedDocumentAdapter; 15 import org.eclipse.compare.internal.Utilities; 16 import org.eclipse.core.runtime.*; 17 import org.eclipse.jface.text.IDocument; 18 import org.eclipse.ui.IEditorInput; 19 import org.eclipse.ui.texteditor.IDocumentProvider; 20 21 29 public class SharedDocumentAdapterWrapper implements ISharedDocumentAdapter { 30 31 private ISharedDocumentAdapter wrappedAdapter; 32 33 40 public static ISharedDocumentAdapter getAdapter(Object element) { 41 return (ISharedDocumentAdapter)Utilities.getAdapter(element, ISharedDocumentAdapter.class, true); 42 } 43 44 48 public SharedDocumentAdapterWrapper(ISharedDocumentAdapter wrappedAdapter) { 49 super(); 50 this.wrappedAdapter = wrappedAdapter; 51 } 52 53 56 public void connect(IDocumentProvider provider, IEditorInput documentKey) 57 throws CoreException { 58 wrappedAdapter.connect(provider, documentKey); 59 } 60 61 64 public void disconnect(IDocumentProvider provider, IEditorInput documentKey) { 65 wrappedAdapter.disconnect(provider, documentKey); 66 } 67 68 71 public IEditorInput getDocumentKey(Object element) { 72 return wrappedAdapter.getDocumentKey(element); 73 } 74 75 78 public void flushDocument(IDocumentProvider provider, 79 IEditorInput documentKey, IDocument document, boolean overwrite) throws CoreException { 80 wrappedAdapter.flushDocument(provider, documentKey, document, overwrite); 81 } 82 83 87 public final ISharedDocumentAdapter getWrappedAdapter() { 88 return wrappedAdapter; 89 } 90 91 94 public void disconnect(Object element) { 95 IEditorInput input = getDocumentKey(element); 96 if (input == null) 97 return; 98 IDocumentProvider provider = SharedDocumentAdapter.getDocumentProvider(input); 99 if (provider == null) 100 return; 101 disconnect(provider, input); 102 } 103 104 } 105 | Popular Tags |