Bug 6147 Templates don't work in "Show source of selected element only" mode
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/link/LinkedPositionUI.java
import org.eclipse.jface.text.ITextInputListener;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.util.Assert;
import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
 * A user interface for <code>LinkedPositionManager</code>, using <code>ITextViewer</code>.
 */
public class LinkedPositionUI implements LinkedPositionListener,
	ITextInputListener, ModifyListener, VerifyListener, VerifyKeyListener, PaintListener {
	/**
	 * A listener for notification when the user cancelled the edit operation.
	 */
	public interface ExitListener {
		void exit(boolean accept);
	}
	
	
	private static final int UNINSTALL= 1;			
	private static final int COMMIT= 2;				
	private static final int DOCUMENT_CHANGED= 4;	
	private static final int UPDATE_CARET= 8;		
	private static final String CARET_POSITION= "LinkedPositionUI.caret.position";
	private static final IPositionUpdater fgUpdater= new DefaultPositionUpdater(CARET_POSITION);
	
	private final ITextViewer fViewer;
	private final LinkedPositionManager fManager;	
	private final Color fFrameColor;
	private int fFinalCaretOffset= -1;