diff options
93 files changed, 398 insertions, 5026 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java index 989ecf993c3..a4ffb83db98 100644 --- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java +++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IDocumentFactory.java @@ -25,5 +25,5 @@ public interface IDocumentFactory { * * @return a new, empty document */ - IDocument createDocument(); + IDocument createDocument(); } diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java index 60da3a8bb73..d5676f67776 100644 --- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java +++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java @@ -40,7 +40,7 @@ public interface ITextFileBuffer extends IFileBuffer { /** * Sets the character encoding to be used for reading and writing the buffer's - * underlyning file. + * underlying file. * * @param encoding the encoding */ diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java deleted file mode 100644 index d8a7e9bd64f..00000000000 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/OutlinerRulerColumn.java +++ /dev/null @@ -1,117 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.text.source; - - -import java.util.Iterator; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.Position; - - -/** - * A ruler column for controlling the behavior of a <code>ProjectionSourceViewer</code>. - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class OutlinerRulerColumn extends AnnotationRulerColumn { - - /** - * Creates a new outliner ruler column. - * - * @param model the column's annotation model - * @param width the width in pixels - */ - public OutlinerRulerColumn(IAnnotationModel model, int width) { - super(model, width); - } - - /* - * @see org.eclipse.jface.text.source.AnnotationRulerColumn#mouseDoubleClicked(int) - */ - protected void mouseDoubleClicked(int line) { - ProjectionAnnotation annotation= findAnnotation(line); - if (annotation != null) - annotation.run(getCachedTextViewer()); - } - - /** - * Returns the projection annotation of the column's annotation - * model that contains the given line. - * - * @param line the line - * @return the projection annotation containing the given line - */ - private ProjectionAnnotation findAnnotation(int line) { - IAnnotationModel model= getModel(); - if (model != null) { - Iterator e= model.getAnnotationIterator(); - while (e.hasNext()) { - Object next= e.next(); - if (next instanceof ProjectionAnnotation) { - ProjectionAnnotation annotation= (ProjectionAnnotation) next; - Position p= model.getPosition(annotation); - if (contains(p, line)) - return annotation; - } - } - } - return null; - } - - /** - * Returns whether the given position contains the given line. - * - * @param p the position - * @param line the line - * @return <code>true</code> if the given position contains the given line, <code>false</code> otherwise - */ - private boolean contains(Position p, int line) { - - IDocument document= getCachedTextViewer().getDocument(); - - try { - - int startLine= document.getLineOfOffset(p.getOffset()); - if (line < startLine) - return false; - if (line == startLine) - return true; - - int endLine= document.getLineOfOffset(p.getOffset() + Math.max(p.getLength() -1, 0)); - return (startLine < line && line <= endLine) ; - - } catch (BadLocationException x) { - } - - return false; - } - - /* - * @see org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite) - */ - public Control createControl(CompositeRuler parentRuler, Composite parentControl) { - Control control= super.createControl(parentRuler, parentControl); - Display display= parentControl.getDisplay(); - Color background= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND); - control.setBackground(background); - return control; - } -} diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java deleted file mode 100644 index 822b3a7b8d9..00000000000 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionAnnotation.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.text.source; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Canvas; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Position; - -/** - * Annotation used to represent the projection of a master document onto - * a <code>ProjectionDocument</code>. A projection annotation can be either - * expanded or collapsed. If expaned it corresponds to a fragment of the - * projection document. If collapsed, it represents a region of the master document - * that does not have a corresponding fragment in the projection document. <p> - * Draws itself in a tree like fashion.<p> - * This class if for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class ProjectionAnnotation extends Annotation implements IAnnotationPresentation { - - private static final int OUTER_MARGIN= 1; - private static final int INNER_MARGIN= 1; - private static final int PIXELS= 1; - private static final int LEGS= 2; - private static final int MIDDLE= PIXELS + INNER_MARGIN + LEGS; - private static final int SIZE= 2 * MIDDLE + PIXELS; - - /** The range in the master document */ - private Position fProjectionRange; - /** The state of this annotation */ - private boolean fIsFolded= false; - - /** - * Creates a new projection annotation for the given range of the master document. - * - * @param range the range. - */ - public ProjectionAnnotation(Position range) { - fProjectionRange= range; - } - - /* - * @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle) - */ - public void paint(GC gc, Canvas canvas, Rectangle rectangle) { - Color fg= gc.getForeground(); - gc.setForeground(canvas.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - - - Rectangle r= new Rectangle(rectangle.x + OUTER_MARGIN, rectangle.y + OUTER_MARGIN, SIZE -1 , SIZE -1); - gc.drawRectangle(r); - gc.drawLine(r.x + PIXELS + INNER_MARGIN, r.y + MIDDLE, r.x + r.width - PIXELS - INNER_MARGIN , r.y + MIDDLE); - if (fIsFolded) { - gc.drawLine(r.x + MIDDLE, r.y + PIXELS + INNER_MARGIN, r.x + MIDDLE, r.y + r.height - PIXELS - INNER_MARGIN); - } else { - gc.drawLine(r.x + MIDDLE, r.y + r.height, r.x + MIDDLE, rectangle.y + rectangle.height - OUTER_MARGIN); - gc.drawLine(r.x + MIDDLE, rectangle.y + rectangle.height - OUTER_MARGIN, r.x + r.width - INNER_MARGIN, rectangle.y + rectangle.height - OUTER_MARGIN); - } - - gc.setForeground(fg); - } - - /** - * Toogles the state of this annotation and updates the given viewer accordingly. - * - * @param viewer the viewer - */ - public void run(ITextViewer viewer) { - - if (viewer instanceof ProjectionSourceViewer) { - ProjectionSourceViewer projectionViewer= (ProjectionSourceViewer) viewer; - - if (fIsFolded) { - - fIsFolded= false; - projectionViewer.expand(fProjectionRange.getOffset(), fProjectionRange.getLength()); - - } else { - - try { - IDocument document= projectionViewer.getDocument(); - int line= document.getLineOfOffset(fProjectionRange.getOffset()); - int offset= document.getLineOffset(line + 1); - - int length= fProjectionRange.getLength() - (offset - fProjectionRange.getOffset()); - if (length > 0) { - fIsFolded= true; - projectionViewer.collapse(offset, length); - } - } catch (BadLocationException x) { - } - } - } - } - - /** - * Returns the state of this annotation. - * - * @return <code>true</code> if collapsed - */ - public boolean isFolded() { - return fIsFolded; - } -} diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java deleted file mode 100644 index 855283d0218..00000000000 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/ProjectionSourceViewer.java +++ /dev/null @@ -1,265 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text.source; - - -import java.util.Iterator; - -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.VerifyEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.ISlaveDocumentManager; -import org.eclipse.jface.text.ITextViewerExtension3; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.ProjectionDocument; -import org.eclipse.jface.text.ProjectionDocumentManager; - - -/** - * A projection source viewer is a source viewer which does not support the concept of a visible region. Instead it supports - * to dynamically hide and show regions of its document. Uses <code>ProjectionDocumentManager</code> as it internal slave document manager.<p> - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class ProjectionSourceViewer extends SourceViewer implements ISourceViewer, ITextViewerExtension3 { - - /** The projection annotation model */ - private IAnnotationModel fProjectionAnnotationModel; - - /** - * Creates a new projection source viewer. - * - * @param parent the SWT parent control - * @param ruler the vertical ruler - * @param styles the SWT style bits - */ - public ProjectionSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { - super(parent, ruler, styles); - } - - /* - * @see ISourceViewer#setDocument(IDocument, IAnnotationModel, int, int) - */ - public void setDocument(IDocument document, IAnnotationModel annotationModel, int visibleRegionOffset, int visibleRegionLength) { - if (getDocument() != null && fProjectionAnnotationModel != null) - fProjectionAnnotationModel.disconnect(getDocument()); - - super.setDocument(document, annotationModel, visibleRegionOffset, visibleRegionLength); - - if (getDocument() != null && fProjectionAnnotationModel != null) - fProjectionAnnotationModel.connect(getDocument()); - } - - /* - * @see TextViewer#handleDispose() - */ - protected void handleDispose() { - - if (getDocument() != null && fProjectionAnnotationModel != null) { - fProjectionAnnotationModel.disconnect(getDocument()); - fProjectionAnnotationModel= null; - } - - super.handleDispose(); - } - - /** - * Returns the projection annotation model. - * - * @return the projection annotation model - */ - public IAnnotationModel getProjectionAnnotationModel() { - return fProjectionAnnotationModel; - } - - /** - * Sets the projection annotation model. - * - * @param projectionAnnotationModel the projection annotation model - */ - public void setProjectionAnnotationModel(IAnnotationModel projectionAnnotationModel) { - fProjectionAnnotationModel= projectionAnnotationModel; - } - - /* - * @see org.eclipse.jface.text.TextViewer#createSlaveDocumentManager() - */ - protected ISlaveDocumentManager createSlaveDocumentManager() { - return new ProjectionDocumentManager(); - } - - /* - * @see org.eclipse.jface.text.TextViewer#updateVisibleDocument(org.eclipse.jface.text.IDocument, int, int) - */ - protected boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException { - if (visibleDocument instanceof ProjectionDocument) { - ProjectionDocument document= (ProjectionDocument) visibleDocument; - document.addFragment(visibleRegionOffset, visibleRegionLength); - } - return true; - } - - /** - * Hides the given range by collapsing it. - * - * @param offset the offset of the range to hide - * @param length the length of the range to hide - */ - public void collapse(int offset, int length) { - - IDocument previous= getVisibleDocument(); - IDocument slave= createSlaveDocument(previous); - - if (slave instanceof ProjectionDocument) { - - StyledText textWidget= getTextWidget(); - try { - - if (textWidget != null) - textWidget.setRedraw(false); - - - int topIndex= getTopIndex(); - Point selection= getSelectedRange(); - - // adapt selection - int selectionEnd= selection.x + selection.y; - if (offset < selectionEnd && selectionEnd <= offset + length) { - - int lineEnd= offset; - - try { - IDocument document= getDocument(); - int line= document.getLineOfOffset(offset); - IRegion lineInfo= document.getLineInformation(Math.max(line -1, 0)); - lineEnd= lineInfo.getOffset() + lineInfo.getLength(); - } catch (BadLocationException x) { - } - - if (offset <= selection.x && selection.x < offset + length) { - selection.x= lineEnd; - selection.y= 0; - } else { - selection.y= Math.max(lineEnd - selection.x, 0); - } - - } else if (offset <= selection.x && selection.x < offset + length) { - int delta= offset + length - selection.x; - selection.x= offset + length; - selection.y -= delta; - } - - ((ProjectionDocument) slave).hide(offset, length); - setVisibleDocument(slave); - - setSelectedRange(selection.x, selection.y); - setTopIndex(topIndex); - - } finally { - if(textWidget != null) - textWidget.setRedraw(true); - } - } - } - - /** - * Makes all hidden ranges in the given range visible again. - * - * @param offset the offset of the range - * @param length the length of the range - */ - public void expand(int offset, int length) { - if (getVisibleDocument() instanceof ProjectionDocument) { - ProjectionDocument document= (ProjectionDocument) getVisibleDocument(); - - StyledText textWidget= getTextWidget(); - try { - - if (textWidget != null) - textWidget.setRedraw(false); - - Point selection= getSelectedRange(); - int topIndex= getTopIndex(); - - document.show(offset, length); - setVisibleDocument(document); - - setSelectedRange(selection.x, selection.y); - setTopIndex(topIndex); - - } finally { - if (textWidget != null) - textWidget.setRedraw(true); - } - } - } - - /* - * @see org.eclipse.jface.text.ITextViewer#getVisibleRegion() - */ - public IRegion getVisibleRegion() { - return null; - } - - /* - * @see org.eclipse.jface.text.TextViewer#getVisibleRegionOffset() - */ - protected int getVisibleRegionOffset() { - return -1; - } - - /* - * @see org.eclipse.jface.text.TextViewer#internalGetVisibleRegion() - */ - protected IRegion internalGetVisibleRegion() { - return null; - } - - /* - * @see org.eclipse.jface.text.ITextViewer#overlapsWithVisibleRegion(int,int) - */ - public boolean overlapsWithVisibleRegion(int offset, int length) { - return false; - } - - /* - * @see org.eclipse.jface.text.TextViewer#getVisibleDocument() - */ - public IDocument getVisibleDocument() { - return super.getVisibleDocument(); - } - - /* - * @see org.eclipse.jface.text.TextViewer#handleVerifyEvent(org.eclipse.swt.events.VerifyEvent) - */ - protected void handleVerifyEvent(VerifyEvent e) { - IRegion modelRange= event2ModelRange(e); - Iterator iterator= fProjectionAnnotationModel.getAnnotationIterator(); - while (iterator.hasNext()) { - ProjectionAnnotation annotation= (ProjectionAnnotation) iterator.next(); - if (annotation.isFolded()) { - Position position= fProjectionAnnotationModel.getPosition(annotation); - if (position.overlapsWith(modelRange.getOffset(), modelRange.getLength()) /* || is a delete at the boundary */ ) { - e.doit= false; - annotation.run(this); - } - } - } - } -} diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java index 6cf994677e9..8a3acfe08c1 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionAnnotationHover.java @@ -38,16 +38,16 @@ import org.eclipse.jface.text.source.LineRange; * * @since 3.0 */ -public class ProjectionAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension { +class ProjectionAnnotationHover implements IAnnotationHover, IAnnotationHoverExtension { private IInformationControlCreator fInformationControlCreator; /** - * Sets the information control creator for this projection annotation hover. + * Sets the hover control creator for this projection annotation hover. * * @param creator the creator */ - public void setInformationControlCreator(IInformationControlCreator creator) { + public void setHoverControlCreator(IInformationControlCreator creator) { fInformationControlCreator= creator; } @@ -144,9 +144,9 @@ public class ProjectionAnnotationHover implements IAnnotationHover, IAnnotationH } /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator() + * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator() */ - public IInformationControlCreator getInformationControlCreator() { + public IInformationControlCreator getHoverControlCreator() { if (fInformationControlCreator != null) return fInformationControlCreator; diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java index faa45b649aa..c9899656457 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionRulerColumn.java @@ -39,7 +39,7 @@ import org.eclipse.jface.text.source.IAnnotationModel; * * @since 3.0 */ -public class ProjectionRulerColumn extends AnnotationRulerColumn { +class ProjectionRulerColumn extends AnnotationRulerColumn { private ProjectionAnnotation fCurrentAnnotation; diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java index 0e766bc6817..1c3422bc996 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSupport.java @@ -215,7 +215,7 @@ public class ProjectionSupport { private IAnnotationHover createProjectionAnnotationHover() { ProjectionAnnotationHover hover= new ProjectionAnnotationHover(); - hover.setInformationControlCreator(fInformationControlCreator); + hover.setHoverControlCreator(fInformationControlCreator); return hover; } diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java index 62e8f5e57ab..fdaca98be94 100644 --- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java +++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/SourceViewerInformationControl.java @@ -46,7 +46,7 @@ import org.eclipse.jface.text.source.SourceViewerConfiguration; * * @since 3.0 */ -public class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener { +class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener { /** Border thickness in pixels. */ private static final int BORDER= 1; diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html index b1d9f48b3b3..98a5bfbda2f 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html +++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/package.html @@ -10,7 +10,5 @@ <body> This package is a modified copy of <code>org.eclipse.jface.text.contentassist</code> that supports the linked mode proposals. This package is internal and may disappear if the changes are merged with the API content assist package. Subject to change without notice. -<br> -Use at your own risk. </body> </html> diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java index dcac15ef06d..2f2ee957df9 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentAdapter.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java @@ -25,7 +25,7 @@ import org.eclipse.swt.custom.TextChangingEvent; /** * Adapts an <code>IDocument</code> to the <code>StyledTextContent</code> interface. */ -class DocumentAdapter implements IDocumentAdapter, IDocumentListener, IDocumentAdapterExtension { +class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDocumentAdapterExtension { /** The adapted document. */ private IDocument fDocument; @@ -64,7 +64,7 @@ class DocumentAdapter implements IDocumentAdapter, IDocumentListener, IDocumentA * Creates a new document adapter which is initially not connected to * any document. */ - public DocumentAdapter() { + public DefaultDocumentAdapter() { } /** diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java index 53cf935ba9e..3adde646ba4 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/IAutoIndentStrategy.java @@ -14,7 +14,8 @@ package org.eclipse.jface.text; /** * Exists for backward compatibility. - * Please use <code>IAutoEditStrategy</code> directly. + * + * @deprecated since 3.0, use <code>IAutoEditStrategy</code> directly */ public interface IAutoIndentStrategy extends IAutoEditStrategy { } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java index a68948e9e69..0cad3e67fe0 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/IInformationControlCreatorExtension.java @@ -29,11 +29,13 @@ public interface IInformationControlCreatorExtension { boolean canReuse(IInformationControl control); /** - * Tests whether the given information provider can replace the given information provide. This is - * the case if the two creators create the same kind of information controls. + * Tests whether this information control creator can replace the given + * information control creator. This is the case if the two creators create + * the same kind of information controls. * * @param creator the creator to be checked - * @return <code>true</code> if the given creator can be replaced + * @return <code>true</code> if the given creator can be replaced, + * <code>false</code> otherwise */ boolean canReplace(IInformationControlCreator creator); } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java index e1257ccee8f..5dcdf57fc0a 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextHoverExtension.java @@ -21,9 +21,9 @@ package org.eclipse.jface.text; public interface ITextHoverExtension { /** - * Returns the information control creator of this text hover. + * Returns the hover control creator of this text hover. * - * @return the information control creator + * @return the hover control creator */ - IInformationControlCreator getInformationControlCreator(); + IInformationControlCreator getHoverControlCreator(); } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java index 624c44e0992..85670190ebc 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/ITextViewerExtension3.java @@ -19,7 +19,7 @@ package org.eclipse.jface.text; * This general concepts replaces the notion of <code>visible region</code>. * * @since 2.1 - * @deprecated replaced by <code>ITextViewerExtension5</code> + * @deprecated completely replaced by <code>ITextViewerExtension5</code> */ public interface ITextViewerExtension3 { diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java index 78b9c9b8898..790e3884587 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/PropagatingFontFieldEditor.java @@ -35,6 +35,7 @@ import org.eclipse.jface.util.PropertyChangeEvent; * * @see FontFieldEditor * @since 2.0 + * @deprecated since 3.0 not longer in use, no longer supported */ public class PropagatingFontFieldEditor extends FontFieldEditor { diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java index 8e111573b33..6e340e0c01e 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java @@ -699,7 +699,7 @@ public class TextViewer extends Viewer implements * @since 3.0 */ void resetFindRepalceDocumentAdapter() { - fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(TextViewer.this.getVisibleDocument()); + fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(TextViewer.this.getVisibleDocument()); } /* @@ -1256,7 +1256,7 @@ public class TextViewer extends Viewer implements * * @since 3.0 */ - private FindReplaceDocumentAdapter fFindRepalceDocumentAdapter; + private FindReplaceDocumentAdapter fFindReplaceDocumentAdapter; /** Should the auto indent strategies ignore the next edit operation */ protected boolean fIgnoreAutoIndent= false; @@ -1347,7 +1347,7 @@ public class TextViewer extends Viewer implements * @return the document adapter to be used */ protected IDocumentAdapter createDocumentAdapter() { - return new DocumentAdapter(); + return new DefaultDocumentAdapter(); } /** @@ -3000,7 +3000,7 @@ public class TextViewer extends Viewer implements initializeWidgetContents(); if (fVisibleDocument != null) { - fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument()); + fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument()); if (fVisibleDocumentListener != null) fVisibleDocument.addDocumentListener(fVisibleDocumentListener); } @@ -3880,7 +3880,7 @@ public class TextViewer extends Viewer implements try { int widgetOffset= (startPosition == -1 ? startPosition : modelOffset2WidgetOffset(startPosition)); - IRegion matchRegion= getFindRepalceDocumentAdapter().search(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); + IRegion matchRegion= getFindRepalceDocumentAdapter().find(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); if (matchRegion != null) { int widgetPos= matchRegion.getOffset(); int length= matchRegion.getLength(); @@ -3926,7 +3926,7 @@ public class TextViewer extends Viewer implements if (widgetOffset == -1) return -1; - IRegion matchRegion= getFindRepalceDocumentAdapter().search(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); + IRegion matchRegion= getFindRepalceDocumentAdapter().find(widgetOffset, findString, forwardSearch, caseSensitive, wholeWord, regExSearch); int widgetPos= -1; int length= 0; if (matchRegion != null) { @@ -4139,9 +4139,9 @@ public class TextViewer extends Viewer implements * @since 3.0 */ private FindReplaceDocumentAdapter getFindRepalceDocumentAdapter() { - if (fFindRepalceDocumentAdapter == null) - fFindRepalceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument()); - return fFindRepalceDocumentAdapter; + if (fFindReplaceDocumentAdapter == null) + fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(getVisibleDocument()); + return fFindReplaceDocumentAdapter; } /* diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java index fd8a41abf81..e96bff22cce 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewerHoverManager.java @@ -169,7 +169,7 @@ class TextViewerHoverManager extends AbstractHoverInformationControlManager impl } if (hover instanceof ITextHoverExtension) - setCustomInformationControlCreator(((ITextHoverExtension) hover).getInformationControlCreator()); + setCustomInformationControlCreator(((ITextHoverExtension) hover).getHoverControlCreator()); else setCustomInformationControlCreator(null); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java index eaa66233083..68ff71462a6 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/IInformationProviderExtension2.java @@ -12,20 +12,20 @@ package org.eclipse.jface.text.information; import org.eclipse.jface.text.IInformationControlCreator; +/** + * Extension interface for <code>IInformationProvider</code> to provide + * its own information control creator. + * + * @see org.eclipse.jface.text.IInformationControlCreator + * @see org.eclipse.jface.text.information.IInformationProvider + * @since 3.0 + */ +public interface IInformationProviderExtension2 { + /** - * Extension interface for <code>IInformationProvider</code> to provide - * its own information control creator. + * Returns the information control creator of this information provider. * - * @see org.eclipse.jface.text.IInformationControlCreator - * @see org.eclipse.jface.text.information.IInformationProvider - * @since 3.0 + * @return the information control creator */ - public interface IInformationProviderExtension2 { - - /** - * Returns the information control creator of this information provider. - * - * @return the information control creator - */ - IInformationControlCreator getInformationPresenterControlCreator(); + IInformationControlCreator getInformationPresenterControlCreator(); } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java index a44314dc0b1..a9c97a2a100 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java @@ -1108,7 +1108,7 @@ public class LinkedModeUI { * * @param listener the new listener, never <code>null</code>. */ - public void setPositionListener(ILinkedModeUIFocusListener listener) { + protected void setPositionListener(ILinkedModeUIFocusListener listener) { Assert.isNotNull(listener); fPositionListener= listener; } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java deleted file mode 100644 index c7fdbfccc53..00000000000 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/CompositeReconcilingStrategy.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.text.reconciler; - -import org.eclipse.core.runtime.IProgressMonitor; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; - -/** - * A reconciling strategy consisting of a sequence of internal reconciling strategies. - * By default, all requests are passed on to the contained strategies. - * - * @since 3.0 - */ -public class CompositeReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension { - - /** The list of internal reconciling strategies. */ - private IReconcilingStrategy[] fStrategies; - - /** - * Creates a new, empty composite reconciling strategy. - */ - public CompositeReconcilingStrategy() { - } - - /** - * Sets the reconciling strategies for this composite strategy. - * - * @param strategies the strategies to be set or <code>null</code> - */ - public void setReconcilingStrategies(IReconcilingStrategy[] strategies) { - fStrategies= strategies; - } - - /** - * Returns the previously set stratgies or <code>null</code>. - * - * @return the contained strategies or <code>null</code> - */ - public IReconcilingStrategy[] getReconcilingStrategies() { - return fStrategies; - } - - /* - * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument) - */ - public void setDocument(IDocument document) { - if (fStrategies == null) - return; - - for (int i= 0; i < fStrategies.length; i++) - fStrategies[i].setDocument(document); - } - - /* - * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion) - */ - public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) { - if (fStrategies == null) - return; - - for (int i= 0; i < fStrategies.length; i++) - fStrategies[i].reconcile(dirtyRegion, subRegion); - } - - /* - * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion) - */ - public void reconcile(IRegion partition) { - if (fStrategies == null) - return; - - for (int i= 0; i < fStrategies.length; i++) - fStrategies[i].reconcile(partition); - } - - /* - * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) - */ - public void setProgressMonitor(IProgressMonitor monitor) { - if (fStrategies == null) - return; - - for (int i=0; i < fStrategies.length; i++) { - if (fStrategies[i] instanceof IReconcilingStrategyExtension) { - IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i]; - extension.setProgressMonitor(monitor); - } - } - } - - /* - * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile() - */ - public void initialReconcile() { - if (fStrategies == null) - return; - - for (int i=0; i < fStrategies.length; i++) { - if (fStrategies[i] instanceof IReconcilingStrategyExtension) { - IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) fStrategies[i]; - extension.initialReconcile(); - } - } - } -} diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java deleted file mode 100644 index dbbd70f60ea..00000000000 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DocumentAdapter.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text.reconciler; - -import org.eclipse.jface.text.IDocument; - -/** - * Adapts an <code>IDocument</code> to a <code>IReconcilableModel</code>. - * - * @since 3.0 - */ -public class DocumentAdapter implements IReconcilableModel { - - private IDocument fDocument; - - /** - * Creates a text model adapter for the given document. - * - * @param document - */ - public DocumentAdapter(IDocument document) { - fDocument= document; - } - - /** - * Returns this model's document. - * - * @return the model's input document - */ - public IDocument getDocument() { - return fDocument; - } -} diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java index 83bfd360135..2ab8d3658d7 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java @@ -279,7 +279,7 @@ public class AnnotationBarHoverManager extends AbstractHoverInformationControlMa if (hover instanceof IAnnotationHoverExtension) { IAnnotationHoverExtension extension= (IAnnotationHoverExtension) hover; - setCustomInformationControlCreator(extension.getInformationControlCreator()); + setCustomInformationControlCreator(extension.getHoverControlCreator()); ILineRange range= extension.getHoverLineRange(fSourceViewer, line); range= adaptLineRange(range, line); if (range != null) diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java index e852b351925..df136b24739 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java @@ -695,18 +695,18 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) * @since 3.0 */ - public void addAnnotationListener(IAnnotationListener listener) { + public void addVerticalRulerListener(IVerticalRulerListener listener) { throw new UnsupportedOperationException(); } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) * @since 3.0 */ - public void removeAnnotationListener(IAnnotationListener listener) { + public void removeVerticalRulerListener(IVerticalRulerListener listener) { throw new UnsupportedOperationException(); } } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java index aa744885185..526ea7450f6 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/ChangeRulerColumn.java @@ -43,7 +43,7 @@ import org.eclipse.jface.text.TextEvent; /** * A vertical ruler column displaying line numbers and serving as a UI for quick diff. - * Clients usually instantiate and configure object of this class. + * Clients instantiate and configure object of this class. * * @since 3.0 */ @@ -676,16 +676,16 @@ public final class ChangeRulerColumn implements IVerticalRulerColumn, IVerticalR } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) */ - public void addAnnotationListener(IAnnotationListener listener) { + public void addVerticalRulerListener(IVerticalRulerListener listener) { throw new UnsupportedOperationException(); } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) */ - public void removeAnnotationListener(IAnnotationListener listener) { + public void removeVerticalRulerListener(IVerticalRulerListener listener) { throw new UnsupportedOperationException(); } } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java index a4bd2959872..734f39687bf 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java @@ -64,7 +64,7 @@ import org.eclipse.jface.text.ITextViewerExtension5; * @see ITextViewer * @since 2.0 */ -public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension, IVerticalRulerInfoExtension, IAnnotationListener { +public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension, IVerticalRulerInfoExtension { /** @@ -790,53 +790,66 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension, } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) * @since 3.0 */ - public void addAnnotationListener(IAnnotationListener listener) { + public void addVerticalRulerListener(IVerticalRulerListener listener) { fAnnotationListeners.add(listener); } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) * @since 3.0 */ - public void removeAnnotationListener(IAnnotationListener listener) { + public void removeVerticalRulerListener(IVerticalRulerListener listener) { fAnnotationListeners.remove(listener); } - /* - * @see org.eclipse.jface.text.source.IAnnotationListener#annotationSelected(org.eclipse.jface.text.source.AnnotationEvent) + /** + * Fires the annotation selected event to all registered vertical ruler + * listeners. + * TODO use robust iterators + * + * @param event the event to fire * @since 3.0 */ - public void annotationSelected(AnnotationEvent event) { + public void fireAnnotationSelected(VerticalRulerEvent event) { // forward to listeners for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) { - IAnnotationListener listener= (IAnnotationListener) it.next(); + IVerticalRulerListener listener= (IVerticalRulerListener) it.next(); listener.annotationSelected(event); } } - /* - * @see org.eclipse.jface.text.source.IAnnotationListener#annotationDefaultSelected(org.eclipse.jface.text.source.AnnotationEvent) + /** + * Fires the annotation default selected event to all registered vertical + * ruler listeners. + * TODO use robust iterators + * + * @param event the event to fire * @since 3.0 */ - public void annotationDefaultSelected(AnnotationEvent event) { + public void fireAnnotationDefaultSelected(VerticalRulerEvent event) { // forward to listeners for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) { - IAnnotationListener listener= (IAnnotationListener) it.next(); + IVerticalRulerListener listener= (IVerticalRulerListener) it.next(); listener.annotationDefaultSelected(event); } } - - /* - * @see org.eclipse.jface.text.source.IAnnotationListener#annotationContextMenuAboutToShow(org.eclipse.jface.text.source.AnnotationEvent, org.eclipse.swt.widgets.Menu) + + /** + * Informs all registered vertical ruler listeners that the content menu on a selected annotation\ + * is about to be shown. + * TODO use robust iterators + * + * @param event the event to fire + * @param menu the menu that is about to be shown * @since 3.0 */ - public void annotationContextMenuAboutToShow(AnnotationEvent event, Menu menu) { + public void fireAnnotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) { // forward to listeners for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) { - IAnnotationListener listener= (IAnnotationListener) it.next(); + IVerticalRulerListener listener= (IVerticalRulerListener) it.next(); listener.annotationContextMenuAboutToShow(event, menu); } } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java index c3525a0ef7b..a6c2b1dc079 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationHoverExtension.java @@ -27,11 +27,11 @@ import org.eclipse.jface.text.IInformationControlCreator; public interface IAnnotationHoverExtension { /** - * Returns the information control creator of this annotation hover. + * Returns the hover control creator of this annotation hover. * - * @return the information control creator + * @return the hover control creator */ - IInformationControlCreator getInformationControlCreator(); + IInformationControlCreator getHoverControlCreator(); /** * Returns whether the provided information control can interact with the mouse cursor. I.e. the diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java index 4773ce2d204..ec7eb4c3cf1 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerInfoExtension.java @@ -30,12 +30,12 @@ public interface IVerticalRulerInfoExtension { IAnnotationModel getModel(); /** - * Registers an annotation listener to be informed if an annotation gets + * Registers a vertical ruler listener to be informed if an annotation gets * selected on the vertical ruler. * - * @param listener the listener to be informed about annotation selection events + * @param listener the listener to be informed */ - void addAnnotationListener(IAnnotationListener listener); + void addVerticalRulerListener(IVerticalRulerListener listener); /** * Removes a previously registered listener. If <code>listener</code> is not registered @@ -43,5 +43,5 @@ public interface IVerticalRulerInfoExtension { * * @param listener the listener to be removed */ - void removeAnnotationListener(IAnnotationListener listener); + void removeVerticalRulerListener(IVerticalRulerListener listener); } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationListener.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerListener.java index 02d7076f501..69d5a407b28 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationListener.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IVerticalRulerListener.java @@ -14,23 +14,21 @@ import org.eclipse.swt.widgets.Menu; /** - * Interface for listening to annotation selection events. + * Interface for listening to annotation related events happening on a vertical ruler. * <p> * This interface may be implemented by clients. * </p> - * <p> - * TODO Note that this is work in progress and the interface is still subject to change. - * </p> * * @since 3.0 */ -public interface IAnnotationListener { +public interface IVerticalRulerListener { + /** * Called when an annotation is selected (e.g. hovering or selecting via keyboard) in the UI. * * @param event the annotation event that occurred */ - void annotationSelected(AnnotationEvent event); + void annotationSelected(VerticalRulerEvent event); /** * Called when default selection (e.g. double clicking or pressing enter) occurs on an @@ -38,7 +36,7 @@ public interface IAnnotationListener { * * @param event the annotation event that occurred */ - void annotationDefaultSelected(AnnotationEvent event); + void annotationDefaultSelected(VerticalRulerEvent event); /** * Called when the context menu is opened on an annotation. @@ -46,5 +44,5 @@ public interface IAnnotationListener { * @param event the annotation event that occurred * @param menu the menu that is about to be shown */ - void annotationContextMenuAboutToShow(AnnotationEvent event, Menu menu); + void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu); } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java index a6ce8e4ac0d..cb3838b3a85 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java @@ -244,9 +244,9 @@ public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtens } /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator() + * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator() */ - public IInformationControlCreator getInformationControlCreator() { + public IInformationControlCreator getHoverControlCreator() { return null; } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java index 7f3c952c4e3..97f6d3f7187 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberChangeRulerColumn.java @@ -419,16 +419,16 @@ public final class LineNumberChangeRulerColumn extends LineNumberRulerColumn imp } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) */ - public void addAnnotationListener(IAnnotationListener listener) { + public void addVerticalRulerListener(IVerticalRulerListener listener) { throw new UnsupportedOperationException(); } /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeAnnotationListener(org.eclipse.jface.text.source.IAnnotationListener) + * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) */ - public void removeAnnotationListener(IAnnotationListener listener) { + public void removeVerticalRulerListener(IVerticalRulerListener listener) { throw new UnsupportedOperationException(); } } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationEvent.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRulerEvent.java index b41d0623d9b..5787eaf9b71 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationEvent.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRulerEvent.java @@ -12,16 +12,13 @@ package org.eclipse.jface.text.source; /** - * An event sent to {@link org.eclipse.jface.text.source.IAnnotationListener} instances when annotation + * An event sent to {@link org.eclipse.jface.text.source.IVerticalRulerListener} instances when annotation * selection etc. occurs. * - * <p> - * TODO Note that this is work in progress and the interface is still subject to change. - * </p> - * * @since 3.0 */ -public class AnnotationEvent { +public class VerticalRulerEvent { + private Annotation fAnnotation; /** @@ -29,21 +26,21 @@ public class AnnotationEvent { * * @param annotation the annotation concerned, or <code>null</code> */ - public AnnotationEvent(Annotation annotation) { + public VerticalRulerEvent(Annotation annotation) { fAnnotation= annotation; } /** * @return the concerned annotation or <code>null</code> */ - public Annotation getAnnotation() { + public Annotation getSelectedAnnotation() { return fAnnotation; } /** * @param annotation the concerned annotation, or <code>null</code> */ - public void setAnnotation(Annotation annotation) { + public void setSelectedAnnotation(Annotation annotation) { fAnnotation= annotation; } } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java index 85161cc9e2d..d0fabceafd5 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java @@ -54,7 +54,7 @@ public class ContextTypeRegistry { * * @param contextType the context type to add */ - public void addContextType(ContextType contextType) { + public void addContextType(TemplateContextType contextType) { fContextTypes.put(contextType.getId(), contextType); } @@ -64,8 +64,8 @@ public class ContextTypeRegistry { * @param id the id of the context type to retrieve * @return the context type if <code>name</code> is valid, <code>null</code> otherwise */ - public ContextType getContextType(String id) { - return (ContextType) fContextTypes.get(id); + public TemplateContextType getContextType(String id) { + return (TemplateContextType) fContextTypes.get(id); } /** @@ -91,7 +91,7 @@ public class ContextTypeRegistry { if (fContextTypes.containsKey(id)) return; - ContextType type= createContextType(id); + TemplateContextType type= createContextType(id); if (type != null) addContextType(type); @@ -108,11 +108,11 @@ public class ContextTypeRegistry { * @param id the id for the context type as specified in XML * @return the instantiated and configured context type, or <code>null</code> if it is not found or cannot be instantiated */ - public static ContextType createContextType(String id) { + public static TemplateContextType createContextType(String id) { Assert.isNotNull(id); IConfigurationElement[] extensions= getTemplateExtensions(); - ContextType type= createContextType(extensions, id); + TemplateContextType type= createContextType(extensions, id); if (type != null) { TemplateVariableResolver[] resolvers= createResolvers(extensions, id); @@ -123,7 +123,7 @@ public class ContextTypeRegistry { return type; } - private static ContextType createContextType(IConfigurationElement[] extensions, String contextTypeId) { + private static TemplateContextType createContextType(IConfigurationElement[] extensions, String contextTypeId) { for (int i= 0; i < extensions.length; i++) { // TODO create half-order over contributions if (extensions[i].getName().equals(CONTEXT_TYPE)) { @@ -157,10 +157,10 @@ public class ContextTypeRegistry { return Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATES_EXTENSION_POINT); } - private static ContextType createContextType(IConfigurationElement element) { + private static TemplateContextType createContextType(IConfigurationElement element) { String id= element.getAttributeAsIs(ID); try { - ContextType contextType= (ContextType) element.createExecutableExtension(CLASS); + TemplateContextType contextType= (TemplateContextType) element.createExecutableExtension(CLASS); String name= element.getAttribute(NAME); if (name == null) name= id; diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/ExclusivePositionUpdater.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/InclusivePositionUpdater.java index 039fb592901..9b177250648 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/link/ExclusivePositionUpdater.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/InclusivePositionUpdater.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.jface.text.link; +package org.eclipse.jface.text.templates; import org.eclipse.jface.text.BadPositionCategoryException; import org.eclipse.jface.text.DocumentEvent; @@ -16,11 +16,12 @@ import org.eclipse.jface.text.IPositionUpdater; import org.eclipse.jface.text.Position; /** - * Position updater that takes any changes at the borders of a position to not belong to the position. + * Position updater that takes any change in [position.offset, position.offset + position.length] as + * belonging to the position. * * @since 3.0 */ -public class ExclusivePositionUpdater implements IPositionUpdater { +class InclusivePositionUpdater implements IPositionUpdater { /** The position category. */ private final String fCategory; @@ -30,7 +31,7 @@ public class ExclusivePositionUpdater implements IPositionUpdater { * * @param category the new category. */ - public ExclusivePositionUpdater(String category) { + public InclusivePositionUpdater(String category) { fCategory= category; } @@ -58,11 +59,11 @@ public class ExclusivePositionUpdater implements IPositionUpdater { int length= position.getLength(); int end= offset + length; - if (offset >= eventOffset + eventOldLength) - // position comes + if (offset > eventOffset + eventOldLength) + // position comes way // after change - shift position.setOffset(offset + deltaLength); - else if (end <= eventOffset) + else if (end < eventOffset) // position comes way before change - // leave alone ; @@ -71,15 +72,16 @@ public class ExclusivePositionUpdater implements IPositionUpdater { position.setLength(length + deltaLength); } else if (offset < eventOffset) { // event extends over end of position - adjust length - int newEnd= eventOffset; + int newEnd= eventOffset + eventNewLength; position.setLength(newEnd - offset); } else if (end > eventOffset + eventOldLength) { // event extends from before position into it - adjust offset // and length // offset becomes end of event, length ajusted acordingly - int newOffset= eventOffset + eventNewLength; - position.setOffset(newOffset); - position.setLength(end - newOffset); + // we want to recycle the overlapping part + position.setOffset(eventOffset); + int deleted= eventOffset + eventOldLength - offset; + position.setLength(length - deleted + eventNewLength); } else { // event consumes the position - delete it position.delete(); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java index bee9035d099..615f87585f0 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java @@ -119,7 +119,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce * @return a template context that can handle template insertion at the given location, or <code>null</code> */ protected TemplateContext createContext(ITextViewer viewer, IRegion region) { - ContextType contextType= getContextType(viewer, region); + TemplateContextType contextType= getContextType(viewer, region); if (contextType != null) { IDocument document= viewer.getDocument(); return new DocumentTemplateContext(contextType, document, region.getOffset(), region.getLength()); @@ -135,7 +135,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce * @param region the region into the document displayed by viewer * @return the context type that can handle template expansion for the given location, or <code>null</code> if none exists */ - protected abstract ContextType getContextType(ITextViewer viewer, IRegion region); + protected abstract TemplateContextType getContextType(ITextViewer viewer, IRegion region); /** * Returns the relevance of a template given a prefix. The default diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java index 34fea772448..22136ebde55 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateProposal.java @@ -32,7 +32,6 @@ import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension3; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.link.ILinkedModeListener; -import org.eclipse.jface.text.link.InclusivePositionUpdater; import org.eclipse.jface.text.link.LinkedModeModel; import org.eclipse.jface.text.link.LinkedPosition; import org.eclipse.jface.text.link.LinkedPositionGroup; @@ -212,7 +211,7 @@ public class TemplateProposal implements ICompletionProposal, ICompletionProposa TemplateVariable[] variables= buffer.getVariables(); for (int i= 0; i != variables.length; i++) { TemplateVariable variable= variables[i]; - if (variable.getType().equals(GlobalVariables.Cursor.NAME)) + if (variable.getType().equals(GlobalTemplateVariables.Cursor.NAME)) return variable.getOffsets()[0]; } diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java b/org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java deleted file mode 100644 index eb4af1d45da..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/CoordinatesTranslator.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - -import java.util.Arrays; -import java.util.Comparator; - -/** - * Implementation of <code>IDocumentInformationMapping</code> matching <code>ProjectionDocument</code> and - * <code>ProjectionDocumentManager</code>. The parent document is considered the original document, the projection - * document is considered the image document.<p> - * This class is for internal use only. - * @since 2.1 - * @deprecated - */ -public class CoordinatesTranslator implements IDocumentInformationMapping { - - /** The parent document */ - private IDocument fParentDocument; - /** The position category used to manage the projected regions of the parent document */ -// private String fParentCategory; - /** The projection document */ - private ProjectionDocument fProjectionDocument; - /** The position category to manage the fragments of the projection document. */ -// private String fProjectionCategory; - - /** - * Creates a new mapping between the given parent document and the given projection document. - * - * @param parent the parent document - * @param parentCategory the position category of the parent document used to manage the projected regions - * @param projection the projection document - * @param projectionCategory the position category of the projection document used to manage the fragments - */ - public CoordinatesTranslator(IDocument parent, String parentCategory, ProjectionDocument projection, String projectionCategory) { - fParentDocument= parent; -// fParentCategory= parentCategory; - fProjectionDocument= projection; -// fProjectionCategory= projectionCategory; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginOffset(int) - */ - public int toOriginOffset(int imageOffset) throws BadLocationException { - Fragment fragment= (Fragment) getPositionOfOffset(fProjectionDocument, ProjectionDocument.FRAGMENT_CATEGORY, imageOffset); - if (fragment == null) { - if (imageOffset == 0) - return 0; - throw new BadLocationException(); - } - - int relative= imageOffset - fragment.offset; - return fragment.getOrigin().offset + relative; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginRegion(org.eclipse.jface.text.IRegion) - */ - public IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException { - - int projectionOffset= imageRegion.getOffset(); - int projectionLength= imageRegion.getLength(); - - if (projectionLength == 0) { - if (projectionOffset == 0 && projectionLength == fProjectionDocument.getLength()) - return new Region(0, fParentDocument.getLength()); - return new Region(toOriginOffset(projectionOffset), 0); - } - - int o1= toOriginOffset(projectionOffset); - int o2= toOriginOffset(projectionOffset + projectionLength -1); - return new Region(o1, o2 - o1 + 1); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLines(int) - */ - public IRegion toOriginLines(int imageLine) throws BadLocationException { - - IRegion projectionDocumentRegion= fProjectionDocument.getLineInformation(imageLine); - IRegion parentDocumentRegion= toOriginRegion(projectionDocumentRegion); - - int startLine= fParentDocument.getLineOfOffset(parentDocumentRegion.getOffset()); - if (parentDocumentRegion.getLength() == 0) - return new Region(startLine, 0); - - int endLine= fParentDocument.getLineOfOffset(parentDocumentRegion.getOffset() + parentDocumentRegion.getLength() -1); - return new Region(startLine, endLine - startLine); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLine(int) - */ - public int toOriginLine(int imageLine) throws BadLocationException { - IRegion lines= toOriginLines(imageLine); - if (lines.getLength() > 0) - throw new IllegalStateException(); - return lines.getOffset(); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageOffset(int) - */ - public int toImageOffset(int originOffset) throws BadLocationException { - ProjectionPosition projection= (ProjectionPosition) getPositionOfOffset(fParentDocument, ProjectionDocumentManager.PROJECTION_DOCUMENTS, originOffset); - if (projection != null) - return translateOffset(projection, originOffset, projection.getFragment()); - // not included - return -1; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageRegion(org.eclipse.jface.text.IRegion) - */ - public IRegion toImageRegion(IRegion originRegion) throws BadLocationException { - - if (originRegion.getLength() == 0) { - int projectionOffset= toImageOffset(originRegion.getOffset()); - return projectionOffset == -1 ? null : new Region(projectionOffset, 0); - } - - Position[] positions= getPositionsOfRange(fParentDocument, ProjectionDocumentManager.PROJECTION_DOCUMENTS, originRegion, null); - if (positions != null && positions.length > 0) { - ProjectionPosition projection= (ProjectionPosition) positions[0]; - - int offset= originRegion.getOffset(); - int length= originRegion.getLength(); - - int delta= projection.getOffset() - offset; - if (delta > 0) { - offset += delta; - length -= delta; - } - int start= translateOffset(projection, offset, projection.getFragment()); - - projection= (ProjectionPosition) positions[positions.length -1]; - int decrease= 0; - int endOffset= offset + length; - if (length > 0) - decrease= 1; - endOffset -= decrease; - - delta= endOffset - (projection.getOffset() + Math.max(projection.getLength() -1, 0)); - if (delta > 0) - endOffset -= delta; - - int end= translateOffset(projection, endOffset, projection.getFragment()); - return new Region(start, end - start + decrease); - } - - return null; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageLine(int) - */ - public int toImageLine(int originLine) throws BadLocationException { - - IRegion parentDocumentRegion= fParentDocument.getLineInformation(originLine); - IRegion projectionDocumentRegion= toImageRegion(parentDocumentRegion); - if (projectionDocumentRegion == null) - return -1; - - int startLine= fProjectionDocument.getLineOfOffset(projectionDocumentRegion.getOffset()); - if (projectionDocumentRegion.getLength() == 0) - return startLine; - - int endLine= fProjectionDocument.getLineOfOffset(projectionDocumentRegion.getOffset() + projectionDocumentRegion.getLength() -1); - if (endLine != startLine) - throw new IllegalStateException(); - - return startLine; - } - - - //----------------------------------------------------------------------------------------------------------------------------------- - - /** - * Translates the given offset relative to the given origin position into an - * offset relative to the given target position. - * - * @param origin the origin position - * @param originOffset the offset relative to <code>originOffset</code> - * @param target the target position - * @return <code>originOffset</code> translated to the given target position - */ - private int translateOffset(Position origin, int originOffset, Position target) { - int relative= originOffset - origin.offset; - return target.offset + relative; - } - - /** - * Returns the position of the given category of the given document that includes the given offset - * or <code>null</code> if there is no such position. - * - * @param document the document - * @param category the position category of <code>document</code> - * @param offset the offset into <code>document</code> - * @return the position including the given offset or <code>null</code> - * @throws BadLocationException if <code>offset</code> is not valid in the given document - */ - private Position getPositionOfOffset(IDocument document, String category, int offset) throws BadLocationException { - try { - int index= getPositionIndexOfOffset(document, category, offset, 0); - if (index > -1) { - Position[] positions= document.getPositions(category); - return positions[index]; - } - } catch (BadPositionCategoryException x) { - } - return null; - } - - /** - * Returns an array of positions of the given category that cover the given range of the document. - * - * @param document the document - * @param category the position category of <code>document</code> - * @param range the range of <code>document</code> - * @param comparator the comparator to sort the array to be returned - * @return an array of positions that cover the given range in the given document - */ - private Position[] getPositionsOfRange(IDocument document, String category, IRegion range, Comparator comparator) { - - int offset= range.getOffset(); - int length= range.getLength(); - - try { - - int start= getPositionIndexOfOffset(document, category, offset, length); - int end= getPositionIndexOfOffset(document, category, offset + length -1, 1 - length); - - if (start > -1 && end > -1) { - - Position[] positions= document.getPositions(category); - - if (start == end) - return new Position[] { positions[start] }; - - Position[] result= new Position[end - start + 1]; - for (int i= start; i <= end; i++) - result[i - start]= positions[i]; - - if (comparator != null) - Arrays.sort(result, comparator); - - return result; - } - - } catch (BadPositionCategoryException e) { - } catch (BadLocationException e) { - } - - return new Position[0]; - } - - /** - * Returns the index of the position of the given category of the given document that includes the - * given offset. <code>direction</code> indicates the direction into which the algorithm should search. - * - * @param document the document - * @param category the position category of <code>document</code> - * @param offset the offset into <code>document</code> - * @param direction the search direction - * @return the index of the position - * @throws BadPositionCategoryException if <code>category</code> is not valid in <code>document</code> - * @throws BadLocationException if <code>offset</code> is not valid in <code>document</code> - */ - private int getPositionIndexOfOffset(IDocument document, String category, int offset, int direction ) throws BadPositionCategoryException, BadLocationException{ - - Position[] positions= document.getPositions(category); - if (positions != null && positions.length > 0) { - - // test for inclusion - int index= document.computeIndexInCategory(category, offset); - if (index < positions.length && positions[index].includes(offset)) - return index; - if (index > 0 && positions[index -1].includes(offset)) - return index -1; - - // find next accorrding to direction - if (direction != 0) { - if (direction > 0) { - if (index < positions.length && positions[index].overlapsWith(offset, direction)) - return index; - } else { - if (index > 0 && positions[index -1].overlapsWith(offset + direction, -direction)) - return index -1; - } - } - } - - return -1; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#getCoverage() - */ - public IRegion getCoverage() { - Position coverage= fProjectionDocument.getParentDocumentCoverage(); - return new Region(coverage.getOffset(), coverage.getLength()); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toClosestImageLine(int) - */ - public int toClosestImageLine(int originLine) throws BadLocationException { - try { - - int modelLineOffset= fParentDocument.getLineOffset(originLine); - int index= fParentDocument.computeIndexInCategory(ProjectionDocumentManager.PROJECTION_DOCUMENTS, modelLineOffset); - Position[] projections= fParentDocument.getPositions(ProjectionDocumentManager.PROJECTION_DOCUMENTS); - - if (index < projections.length) { - Position p= projections[index -1]; - int delta1= modelLineOffset - (p.getOffset() + p.getLength()); - p= projections[index]; - int delta2= modelLineOffset - (p.getOffset() + p.getLength()); - if (delta1 < delta2) { - p= projections[index -1]; - originLine= fParentDocument.getLineOfOffset(p.getOffset() + Math.max(p.getLength() -1, 0)); - } else { - originLine= fParentDocument.getLineOfOffset(p.getOffset()); - } - } else if (projections.length > 0) { - Position p= projections[index -1]; - originLine= fParentDocument.getLineOfOffset(p.getOffset() + Math.max(p.getLength() -1, 0)); - } else { - return 0; - } - - return toImageLine(originLine); - - } catch (BadLocationException x) { - } catch (BadPositionCategoryException x) { - } - - return 0; - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java b/org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java deleted file mode 100644 index ffaf01716d9..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/Fragment.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.text; - - -/** - * Represents a fragment of a <code>ProjectionDocument</code>.<p> - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class Fragment extends Position { - - /** Position representing the corresponding range in the parent document. */ - private Position fOrigin; - - /** - * Creates new position representing a fragment. - * - * @param offset the offset of the fragment - * @param length the length of the fragment - * @param origin the cooresponding range in the parent document - */ - public Fragment(int offset, int length, Position origin) { - super(offset, length); - fOrigin= origin; - } - - /** - * Returns the corresponding range in the parent document. - * @return the corresponding range in the parent document - */ - public Position getOrigin() { - return fOrigin; - } - - /** - * Sets the corresponding range in the parent document. - * @param origin the cooresponding range in the parent document - */ - public void setOrigin(Position origin) { - fOrigin= origin; - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java deleted file mode 100644 index c8c0732d632..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/FragmentUpdater.java +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - -/** - * The position updater used to adapt the fragments of a projection document to - * changes of the master document. The updater supports two modes: a shifting mode - * and a non shifting mode. In the shifting mode the updater behaves identical to the - * <code>DefaultPositionUpdater</code>. In non shifting mode, if an insertion happens at - * a fragment's offset, the fragment is extended rather than shifted. Also, the - * last fragment is extended if an inserte operation happens at the end of the fragment.<p> - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class FragmentUpdater extends DefaultPositionUpdater { - - /** Indicates whether this updater is in shift mode. */ - private boolean fShiftMode= false; - /** Indicates whether the positon currently being updated represents the last fragment. */ - private boolean fIsLast= false; - - /** - * Creates the fragment updater for the given category. - * - * @param fragmentCategory the position category used for managing the fragments of a projection document - */ - protected FragmentUpdater(String fragmentCategory) { - super(fragmentCategory); - } - - /** - * Enables/disables the shift mode of this updater. - * - * @param enable <code>true</code> if shift mode should be enabled - */ - public void enableShiftMode(boolean enable) { - fShiftMode= enable; - } - - /** - * If an insertion happens at a fragment's offset, the fragment is extended - * rather than shifted. Also, the last fragment is extended if an inserte operation - * happens at the end of the fragment. - */ - protected void adaptToInsert() { - - if (fShiftMode) { - super.adaptToInsert(); - return; - } - - int myStart= fPosition.offset; - int myEnd= fPosition.offset + fPosition.length - (fIsLast ? 0 : 1); - myEnd= Math.max(myStart, myEnd); - - int yoursStart= fOffset; - int yoursEnd= fOffset + fReplaceLength -1; - yoursEnd= Math.max(yoursStart, yoursEnd); - - if (myEnd < yoursStart) - return; - - if (fLength <= 0) { - - if (myStart <= yoursStart) - fPosition.length += fReplaceLength; - else - fPosition.offset += fReplaceLength; - - } else { - - if (myStart <= yoursStart && fOriginalPosition.offset <= yoursStart) - fPosition.length += fReplaceLength; - else - fPosition.offset += fReplaceLength; - } - } - - /* - * @see IPositionUpdater#update(DocumentEvent event) - */ - public void update(DocumentEvent event) { - - try { - - Position[] category= event.getDocument().getPositions(getCategory()); - - fOffset= event.getOffset(); - fLength= event.getLength(); - fReplaceLength= (event.getText() == null ? 0 : event.getText().length()); - fDocument= event.getDocument(); - - for (int i= 0; i < category.length; i++) { - - fPosition= category[i]; - fIsLast= (i == category.length -1); - - fOriginalPosition.offset= fPosition.offset; - fOriginalPosition.length= fPosition.length; - - if (notDeleted()) - adaptToReplace(); - } - - } catch (BadPositionCategoryException x) { - // do nothing - } - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java deleted file mode 100644 index 9cbf9dbcfcb..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocument.java +++ /dev/null @@ -1,835 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - -import java.util.Arrays; -import java.util.Comparator; - - - -/** - * A <code>ProjectionDocument</code> represents a projection of its master document. - * The contents of a projection document is a sequence of fragments of the master document, i.e. - * the projection document can be thought as being constructed from the master document by - * not copying the whole master document by omitting serveral ranges of the master document. <p> - * The projection document utilizes its master document as <code>ITextStore</code>.<p> - * This class if for internal use only. - * - * @since 2.1 - * @deprecated - */ -public final class ProjectionDocument extends AbstractDocument { - - /** The position category used by <code>ProjectionDocument</code>s to manage the fragments they consist of. */ - final public static String FRAGMENT_CATEGORY= "__fragment_category"; //$NON-NLS-1$ - - /** The parent document */ - private IDocument fParentDocument; - /** The parent document as document extension */ - private IDocumentExtension fExtension; - /** The position category defining the projection */ - private String fProjectionCategory; - /** The document event issued by the parent document */ - private DocumentEvent fParentEvent; - /** The document event issued and to be issued by the projection document */ - private SlaveDocumentEvent fEvent; - /** Indicates whether the projection document initiated a parent document update or not */ - private boolean fIsUpdating= false; - /** The position updater for the positions managing the fragments */ - private FragmentUpdater fFragmentUpdater= new FragmentUpdater(FRAGMENT_CATEGORY); - - /** - * Creates a projection document for the given parent document. - * - * @param parentDocument the parent Document - * @param projectionCategory the document position category whose positions define the projection of the parent document - */ - public ProjectionDocument(IDocument parentDocument, String projectionCategory) { - super(); - - fParentDocument= parentDocument; - if (fParentDocument instanceof IDocumentExtension) - fExtension= (IDocumentExtension) fParentDocument; - - ITextStore s= new ProjectionTextStore(this); - ILineTracker tracker= new DefaultLineTracker(); - - setTextStore(s); - setLineTracker(tracker); - - completeInitialization(); - - initializeProjection(projectionCategory); - tracker.set(s.get(0, s.getLength())); - } - - /** - * Initializes the projection document from the parent document based on the given projection category. - * - * @param projectionCategory the document position category whose positions define the projection of the parent document - */ - private void initializeProjection(String projectionCategory) { - - fProjectionCategory= projectionCategory; - - try { - - addPositionCategory(FRAGMENT_CATEGORY); - addPositionUpdater(fFragmentUpdater); - - int offset= 0; - Position[] patch= fParentDocument.getPositions(fProjectionCategory); - for (int i= 0; i < patch.length; i++) { - Position p= patch[i]; - addPosition(FRAGMENT_CATEGORY, new Fragment(offset, p.length, p)); - offset += p.length; - } - - } catch (BadPositionCategoryException x) { - } catch (BadLocationException x) { - } - } - - /** - * Creates a fragment from a postion of the parent document. - * - * @param parentPosition a position of the parent document - * @return the fragment representing the range given by the parent position - */ - public Fragment createFragment(Position parentPosition) { - try { - - int index= fParentDocument.computeIndexInCategory(fProjectionCategory, parentPosition.offset); - if (index <= 0) - return new Fragment(0, parentPosition.length, parentPosition); - - Position[] fragments= getPositions(FRAGMENT_CATEGORY); - Position p= fragments[index -1]; - return new Fragment(p.offset + p.length, parentPosition.length, parentPosition); - - } catch (BadPositionCategoryException e) { - } catch (BadLocationException e) { - } - - return null; - } - - /** - * Returns the index of the position of the given category of the given document that includes the - * given offset. <code>direction</code> indicates the direction into which the algorithm should search. - * - * @param document the document - * @param category the position category of <code>document</code> - * @param offset the offset into <code>document</code> - * @param direction the search direction - * @return the index of the position - * @throws BadPositionCategoryException if <code>category</code> is not valid in <code>document</code> - * @throws BadLocationException if <code>offset</code> is not valid in <code>document</code> - */ - private int getPositionOfOffset(IDocument document, String category, int offset, int direction ) throws BadPositionCategoryException, BadLocationException{ - - Position[] positions= document.getPositions(category); - if (positions != null && positions.length > 0) { - - // test for inclusion - int index= document.computeIndexInCategory(category, offset); - if (index < positions.length && positions[index].includes(offset)) - return index; - if (index > 0 && positions[index -1].includes(offset)) - return index -1; - - // find next accorrding to direction - if (direction != 0) { - if (direction > 0) { - if (index < positions.length && positions[index].overlapsWith(offset, direction)) - return index; - } else { - if (index > 0 && positions[index -1].overlapsWith(offset + direction, -direction)) - return index -1; - } - } - } - - return -1; - } - - /** - * Returns the position which is used to manage a parent - * document range represented in this projection document and that - * includes or is close to the given parent document offset. The distance - * is computed based on the given direction hint. - * - * @param offsetInParent the parent document offset - * @param direction the direction hint used for computing the distance - * @return position the parent document position including or near to the parent document offset - */ - private Position getParentDocumentPositionOfOffset(int offsetInParent, int direction ) { - try { - - int index= getPositionOfOffset(fParentDocument, fProjectionCategory, offsetInParent, direction); - if (index > -1) { - Position[] positions= fParentDocument.getPositions(fProjectionCategory); - return positions[index]; - } - - } catch (BadPositionCategoryException x) { - } catch (BadLocationException x) { - } - - return null; - } - - /** - * Returns the offset in the projection document corresponding to the - * given parent document offset. - * - * @param offsetInParent the parent document offset - * @return the projection document offset corresponding to the given parent document offset - */ - private int toProjectionDocumentOffset(int offsetInParent, int direction) { - - Position p= getParentDocumentPositionOfOffset(offsetInParent, direction); - if (p == null) - return -1; - - int relative= offsetInParent - p.offset; - - if (direction > 0) { - if (relative < 0) - relative= 0; - } else if (direction < 0) { - if (relative >= p.length) - relative= p.length -1; - } - - Fragment f= findCorrespondingFragment(p); - return f.offset + relative; - } - - /** - * Creates a position describing the projection document range corresponding to - * the given parent document range. - * - * @param offsetInParent the parent document offset - * @param lengthInParent the parent document lengh - * @return position describing the projection document range corresponding to the given parent document range - */ - public Position computeProjectionDocumentPosition(int offsetInParent, int lengthInParent) { - - Position p= getParentDocumentCoverage(); - if (p != null) { - - if (p.overlapsWith(offsetInParent, lengthInParent)) { - - int o1= toProjectionDocumentOffset(offsetInParent, lengthInParent); - if (o1 == -1) - return null; - - if (lengthInParent == 0) - return new Position(o1, 0); - - int o2= toProjectionDocumentOffset(offsetInParent + lengthInParent -1, 1 - lengthInParent); - if (o2 == -1) - return null; - - return new Position(o1, o2 - o1 + 1); - - } else if (p.getOffset() + p.getLength() == offsetInParent + lengthInParent) { - - Position[] fragments= getFragmentation(); - if (fragments != null && fragments.length > 0) { - Position last= fragments[fragments.length -1]; - return new Position(last.getOffset() + last.getLength()); - } - } - } - - return null; - } - - /** - * Returns the offset in the parent document that corresponds to the given offset in this - * projection document. - * - * @param offset the offset in the projection document - * @return the corresponding parent document offset - * @throws BadLocationException if <code>offset</code> is not valid in this projection document - */ - public int toParentDocumentOffset(int offset) throws BadLocationException { - Fragment fragment= getFragmentOfOffset(offset); - - if (fragment == null) { - -// if (offset == 0) -// return 0; -// throw new BadLocationException(); - - Position[] fragmentation= getFragmentation(); - if (fragmentation != null && fragmentation.length > 0) { - Fragment last= (Fragment) fragmentation[fragmentation.length -1]; - if (last.offset + last.length == offset) { - Position origin= last.getOrigin(); - return origin.offset + origin.length; - } - } - - throw new BadLocationException(); - } - - int relative= offset - fragment.offset; - return fragment.getOrigin().offset + relative; - } - - /** - * Computes and returns the region of the parent document that corresponds to the given region of the - * projection document. - * - * @param offset the offset of the projection document region - * @param length the length of the projection document region - * @return the corresponding region of the parent document - * @throws BadLocationException if the given projection document region is not valid - */ - public IRegion computeParentDocumentRegion(int offset, int length) throws BadLocationException { - - if (length == 0) { - if (offset == 0 && length == getLength()) - return new Region(0, fParentDocument.getLength()); - return new Region(toParentDocumentOffset(offset), 0); - } - - int o1= toParentDocumentOffset(offset); - int o2= toParentDocumentOffset(offset + length -1); - return new Region(o1, o2 - o1 + 1); - } - - /** - * Removes all fragments and thereby clears this projection document. - */ - public void removeAllFragments() { - Position[] projection= getProjection(); - if (projection == null) - return; - - for (int i= 0; i < projection.length; i++) { - try { - removeFragment(projection[i]); - } catch (BadLocationException e) { - } - } - } - - /** - * Add a new fragment of the parent document to this projection document. - * - * @param offsetInParent offset of the parent document range - * @param lengthInParent length of the parent document range - * @return returns the position representing the parent document range in this projection document - * @throws BadLocationException - */ - public void addFragment(int offsetInParent, int lengthInParent) throws BadLocationException { - - if (lengthInParent == 0) - return; - - try { - - ProjectionPosition p= new ProjectionPosition(this, offsetInParent, lengthInParent); - fParentDocument.addPosition(fProjectionCategory, p); - - Fragment fragment= createFragment(p); - p.setFragment(fragment); - fireDocumentProjectionChanged(new DocumentEvent(this, fragment.offset, 0, fParentDocument.get(offsetInParent, lengthInParent))); - addPosition(FRAGMENT_CATEGORY, fragment); - - - getTracker().set(getStore().get(0, getStore().getLength())); - - } catch (BadPositionCategoryException x) { - } - - } - - /** - * Joins all fragments that represent neighboring regions in the parent document. - */ - public void joinFragments() { - try { - while (joinTwoFragments()) {} - } catch (BadPositionCategoryException x) { - } - } - - /** - * Joins the first two fragments that represent neighboring regions of the parent document. - * @return <code>true</code> if two segments have been joined, <code>false</code> otherwise - * @throws BadPositionCategoryException - */ - private boolean joinTwoFragments() throws BadPositionCategoryException { - Position[] projection= getProjection(); - if (projection != null && projection.length > 0) { - Position previous= projection[0]; - for (int i= 1; i < projection.length; i++) { - Position current= projection[i]; - if (previous.offset + previous.length == current.offset) { - join(previous, current); - return true; - } - previous= current; - } - } - return false; - } - - /** - * Joins the fragments of this projection document that correspond to the two given, - * neighboring ranges of the parent document. - * - * @param p1 lower range in the parent document - * @param p2 higher range of the parent document - * @throws BadPositionCategoryException if the fragment position category is not defined in this projection document - */ - private void join(Position p1, Position p2) throws BadPositionCategoryException { - // remove p2 - Fragment fragment= findCorrespondingFragment(p2); - removePosition(FRAGMENT_CATEGORY, fragment); - fParentDocument.removePosition(fProjectionCategory, p2); - // extend p1 by length of p2 - fragment= findCorrespondingFragment(p1); - fragment.length += p2.length; - p1.length += p2.length; - } - - /** - * Removes the fragment that corresponds to the given parent document range. - * - * @param parentPosition the position representing the parent document range - * @throws BadLocationException if the fragment position category is not defined in this projection document - */ - public void removeFragment(Position parentPosition) throws BadLocationException { - try { - - Fragment fragment= findCorrespondingFragment(parentPosition); - if (fragment != null) { - removePosition(FRAGMENT_CATEGORY, fragment); - fParentDocument.removePosition(fProjectionCategory, parentPosition); - fireDocumentProjectionChanged(new DocumentEvent(this, fragment.offset, fragment.length, null)); - getTracker().set(getStore().get(0, getStore().getLength())); - } - - } catch (BadPositionCategoryException x) { - } - } - - /** - * Returns the list of fragments whose corresponding ranges in the parent document overlap with - * the specifed range of the parent document. - * - * @param offsetInParent the offset of the parent document range - * @param lengthInParent the length of the parent document range - * @return the list of affected fragments - */ - public Position[] getAffectedFragments(int offsetInParent, int lengthInParent) { - - Position p= computeProjectionDocumentPosition(offsetInParent, lengthInParent); - if (p == null) - return null; - - Fragment[] f= getFragmentsOfRange(p.offset, p.length); - if (f == null) - return null; - - Position[] result= new Position[f.length]; - for (int i= 0; i < f.length; i++) - result[i]= f[i].getOrigin(); - return result; - } - - /** - * Finds the fragment that represents the given parent document range in this projection document. - * - * @param parentPosition the parent document range - * @return the fragment representing the given parent document range - */ - private Fragment findCorrespondingFragment(Position parentPosition) { - try { - Position[] fragments= getPositions(FRAGMENT_CATEGORY); - for (int i= 0; i < fragments.length; i++) { - Fragment f= (Fragment) fragments[i]; - if (parentPosition.equals(f.getOrigin())) - return f; - } - } catch (BadPositionCategoryException x) { - } - - return null; - } - - /** - * Returns the fragment that contains the given offset. - * - * @param offset the offset - * @return the fragment that contains the given offset - * @throws BadLocationException if <code>offset</code> is not a valid offset - */ - protected Fragment getFragmentOfOffset(int offset) throws BadLocationException { - try { - int index= getPositionOfOffset(this, FRAGMENT_CATEGORY, offset, 0); - if (index > -1) { - Position[] fragments= getPositions(FRAGMENT_CATEGORY); - return (Fragment) fragments[index]; - } - } catch (BadPositionCategoryException x) { - } - return null; - } - - /** - * Returns the minimal consecutive list of fragments that completely covers the given range. - * - * @param offset the offset of the range - * @param length the length of the range - * @return the minimal consecutive list of fragments convering the given range - */ - protected Fragment[] getFragmentsOfRange(int offset, int length) { - - try { - - int start= getPositionOfOffset(this, FRAGMENT_CATEGORY, offset, length); - int end= getPositionOfOffset(this, FRAGMENT_CATEGORY, offset + length -1, 1 - length); - - if (start > -1 && end > -1) { - - Position[] positions= getPositions(FRAGMENT_CATEGORY); - - if (start == end) - return new Fragment[] { (Fragment) positions[start] }; - - Fragment[] result= new Fragment[end - start + 1]; - for (int i= start; i <= end; i++) - result[i - start]= (Fragment) positions[i]; - sortFragments(result); - return result; - } - - } catch (BadPositionCategoryException e) { - } catch (BadLocationException e) { - } - - return new Fragment[0]; - } - - /** - * Sorts a list of fragments based on the offsets of their corresponding ranges in the parent document. - * - * @param result the list for fragments - */ - private void sortFragments(Object[] result) { - - Comparator comparator= new Comparator() { - - public int compare(Object o1, Object o2) { - Fragment f1= (Fragment) o1; - Fragment f2= (Fragment) o2; - return f1.getOrigin().getOffset() - f2.getOrigin().getOffset(); - } - - public boolean equals(Object obj) { - return false; - } - }; - - Arrays.sort(result, comparator); - } - - /** - * Returns the minimal range of the parent document that covers all ranges that - * correspond to the fragments of this projection document. - * - * @return a position describing the minimal parent document range covering all fragments - */ - public Position getParentDocumentCoverage() { - Position[] projection= getProjection(); - if (projection != null && projection.length > 0) { - Position first=projection[0]; - Position last= projection[projection.length -1]; - return new Position(first.offset, last.offset - first.offset + last.length); - } - return new Position(0, 0); - } - - /** - * The projection of the parent document has been changed by inserting or removing - * new fragments into this projection document. The projection change is described in - * the given <code>DocumentEvent</code>. All positions managed by this projection - * document must be adapted accordingly. - * - * @param event the document event - */ - private void fireDocumentProjectionChanged(DocumentEvent event) { - fFragmentUpdater.enableShiftMode(true); - try { - updatePositions(event); - } finally { - fFragmentUpdater.enableShiftMode(false); - } - } - - /** - * Returns parent document. - * - * @return the parent document - */ - public IDocument getParentDocument() { - return fParentDocument; - } - - /** - * Returns the ranges of the parent document that correspond to the fragments of this - * projection document. - * - * @return the ranges of the parent document corresponding to the fragments - */ - public Position[] getProjection() { - try { - return fParentDocument.getPositions(fProjectionCategory); - } catch (BadPositionCategoryException x) { - } - return null; - } - - /** - * Returns the list of all fragments of this projection document. - * - * @return the list of all fragments of this projection document - */ - public Position[] getFragmentation() { - try { - - Position[] fragmentation= getPositions(FRAGMENT_CATEGORY); - sortFragments(fragmentation); - return fragmentation; - - } catch (BadPositionCategoryException x) { - } - return null; - } - - /** - * Transforms a document event of the parent document into a projection document - * based document event. - * - * @param e the parent document event - * @return the slave document event - */ - private SlaveDocumentEvent normalize(DocumentEvent e) { - - Position c= computeProjectionDocumentPosition(e.getOffset(), e.getLength()); - - if (c != null) { - if (c.length == 0) { - int insertLength= e.getText() == null ? 0 : e.getText().length(); - if (insertLength == 0) - return null; - } - return new SlaveDocumentEvent(this, c.offset, c.length, e.getText(), e); - } - - return null; - } - - /** - * When called, this projection document is informed about a forthcoming change - * of its parent document. This projection document checks whether the parent - * document change affects it and if so informs all document listeners. - * - * @param event the parent document event - */ - public void parentDocumentAboutToBeChanged(DocumentEvent event) { - fParentEvent= event; - fEvent= normalize(event); - if (fEvent != null) - delayedFireDocumentAboutToBeChanged(); - } - - /** - * When called, this projection document is informed about a change of its parent document. - * If this projection document is affected it informs all of its document listeners. - * - * @param event the parent document event - */ - public void parentDocumentChanged(DocumentEvent event) { - if ( !fIsUpdating && event == fParentEvent && fEvent != null) { - try { - getTracker().replace(fEvent.getOffset(), fEvent.getLength(), fEvent.getText()); - fireDocumentChanged(fEvent); - } catch (BadLocationException x) { - Assert.isLegal(false); - } - } - } - - /* - * @see AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent) - */ - protected void fireDocumentAboutToBeChanged(DocumentEvent event) { - // delay it until there is a notification from the parent document - // otherwise there it is expensive to construct the parent document information - } - - /** - * Fires the slave document event as about-to-be-changed event to all registed listeners. - */ - private void delayedFireDocumentAboutToBeChanged() { - super.fireDocumentAboutToBeChanged(fEvent); - } - - /** - * Ignores the given event and sends the semantically equal slave document event instead. - * - * @param event the event to be ignored - */ - protected void fireDocumentChanged(DocumentEvent event) { - super.fireDocumentChanged(fEvent); - } - - /* - * @see IDocument#replace(int, int, String) - */ - public void replace(int offset, int length, String text) throws BadLocationException { - try { - fIsUpdating= true; - if (fExtension != null) - fExtension.stopPostNotificationProcessing(); - - super.replace(offset, length, text); - - } finally { - fIsUpdating= false; - if (fExtension != null) - fExtension.resumePostNotificationProcessing(); - } - } - - /* - * @see IDocument#set(String) - */ - public void set(String text) { - try { - fIsUpdating= true; - if (fExtension != null) - fExtension.stopPostNotificationProcessing(); - - super.set(text); - - } finally { - fIsUpdating= false; - if (fExtension != null) - fExtension.resumePostNotificationProcessing(); - } - } - - /* - * @see IDocumentExtension#registerPostNotificationReplace(IDocumentListener, IDocumentExtension.IReplace) - */ - public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) { - if (!fIsUpdating) - throw new UnsupportedOperationException(); - super.registerPostNotificationReplace(owner, replace); - } - - - /** - * Convenience method for removing and adapting the fragments whose corresponding - * ranges in the parent document are included or overlap with the given range of the - * parent document. - * - * @param offsetInParent the offset of the parent document range - * @param lengthInParent the length of the parent document range - */ - public void hide(int offsetInParent, int lengthInParent) { - - IDocument parent= getParentDocument(); - Position[] effected= getAffectedFragments(offsetInParent, lengthInParent); - - try { - - if (effected == null) { - // populate new document with two new fragments, the left and the right of the hidden region - int end= offsetInParent + lengthInParent; - addFragment(0, offsetInParent); - addFragment(end, parent.getLength() - end); - } else if (effected.length == 1) { - // the only affected fragment must be splitted into two - Position fragment= effected[0]; - removeFragment(fragment); - addFragment(fragment.offset, offsetInParent - fragment.offset); - int secondOffset= offsetInParent + lengthInParent; - addFragment(secondOffset, fragment.offset + fragment.length - secondOffset); - } else { - // first expand and than collapse - internalShow(offsetInParent, lengthInParent, effected); - hide(offsetInParent, lengthInParent); - } - - joinFragments(); - - } catch (BadLocationException x) { - } - } - - /** - * Convenience method for adding fragments or adapting existing fragments so that their corresponding - * ranges in the parent document include the given range of the parent document. - * - * @param offsetInParent the offset of the parent document range - * @param lengthInParent the length of the parent document range - */ - public void show(int offsetInParent, int lengthInParent) { - - Position[] effected= getAffectedFragments(offsetInParent, lengthInParent); - if (effected == null || effected.length == 0) { - try { - addFragment(offsetInParent, lengthInParent); - joinFragments(); - } catch (BadLocationException x) { - } - return; - } - - internalShow(offsetInParent, lengthInParent, effected); - joinFragments(); - - } - - /** - * Removes the given fragments and inserts a new fragment whose parent document - * range corresponds the given range of the parent document. - * - * @param offsetInParent the offset of the parent document range - * @param lengthInParent the length of the parent document range - * @param effected the list for fragments to be removed - */ - private void internalShow(int offsetInParent, int lengthInParent, Position[] effected) { - try { - - int size= effected.length; - for (int i= 0; i < size; i++) - removeFragment(effected[i]); - - int offset= Math.min(offsetInParent, effected[0].offset); - int end= Math.max(offsetInParent + lengthInParent, effected[size -1].offset + effected[size -1].length); - addFragment(offset, end - offset); - - } catch (BadLocationException x) { - } - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java deleted file mode 100644 index 63c69bceafa..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionDocumentManager.java +++ /dev/null @@ -1,321 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - - - -/** - * <code>ProjectionDocumentManager</code> is one particular implementation of - * <code>ISlaveDocumentManager</code>. This manager creates so called projection - * documents as slave documents for given master documents.<p> - * - * A projection document represents a particular projection of the parent - * document and is accordingly adapted to changes of the parent document. - * Vice versa, the parent document is accordingly adapted to changes of - * its child documents. The manager does not maintain any particular management - * structure but utilizes mechanisms given by <code>IDocument</code> such - * as position categories and position updaters. <p> - * This class if for internal use only. - * - * @since 2.1 - * @deprecated - */ -public final class ProjectionDocumentManager implements IDocumentListener, ISlaveDocumentManager { - - - /** - * Name of the position category used to keep track of the parent document - * ranges that correspond to the fragments of the projection documents. - */ - public final static String PROJECTION_DOCUMENTS= "__projectiondocuments"; //$NON-NLS-1$ - - -// static class ProjectionDocumentPartitioner implements IDocumentPartitioner { -// -// protected ProjectionDocument fProjectionDocument; -// protected IDocument fParentDocument; -// -// protected ProjectionDocumentPartitioner() { -// } -// -// /* -// * @see IDocumentPartitioner#getPartition(int) -// */ -// public ITypedRegion getPartition(int offset) { -// try { -// offset += fProjectionDocument.getParentDocumentRange().getOffset(); -// return fParentDocument.getPartition(offset); -// } catch (BadLocationException x) { -// } -// -// return null; -// } -// -// /* -// * @see IDocumentPartitioner#computePartitioning(int, int) -// */ -// public ITypedRegion[] computePartitioning(int offset, int length) { -// try { -// offset += fProjectionDocument.getParentDocumentRange().getOffset(); -// return fParentDocument.computePartitioning(offset, length); -// } catch (BadLocationException x) { -// } -// -// return null; -// } -// -// /* -// * @see IDocumentPartitioner#getContentType(int) -// */ -// public String getContentType(int offset) { -// try { -// offset += fProjectionDocument.getParentDocumentRange().getOffset(); -// return fParentDocument.getContentType(offset); -// } catch (BadLocationException x) { -// } -// -// return null; -// } -// -// /* -// * @see IDocumentPartitioner#getLegalContentTypes() -// */ -// public String[] getLegalContentTypes() { -// return fParentDocument.getLegalContentTypes(); -// } -// -// /* -// * @see IDocumentPartitioner#documentChanged(DocumentEvent) -// */ -// public boolean documentChanged(DocumentEvent event) { -// // ignore as the parent does this for us -// return false; -// } -// -// /* -// * @see IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent) -// */ -// public void documentAboutToBeChanged(DocumentEvent event) { -// // ignore as the parent does this for us -// } -// -// /* -// * @see IDocumentPartitioner#disconnect() -// */ -// public void disconnect() { -// fProjectionDocument= null; -// fParentDocument= null; -// } -// -// /* -// * @see IDocumentPartitioner#connect(IDocument) -// */ -// public void connect(IDocument childDocument) { -// Assert.isTrue(childDocument instanceof ProjectionDocument); -// fProjectionDocument= (ProjectionDocument) childDocument; -// fParentDocument= fProjectionDocument.getParentDocument(); -// } -// }; - - - - /** The position updater shared by all master documents which have projection documents */ - private IPositionUpdater fProjectionPositionUpdater; - /** Registry for master documents and their projection documents. */ - private Map fRegistar= new HashMap(); - - - /** - * Returns the projection position updater. If necessary, it is dynamically created. - * - * @return the child position updater - */ - protected IPositionUpdater getProjectionPositionUpdater() { - if (fProjectionPositionUpdater == null) - fProjectionPositionUpdater= new FragmentUpdater(PROJECTION_DOCUMENTS); - return fProjectionPositionUpdater; - } - - /** - * Registers the given projection document for the given master document. - * - * @param parent the master document - * @param projection the projection document - */ - private void add(IDocument parent, ProjectionDocument projection) { - List list= (List) fRegistar.get(parent); - if (list == null) { - list= new ArrayList(1); - fRegistar.put(parent, list); - } - list.add(projection); - } - - /** - * Unregisters the given projection document from its master. - * - * @param parent the master document - * @param projection the projection document - */ - private void remove(IDocument parent, ProjectionDocument projection) { - List list= (List) fRegistar.get(parent); - if (list != null) { - list.remove(projection); - if (list.size() == 0) - fRegistar.remove(parent); - } - } - - /** - * Returns whether the given document is a master document. - * - * @param parent the document - * @return <code>true</code> if the given document is a master document known to this manager - */ - private boolean hasProjection(IDocument parent) { - return (fRegistar.get(parent) instanceof List); - } - - /** - * Returns an iterator enumerating all projection documents registered for the given document or - * <code>null</code> if the document is not a known master document. - * - * @param parent the document - * @return an iterator for all registered projection documents or <code>null</code> - */ - private Iterator getProjectionsIterator(IDocument parent) { - List list= (List) fRegistar.get(parent); - if (list != null) - return list.iterator(); - return null; - } - - /** - * Informs all projection documents of the master document that issued the given document event. - * - * @param about indicates whether the change is about to happen or alread happend - * @param event the document event which will be processed to inform the projection documents - */ - protected void fireDocumentEvent(boolean about, DocumentEvent event) { - IDocument parent= event.getDocument(); - Iterator e= getProjectionsIterator(parent); - if (e == null) - return; - - while (e.hasNext()) { - ProjectionDocument document= (ProjectionDocument) e.next(); - if (about) - document.parentDocumentAboutToBeChanged(event); - else - document.parentDocumentChanged(event); - } - } - - /* - * @see IDocumentListener#documentChanged(DocumentEvent) - */ - public void documentChanged(DocumentEvent event) { - fireDocumentEvent(false, event); - } - - /* - * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) - */ - public void documentAboutToBeChanged(DocumentEvent event) { - fireDocumentEvent(true, event); - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#createMasterSlaveMapping(org.eclipse.jface.text.IDocument) - */ - public IDocumentInformationMapping createMasterSlaveMapping(IDocument slave) { - if (slave instanceof ProjectionDocument) { - ProjectionDocument projectionDocument= (ProjectionDocument) slave; - return new CoordinatesTranslator(projectionDocument.getParentDocument(), PROJECTION_DOCUMENTS, projectionDocument, ProjectionDocument.FRAGMENT_CATEGORY); - } - return null; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#createSlaveDocument(org.eclipse.jface.text.IDocument) - */ - public IDocument createSlaveDocument(IDocument master) { - if (!master.containsPositionCategory(PROJECTION_DOCUMENTS)) { - master.addPositionCategory(PROJECTION_DOCUMENTS); - master.addPositionUpdater(getProjectionPositionUpdater()); - master.addDocumentListener(this); - } - - ProjectionDocument slave= new ProjectionDocument(master, PROJECTION_DOCUMENTS); -// IDocumentPartitioner partitioner= new ProjectionDocumentPartitioner(); -// slave.setDocumentPartitioner(partitioner); -// partitioner.connect(master); - - add(master, slave); - return slave; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#freeSlaveDocument(org.eclipse.jface.text.IDocument) - */ - public void freeSlaveDocument(IDocument slave) { - - if ( !(slave instanceof ProjectionDocument)) - return; - - ProjectionDocument projectionDocument= (ProjectionDocument) slave; - -// projectionDocument.getDocumentPartitioner().disconnect(); - - IDocument parent= projectionDocument.getParentDocument(); - remove(parent, projectionDocument); - - try { - if (!hasProjection(parent)) { - parent.removeDocumentListener(this); - parent.removePositionUpdater(getProjectionPositionUpdater()); - parent.removePositionCategory(PROJECTION_DOCUMENTS); - } - } catch (BadPositionCategoryException x) { - } - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#getMasterDocument(org.eclipse.jface.text.IDocument) - */ - public IDocument getMasterDocument(IDocument slave) { - if (slave instanceof ProjectionDocument) - return ((ProjectionDocument) slave).getParentDocument(); - return null; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#isSlaveDocument(org.eclipse.jface.text.IDocument) - */ - public boolean isSlaveDocument(IDocument document) { - return (document instanceof ProjectionDocument); - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#setAutoExpandMode(org.eclipse.jface.text.IDocument, boolean) - */ - public void setAutoExpandMode(IDocument slave, boolean autoExpand) { - // TODO - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java deleted file mode 100644 index 1724a1332d0..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPosition.java +++ /dev/null @@ -1,64 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.text; - -/** - * Represents the corresponding parent document range of a fragment of a <code>ProjectionDocument</code>.<p> - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class ProjectionPosition extends Position { - - /** The projection document. */ -// private IDocument fProjectionDocument; - /** The corresponding fragment. */ - private Fragment fFragment; - - /** - * Creates a new position representing the corresponding range of a fragment. - * - * @param projectionDocument the projection document - * @param offset the offset of the range of the parent document - * @param length the length of the range of the parent document - */ - public ProjectionPosition(IDocument projectionDocument, int offset, int length) { - super(offset, length); -// fProjectionDocument= projectionDocument; - } - - /** - * Sets the corresponding fragment. - * - * @param fragment the corresponding fragment - */ - public void setFragment(Fragment fragment) { - fFragment= fragment; - } - - /** - * Returns the corresponding fragment. - * @return the corresponding fragment - */ - public Fragment getFragment() { - return fFragment; - } - -// /** -// * Changed to be compatible to the position updater behavior -// * @see Position#overlapsWith(int, int) -// */ -// public boolean overlapsWith(int offset, int length) { -// boolean append= (offset == this.offset + this.length) && length == 0; -// return append || super.overlapsWith(offset, length); -// } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java deleted file mode 100644 index 1ad05dd4560..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionPositionUpdater.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - -/** - * The position updater used to adapt the positions corresponding to the fragments of - * projection documents. The startegy of this updater differs from the - * <code>DefaultPositionUpdater</code>. If an insertion happens at a start offset of a - * range corresponding to a fragment, the range is extended rather than shifted. Also, if - * text is added right behind the end of such a range, the range is extended rather than - * kept stable.<p> - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class ProjectionPositionUpdater extends DefaultPositionUpdater { - - /** - * Creates the position updater for the given category. - * - * @param category the category used to manage the positions representing the ranges corresponding to fragments - */ - protected ProjectionPositionUpdater(String category) { - super(category); - } - - /** - * Projection document ranges cannot be deleted other then by calling - * <code>ProjectionDocumentManager#removeFragment</code>. - * @return <code>true</code> - */ - protected boolean notDeleted() { - return true; - } - - /** - * If an insertion happens at a start offset of a - * range corresponding to a fragment, the range is extended rather than shifted. Also, if - * text is added right behind the end of such a range, the range is extended rather than - * kept stable. - */ - protected void adaptToInsert() { - - int myStart= fPosition.offset; - int myEnd= fPosition.offset + fPosition.length; - myEnd= Math.max(myStart, myEnd); - - int yoursStart= fOffset; - int yoursEnd= fOffset + fReplaceLength -1; - yoursEnd= Math.max(yoursStart, yoursEnd); - - if (myEnd < yoursStart) - return; - - if (myStart <= yoursStart) - fPosition.length += fReplaceLength; - else - fPosition.offset += fReplaceLength; - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java b/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java deleted file mode 100644 index b163d040dda..00000000000 --- a/org.eclipse.text/projection/org/eclipse/jface/text/ProjectionTextStore.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - -/** - * The text store of a <code>ProjectionDocument</code>. Implements the projection onto - * the master document.<p> - * This class is for internal use only. - * - * @since 2.1 - * @deprecated - */ -public class ProjectionTextStore implements ITextStore { - - /** The projection document */ - private ProjectionDocument fProjectionDocument; - - /** - * Creates a new projection text store for the given projection document. - * - * @param projectionDocument the projection document - */ - public ProjectionTextStore(ProjectionDocument projectionDocument) { - fProjectionDocument= projectionDocument; - } - - /** - * Computes the offset in the parent document that corresponds to the given offset. - * - * @param offset the offset - * @return the corresponding parent document offset - */ - private int computeParentDocumentOffset(int offset) { - try { - return fProjectionDocument.toParentDocumentOffset(offset); - } catch (BadLocationException x) { - throw new RuntimeException(); - } - } - - /* - * @see ITextStore#set(String) - */ - public void set(String contents) { - - try { - - Position[] projection= fProjectionDocument.getProjection(); - if (projection != null && projection.length > 0) { - Position first=projection[0]; - Position last= projection[projection.length -1]; - int length= last.offset - first.offset + last.length; - getParentDocument().replace(first.getOffset(), length, contents); - } else { - getParentDocument().set(contents); - } - - } catch (BadLocationException x) { - } - } - - /* - * @see ITextStore#replace(int, int, String) - */ - public void replace(int offset, int length, String text) { - - try { - - int endoffset= length > 0 ? offset + length -1 : offset; - int o2= computeParentDocumentOffset(endoffset); - if (length > 0) - ++ o2; - - offset= computeParentDocumentOffset(offset); - length= o2 - offset; - - getParentDocument().replace(offset, length, text); - - } catch (BadLocationException x) { - // ignored as surrounding document should have handled this - } - } - - /* - * @see ITextStore#getLength() - */ - public int getLength() { - Position[] projection= fProjectionDocument.getProjection(); - if (projection == null || projection.length == 0) - return 0; - - int length= 0; - for (int i= 0; i < projection.length; i++) - length += projection[i].length; - return length; - } - - /* - * @see ITextStore#get(int, int) - */ - public String get(int offset, int length) { - try { - - Fragment[] fragments= fProjectionDocument.getFragmentsOfRange(offset, length); - if (fragments == null || fragments.length == 0) - return ""; //$NON-NLS-1$ - - StringBuffer buffer= new StringBuffer(); - for (int i= 0; i < fragments.length; i++) { - Position p= fragments[i].getOrigin(); - buffer.append(getParentDocument().get(p.offset, p.length)); - } - - offset -= fragments[0].offset; - return buffer.substring(offset, offset + length); - - } catch (BadLocationException x) { - } - - return null; - } - - /** - * Returns the parent document of the store's document. - * - * @return the parent document of the store's document - */ - private IDocument getParentDocument() { - return fProjectionDocument.getParentDocument(); - } - - /* - * @see ITextStore#get(int) - */ - public char get(int offset) { - try { - int o= computeParentDocumentOffset(offset); - return getParentDocument().getChar(o); - } catch (BadLocationException x) { - } - - return (char) 0; - } -} diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java index 1f13a39480d..35e37524b42 100644 --- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java +++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/FragmentUpdater.java @@ -29,7 +29,7 @@ import org.eclipse.jface.text.Position; * * @since 3.0 */ -public class FragmentUpdater extends DefaultPositionUpdater { +class FragmentUpdater extends DefaultPositionUpdater { /** Indicates whether the position being updated represents the last fragment. */ private boolean fIsLast= false; diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java index 19cf110dcee..a07d5664494 100644 --- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java +++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/IMinimalMapping.java @@ -14,7 +14,7 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; /** - * Internal class. Do not use. + * Internal interface. Do not use. * * @since 3.0 */ diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java index 8a6d492f5e8..d2008a70985 100644 --- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java +++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/ProjectionTextStore.java @@ -25,7 +25,7 @@ import org.eclipse.jface.text.Region; * * @since 3.0 */ -public class ProjectionTextStore implements ITextStore { +class ProjectionTextStore implements ITextStore { /** * Implementation of <code>IRegion</code> that can be reused diff --git a/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java b/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java index cb242e32efa..1142a7d6999 100644 --- a/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java +++ b/org.eclipse.text/projection/org/eclipse/jface/text/projection/SegmentUpdater.java @@ -27,7 +27,7 @@ import org.eclipse.jface.text.Position; * * @since 3.0 */ -public class SegmentUpdater extends DefaultPositionUpdater { +class SegmentUpdater extends DefaultPositionUpdater { private Segment fNextSegment= null; private boolean fIsProjectionChange= false; diff --git a/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java index 6a87e874bf4..bfb41536cde 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java @@ -1025,7 +1025,7 @@ public abstract class AbstractDocument implements IDocument, IDocumentExtension, */ public int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException { try { - IRegion region= getFindReplaceDocumentAdapter().search(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false); + IRegion region= getFindReplaceDocumentAdapter().find(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false); if (region == null) return -1; else diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java deleted file mode 100644 index fa1eaa2e1a5..00000000000 --- a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocument.java +++ /dev/null @@ -1,454 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - - -/** - * A child document is one particular example of a slave document. Child documents - * are created by the <code>ChildDocumentManager</code>, an implementation of - * <code>ISlaveDocumentManager</code>.<p> - * - * A child document represents one consequetive range of its master document. - * The master document is called parent document. The child document is always in sync - * with its parent document by utilizing the parent document as its <code>ITextStore</code>.<p> - * - * This class is for internal use only. - * - * @see ITextStore - * @deprecated - */ -public final class ChildDocument extends AbstractDocument { - - - /** - * Implements <code>ITextStore</code> based on <code>IDocument</code>. - */ - class TextStore implements ITextStore { - - /* - * @see ITextStore#set(String) - */ - public void set(String txt) { - try { - fParentDocument.replace(fRange.getOffset(), fRange.getLength(), txt); - } catch (BadLocationException x) { - // cannot happen - } - } - - /* - * @see ITextStore#replace(int, int, String) - */ - public void replace(int offset, int length, String txt) { - try { - fParentDocument.replace(fRange.getOffset() + offset, length, txt); - } catch (BadLocationException x) { - // ignored as surrounding document should have handled this - } - } - - /* - * @see ITextStore#getLength() - */ - public int getLength() { - return fRange.getLength(); - } - - /* - * @see ITextStore#get(int, int) - */ - public String get(int offset, int length) { - try { - return fParentDocument.get(fRange.getOffset() + offset, length); - } catch (BadLocationException x) { - } - - return ""; - } - - /* - * @see ITextStore#get(int) - */ - public char get(int offset) { - try { - return fParentDocument.getChar(fRange.getOffset() + offset); - } catch (BadLocationException x) { - } - - return (char) 0; - } - } - - - - /** The parent document */ - private IDocument fParentDocument; - /** - * The parent document as <code>IDocumentExtension</code> - * @since 2.0 - */ - private IDocumentExtension fExtension; - /** - * The parent document as <code>IDocumentExtension2</code> - * @since 2.1 - */ - private IDocumentExtension2 fExtension2; - /** The section inside the parent document */ - private Position fRange; - /** The document event issued by the parent document */ - private DocumentEvent fParentEvent; - /** The document event issued and to be issued by the child document */ - private DocumentEvent fEvent; - /** Indicates whether the child document initiated a parent document update or not */ - private boolean fIsUpdating= false; - /** - * The expected document content after the parent document changed. - * @since 2.1 - */ - private String fExpectedContent; - /** - * The length of this child document prior to the change of the parent document - * @since 2.1 - */ - private int fRememberedLength; - /** - * Indicates whether this document is in auto expand mode. - * @since 2.1 - */ - private boolean fIsAutoExpanding= false; - - - /** - * Creates a child document for the given range of the given parent document. - * - * @param parentDocument the parent Document - * @param range the parent document range covered by the child document - */ - public ChildDocument(IDocument parentDocument, Position range) { - super(); - - fParentDocument= parentDocument; - if (fParentDocument instanceof IDocumentExtension) - fExtension= (IDocumentExtension) fParentDocument; - if (fParentDocument instanceof IDocumentExtension2) - fExtension2= (IDocumentExtension2) fParentDocument; - - fRange= range; - - ITextStore s= new TextStore(); - ILineTracker tracker= new DefaultLineTracker(); - tracker.set(s.get(0, fRange.getLength())); - - setTextStore(s); - setLineTracker(tracker); - - completeInitialization(); - } - - /** - * Sets the child document's parent document range. - * - * @param offset the offset of the parent document range - * @param length the length of the parent document range - */ - public void setParentDocumentRange(int offset, int length) throws BadLocationException { - - if (offset < 0 || length < 0 || offset + length > fParentDocument.getLength()) - throw new BadLocationException(); - - fRange.setOffset(offset); - fRange.setLength(length); - - getTracker().set(fParentDocument.get(offset, length)); - } - - /** - * Returns parent document - * - * @return the parent document - */ - public IDocument getParentDocument() { - return fParentDocument; - } - - /** - * Returns the range of the parent document covered by this child document. - * - * @return the child document's parent document range - */ - public Position getParentDocumentRange() { - return fRange; - } - - /** - * <p>Transforms a document event of the parent document into a child document - * based document event. This method considers whether the document is in - * auto expand mode.</p> - * This method is public for test purposes only. - * - * @param e the parent document event - * @return the child document event - */ - public DocumentEvent normalize(DocumentEvent event) { - - int delta= event.getOffset() - fRange.getOffset(); - - if (isAutoExpandEvent(event)) { - - if (delta < 0) { - int eventEndOffset= event.getOffset() + event.getLength(); - - if (eventEndOffset <= fRange.getOffset()) { - - // case 1 - StringBuffer buffer= new StringBuffer(); - if (event.getText() != null) - buffer.append(event.getText()); - try { - buffer.append(fParentDocument.get(eventEndOffset, -delta - event.getLength())); - } catch (BadLocationException e) { - // should not happen as the event is a valid parent document event - } - - return new SlaveDocumentEvent(this, 0, 0, buffer.toString(), event); - - } else { - - // cases 2 and 3 - int length= Math.min(eventEndOffset - fRange.getOffset(), fRange.getLength()); - return new SlaveDocumentEvent(this, 0, length, event.getText(), event); - } - - } else { - int rangeEndOffset= fRange.getOffset() + fRange.getLength(); - - if (event.getOffset() >= rangeEndOffset) { - - // case 5 - StringBuffer buffer= new StringBuffer(); - try { - buffer.append(fParentDocument.get(rangeEndOffset, event.getOffset() - rangeEndOffset)); - } catch (BadLocationException e) { - // should not happen as this event is a valid parent document event - } - if (event.getText() != null) - buffer.append(event.getText()); - - return new SlaveDocumentEvent(this, fRange.getLength(), 0, buffer.toString(), event); - - } else { - - // case 4 and 6 - int offset= event.getOffset() - fRange.getOffset(); - int length= Math.min(rangeEndOffset - event.getOffset(), event.getLength()); - return new SlaveDocumentEvent(this, offset, length, event.getText(), event); - } - } - - } else if (fRange.overlapsWith(event.fOffset, event.fLength)) { - - int offset= delta < 0 ? 0 : delta; - int length= delta < 0 ? event.fLength + delta : event.fLength; - if (offset + length > fRange.getLength()) - length= fRange.getLength() - offset; - - return new SlaveDocumentEvent(this, offset, length, event.fText, event); - } - - return null; - } - - /** - * When called this child document is informed about a forthcoming change - * of its parent document. This child document checks whether the parent - * document change affects it and if so informs all document listeners. - * - * @param event the parent document event - */ - public void parentDocumentAboutToBeChanged(DocumentEvent event) { - - fParentEvent= event; - - fEvent= normalize(event); - if (fEvent != null) { - - StringBuffer buffer= new StringBuffer(get()); - fRememberedLength= buffer.length(); - buffer.replace(fEvent.fOffset, fEvent.fOffset+ fEvent.fLength, fEvent.fText == null ? "" : fEvent.fText); //$NON-NLS-1$ - fExpectedContent= buffer.toString(); - - delayedFireDocumentAboutToBeChanged(); - } - } - - /** - * When called this child document is informed about a change of its parent document. - * If this child document is affected it informs all of its document listeners. - * - * @param event the parent document event - */ - public void parentDocumentChanged(DocumentEvent event) { - if ( !fIsUpdating && event == fParentEvent && fEvent != null) { - try { - - if (!fExpectedContent.equals(get())) { - // patch the event - fEvent.fOffset= 0; - fEvent.fLength= fRememberedLength; - fEvent.fText= get(); - } - - fRememberedLength= 0; - fExpectedContent= null; - - getTracker().replace(fEvent.fOffset, fEvent.fLength, fEvent.fText); - fireDocumentChanged(fEvent); - - } catch (BadLocationException x) { - Assert.isLegal(false); - } - } - } - - /* - * @see AbstractDocument#fireDocumentAboutToBeChanged(DocumentEvent) - */ - protected void fireDocumentAboutToBeChanged(DocumentEvent event) { - // delay it until there is a notification from the parent document - // otherwise there it is expensive to construct the parent document information - } - - /** - * Fires the child document event as about-to-be-changed event to all - * registed listeners. - */ - private void delayedFireDocumentAboutToBeChanged() { - super.fireDocumentAboutToBeChanged(fEvent); - } - - /** - * Ignores the given event and sends the similar child document event instead. - * - * @param event the event to be ignored - */ - protected void fireDocumentChanged(DocumentEvent event) { - super.fireDocumentChanged(fEvent); - } - - /* - * @see IDocument#replace(int, int, String) - * @since 2.0 - */ - public void replace(int offset, int length, String text) throws BadLocationException { - try { - fIsUpdating= true; - if (fExtension != null) - fExtension.stopPostNotificationProcessing(); - - if ((0 > offset) || (0 > length) || (offset + length > getLength())) - throw new BadLocationException(); - - DocumentEvent event= new DocumentEvent(this, offset, length, text); - fireDocumentAboutToBeChanged(event); - - try { - - if (fExtension2 != null) - fExtension2.stopListenerNotification(); - - getStore().replace(offset, length, text); - getTracker().replace(offset, length, text); - updateDocumentStructures(fEvent); - - } finally { - if (fExtension2 != null) - fExtension2.resumeListenerNotification(); - } - - doFireDocumentChanged(fEvent); - - } finally { - fIsUpdating= false; - if (fExtension != null) - fExtension.resumePostNotificationProcessing(); - } - } - - /* - * @see IDocument#set(String) - * @since 2.0 - */ - public void set(String text) { - try { - fIsUpdating= true; - if (fExtension != null) - fExtension.stopPostNotificationProcessing(); - - int length= getStore().getLength(); - DocumentEvent event= new DocumentEvent(this, 0, length, text); - fireDocumentAboutToBeChanged(event); - - try { - - if (fExtension2 != null) - fExtension2.stopListenerNotification(); - - getStore().set(text); - getTracker().set(text); - updateDocumentStructures(fEvent); - - } finally { - if (fExtension2 != null) - fExtension2.resumeListenerNotification(); - } - - doFireDocumentChanged(fEvent); - - } finally { - fIsUpdating= false; - if (fExtension != null) - fExtension.resumePostNotificationProcessing(); - } - } - - /* - * @see IDocumentExtension#registerPostNotificationReplace(IDocumentListener, IDocumentExtension.IReplace) - * @since 2.0 - */ - public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) { - if (!fIsUpdating) - throw new UnsupportedOperationException(); - super.registerPostNotificationReplace(owner, replace); - } - - /** - * Sets the auto expand mode of this document. - * - * @param autoExpand <code>true</code> if auto expanding, <code>false</code> otherwise - * @since 2.1 - */ - public void setAutoExpandMode(boolean autoExpand) { - fIsAutoExpanding= autoExpand; - } - - /** - * Returns whether the given document might cause this document to auto expand. - * This default implementation always answers with its auto expand state. - * - * @param event the document event - * @return <code>true</code> if the given event might cause this document to auto expand - */ - public boolean isAutoExpandEvent(DocumentEvent event) { - return fIsAutoExpanding; - } -} diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java b/org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java deleted file mode 100644 index 70451d8dfc4..00000000000 --- a/org.eclipse.text/src/org/eclipse/jface/text/ChildDocumentManager.java +++ /dev/null @@ -1,466 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - -/** - * <code>ChildDocumentManager</code> is one particular implementation of - * <code>ISlaveDocumentManager</code>. This manager creates so called child - * documents as slave documents for given master documents.<p> - * - * A child document represents a particular range of the parent - * document and is accordingly adapted to changes of the parent document. - * Vice versa, the parent document is accordingly adapted to changes of - * its child documents. The manager does not maintain any particular management - * structure but utilizes mechanisms given by <code>IDocument</code> such - * as position categories and position updaters. <p> - * - * For internal use only. - * @deprecated - */ -public final class ChildDocumentManager implements IDocumentListener, ISlaveDocumentManager { - - - /** - * Name of the position category used to keep track of the ranges of the parent documents - * that correspond to child documents. - */ - public final static String CHILDDOCUMENTS= "__childdocuments"; //$NON-NLS-1$ - - - /** - * Positions which are used to mark the child documents offset ranges into - * the parent documents. This position uses as bidirectional reference as - * it knows the child document as well as the parent document. - */ - static class ChildPosition extends Position { - - /** The parent document. */ - public IDocument fParentDocument; - /* The child document */ - public ChildDocument fChildDocument; - - /** - * Creates a new child position for the given parent document. - * @param parentDocument the parent document - * @param offset the offset into the parent document - * @param length the length in the parent document - */ - public ChildPosition(IDocument parentDocument, int offset, int length) { - super(offset, length); - fParentDocument= parentDocument; - } - - /** - * Changed to be compatible to the position updater behavior - * @see Position#overlapsWith(int, int) - */ - public boolean overlapsWith(int offset, int length) { - boolean append= (offset == this.offset + this.length) && length == 0; - return append || super.overlapsWith(offset, length); - } - } - - - /** - * The position updater used to adapt the positions representing - * the child document ranges to changes of the parent document. - */ - static class ChildPositionUpdater extends DefaultPositionUpdater { - - /** Cached document event */ - private DocumentEvent fDocumentEvent; - - /** - * Creates the position updated. - */ - protected ChildPositionUpdater() { - super(CHILDDOCUMENTS); - } - - /** - * Child document ranges cannot be deleted other then by calling - * freeChildDocument. - */ - protected boolean notDeleted() { - return true; - } - - /* - * @see org.eclipse.jface.text.DefaultPositionUpdater#update(org.eclipse.jface.text.DocumentEvent) - */ - public void update(DocumentEvent event) { - try { - fDocumentEvent= event; - super.update(event); - } finally { - fDocumentEvent= null; - } - } - - /** - * If an insertion happens at a child document's start offset, the - * position is extended rather than shifted. Also, if something is added - * right behind the end of the position, the position is extended rather - * than kept stable. - * - * In auto expand mode the position is always streched to contain the - * whole area of the change. - */ - protected void adaptToInsert() { - - int myStart= fPosition.offset; - int myEnd= fPosition.offset + fPosition.length; - boolean isAutoExpanding= isAutoExpanding(); - - if (fLength != 0 && fOffset < myEnd && !isAutoExpanding) { - super.adaptToInsert(); - return; - } - - int yoursStart= fOffset; - int yoursEnd= fOffset + fReplaceLength -1; - yoursEnd= Math.max(yoursStart, yoursEnd); - - if (myEnd < yoursStart) { - if (isAutoExpanding) - fPosition.length= yoursEnd - myStart + 1; - return; - } - - if (myStart <= yoursStart) { - if (yoursStart < myEnd || fLength == 0) - fPosition.length += fReplaceLength; - } else { // yoursStart < myStart - if (isAutoExpanding) { - fPosition.offset= yoursStart; - fPosition.length += (myStart - yoursStart + fReplaceLength); - } else { - fPosition.offset += fReplaceLength; - } - } - } - - /** - * Returns whether the child documents should automatically expand to include - * any parent document change. - * - * @return <code>true</code> if auto expanding, <code>false</code> otherwise - * @since 2.1 - */ - private boolean isAutoExpanding() { - if (fPosition instanceof ChildPosition) { - ChildPosition position= (ChildPosition) fPosition; - return position.fChildDocument.isAutoExpandEvent(fDocumentEvent); - } - return false; - } - } - - /** - * The child document partitioner uses the parent document to answer all questions. - */ - static class ChildPartitioner implements IDocumentPartitioner { - - /** The child document. */ - protected ChildDocument fChildDocument; - /** The parent document */ - protected IDocument fParentDocument; - /** - * The parent document as <code>IDocumentExtensions3</code>. - * @since 3.0 - */ - protected IDocumentExtension3 fParentDocument3; - /** - * The partitioning of this partitioner. - * @since 3.0 - */ - protected String fPartitioning; - - /** - * Creates a new child document partitioner for the given document - * partitioning. - * - * @param partitioning the document partitioning - * @since 3.0 - */ - protected ChildPartitioner(String partitioning) { - fPartitioning= partitioning; - } - - /** - * Creates a new child document partitioner. - */ - protected ChildPartitioner() { - fPartitioning= null; - } - - /* - * @see IDocumentPartitioner#getPartition(int) - */ - public ITypedRegion getPartition(int offset) { - try { - offset += fChildDocument.getParentDocumentRange().getOffset(); - if (fParentDocument3 != null) - return fParentDocument3.getPartition(fPartitioning, offset, false); - return fParentDocument.getPartition(offset); - } catch (BadLocationException x) { - } catch (BadPartitioningException x) { - } - - return null; - } - - /* - * @see IDocumentPartitioner#computePartitioning(int, int) - */ - public ITypedRegion[] computePartitioning(int offset, int length) { - try { - offset += fChildDocument.getParentDocumentRange().getOffset(); - if (fParentDocument3 != null) - return fParentDocument3.computePartitioning(fPartitioning, offset, length, false); - return fParentDocument.computePartitioning(offset, length); - } catch (BadLocationException x) { - } catch (BadPartitioningException x) { - } - - return null; - } - - /* - * @see IDocumentPartitioner#getContentType(int) - */ - public String getContentType(int offset) { - try { - offset += fChildDocument.getParentDocumentRange().getOffset(); - if (fParentDocument3 != null) - return fParentDocument3.getContentType(fPartitioning, offset, false); - return fParentDocument.getContentType(offset); - } catch (BadLocationException x) { - } catch (BadPartitioningException x) { - } - - return null; - } - - /* - * @see IDocumentPartitioner#getLegalContentTypes() - */ - public String[] getLegalContentTypes() { - if (fParentDocument3 != null) - try { - return fParentDocument3.getLegalContentTypes(fPartitioning); - } catch (BadPartitioningException x) { - return new String[0]; - } - return fParentDocument.getLegalContentTypes(); - } - - /* - * @see IDocumentPartitioner#documentChanged(DocumentEvent) - */ - public boolean documentChanged(DocumentEvent event) { - // ignore as the parent does this for us - return false; - } - - /* - * @see IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent) - */ - public void documentAboutToBeChanged(DocumentEvent event) { - // ignore as the parent does this for us - } - - /* - * @see IDocumentPartitioner#disconnect() - */ - public void disconnect() { - fChildDocument= null; - fParentDocument= null; - fParentDocument3= null; - } - - /* - * @see IDocumentPartitioner#connect(IDocument) - */ - public void connect(IDocument childDocument) { - Assert.isTrue(childDocument instanceof ChildDocument); - fChildDocument= (ChildDocument) childDocument; - fParentDocument= fChildDocument.getParentDocument(); - if (fParentDocument instanceof IDocumentExtension3) - fParentDocument3= (IDocumentExtension3) fParentDocument; - } - } - - - - /** The position updater shared by all documents which have child documents */ - private IPositionUpdater fChildPositionUpdater; - - - /** - * Returns the child position updater. If necessary, it is dynamically created. - * - * @return the child position updater - */ - protected IPositionUpdater getChildPositionUpdater() { - if (fChildPositionUpdater == null) - fChildPositionUpdater= new ChildPositionUpdater(); - return fChildPositionUpdater; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#createSlaveDocument(org.eclipse.jface.text.IDocument) - */ - public IDocument createSlaveDocument(IDocument master) { - - if (!master.containsPositionCategory(CHILDDOCUMENTS)) { - master.addPositionCategory(CHILDDOCUMENTS); - master.addPositionUpdater(getChildPositionUpdater()); - master.addDocumentListener(this); - } - - ChildPosition pos= new ChildPosition(master, 0, 0); - try { - master.addPosition(CHILDDOCUMENTS, pos); - } catch (BadPositionCategoryException x) { - // cannot happen - } catch (BadLocationException x) { - // (0, 0) is OK - } - - ChildDocument child= new ChildDocument(master, pos); - if (master instanceof IDocumentExtension3) { - IDocumentExtension3 extension3= (IDocumentExtension3) master; - String[] partitionings= extension3.getPartitionings(); - for (int i= 0; i < partitionings.length; i++) { - IDocumentPartitioner partitioner= new ChildPartitioner(partitionings[i]); - child.setDocumentPartitioner(partitionings[i], partitioner); - partitioner.connect(child); - } - } else { - IDocumentPartitioner partitioner= new ChildPartitioner(); - child.setDocumentPartitioner(partitioner); - partitioner.connect(child); - } - - pos.fChildDocument= child; - - return child; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#freeSlaveDocument(org.eclipse.jface.text.IDocument) - */ - public void freeSlaveDocument(IDocument slave) { - - if (! (slave instanceof ChildDocument)) - return; - - ChildDocument childDocument= (ChildDocument) slave; - - String[] partitionings= childDocument.getPartitionings(); - for (int i= 0; i < partitionings.length; i ++) { - IDocumentPartitioner partitioner= childDocument.getDocumentPartitioner(partitionings[i]); - if (partitioner != null) - partitioner.disconnect(); - } - - ChildPosition pos= (ChildPosition) childDocument.getParentDocumentRange(); - IDocument parent= pos.fParentDocument; - - try { - parent.removePosition(CHILDDOCUMENTS, pos); - Position[] category= parent.getPositions(CHILDDOCUMENTS); - if (category.length == 0) { - parent.removeDocumentListener(this); - parent.removePositionUpdater(getChildPositionUpdater()); - parent.removePositionCategory(CHILDDOCUMENTS); - } - } catch (BadPositionCategoryException x) { - // cannot happen - } - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#createMasterSlaveMapping(org.eclipse.jface.text.IDocument) - */ - public IDocumentInformationMapping createMasterSlaveMapping(IDocument slave) { - if (slave instanceof ChildDocument) - return new ParentChildMapping((ChildDocument) slave); - return null; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#getMasterDocument(org.eclipse.jface.text.IDocument) - */ - public IDocument getMasterDocument(IDocument slave) { - if (slave instanceof ChildDocument) - return ((ChildDocument) slave).getParentDocument(); - return null; - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#isSlaveDocument(org.eclipse.jface.text.IDocument) - */ - public boolean isSlaveDocument(IDocument document) { - return (document instanceof ChildDocument); - } - - /** - * Informs all child documents of the document which issued this document event. - * - * @param about indicates whether the change is about to happen or alread happend - * @param event the document event which will be processed to inform child documents - */ - protected void fireDocumentEvent(boolean about, DocumentEvent event) { - try { - - IDocument parent= event.getDocument(); - Position[] children= parent.getPositions(CHILDDOCUMENTS); - for (int i= 0; i < children.length; i++) { - Object o= children[i]; - if (o instanceof ChildPosition) { - ChildPosition pos= (ChildPosition) o; - if (about) - pos.fChildDocument.parentDocumentAboutToBeChanged(event); - else - pos.fChildDocument.parentDocumentChanged(event); - } - } - } catch (BadPositionCategoryException x) { - // cannot happen - } - } - - /* - * @see IDocumentListener#documentChanged(DocumentEvent) - */ - public void documentChanged(DocumentEvent event) { - fireDocumentEvent(false, event); - } - - /* - * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent) - */ - public void documentAboutToBeChanged(DocumentEvent event) { - fireDocumentEvent(true, event); - } - - /* - * @see org.eclipse.jface.text.ISlaveDocumentManager#setAutoExpandMode(org.eclipse.jface.text.IDocument, boolean) - */ - public void setAutoExpandMode(IDocument slaveDocument, boolean autoExpand) { - if (slaveDocument instanceof ChildDocument) - ((ChildDocument) slaveDocument).setAutoExpandMode(autoExpand); - } -} diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java index bc9a42e0510..935ae8df808 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java @@ -24,11 +24,14 @@ import java.util.regex.PatternSyntaxException; */ public class FindReplaceDocumentAdapter implements CharSequence { + private static class FindReplaceOperationCode { + } + // Shortcuts to findReplace operation codes - private static final FindReplaceOperationCode FIND_FIRST= FindReplaceOperationCode.FIND_FIRST; - private static final FindReplaceOperationCode FIND_NEXT= FindReplaceOperationCode.FIND_NEXT; - private static final FindReplaceOperationCode REPLACE= FindReplaceOperationCode.REPLACE; - private static final FindReplaceOperationCode REPLACE_FIND_NEXT= FindReplaceOperationCode.REPLACE_FIND_NEXT; + private static final FindReplaceOperationCode FIND_FIRST= new FindReplaceOperationCode(); + private static final FindReplaceOperationCode FIND_NEXT= new FindReplaceOperationCode(); + private static final FindReplaceOperationCode REPLACE= new FindReplaceOperationCode(); + private static final FindReplaceOperationCode REPLACE_FIND_NEXT= new FindReplaceOperationCode(); /** * The adapted document. @@ -61,7 +64,7 @@ public class FindReplaceDocumentAdapter implements CharSequence { } /** - * Returns the region of a given search string in the document based on a set of search criteria. + * Returns the location of a given string in this adapter's document based on a set of search criteria. * * @param startOffset document offset at which search starts * @param findString the string to find @@ -75,7 +78,7 @@ public class FindReplaceDocumentAdapter implements CharSequence { * @throws BadLocationException if startOffset is an invalid document offset * @throws PatternSyntaxException if a regular expression has invalid syntax */ - public IRegion search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException { + public IRegion find(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException { Assert.isTrue(!(regExSearch && wholeWord)); // Adjust offset to special meaning of -1 @@ -115,7 +118,7 @@ public class FindReplaceDocumentAdapter implements CharSequence { * @see FindReplaceOperationCode#REPLACE * @see FindReplaceOperationCode#REPLACE_FIND_NEXT */ - public IRegion findReplace(FindReplaceOperationCode operationCode, int startOffset, String findString, String replaceText, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException { + private IRegion findReplace(FindReplaceOperationCode operationCode, int startOffset, String findString, String replaceText, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) throws BadLocationException { // Validate option combinations Assert.isTrue(!(regExSearch && wholeWord)); @@ -269,7 +272,7 @@ public class FindReplaceDocumentAdapter implements CharSequence { * @see IDocumentListener */ public IRegion replace(String text, boolean regExReplace) throws BadLocationException { - return findReplace(FindReplaceOperationCode.REPLACE, -1, null, text, false, false, false, regExReplace); + return findReplace(REPLACE, -1, null, text, false, false, false, regExReplace); } // ---------- CharSequence implementation ---------- diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java deleted file mode 100644 index 9c952c80c26..00000000000 --- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceOperationCode.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jface.text; - - -/** - * Enumeration type declaring the available findReplace operation codes. - * - * @see org.eclipse.jface.text.FindReplaceDocumentAdapter#findReplace(FindReplaceOperationCode, int, String, String, boolean, boolean, boolean, boolean) - * @since 3.0 - */ -public final class FindReplaceOperationCode { - - /** - * The operation code's name. - */ - private final String fName; - - /** - * Creates and returns a new findReplace operation code. - * - * @param operationName the name of this operation - */ - private FindReplaceOperationCode(String operationName) { - Assert.isNotNull(operationName); - fName= operationName; - } - - /* - * @see Object#toString() - */ - public String toString() { - return fName; - } - - /** - * findReplace operation code used to find the first match. - */ - public static final FindReplaceOperationCode FIND_FIRST= new FindReplaceOperationCode("findFirst"); //$NON-NLS-1$ - - /** - * findReplace operation code to find the next match. - */ - public static final FindReplaceOperationCode FIND_NEXT= new FindReplaceOperationCode("findNext"); //$NON-NLS-1$ - - /** - * findReplace operation code to replace the current match. - * This operation must be preceded by a <code>FIND_FIRST</code> or <code>FIND_NEXT</code> operation. - */ - public static final FindReplaceOperationCode REPLACE= new FindReplaceOperationCode("replace"); //$NON-NLS-1$ - - /** - * findReplace operation code to replace the current match and find the next one. - * This operation must be preceded by a <code>FIND_FIRST</code> or <code>FIND_NEXT</code> operation. - */ - public static final FindReplaceOperationCode REPLACE_FIND_NEXT= new FindReplaceOperationCode("replaceAndFindNext"); //$NON-NLS-1$ -}
\ No newline at end of file diff --git a/org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java b/org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java deleted file mode 100644 index 3bff41ab9d3..00000000000 --- a/org.eclipse.text/src/org/eclipse/jface/text/ParentChildMapping.java +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.jface.text; - -/** - * Implementation of <code>IDocumentInformationMapping</code> matching <code>ChildDocument</code> and - * <code>ChildDocumentManager</code>. The parent document is considered the original document, the child - * document is considered the image document. - * - * @deprecated - */ -public class ParentChildMapping implements IDocumentInformationMapping { - - /** The parent document */ - private IDocument fParentDocument; - /** The child document */ - private ChildDocument fChildDocument; - - - /** - * Creates a new document mapping between the parent document of the given - * child document and the child document. - * - * @param childDocument - */ - public ParentChildMapping(ChildDocument childDocument) { - fParentDocument= childDocument.getParentDocument(); - fChildDocument= childDocument; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#getCoverage() - */ - public IRegion getCoverage() { - Position p= fChildDocument.getParentDocumentRange(); - return new Region(p.getOffset(), p.getLength()); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginOffset(int) - */ - public int toOriginOffset(int imageOffset) throws BadLocationException { - int anchorOffset= fChildDocument.getParentDocumentRange().getOffset(); - return anchorOffset + imageOffset; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginRegion(org.eclipse.jface.text.IRegion) - */ - public IRegion toOriginRegion(IRegion imageRegion) throws BadLocationException { - int anchorOffset= fChildDocument.getParentDocumentRange().getOffset(); - return new Region(anchorOffset + imageRegion.getOffset(), imageRegion.getLength()); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLines(int) - */ - public IRegion toOriginLines(int imageLine) throws BadLocationException { - IRegion imageDocumentRegion= fChildDocument.getLineInformation(imageLine); - IRegion originDocumentRegion= toOriginRegion(imageDocumentRegion); - - int startLine= fParentDocument.getLineOfOffset(originDocumentRegion.getOffset()); - if (originDocumentRegion.getLength() == 0) - return new Region(startLine, 0); - - int endLine= fParentDocument.getLineOfOffset(originDocumentRegion.getOffset() + originDocumentRegion.getLength() -1); - return new Region(startLine, endLine - startLine); - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toOriginLine(int) - */ - public int toOriginLine(int imageLine) throws BadLocationException { - int anchorOffset= fChildDocument.getParentDocumentRange().getOffset(); - return fParentDocument.getLineOfOffset(anchorOffset) + imageLine; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageOffset(int) - */ - public int toImageOffset(int originOffset) throws BadLocationException { - Position p= fChildDocument.getParentDocumentRange(); - if (p.includes(originOffset)) - return originOffset - p.getOffset(); - return -1; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageRegion(org.eclipse.jface.text.IRegion) - */ - public IRegion toImageRegion(IRegion originRegion) throws BadLocationException { - - int offset= originRegion.getOffset(); - int length= originRegion.getLength(); - - if (length < 0) { - length= -length; - offset -= length; - } - - Position p= fChildDocument.getParentDocumentRange(); - if (p.overlapsWith(offset, length)) { - - if (offset < p.getOffset()) - offset= p.getOffset(); - - int end= offset + length; - int e= p.getOffset() + p.getLength(); - if (end > e) - end= e; - - offset -= p.getOffset(); - end -= p.getOffset(); - - if (originRegion.getLength() < 0) - return new Region(end, offset - end); - return new Region(offset, end - offset); - } - - return null; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toImageLine(int) - */ - public int toImageLine(int originLine) throws BadLocationException { - int anchorOffset= fChildDocument.getParentDocumentRange().getOffset(); - int startLine= fParentDocument.getLineOfOffset(anchorOffset); - - int imageLine= originLine - startLine; - if (imageLine < 0 || imageLine > fChildDocument.getNumberOfLines()) - return -1; - return imageLine; - } - - /* - * @see org.eclipse.jface.text.IDocumentInformationMapping#toClosestImageLine(int) - */ - public int toClosestImageLine(int originLine) throws BadLocationException { - int anchorOffset= fChildDocument.getParentDocumentRange().getOffset(); - int startLine= fParentDocument.getLineOfOffset(anchorOffset); - - int imageLine= originLine - startLine; - if (imageLine < 0) - return 0; - - int maxLine= fChildDocument.getNumberOfLines(); - if (imageLine > maxLine) - return maxLine; - - return imageLine; - } -} diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java b/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java index 35dc529d577..c64eeb8154e 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/link/InclusivePositionUpdater.java @@ -17,7 +17,9 @@ import org.eclipse.jface.text.Position; /** * Position updater that takes any change in [position.offset, position.offset + position.length] as - * belonging to the position. + * belonging to the position.<p> + * Internal class. Do not use. Public for testing purposes only. + * * * @since 3.0 */ diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeModel.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeModel.java index f84c320458b..0b857ab8f99 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeModel.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeModel.java @@ -60,9 +60,9 @@ import org.eclipse.jface.text.IDocumentExtension.IReplace; * @since 3.0 */ public class LinkedModeModel { - + /** - * Checks whether there is alreay a linked mode model installed on <code>document</code>. + * Checks whether there is already a linked mode model installed on <code>document</code>. * * @param document the <code>IDocument</code> of interest * @return <code>true</code> if there is an existing model, <code>false</code> @@ -74,10 +74,10 @@ public class LinkedModeModel { } /** - * Checks whether there is alreay a linked mode model installed on any of + * Checks whether there is already a linked mode model installed on any of * the <code>documents</code>. * - * @param documents the <code>IDocument</code> s of interest + * @param documents the <code>IDocument</code>s of interest * @return <code>true</code> if there is an existing model, <code>false</code> * otherwise */ diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java index 1c5bf82caa8..9ce73449ef0 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/DocumentTemplateContext.java @@ -37,7 +37,7 @@ public class DocumentTemplateContext extends TemplateContext { * assist) * @param completionLength the completion length */ - public DocumentTemplateContext(ContextType type, IDocument document, int completionOffset, int completionLength) { + public DocumentTemplateContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength) { super(type); Assert.isNotNull(document); diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalVariables.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java index 50b32bccaa0..694b021119f 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalVariables.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java @@ -20,7 +20,7 @@ import java.util.Calendar; * * @since 3.0 */ -public class GlobalVariables { +public class GlobalTemplateVariables { /** The type of the selection variables. */ public static final String SELECTION= "selection"; //$NON-NLS-1$ @@ -28,7 +28,7 @@ public class GlobalVariables { /** * The cursor variable determines the cursor placement after template edition. */ - public static class Cursor extends SimpleVariableResolver { + public static class Cursor extends SimpleTemplateVariableResolver { /** Name of the cursor variable, value= {@value} */ public static final String NAME= "cursor"; //$NON-NLS-1$ @@ -46,7 +46,7 @@ public class GlobalVariables { * The word selection variable determines templates that work on a full * lines selection. */ - public static class WordSelection extends SimpleVariableResolver { + public static class WordSelection extends SimpleTemplateVariableResolver { /** Name of the word selection variable, value= {@value} */ public static final String NAME= "word_selection"; //$NON-NLS-1$ @@ -70,7 +70,7 @@ public class GlobalVariables { * The line selection variable determines templates that work on selected * lines. */ - public static class LineSelection extends SimpleVariableResolver { + public static class LineSelection extends SimpleTemplateVariableResolver { /** Name of the line selection variable, value= {@value} */ public static final String NAME= "line_selection"; //$NON-NLS-1$ @@ -93,7 +93,7 @@ public class GlobalVariables { /** * The dollar variable inserts an escaped dollar symbol. */ - public static class Dollar extends SimpleVariableResolver { + public static class Dollar extends SimpleTemplateVariableResolver { /** * Creates a new dollar variable */ @@ -106,7 +106,7 @@ public class GlobalVariables { /** * The date variable evaluates to the current date. */ - public static class Date extends SimpleVariableResolver { + public static class Date extends SimpleTemplateVariableResolver { /** * Creates a new date variable */ @@ -121,7 +121,7 @@ public class GlobalVariables { /** * The year variable evaluates to the current year. */ - public static class Year extends SimpleVariableResolver { + public static class Year extends SimpleTemplateVariableResolver { /** * Creates a new year variable */ @@ -136,7 +136,7 @@ public class GlobalVariables { /** * The time variable evaluates to the current time. */ - public static class Time extends SimpleVariableResolver { + public static class Time extends SimpleTemplateVariableResolver { /** * Creates a new time variable */ @@ -155,7 +155,7 @@ public class GlobalVariables { /** * The user variable evaluates to the current user. */ - public static class User extends SimpleVariableResolver { + public static class User extends SimpleTemplateVariableResolver { /** * Creates a new user name variable */ diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleVariableResolver.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleTemplateVariableResolver.java index c5e072f174c..c58793a4ebe 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleVariableResolver.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/SimpleTemplateVariableResolver.java @@ -16,7 +16,7 @@ package org.eclipse.jface.text.templates; * * @since 3.0 */ -public class SimpleVariableResolver extends TemplateVariableResolver { +public class SimpleTemplateVariableResolver extends TemplateVariableResolver { /** The string to which this variable evaluates. */ private String fEvaluationString; @@ -24,7 +24,7 @@ public class SimpleVariableResolver extends TemplateVariableResolver { /* * @see TemplateVariableResolver#TemplateVariableResolver(String, String) */ - protected SimpleVariableResolver(String type, String description) { + protected SimpleTemplateVariableResolver(String type, String description) { super(type, description); } diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java index 61145acd1ca..8314ec5ed7d 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContext.java @@ -24,7 +24,7 @@ import org.eclipse.jface.text.BadLocationException; public abstract class TemplateContext { /** The context type of this context */ - private final ContextType fContextType; + private final TemplateContextType fContextType; /** Additional variables. */ private final Map fVariables= new HashMap(); /** A flag to indicate that the context should not be modified. */ @@ -35,7 +35,7 @@ public abstract class TemplateContext { * * @param contextType the context type of this context */ - protected TemplateContext(ContextType contextType) { + protected TemplateContext(TemplateContextType contextType) { fContextType= contextType; fReadOnly= true; } @@ -45,7 +45,7 @@ public abstract class TemplateContext { * * @return the context type of this context */ - public ContextType getContextType() { + public TemplateContextType getContextType() { return fContextType; } diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/ContextType.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContextType.java index 13a892aa295..68ad6ad01f5 100644 --- a/org.eclipse.text/src/org/eclipse/jface/text/templates/ContextType.java +++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/TemplateContextType.java @@ -38,7 +38,7 @@ import org.eclipse.jface.text.IDocument; * * @since 3.0 */ -public class ContextType { +public class TemplateContextType { /** Name of the context type. */ private /* final */ String fId= null; @@ -55,7 +55,7 @@ public class ContextType { * * @param id the unique identifier of the context type */ - public ContextType(String id) { + public TemplateContextType(String id) { this(id, id); } @@ -65,7 +65,7 @@ public class ContextType { * @param id the unique identifier of the context type * @param name the name of the context type */ - public ContextType(String id, String name) { + public TemplateContextType(String id, String name) { Assert.isNotNull(id); Assert.isNotNull(name); fId= id; @@ -100,7 +100,7 @@ public class ContextType { * {@link #ContextType(String)} instead. * </p> */ - public ContextType() { + public TemplateContextType() { } /** diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java index 35c90506db4..4302df921cf 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java @@ -11,7 +11,6 @@ package org.eclipse.ui.editors.text; import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; -import org.eclipse.ui.texteditor.AnnotationTypeHierarchy; import org.eclipse.ui.texteditor.AnnotationTypeLookup; import org.eclipse.ui.internal.editors.text.EditorsPlugin; @@ -54,15 +53,6 @@ public final class EditorsUI { return EditorsPlugin.getDefault().getAnnotationPreferenceLookup(); } - /** - * Returns the annotation type hierarchy for this plug-in. - * - * @return the annotation type hierarchy - */ - public static AnnotationTypeHierarchy getAnnotationTypeHierarchy() { - return EditorsPlugin.getDefault().getAnnotationTypeHierarchy(); - } - private EditorsUI() { // block instantiation } diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java index 3ea9afff8c6..fe77f4e4892 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java @@ -52,6 +52,7 @@ import org.eclipse.ui.dialogs.ContainerGenerator; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel; import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel; +import org.eclipse.ui.internal.editors.text.*; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java index 31a4dceaed9..25f3a4edc68 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java @@ -68,6 +68,7 @@ import org.eclipse.ui.texteditor.IElementStateListener; import org.eclipse.ui.texteditor.IElementStateListenerExtension; import org.eclipse.ui.texteditor.ISchedulingRuleProvider; import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel; +import org.eclipse.ui.internal.editors.text.*; /** * @since 3.0 diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java index 534e3f018e4..451784c68f3 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java @@ -27,9 +27,9 @@ import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.TextEditorPreferenceConstants; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; -import org.eclipse.ui.texteditor.AnnotationTypeHierarchy; import org.eclipse.ui.texteditor.AnnotationTypeLookup; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; +import org.eclipse.ui.internal.texteditor.AnnotationTypeHierarchy; /** * Represents the editors plug-in. It provides a series of convenience methods such as diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/UISynchronizationContext.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java index 2911b5bbe95..85e77b42053 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/UISynchronizationContext.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java @@ -8,7 +8,7 @@ http://www.eclipse.org/legal/cpl-v10.html Contributors: IBM Corporation - Initial implementation **********************************************************************/ -package org.eclipse.ui.editors.text; +package org.eclipse.ui.internal.editors.text; import org.eclipse.core.filebuffers.ISynchronizationContext; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/WorkspaceOperationRunner.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java index 467aa5196a4..04381cdac57 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/WorkspaceOperationRunner.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.ui.editors.text; +package org.eclipse.ui.internal.editors.text; import java.lang.reflect.InvocationTargetException; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationType.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java index bd5d1bdcfba..62a4c146a67 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationType.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java @@ -8,14 +8,16 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.ui.texteditor; +package org.eclipse.ui.internal.texteditor; + +import org.eclipse.ui.texteditor.AnnotationPreference; /** * Represents an annotation type. * * @since 3.0 */ -public class AnnotationType { +public final class AnnotationType { private String fType; private String[] fSuperTypes; private AnnotationPreference fPreference; @@ -35,7 +37,6 @@ public class AnnotationType { /** * For internal use only. - * Visibility will be changed to default. * * @return the annotation preference */ @@ -45,7 +46,6 @@ public class AnnotationType { /** * For internal use only. - * Visibility will be changed to default. * * @param preference the annotation preference */ diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeHierarchy.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java index fba388a63d8..f52e57f0cbe 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeHierarchy.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.ui.texteditor; +package org.eclipse.ui.internal.texteditor; import java.util.ArrayList; import java.util.HashMap; @@ -28,7 +28,7 @@ import org.eclipse.ui.editors.text.EditorsUI; * * @since 3.0 */ -public class AnnotationTypeHierarchy { +public final class AnnotationTypeHierarchy { private Map fTypeMap; private Map fTypesCache= new HashMap(); diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DelegatingAnnotationPreference.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java index c940c9f95df..fc0c13e76eb 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DelegatingAnnotationPreference.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.ui.texteditor; +package org.eclipse.ui.internal.texteditor; import java.util.HashSet; import java.util.Set; @@ -18,9 +18,12 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.source.IAnnotationAccessExtension; +import org.eclipse.ui.texteditor.AnnotationPreference; +import org.eclipse.ui.texteditor.AnnotationPreferenceLookup; +import org.eclipse.ui.texteditor.IAnnotationImageProvider; -class DelegatingAnnotationPreference extends AnnotationPreference { +public class DelegatingAnnotationPreference extends AnnotationPreference { private AnnotationType fType; private AnnotationPreferenceLookup fLookup; diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java index ce15da0236f..edc874c116e 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java @@ -53,8 +53,6 @@ import org.eclipse.ui.PlatformUI; * </ul> * This class may be instantiated but is not intended for subclassing. * </p> - * - * @since 3.0 */ public class AddMarkerAction extends TextEditorAction { diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java index 5dc7db932e1..addddcf426c 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java @@ -17,6 +17,7 @@ import java.util.Map; import org.eclipse.jface.text.source.Annotation; import org.eclipse.ui.internal.editors.text.EditorsPlugin; +import org.eclipse.ui.internal.texteditor.*; /** * Provides the strategy for finding the annotation preference for a given diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java index 38012803e47..d7cce62f275 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java @@ -30,7 +30,7 @@ import org.eclipse.ui.editors.text.EditorsUI; * * @since 3.0 */ -public class AnnotationTypeLookup { +public final class AnnotationTypeLookup { /** * Record representing an annotation type mapping. diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java index 4a71110606d..9b81e0ab03d 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java @@ -31,6 +31,7 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.internal.editors.text.EditorsPlugin; +import org.eclipse.ui.internal.texteditor.*; /** diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java index b691e581ed8..ecd51c6fa34 100644 --- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java +++ b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLCompletionProcessor.java @@ -19,7 +19,7 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.templates.ContextType; +import org.eclipse.jface.text.templates.TemplateContextType; import org.eclipse.jface.text.templates.Template; import org.eclipse.jface.text.templates.TemplateCompletionProcessor; @@ -78,7 +78,7 @@ public class XMLCompletionProcessor extends TemplateCompletionProcessor { /** * Return the XML context type that is supported by this plugin. */ - protected ContextType getContextType(ITextViewer viewer, IRegion region) { + protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { return TemplateEditorUI.getDefault().getContextTypeRegistry().getContextType(XMLContextType.XML_CONTEXT_TYPE); } diff --git a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java index 01a6484a776..c25e00fe7f3 100644 --- a/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java +++ b/org.eclipse.ui.examples.javaeditor/Template Editor Example/org/eclipse/ui/examples/templateeditor/template/XMLContextType.java @@ -10,14 +10,14 @@ *******************************************************************************/ package org.eclipse.ui.examples.templateeditor.template; -import org.eclipse.jface.text.templates.ContextType; -import org.eclipse.jface.text.templates.GlobalVariables; +import org.eclipse.jface.text.templates.TemplateContextType; +import org.eclipse.jface.text.templates.GlobalTemplateVariables; /** * A very simple context type. */ -public class XMLContextType extends ContextType { +public class XMLContextType extends TemplateContextType { /** This context's id */ public static final String XML_CONTEXT_TYPE= "org.eclipse.ui.examples.templateeditor.xml"; //$NON-NLS-1$ @@ -30,14 +30,14 @@ public class XMLContextType extends ContextType { } private void addGlobalResolvers() { - addResolver(new GlobalVariables.Cursor()); - addResolver(new GlobalVariables.WordSelection()); - addResolver(new GlobalVariables.LineSelection()); - addResolver(new GlobalVariables.Dollar()); - addResolver(new GlobalVariables.Date()); - addResolver(new GlobalVariables.Year()); - addResolver(new GlobalVariables.Time()); - addResolver(new GlobalVariables.User()); + addResolver(new GlobalTemplateVariables.Cursor()); + addResolver(new GlobalTemplateVariables.WordSelection()); + addResolver(new GlobalTemplateVariables.LineSelection()); + addResolver(new GlobalTemplateVariables.Dollar()); + addResolver(new GlobalTemplateVariables.Date()); + addResolver(new GlobalTemplateVariables.Year()); + addResolver(new GlobalTemplateVariables.Time()); + addResolver(new GlobalTemplateVariables.User()); } } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java index 1f5f70dc577..4bb5072e034 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java @@ -21,6 +21,7 @@ import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.viewers.IDoubleClickListener; @@ -34,26 +35,25 @@ import org.eclipse.jface.text.ITextViewerExtension5; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.text.source.Annotation; +import org.eclipse.jface.text.source.CompositeRuler; import org.eclipse.jface.text.source.IAnnotationAccess; import org.eclipse.jface.text.source.IAnnotationAccessExtension; import org.eclipse.jface.text.source.IAnnotationHover; import org.eclipse.jface.text.source.IAnnotationHoverExtension; -import org.eclipse.jface.text.source.IAnnotationListener; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.ILineRange; import org.eclipse.jface.text.source.ISourceViewer; -import org.eclipse.jface.text.source.IVerticalRulerExtension; -import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.jface.text.source.IVerticalRulerListener; import org.eclipse.jface.text.source.LineRange; +import org.eclipse.jface.text.source.VerticalRulerEvent; import org.eclipse.ui.internal.texteditor.AnnotationExpansionControl.AnnotationHoverInput; /** * @since 3.0 */ -public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHoverExtension { - - +public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHoverExtension { + private class InformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension { /* @@ -78,9 +78,34 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover } } + private class VerticalRulerListener implements IVerticalRulerListener { + + /* + * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationSelected(org.eclipse.jface.text.source.VerticalRulerEvent) + */ + public void annotationSelected(VerticalRulerEvent event) { + fCompositeRuler.fireAnnotationSelected(event); + } + + /* + * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.jface.text.source.VerticalRulerEvent) + */ + public void annotationDefaultSelected(VerticalRulerEvent event) { + fCompositeRuler.fireAnnotationDefaultSelected(event); + } + + /* + * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationContextMenuAboutToShow(org.eclipse.jface.text.source.VerticalRulerEvent, org.eclipse.swt.widgets.Menu) + */ + public void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) { + fCompositeRuler.fireAnnotationContextMenuAboutToShow(event, menu); + } + } + + private final IInformationControlCreator fgCreator= new InformationControlCreator(); - protected IVerticalRulerInfo fVerticalRulerInfo; - protected IAnnotationListener fAnnotationListener; + protected final IVerticalRulerListener fgListener= new VerticalRulerListener(); + protected CompositeRuler fCompositeRuler; protected IDoubleClickListener fDblClickListener; protected IAnnotationAccess fAnnotationAccess; @@ -88,19 +113,13 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover * Creates a new hover instance. * * @param ruler - * @param listener - * @param doubleClickListener * @param access + * @param doubleClickListener */ - public AnnotationExpandHover(IVerticalRulerInfo ruler, IAnnotationListener listener, IDoubleClickListener doubleClickListener, IAnnotationAccess access) { - fAnnotationListener= listener; - fVerticalRulerInfo= ruler; - fDblClickListener= doubleClickListener; + public AnnotationExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) { + fCompositeRuler= ruler; fAnnotationAccess= access; - } - - public AnnotationExpandHover(IVerticalRulerInfo ruler, IAnnotationAccess access) { - this(ruler, null, null, access); + fDblClickListener= doubleClickListener; } /* @@ -147,8 +166,8 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover AnnotationHoverInput input= new AnnotationHoverInput(); input.fAnnotations= (Annotation[]) exact.toArray(new Annotation[0]); input.fViewer= viewer; - input.fRulerInfo= fVerticalRulerInfo; - input.fAnnotationListener= fAnnotationListener; + input.fRulerInfo= fCompositeRuler; + input.fAnnotationListener= fgListener; input.fDoubleClickListener= fDblClickListener; input.model= model; @@ -215,18 +234,18 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover protected void setLastRulerMouseLocation(ISourceViewer viewer, int line) { // set last mouse activity in order to get the correct context menu - if (fVerticalRulerInfo instanceof IVerticalRulerExtension) { + if (fCompositeRuler != null) { StyledText st= viewer.getTextWidget(); if (st != null && !st.isDisposed()) { if (viewer instanceof ITextViewerExtension5) { int widgetLine= ((ITextViewerExtension5)viewer).modelLine2WidgetLine(line); Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine)); - ((IVerticalRulerExtension)fVerticalRulerInfo).setLocationOfLastMouseButtonActivity(0, loc.y); + fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y); } else if (viewer instanceof TextViewer) { // TODO remove once TextViewer implements the extension int widgetLine= ((TextViewer)viewer).modelLine2WidgetLine(line); Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine)); - ((IVerticalRulerExtension)fVerticalRulerInfo).setLocationOfLastMouseButtonActivity(0, loc.y); + fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y); } } } @@ -257,9 +276,9 @@ public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHover } /* - * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator() + * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator() */ - public IInformationControlCreator getInformationControlCreator() { + public IInformationControlCreator getHoverControlCreator() { return fgCreator; } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java index ca09330cd81..f28cc0155fa 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java @@ -59,13 +59,13 @@ import org.eclipse.jface.text.Position; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.TextViewer; import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.AnnotationEvent; import org.eclipse.jface.text.source.IAnnotationAccess; import org.eclipse.jface.text.source.IAnnotationAccessExtension; -import org.eclipse.jface.text.source.IAnnotationListener; +import org.eclipse.jface.text.source.IVerticalRulerListener; import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.jface.text.source.VerticalRulerEvent; /** @@ -94,7 +94,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma public Annotation[] fAnnotations; public ISourceViewer fViewer; public IVerticalRulerInfo fRulerInfo; - public IAnnotationListener fAnnotationListener; + public IVerticalRulerListener fAnnotationListener; public IDoubleClickListener fDoubleClickListener; public ICallback redoAction; public IAnnotationModel model; @@ -121,7 +121,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma fHoverManager.showInformation(); if (fInput.fAnnotationListener != null) { - AnnotationEvent event= new AnnotationEvent(fAnnotation); + VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation); fInput.fAnnotationListener.annotationSelected(event); } @@ -129,7 +129,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma public void defaultSelected() { if (fInput.fAnnotationListener != null) { - AnnotationEvent event= new AnnotationEvent(fAnnotation); + VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation); fInput.fAnnotationListener.annotationDefaultSelected(event); } @@ -138,7 +138,7 @@ public class AnnotationExpansionControl implements IInformationControl, IInforma public void showContextMenu(Menu menu) { if (fInput.fAnnotationListener != null) { - AnnotationEvent event= new AnnotationEvent(fAnnotation); + VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation); fInput.fAnnotationListener.annotationContextMenuAboutToShow(event, menu); } } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java index bd82e13faf1..adfa1b906d0 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java @@ -3982,12 +3982,12 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit action.setActionDefinitionId(ITextEditorActionDefinitionIds.LOWER_CASE); setAction(ITextEditorActionConstants.LOWER_CASE, action); - action = new SmartEnterAction(EditorMessages.getResourceBundle(), "Editor.SmartEnter.", this, false); //$NON-NLS-1$ + action = new InsertLineAction(EditorMessages.getResourceBundle(), "Editor.SmartEnter.", this, false); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER); setAction(ITextEditorActionConstants.SMART_ENTER, action); - action = new SmartEnterAction(EditorMessages.getResourceBundle(), "Editor.SmartEnterInverse.", this, true); //$NON-NLS-1$ + action = new InsertLineAction(EditorMessages.getResourceBundle(), "Editor.SmartEnterInverse.", this, true); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER_INVERSE); setAction(ITextEditorActionConstants.SMART_ENTER_INVERSE, action); diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java index 467da2927f4..c06b2c622d1 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java @@ -20,7 +20,7 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.ISourceViewer; /** - * Action that converts the current selection to lower case. + * Action that converts the current selection to lower case or upper case. * @since 3.0 */ public class CaseAction extends ResourceAction implements IUpdate { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java deleted file mode 100644 index 0f16e564c1b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java +++ /dev/null @@ -1,550 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.Assert; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.util.PropertyChangeEvent; - -/** - * Preference store that composes multiple preference stores in a - * chain and serves a preference value from the first preference store in the - * chain that contains the preference. - * <p> - * This preference store is read-only i.e. write access - * throws an {@link java.lang.UnsupportedOperationException}.</p> - * - * @since 3.0 - */ -public class ChainedPreferenceStore implements IPreferenceStore { - - /** Child preference stores */ - private IPreferenceStore[] fPreferenceStores; - - /** Listeners on this chained preference store */ - private ListenerList fClientListeners= new ListenerList(); - - /** Listeners on the child preference stores */ - private List fChildListeners= new ArrayList(); - - /** - * Listener on the chained preference stores. Forwards only the events - * that are visible to clients. - */ - private class PropertyChangeListener implements IPropertyChangeListener { - - /** Preference store to listen too. */ - private IPreferenceStore fPreferenceStore; - - /** - * Initialize with the given preference store. - * - * @param preferenceStore the preference store - */ - public PropertyChangeListener(IPreferenceStore preferenceStore) { - setPreferenceStore(preferenceStore); - } - - /* - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - IPreferenceStore childPreferenceStore= getPreferenceStore(); - handlePropertyChangeEvent(childPreferenceStore, event); - } - - /** - * Registers this listener on the preference store. - */ - public void register() { - getPreferenceStore().addPropertyChangeListener(this); - } - - /** - * Unregisters this listener from the preference store. - */ - public void unregister() { - getPreferenceStore().removePropertyChangeListener(this); - } - - /** - * Returns the preference store. - * @return The preference store - */ - public IPreferenceStore getPreferenceStore() { - return fPreferenceStore; - } - - /** - * Sets the preference store. - * @param preferenceStore The new preference store to set. - */ - public void setPreferenceStore(IPreferenceStore preferenceStore) { - fPreferenceStore= preferenceStore; - } - - } - - /** - * Sets the chained preference stores. - * - * @param preferenceStores The chained preference stores to set. - */ - public ChainedPreferenceStore(IPreferenceStore[] preferenceStores) { - Assert.isTrue(preferenceStores != null && preferenceStores.length > 0); - fPreferenceStores= preferenceStores; - // Create listeners - for (int i= 0, length= fPreferenceStores.length; i < length; i++) { - PropertyChangeListener listener= new PropertyChangeListener(fPreferenceStores[i]); - fChildListeners.add(listener); - } - } - - /** - * {@inheritDoc} - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fClientListeners.size() == 0) { - registerChildListeners(); - } - fClientListeners.add(listener); - } - - /** - * {@inheritDoc} - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fClientListeners.remove(listener); - if (fClientListeners.size() == 0) { - unregisterChildListeners(); - } - } - - /** - * {@inheritDoc} - */ - public boolean contains(String name) { - return getVisibleStore(name) != null; - } - - /** - * {@inheritDoc} - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - firePropertyChangeEvent(new PropertyChangeEvent(this, name, oldValue, newValue)); - } - - /** - * Fire the given property change event. - * @param event The property change event - */ - private void firePropertyChangeEvent(PropertyChangeEvent event) { - Object[] listeners= fClientListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IPropertyChangeListener) listeners[i]).propertyChange(event); - } - - /* - * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String) - */ - public boolean getBoolean(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getBoolean(name); - return BOOLEAN_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public boolean getDefaultBoolean(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDefaultBoolean(name); - return BOOLEAN_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public double getDefaultDouble(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDefaultDouble(name); - return DOUBLE_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public float getDefaultFloat(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDefaultFloat(name); - return FLOAT_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public int getDefaultInt(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDefaultInt(name); - return INT_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public long getDefaultLong(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDefaultLong(name); - return LONG_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public String getDefaultString(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDefaultString(name); - return STRING_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public double getDouble(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getDouble(name); - return DOUBLE_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public float getFloat(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getFloat(name); - return FLOAT_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public int getInt(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getInt(name); - return INT_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public long getLong(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getLong(name); - return LONG_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public String getString(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.getString(name); - return STRING_DEFAULT_DEFAULT; - } - - /** - * {@inheritDoc} - */ - public boolean isDefault(String name) { - IPreferenceStore visibleStore= getVisibleStore(name); - if (visibleStore != null) - return visibleStore.isDefault(name); - return false; - } - - /** - * {@inheritDoc} - */ - public boolean needsSaving() { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void putValue(String name, String value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, double value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, float value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, int value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, long value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, String defaultObject) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, boolean value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setToDefault(String name) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, double value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, float value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, int value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, long value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, String value) { - throw new UnsupportedOperationException(); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, boolean value) { - throw new UnsupportedOperationException(); - } - - /** - * Handle property change event from the child listener with the given child preference store. - * - * @param childPreferenceStore The child preference store - * @param event The event - */ - private void handlePropertyChangeEvent(IPreferenceStore childPreferenceStore, PropertyChangeEvent event) { - String property= event.getProperty(); - Object oldValue= event.getOldValue(); - Object newValue= event.getNewValue(); - - IPreferenceStore visibleStore= getVisibleStore(property); - - /* - * Assume that the property is there but has no default value (its owner relies on the default-default value) - * see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827 - */ - if (visibleStore == null && newValue != null) - visibleStore= childPreferenceStore; - - if (visibleStore == null) { - // no visible store - Assert.isTrue(newValue == null); - if (oldValue != null) - // removal in child, last in chain -> removal in this chained preference store - firePropertyChangeEvent(event); - } else if (visibleStore == childPreferenceStore) { - // event from visible store - Assert.isNotNull(newValue); - if (oldValue != null) { - // change in child, visible store -> change in this chained preference store - firePropertyChangeEvent(event); - } else { - // insertion in child - IPreferenceStore oldVisibleStore= null; - int i= 0; - int length= fPreferenceStores.length; - while (i < length && fPreferenceStores[i++] != visibleStore); - while (oldVisibleStore == null && i < length) { - if (fPreferenceStores[i].contains(property)) - oldVisibleStore= fPreferenceStores[i]; - i++; - } - - if (oldVisibleStore == null) { - // insertion in child, first in chain -> insertion in this chained preference store - firePropertyChangeEvent(event); - } else { - // insertion in child, not first in chain - oldValue= getOtherValue(property, oldVisibleStore, newValue); - if (!oldValue.equals(newValue)) - // insertion in child, different old value -> change in this chained preference store - firePropertyChangeEvent(property, oldValue, newValue); - // else: insertion in child, same old value -> no change in this chained preference store - } - } - } else { - // event from other than the visible store - boolean eventBeforeVisibleStore= false; - for (int i= 0, length= fPreferenceStores.length; i < length; i++) { - IPreferenceStore store= fPreferenceStores[i]; - if (store == visibleStore) - break; - if (store == childPreferenceStore) { - eventBeforeVisibleStore= true; - break; - } - } - - if (eventBeforeVisibleStore) { - // removal in child, before visible store - Assert.isTrue(newValue == null); - newValue= getOtherValue(property, visibleStore, oldValue); - if (!newValue.equals(oldValue)) - // removal in child, before visible store, different old value -> change in this chained preference store - firePropertyChangeEvent(property, oldValue, newValue); - // else: removal in child, before visible store, same old value -> no change in this chained preference store - } - // else: event behind visible store -> no change in this chained preference store - } - } - - /** - * Returns an object of the same dynamic type as <code>thisValue</code>, the returned object - * encapsulates the value of the <code>property</code> from the preference <code>store</code>. - * Allowed dynamic types for <code>thisValue</code> are <code>Boolean</code>, <code>Double</code>, - * <code>Float</code>, <code>Integer</code>, <code>Long</code> and <code>String</code>. If - * <code>thisValue</code> has a different type a {@link java.lang.IllegalArgumentException} is thrown. - * - * @param property The name of the considered property - * @param store The preference store - * @param thisValue The given value - * @return The other value - */ - private Object getOtherValue(String property, IPreferenceStore store, Object thisValue) { - Object otherValue; - if (thisValue instanceof Boolean) - otherValue= new Boolean(store.getBoolean(property)); - else if (thisValue instanceof Double) - otherValue= new Double(store.getDouble(property)); - else if (thisValue instanceof Float) - otherValue= new Float(store.getFloat(property)); - else if (thisValue instanceof Integer) - otherValue= new Integer(store.getInt(property)); - else if (thisValue instanceof Long) - otherValue= new Long(store.getLong(property)); - else if (thisValue instanceof String) - otherValue= store.getString(property); - else - throw new IllegalArgumentException(); - return otherValue; - } - - /** - * Returns the preference store from which the given property's value - * is visible. - * - * @param property Name of the property. - * @return Preference store from which the property's value is visible, - * <code>null</code> if the property is unknown. - */ - private IPreferenceStore getVisibleStore(String property) { - IPreferenceStore visibleStore= null; - - for (int i= 0, length= fPreferenceStores.length; i < length && visibleStore == null; i++) { - IPreferenceStore store= fPreferenceStores[i]; - if (store.contains(property)) - visibleStore= store; - } - return visibleStore; - } - - /** - * Register the child listeners on the child preference stores. - */ - private void registerChildListeners() { - Iterator iter= fChildListeners.iterator(); - while (iter.hasNext()) { - PropertyChangeListener listener= (PropertyChangeListener) iter.next(); - listener.register(); - } - } - - /** - * Unregister the child listeners from the child preference stores. - */ - private void unregisterChildListeners() { - Iterator iter= fChildListeners.iterator(); - while (iter.hasNext()) { - PropertyChangeListener listener= (PropertyChangeListener) iter.next(); - listener.unregister(); - } - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java index ab92a0838bb..07f577be601 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java @@ -31,7 +31,7 @@ import org.eclipse.jface.text.Assert; * Allows to sort an array based on their elements' configuration elements * according to the prerequisite relation of their defining plug-ins. * <p> - * This class can be directly used or subclassed. + * This class can directly be used or subclassed. * </p> * * @since 3.0 diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java index c90bf9dbc43..48e81b5f1b4 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java @@ -35,6 +35,7 @@ import org.eclipse.jface.util.PropertyChangeEvent; * separated by a separator line. This form must be handled like a SWT widget. * * @since 2.0 + * @deprecated since 3.0. there is no replacement, use org.eclipse.ui.forms to define a component with a similar look and function. */ public class InfoForm { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SmartEnterAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.java index c2751b09d91..5b07a6ec1b7 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SmartEnterAction.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.java @@ -39,7 +39,7 @@ import org.eclipse.swt.custom.StyledText; * </p> * @since 3.0 */ -public class SmartEnterAction extends TextEditorAction { +public class InsertLineAction extends TextEditorAction { /** * <code>true</code> if this action inserts a line above the current (Smart Enter Inverse), @@ -54,7 +54,7 @@ public class SmartEnterAction extends TextEditorAction { * @param textEditor the editor that the action acts upon * @param above whether new lines are inserted above or below the caret's line. */ - public SmartEnterAction(ResourceBundle bundle, String prefix, ITextEditor textEditor, boolean above) { + public InsertLineAction(ResourceBundle bundle, String prefix, ITextEditor textEditor, boolean above) { super(bundle, prefix, textEditor); fAbove= above; } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PreferencesAdapter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PreferencesAdapter.java deleted file mode 100644 index 34a5eaa52f7..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PreferencesAdapter.java +++ /dev/null @@ -1,309 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.ui.texteditor; - -import org.eclipse.core.runtime.Preferences; - -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.ListenerList; -import org.eclipse.jface.util.PropertyChangeEvent; - -/** - * Adapts {@link org.eclipse.core.runtime.Preferences} to - * {@link org.eclipse.jface.preference.IPreferenceStore} - * - * @since 3.0 - */ -public class PreferencesAdapter implements IPreferenceStore { - - /** - * Property change listener. Listens for events of type - * {@link org.eclipse.core.runtime.Preferences.PropertyChangeEvent} and fires - * a {@link org.eclipse.jface.util.PropertyChangeEvent} on the - * adapter with arguments from the received event. - */ - private class PropertyChangeListener implements Preferences.IPropertyChangeListener { - - /* - * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) - */ - public void propertyChange(Preferences.PropertyChangeEvent event) { - firePropertyChangeEvent(event.getProperty(), event.getOldValue(), event.getNewValue()); - } - } - - /** Listeners on the adapter */ - private ListenerList fListeners= new ListenerList(); - - /** Listener on the adapted Preferences */ - private PropertyChangeListener fListener= new PropertyChangeListener(); - - /** Adapted Preferences */ - private Preferences fPreferences; - - /** True iff no events should be forwarded */ - private boolean fSilent; - - /** - * Initialize with empty Preferences. - */ - public PreferencesAdapter() { - this(new Preferences()); - } - /** - * Initialize with the given Preferences. - * - * @param preferences The preferences to wrap. - */ - public PreferencesAdapter(Preferences preferences) { - fPreferences= preferences; - } - - /** - * {@inheritDoc} - */ - public void addPropertyChangeListener(IPropertyChangeListener listener) { - if (fListeners.size() == 0) - fPreferences.addPropertyChangeListener(fListener); - fListeners.add(listener); - } - - /** - * {@inheritDoc} - */ - public void removePropertyChangeListener(IPropertyChangeListener listener) { - fListeners.remove(listener); - if (fListeners.size() == 0) - fPreferences.removePropertyChangeListener(fListener); - } - - /** - * {@inheritDoc} - */ - public boolean contains(String name) { - return fPreferences.contains(name); - } - - /** - * {@inheritDoc} - */ - public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { - if (!fSilent) { - PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue); - Object[] listeners= fListeners.getListeners(); - for (int i= 0; i < listeners.length; i++) - ((IPropertyChangeListener) listeners[i]).propertyChange(event); - } - } - - /** - * {@inheritDoc} - */ - public boolean getBoolean(String name) { - return fPreferences.getBoolean(name); - } - - /** - * {@inheritDoc} - */ - public boolean getDefaultBoolean(String name) { - return fPreferences.getDefaultBoolean(name); - } - - /** - * {@inheritDoc} - */ - public double getDefaultDouble(String name) { - return fPreferences.getDefaultDouble(name); - } - - /** - * {@inheritDoc} - */ - public float getDefaultFloat(String name) { - return fPreferences.getDefaultFloat(name); - } - - /** - * {@inheritDoc} - */ - public int getDefaultInt(String name) { - return fPreferences.getDefaultInt(name); - } - - /** - * {@inheritDoc} - */ - public long getDefaultLong(String name) { - return fPreferences.getDefaultLong(name); - } - - /** - * {@inheritDoc} - */ - public String getDefaultString(String name) { - return fPreferences.getDefaultString(name); - } - - /** - * {@inheritDoc} - */ - public double getDouble(String name) { - return fPreferences.getDouble(name); - } - - /** - * {@inheritDoc} - */ - public float getFloat(String name) { - return fPreferences.getFloat(name); - } - - /** - * {@inheritDoc} - */ - public int getInt(String name) { - return fPreferences.getInt(name); - } - - /** - * {@inheritDoc} - */ - public long getLong(String name) { - return fPreferences.getLong(name); - } - - /** - * {@inheritDoc} - */ - public String getString(String name) { - return fPreferences.getString(name); - } - - /** - * {@inheritDoc} - */ - public boolean isDefault(String name) { - return fPreferences.isDefault(name); - } - - /** - * {@inheritDoc} - */ - public boolean needsSaving() { - return fPreferences.needsSaving(); - } - - /** - * {@inheritDoc} - */ - public void putValue(String name, String value) { - try { - fSilent= true; - fPreferences.setValue(name, value); - } finally { - fSilent= false; - } - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, double value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, float value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, int value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, long value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, String defaultObject) { - fPreferences.setDefault(name, defaultObject); - } - - /** - * {@inheritDoc} - */ - public void setDefault(String name, boolean value) { - fPreferences.setDefault(name, value); - } - - /** - * {@inheritDoc} - */ - public void setToDefault(String name) { - fPreferences.setToDefault(name); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, double value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, float value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, int value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, long value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, String value) { - fPreferences.setValue(name, value); - } - - /** - * {@inheritDoc} - */ - public void setValue(String name, boolean value) { - fPreferences.setValue(name, value); - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction2.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java index 90c6328b9ed..54ebfc07687 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction2.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java @@ -18,16 +18,20 @@ import java.util.ResourceBundle; import org.eclipse.swt.widgets.Menu; import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.source.*; import org.eclipse.jface.text.source.Annotation; +import org.eclipse.jface.text.source.IVerticalRulerListener; import org.eclipse.jface.text.source.IAnnotationModel; +import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.jface.text.source.IVerticalRulerInfoExtension; +import org.eclipse.jface.text.source.VerticalRulerEvent; /** - * A ruler action which can select the textual range of a marker - * that has a visual representation in a vertical ruler. + * A ruler action which can select the textual range of an annotation that has a + * visual representation in a vertical ruler. + * * @since 3.0 */ -public class SelectMarkerRulerAction2 extends TextEditorAction implements IAnnotationListener { +public class SelectAnnotationRulerAction extends TextEditorAction implements IVerticalRulerListener { /** * Creates a new action for the given ruler and editor. The action configures @@ -40,7 +44,7 @@ public class SelectMarkerRulerAction2 extends TextEditorAction implements IAnnot * * @see ResourceAction#ResourceAction(ResourceBundle, String) */ - public SelectMarkerRulerAction2(ResourceBundle bundle, String prefix, ITextEditor editor) { + public SelectAnnotationRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix, editor); } @@ -51,13 +55,13 @@ public class SelectMarkerRulerAction2 extends TextEditorAction implements IAnnot if (getTextEditor() != null) { IVerticalRulerInfo service= (IVerticalRulerInfo) getTextEditor().getAdapter(IVerticalRulerInfo.class); if (service instanceof IVerticalRulerInfoExtension) - ((IVerticalRulerInfoExtension) service).removeAnnotationListener(this); + ((IVerticalRulerInfoExtension) service).removeVerticalRulerListener(this); } super.setEditor(editor); if (getTextEditor() != null) { IVerticalRulerInfo service= (IVerticalRulerInfo) getTextEditor().getAdapter(IVerticalRulerInfo.class); if (service instanceof IVerticalRulerInfoExtension) - ((IVerticalRulerInfoExtension) service).addAnnotationListener(this); + ((IVerticalRulerInfoExtension) service).addVerticalRulerListener(this); } } @@ -72,16 +76,16 @@ public class SelectMarkerRulerAction2 extends TextEditorAction implements IAnnot } /* - * @see org.eclipse.ui.texteditor.IAnnotationListener#annotationSelected(org.eclipse.ui.texteditor.AnnotationEvent) + * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationSelected(org.eclipse.ui.texteditor.VerticalRulerEvent) */ - public void annotationSelected(AnnotationEvent event) { + public void annotationSelected(VerticalRulerEvent event) { } /* - * @see org.eclipse.ui.texteditor.IAnnotationListener#annotationDefaultSelected(org.eclipse.ui.texteditor.AnnotationEvent) + * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.ui.texteditor.VerticalRulerEvent) */ - public void annotationDefaultSelected(AnnotationEvent event) { - Annotation a= event.getAnnotation(); + public void annotationDefaultSelected(VerticalRulerEvent event) { + Annotation a= event.getSelectedAnnotation(); IAnnotationModel model= getAnnotationModel(); Position position= model.getPosition(a); if (position == null) @@ -91,8 +95,8 @@ public class SelectMarkerRulerAction2 extends TextEditorAction implements IAnnot } /* - * @see org.eclipse.ui.texteditor.IAnnotationListener#annotationContextMenuAboutToShow(org.eclipse.ui.texteditor.AnnotationEvent, org.eclipse.swt.widgets.Menu) + * @see org.eclipse.ui.texteditor.IVerticalRulerListener#annotationContextMenuAboutToShow(org.eclipse.ui.texteditor.VerticalRulerEvent, org.eclipse.swt.widgets.Menu) */ - public void annotationContextMenuAboutToShow(AnnotationEvent event, Menu menu) { + public void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) { } } diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorHistoryUpdater.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorHistoryUpdater.java deleted file mode 100644 index 0e81e90d91f..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorHistoryUpdater.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.link; - -import org.eclipse.jface.text.link.LinkedPosition; -import org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener; -import org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget; - -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - - - -/** - * Updates the editor navigation history upon linked focus changes. - * - * @since 3.0 - */ -public class EditorHistoryUpdater implements ILinkedModeUIFocusListener { - - /* - * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusLost(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) - */ - public void linkingFocusLost(LinkedPosition position, LinkedModeUITarget target) { - // mark navigation history - IWorkbenchWindow win= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (win != null) { - IWorkbenchPage page= win.getActivePage(); - if (page != null) { - IEditorPart part= page.getActiveEditor(); - page.getNavigationHistory().markLocation(part); - } - } - } - - /* - * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusGained(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) - */ - public void linkingFocusGained(LinkedPosition position, LinkedModeUITarget target) { - // does nothing - } -} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java new file mode 100644 index 00000000000..df3d3921ec6 --- /dev/null +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.ui.texteditor.link; + +import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.link.LinkedModeModel; +import org.eclipse.jface.text.link.LinkedModeUI; +import org.eclipse.jface.text.link.LinkedPosition; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; + +/** + * A <code>LinkedModeUI</code> that takes care of updating the focus editor's + * navigation history. + * + * @since 3.0 + */ +public class EditorLinkedModeUI extends LinkedModeUI { + + /** + * Updates the editor navigation history upon linked focus changes. + * + * @since 3.0 + */ + private static class EditorHistoryUpdater implements ILinkedModeUIFocusListener { + + /* + * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusLost(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) + */ + public void linkingFocusLost(LinkedPosition position, LinkedModeUITarget target) { + // mark navigation history + IWorkbenchWindow win= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (win != null) { + IWorkbenchPage page= win.getActivePage(); + if (page != null) { + IEditorPart part= page.getActiveEditor(); + page.getNavigationHistory().markLocation(part); + } + } + } + + /* + * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusGained(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) + */ + public void linkingFocusGained(LinkedPosition position, LinkedModeUITarget target) { + // does nothing + } + } + + + /** + * @param model + * @param viewer + */ + public EditorLinkedModeUI(LinkedModeModel model, ITextViewer viewer) { + super(model, viewer); + setPositionListener(new EditorHistoryUpdater()); + } + + /** + * @param model + * @param viewers + */ + public EditorLinkedModeUI(LinkedModeModel model, ITextViewer[] viewers) { + super(model, viewers); + setPositionListener(new EditorHistoryUpdater()); + } + + /** + * @param model + * @param target + */ + public EditorLinkedModeUI(LinkedModeModel model, LinkedModeUITarget target) { + super(model, target); + setPositionListener(new EditorHistoryUpdater()); + } + + /** + * @param model + * @param targets + */ + public EditorLinkedModeUI(LinkedModeModel model, LinkedModeUITarget[] targets) { + super(model, targets); + setPositionListener(new EditorHistoryUpdater()); + } +} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorTarget.java deleted file mode 100644 index 0ae97ca10bf..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorTarget.java +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2003 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.ui.texteditor.link; - -import org.eclipse.jface.text.Assert; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.link.LinkedPosition; -import org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget; - -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.texteditor.ITextEditor; - - - -/** - * An <code>ILinkedUITarget</code> with an associated editor, which is - * brought to the top when a linked position in its viewer is jumped to. - * - * @since 3.0 - */ -public class EditorTarget extends LinkedModeUITarget { - - /** The text viewer. */ - protected final ITextViewer fTextViewer; - /** The editor displaying the viewer. */ - protected final ITextEditor fTextEditor; - - /** - * Creates a new instance. - * - * @param viewer the viewer - * @param editor the editor displaying <code>viewer</code>, or <code>null</code> - */ - public EditorTarget(ITextViewer viewer, ITextEditor editor) { - Assert.isNotNull(viewer); - Assert.isNotNull(editor); - fTextViewer= viewer; - fTextEditor= editor; - } - - /* - * @see org.eclipse.jdt.internal.ui.text.link2.LinkedModeUI.ILinkedUITarget#getViewer() - */ - public ITextViewer getViewer() { - return fTextViewer; - } - - /* - * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusGained(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) - */ - public void linkingFocusGained(LinkedPosition position, LinkedModeUITarget target) { - IWorkbenchPage page= fTextEditor.getEditorSite().getPage(); - if (page != null) { - page.bringToTop(fTextEditor); - } - fTextEditor.setFocus(); - } - - /* - * @see org.eclipse.jface.text.link.LinkedModeUI.ILinkedModeUIFocusListener#linkedFocusLost(org.eclipse.jface.text.link.LinkedPosition, org.eclipse.jface.text.link.LinkedModeUI.LinkedModeUITarget) - */ - public void linkingFocusLost(LinkedPosition position, LinkedModeUITarget target) { - } - -}
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java index 619f23a3c55..100fbfcf9df 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java @@ -54,7 +54,7 @@ import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.templates.ContextType; +import org.eclipse.jface.text.templates.TemplateContextType; import org.eclipse.jface.text.templates.ContextTypeRegistry; import org.eclipse.jface.text.templates.Template; import org.eclipse.jface.text.templates.TemplateException; @@ -68,7 +68,7 @@ import org.eclipse.ui.texteditor.IUpdate; * * @since 3.0 */ -public class EditTemplateDialog extends StatusDialog { +class EditTemplateDialog extends StatusDialog { private static class TextViewerAction extends Action implements IUpdate { @@ -157,7 +157,7 @@ public class EditTemplateDialog extends StatusDialog { List contexts= new ArrayList(); for (Iterator it= registry.contextTypes(); it.hasNext();) { - ContextType type= (ContextType) it.next(); + TemplateContextType type= (TemplateContextType) it.next(); contexts.add(new String[] { type.getId(), type.getName() }); } fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]); @@ -166,7 +166,7 @@ public class EditTemplateDialog extends StatusDialog { fContextTypeRegistry= registry; - ContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); + TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); fTemplateProcessor.setContextType(type); } @@ -292,7 +292,7 @@ public class EditTemplateDialog extends StatusDialog { String text= document.get(); fTemplate.setPattern(text); fValidationStatus.setOK(); - ContextType contextType= fContextTypeRegistry.getContextType(fTemplate.getContextTypeId()); + TemplateContextType contextType= fContextTypeRegistry.getContextType(fTemplate.getContextTypeId()); if (contextType != null) { try { contextType.validate(text); diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java index 42550bdad49..95db964ef11 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java @@ -21,7 +21,7 @@ import org.eclipse.jface.text.templates.persistence.TemplateStore; * * @since 3.0 */ -public class TemplateContentProvider implements IStructuredContentProvider { +class TemplateContentProvider implements IStructuredContentProvider { /** The template store. */ private TemplateStore fStore; diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java index 448fc249b68..5c380ada607 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java @@ -65,7 +65,7 @@ import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; -import org.eclipse.jface.text.templates.ContextType; +import org.eclipse.jface.text.templates.TemplateContextType; import org.eclipse.jface.text.templates.ContextTypeRegistry; import org.eclipse.jface.text.templates.Template; import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData; @@ -112,7 +112,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I case 0: return template.getName(); case 1: - ContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); + TemplateContextType type= fContextTypeRegistry.getContextType(template.getContextTypeId()); if (type != null) return type.getName(); else @@ -542,7 +542,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I Template template= new Template(); Iterator it= fContextTypeRegistry.contextTypes(); if (it.hasNext()) { - template.setContextTypeId(((ContextType) it.next()).getId()); + template.setContextTypeId(((TemplateContextType) it.next()).getId()); EditTemplateDialog dialog= createTemplateEditDialog(template, false, true); if (dialog.open() == Window.OK) { diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java index 527019b5af6..94022123b54 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java @@ -21,7 +21,7 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; -import org.eclipse.jface.text.templates.ContextType; +import org.eclipse.jface.text.templates.TemplateContextType; import org.eclipse.jface.text.templates.TemplateVariableResolver; @@ -48,14 +48,14 @@ public class TemplateVariableProcessor implements IContentAssistProcessor { /** the context type */ - private ContextType fContextType; + private TemplateContextType fContextType; /** * Sets the context type. * * @param contextType the context type for this processor */ - public void setContextType(ContextType contextType) { + public void setContextType(TemplateContextType contextType) { fContextType= contextType; } @@ -64,7 +64,7 @@ public class TemplateVariableProcessor implements IContentAssistProcessor { * * @return the context type */ - public ContextType getContextType() { + public TemplateContextType getContextType() { return fContextType; } |