1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.jdt.internal.ui.javaeditor; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 16 import org.eclipse.jface.text.IDocument; 17 import org.eclipse.jface.text.ILineTracker; 18 import org.eclipse.jface.text.source.IAnnotationModelListener; 19 20 import org.eclipse.ui.texteditor.IDocumentProvider; 21 import org.eclipse.ui.texteditor.IDocumentProviderExtension2; 22 import org.eclipse.ui.texteditor.IDocumentProviderExtension3; 23 import org.eclipse.ui.texteditor.IDocumentProviderExtension5; 24 25 import org.eclipse.jdt.core.ICompilationUnit; 26 27 /** 28 * @since 3.0 29 */ 30 public interface ICompilationUnitDocumentProvider extends IDocumentProvider, IDocumentProviderExtension2, IDocumentProviderExtension3, IDocumentProviderExtension5 { 31 32 /** 33 * Shuts down this provider. 34 */ 35 void shutdown(); 36 37 /** 38 * Returns the working copy for the given element. 39 * 40 * @param element the element 41 * @return the working copy for the given element 42 */ 43 ICompilationUnit getWorkingCopy(Object element); 44 45 /** 46 * Saves the content of the given document to the given element. This method has 47 * only an effect if it is called when directly or indirectly inside <code>saveDocument</code>. 48 * 49 * @param monitor the progress monitor 50 * @param element the element to which to save 51 * @param document the document to save 52 * @param overwrite <code>true</code> if the save should be enforced 53 */ 54 void saveDocumentContent(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException; 55 56 /** 57 * Creates a line tracker for the given element. It is of the same kind as the one that would be 58 * used for a newly created document for the given element. 59 * 60 * @param element the element 61 * @return a line tracker for the given element 62 */ 63 ILineTracker createLineTracker(Object element); 64 65 /** 66 * Sets the document provider's save policy. 67 * 68 * @param savePolicy the save policy 69 */ 70 void setSavePolicy(ISavePolicy savePolicy); 71 72 /** 73 * Adds a listener that reports changes from all compilation unit annotation models. 74 * 75 * @param listener the listener 76 */ 77 void addGlobalAnnotationModelListener(IAnnotationModelListener listener); 78 79 /** 80 * Removes the listener. 81 * 82 * @param listener the listener 83 */ 84 void removeGlobalAnnotationModelListener(IAnnotationModelListener listener); 85 } 86